﻿# JAX debug callbacks: runtime inspection does not guarantee an audit event

Use JAX debug callbacks for runtime numerical inspection while keeping durable event accounting separate from transformation-dependent diagnostic effects.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-jax-debug-callback-audit-boundary/
Language: en

## Choose the question the callback should answer

A developer wants to inspect intermediate activations inside a compiled model. Ordinary Python printing can show traced placeholders instead of runtime values. The [external-callback guide](https://docs.jax.dev/en/latest/external-callbacks.html) explains host-side callbacks and distinguishes debug, pure and I/O callbacks. Choose a debug callback for numerical observation. A durable record that a request completed is a separate service requirement and should not be inferred from whether a diagnostic message appeared.

## Expect transformation-dependent observations

The [debug callback reference](https://docs.jax.dev/en/latest/_autosummary/jax.debug.callback.html) explicitly permits effects to be dropped, duplicated or reordered by higher-order transformations. That behavior is useful for understanding the transformed program, but it prevents interpreting message count as an exactly-once step count. For a batched experiment, record which transformation was applied before concluding that repeated prints demonstrate duplicate model requests or that missing prints prove missing computation.

## Review the values made observable

The [compiled-print guide](https://docs.jax.dev/en/latest/debugging/print_breakpoint.html) explains that exposing an intermediate can force materialization and interfere with fusion. Debugging may therefore change memory behavior or numerical details of the compiled calculation. Observe the smallest useful quantity, such as a summary needed to locate a failure. Compare the issue with diagnostics removed before treating the instrumented program's behavior as the production baseline.

## Separate value readiness from effect completion

A numerical result becoming available does not necessarily mean asynchronous debug output has finished. The compiled-print guide documents an effects barrier for waiting on outstanding side effects. Use the appropriate synchronization boundary when a test needs to capture diagnostic output. Do not add a broad wait to every request merely to make logging appear orderly; first establish whether the test is observing a numerical value, a callback effect or a service lifecycle event.

## Preserve production event meaning outside diagnostics

Keep durable request accounting and model-result validation in layers whose contracts support those purposes. If runtime I/O is necessary inside a transformed calculation, review the dedicated callback's supported transformations rather than replacing its semantics with a debug hook. The guides on [terminal request consistency](/journal/provider-terminal-request-record-consistency/) and [stream success measurement](/journal/provider-stream-success-sli-denominator/) show why observation boundaries matter. Diagnostic visibility and a reliable completion record answer different questions about the same workload.
