{"record":{"id":"3726b78f9c49e399","repo":"jax-ml/jax","slug":"str-exc","errorCode":null,"errorMessage":"{str(exc)}","messagePattern":"\\{str\\(exc\\)\\}","errorType":"exception","errorClass":"JaxRuntimeError","httpStatus":null,"severity":"error","filePath":"jax/_src/checkify.py","lineNumber":488,"sourceCode":"\ncore.pp_eqn_rules[check_p] = _pp_check\n\n# TODO(lenamartens): inherit from Exception instead of ValueError.\nclass JaxRuntimeError(ValueError):\n  pass\n\n@check_p.def_impl\ndef check_impl(*args, err_tree, debug):\n  if debug:\n    # NOOP (check will only trigger when discharged)\n    return []\n  error = tree_unflatten(err_tree, args)\n  exc = error.get_exception()\n  if exc:\n    filtered_tb = traceback_util.filter_traceback(\n        exc.traceback_info.as_python_traceback())\n    exc.with_traceback(filtered_tb)\n    raise JaxRuntimeError(str(exc)) from exc\n  return []\n\n@check_p.def_effectful_abstract_eval\ndef check_abstract_eval(*args, err_tree, debug):\n  del debug\n  return [], set(tree_unflatten(err_tree, args)._pred.keys())\n\n# TODO(lenamartens) add in-depth error explanation to link to in module docs.\nfunctionalization_error = ValueError(\n    'Cannot abstractly evaluate a checkify.check which was not'\n    ' functionalized. This probably means you tried to stage'\n    ' (jit/scan/pmap/...) a `check` without functionalizing it'\n    ' through `checkify.checkify`.'\n    )\n\ndef check_lowering_rule(ctx, *args, err_tree, debug):\n  if debug:\n    # NOOP (check will only trigger when discharged)","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/checkify.py#L470-L506","documentation":"This is the user-facing re-raise when a checkify-instrumented function fails at runtime: the deferred error collected by checkify.check is converted to JaxRuntimeError with the original formatted message.","triggerScenarios":"Calling a function wrapped with checkify.checkify(...) (and checkified) whose check/debug_check predicate evaluated False during execution.","commonSituations":"Numeric assertions like NaN checks, index bounds, or custom invariants failing inside jit-compiled code; the whole point of checkify — surfacing logical errors from compiled code.","solutions":["Inspect the message: it names which check failed and its formatted arguments","Fix the underlying logic so the check predicate passes","If NaNs are the cause, gradient-clip, tune learning rate, or sanitize inputs; use jax.debug_nans to locate them"],"exampleFix":"# before\nchecked_fn = checkify.checkify(f)\nerr, out = checked_fn(x)  # later raises JaxRuntimeError('nan check failed')\n# after\ndef f(x):\n  checkify.check(~jnp.isnan(x).any(), 'nan in x')\n  return jnp.where(jnp.isnan(x), 0., x)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err, out = checked_fn(x)  # functional API avoids the raise\nif err:\n    print(err.get())  # inspect before it ever raises\n    handle(out)","preventionTips":["Use checkify's functional API: inspect err explicitly instead of checkified_fn which raises","Sanitize inputs and clip gradients to keep NaN checks passing"],"tags":["jax","checkify","assertion","debugging"],"backgroundTag":"assertion-failed","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}