{
  "id": "tensorflow/not-implemented-while-loop-gradients",
  "signature": "NotImplementedError: Gradient computation for while_loop is not supported when using symbolic execution",
  "signature_zh": "未实现错误：符号执行时不支持while_loop的梯度计算",
  "regex": "NotImplementedError.*while_loop.*not supported",
  "domain": "tensorflow",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "While loops with gradients require autograph or explicit gradient tape; symbolic execution in TF1 graph mode cannot handle them.",
  "root_cause_type": "generic",
  "root_cause_zh": "带梯度的while循环需要自动图或显式梯度磁带；TF1图模式下的符号执行无法处理。",
  "versions": [
    {
      "version": "tensorflow 2.12.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.15.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding more GPU memory doesn't fix the algorithmic limitation.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling eager mode makes symbolic execution worse.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use tf.while_loop with back_prop=True inside a tf.function decorated with autograph: @tf.function; def train_step(): ...",
      "success_rate": 0.85,
      "how": "Use tf.while_loop with back_prop=True inside a tf.function decorated with autograph: @tf.function; def train_step(): ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "Replace while_loop with vectorized operations using tf.map_fn or tf.scan.",
      "success_rate": 0.75,
      "how": "Replace while_loop with vectorized operations using tf.map_fn or tf.scan.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use tf.while_loop with back_prop=True inside a tf.function decorated with autograph: @tf.function; def train_step(): ...",
    "Replace while_loop with vectorized operations using tf.map_fn or tf.scan."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.tensorflow.org/guide/function#autograph",
  "official_doc_section": null,
  "error_code": "WLE",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}