In this article
Python side effects occur during tracing rather than defining a reliable runtime state update for a transformed JAX function.
Notice the stale value before changing the GPU
A scoring function reads a global calibration factor. A notebook changes that factor, but repeated compiled calls keep producing the earlier result. The JAX sharp-bits guide demonstrates globals captured during tracing and later calls reusing the captured value. This is a program-state problem, not evidence that a GPU ignored new data that was explicitly passed to it.
Make evolving state an explicit argument
The stateful-computation guide recommends expressing evolving state through function inputs and returned state. In a calibration pipeline, pass the factor into the numerical function rather than updating a global between requests. If a step changes a running statistic, return the new statistic and route it into the next step. This makes the dependency visible to both the transformation and the reader reviewing the inference path.
Distinguish a trace from an execution log
The JIT guide explains that ordinary Python side effects are not recorded as numerical operations in the traced program. Appending a value to a global list or incrementing a Python counter inside the function therefore does not reliably count runtime invocations. A changed input type or shape can trigger another trace, making the apparent behavior inconsistent. Avoid using such counters to infer how many batches the accelerator actually processed.
Reproduce the dependency in a small example
Construct a pilot with an explicit calibration input and the same input held in a global. Change the value while preserving ordinary array shapes, then compare the observed outputs. Keep the pilot separate from production state. Its purpose is to identify a missing dependency in the function contract. Clearing compilation state may temporarily conceal the symptom, but it does not repair the implicit connection between external Python state and the desired calculation.
Keep model state distinct from service bookkeeping
Runtime request counts, audit records and model statistics have different purposes. Store service bookkeeping in the service layer and make numerical state part of the intended function contract. The guides on autograd computation graphs and request correlation identifiers provide related distinctions. A dependable system can explain both what arithmetic was requested and which request invoked it without pretending that an unrecorded Python side effect is part of the compiled computation.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.