globals¶
globals
¶
Object
¶
Bases: Tensor
save
¶
Save an object to be accessable after the trace context is exited.
Examples:
model = LanguageModel("gpt2", device_map='auto', dispatch=True) with model.trace("Hello World"): ... attn_0 = model.transformer.h[0].attn.output.save() print(attn_0)
TracingCache
¶
Globals
¶
Process-wide tracing state.
Holds two pieces of true global state:
- saves: set of id() for objects marked via .save().
The root tracer's push() filters its frame locals against this
set so only saved values propagate out of the trace.
- cache: source/AST/code-object memoization across traces.
Root-vs-inner detection lives on the tracer itself — see
Tracer.push — by checking whether the target frame is an
nnsight-generated frame (i.e., another trace's compiled body).