Profiler handle most
callers discard.
Calling ci.shutdown() clears the singleton; ci.profile() after
that starts a fresh profiler. This is the supported way to reset
state between tests.
Signature
Parameters
None for snapshots / sample_rate / flush_interval means “use
the Cirron instance default”. Pass an explicit value to override
per-call.
What it does
- Resolves config (explicit
config=→ platform global → SDK defaults). - Reads platform context from
CIRRON_RUN_ID,CIRRON_PIPELINE_ID,CIRRON_DEPLOYMENT_ID,CIRRON_WORKSPACE_ID. - Selects a transport: kernel event stream (inside a Cirron pipeline or deployment), HTTP (with an API key), or file-only (neither).
- Autodetects installed frameworks unless
frameworks=is explicit. - Installs hooks for every detected framework. When multiple are
present, the priority order
transformers > tensorflow > torchdetermines which one owns the semanticepochandstepscopes via a sharedHookContext.owned_scopesmap; lower-priority hooks yield on those names and still produce their own lower-level scopes (torch still emitsforward/backward/optimizer_step/data_loadunder the transformers-ownedstep). - Starts the background flush thread.
- Registers
atexit, SIGTERM, and SIGINT handlers for clean shutdown. - Opens the
cirron.sessionroot scope withframework,device,cuda_count, andmixed_precisionattributes.
Snapshot modes
"full" is not recommended for models over 100M parameters. At 7B+,
even "sampled" is expensive; drop the sample_rate.
Output sinks
Theoutput= parameter selects which local sinks the flush thread
writes each batch to. It is independent of the platform transport:
when CIRRON_RUN_ID is set, batches still flow over the kernel event
stream regardless of output. Sinks control the local experience
(disk, logs, terminal), which is why output="none" is safe even
inside a Cirron pipeline.
Invalid values raise
ValueError at ci.profile() time, before any
hook is installed.
Returns
AProfiler handle exposing
health, flush,
trace, and shutdown.
Examples
Zero-touch
Explicit snapshot mode
sample_rate is the fraction of epoch boundaries that serialize raw
tensors. Higher values give more fidelity for debugging (e.g. you can
inspect the actual weight values at epoch 7 when loss spiked); lower
values keep storage and flush cost bounded. The default 0.01 (1 %)
is conservative. For small models or short runs, 0.05–0.1 is
reasonable; at 7 B+ parameters, stay at 0.01 or lower.
Disable hooks selectively
Dev-only kill switch
Notebook-friendly inspection
ci.trace for the full read-back surface.
Distributed training
Every rank callsci.profile(). The SDK reads RANK, LOCAL_RANK,
and WORLD_SIZE from the environment and tags every span with its
rank. The platform merges views at query time.
Related
Profiling guide
Narrative walk-through of training instrumentation.
Lifecycle
flush, health, and shutdown.