{"record":{"id":"25d3b7b5bd43d352","repo":"jax-ml/jax","slug":"re-tracing-function-fun-for-jit-but-no-traci","errorCode":null,"errorMessage":"re-tracing function {fun} for `jit`, but 'no_tracing' is set","messagePattern":"re-tracing function (.+?) for `jit`, but 'no_tracing' is set","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"jax/_src/interpreters/partial_eval.py","lineNumber":2058,"sourceCode":"    debug_info = debug_info._replace(arg_names=lo_arg_names)\n  if debug_info.result_paths is not None:\n    lo_result_paths = tuple(\n    path for aval, path in zip(hi_jaxpr.out_avals, debug_info.result_paths)\n        for _ in aval.lo_ty())\n    debug_info = debug_info._replace(result_paths=lo_result_paths)\n  return debug_info\n\ndef trace_to_jaxpr_nocache(\n    fun: Callable,\n    in_avals: ft.FlatTree,  # (args, kwargs) pair\n    debug_info: core.DebugInfo,\n    # TODO: let's just make a `trace_to_jaxpr_ft` function for this\n    fun_takes_flat_tree_arg=False,\n    fun_returns_flat_tree=False,\n    requires_low=False,\n) -> tuple[Jaxpr, ft.FlatTree]:\n  if config.no_tracing.value:\n    raise RuntimeError(f\"re-tracing function {fun} for \"\n                       \"`jit`, but 'no_tracing' is set\")\n  test_event(\"trace_to_jaxpr\")\n  config.enable_checks.value and debug_info.assert_arg_names(len(in_avals))\n  parent_trace = core.trace_ctx.trace\n  trace = DynamicJaxprTrace(debug_info, parent_trace=parent_trace,\n                            lower=requires_low)\n  # Name stack and the traceback scope are reset because the metadata on jaxpr\n  # equations should be rooted at the enclosing jaxpr and not contain any\n  # context from the callsite. Otherwise metadata from one caller would bleed\n  # into metadata from a different caller if we, e.g., inline.\n  with (core.ensure_no_leaks(trace), source_info_util.reset_name_stack(),\n        TracebackScope()):\n    source_info = source_info_util.current()\n    if requires_low:\n      if debug_info.arg_names is not None:\n        debug_info = debug_info._replace(arg_names=tuple(\n            name for aval, name in zip(in_avals, debug_info.arg_names)\n            for _ in aval.lo_ty()))","sourceCodeStart":2040,"sourceCodeEnd":2076,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/interpreters/partial_eval.py#L2040-L2076","documentation":"JAX has a diagnostic mode (jax_config no_tracing, often enabled via JAX_NO_TRACING=true) that forbids tracing: it exists to verify code is fully covered by caches/exports. If a jitted function misses the cache and needs re-tracing while this flag is on, tracing aborts with this RuntimeError.","triggerScenarios":"Setting config.no_tracing (e.g. export JAX_NO_TRACING=true) and then calling a jitted function that is not yet compiled/cached — the cache miss forces trace_to_jaxpr, which refuses. Also triggered by anything invalidating the cache (new argument shapes/dtypes, first call).","commonSituations":"CI or production environments that set JAX_NO_TRACING to enforce 'no surprise compilation'; first-call after process start; new input signatures after enabling the flag.","solutions":["Pre-warm the cache: call the function once with all expected shapes/dtypes before enabling no_tracing, or use AOT (jax.export / .lower(...).compile()) artifacts","Unset the flag (remove JAX_NO_TRACING / jax.config.update('no_tracing', False)) if dynamic tracing is expected","Ensure argument shapes/dtypes/static keys match exactly what was traced, so no cache-miss re-trace occurs"],"exampleFix":"# before\n# JAX_NO_TRACING=true in environment, first call of jitted fn\nresult = jitted_fn(x)\n\n# after\n# warm cache in setup, before enabling no_tracing:\nresult = jitted_fn(x_example)\n# then enable jax.config.update('no_tracing', True)","handlingStrategy":"validation","validationCode":"import jax\nassert not jax.config.no_tracing.value or cache_is_warm(fn, args), \\\n    'no_tracing set but function not yet compiled'","typeGuard":null,"tryCatchPattern":"try:\n    out = jitted_fn(x)\nexcept RuntimeError as e:\n    if 'no_tracing' in str(e):\n        jax.config.update('no_tracing', False)\n        out = jitted_fn(x)","preventionTips":["Warm caches or use AOT exports before enabling no_tracing","Keep argument signatures stable in no_tracing environments"],"tags":["jax","config","no-tracing","cache-miss","aot"],"backgroundTag":"config-flag-prevents-operation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}