neuralqx.profile.profiler module¶
- class Profiler¶
Bases:
objectProcess-local profiler with hierarchical section timing and optional trace/telemetry.
- Thread-safety:
Each thread gets an independent stack to compute exclusive time.
Summary aggregation merges into a shared tree. Updates are guarded by a lock. (Summary updates happen at section exit only; trace emission is optional.)
- refresh_if_needed()¶
Refresh config if PROFILE toggled at runtime (common in notebooks).
This is designed to be extremely cheap in the steady state: it only reads os.environ[“NQX_PROFILE”] via profiling_enabled().
- Return type:
- maybe_sync(value)¶
Synchronize JAX arrays if configured. This can introduce delays.
- Return type:
- section(name, cat='', *, args=None, flops=0.0, bytes=0.0)¶
Create a profiling section context manager.
- step(step_num, name='step', cat='step', *, args=None)¶
Mark a repeated step. Adds metadata and (optionally) JAX step trace annotation.