Repository navigation
Support nnsight >= 0.6 - #10
Merged
Merged
Conversation
nnsight 0.6 reworked the tracing/.save() mechanism (mount-once, never unmount) and removed the proxy `.output.stop()` early-stop plus the scan/validate trace kwargs. - cache.py: capture the tracer (`with model.trace(...) as tracer:`) and call `tracer.stop()` instead of the removed `last_submodule.output.stop()`. - cache.py, buffer.py: drop the scan/validate trace kwargs (no-ops in 0.6). - pyproject: require nnsight>=0.6. ActivationCache.collect() output is unchanged: activations are bit-identical under nnsight 0.6.3 vs 0.5.15 (verified on a 3B model).
Sitavi
force-pushed
the
nnsight-0.6-compat
branch
from
June 29, 2026 18:48
f25003e to
0bb3175
Compare
Member
|
@Sitavi tracer_kwargs is dead code now no? I think we cna remove it directlyt instead of just having it empty |
The scan/validate kwargs were dropped for nnsight 0.6, leaving tracer_kwargs as an empty dict splatted into .trace(). Remove it and the ** splats (cache.py, buffer.py). interp.py keeps its own (still uses invoker_args).
Author
|
Yeah good point, removed it! @Butanium |
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make
dictionary_learningcompatible with nnsight >= 0.6 (currently capped at<0.6).Why
nnsight 0.5.x runs
.save()/ tracing on process-global state (Globals.stack,Globals.saves), mounting/unmounting the.save/.stopproxies on every traceenter/exit guarded by a non-atomic counter. Under overlapping traces (e.g. multi-GPU
device_maphooks, or concurrent traces) this desyncs and surfaces asAttributeError: 'Tensor' object has no attribute 'save'/SystemError: unmount ....nnsight 0.6 fixes this by redesigning the mechanism to mount-once / never-unmount.
Upgrading is blocked by two 0.5-only idioms in
ActivationCache.collect():last_submodule.output.stop()— the proxy.stop()early-stop was removed in 0.6→
AttributeError: 'Tensor' object has no attribute 'stop'.scan=/validate=trace kwargs — obsolete in 0.6 (accepted as no-ops);dropped for cleanliness.
Changes
cache.py: capture the tracer (with model.trace(...) as tracer:) and calltracer.stop()instead oflast_submodule.output.stop().cache.py,buffer.py: drop thescan/validatetrace kwargs (theDEBUG-gateddict →
{}; nnsight 0.6 no longer has these kwargs).pyproject.toml:nnsight>=0.4,<0.6→nnsight>=0.6.No public API changes; no behavior change to activation collection.
Validation
Tested in isolated venvs that differ only in the nnsight/nnterp version (same torch,
transformers, model — so any difference is attributable to the upgrade):
ActivationCache.collect()is bit-identical on nnsight 0.6.3 vs 0.5.15(
max_abs_diff = 0.0,np.array_equal == True) — verified on a tiny model and on areal 3B model (layer 27, 3072-dim).
collect()raisesAttributeError: 'Tensor' object has no attribute 'stop'on 0.6.3 (the blocker, reproduced).pytest tests/→ 12 passed / 4 skipped (CUDA-gated), identical onnnsight 0.5.15, 0.6.3 and 0.7.0.
collect()): every nnsight idiom inevaluation.py/buffer.py/interp.py(invoker_args,model.output.save()/model.input.save(),submodule.input[0].save(), and the assignment-writessubmodule.output = (x_hat,)/submodule.output[0][:] = 0) behaves identicallyacross 0.5.15 / 0.6.3 / 0.7.0 (intervention-effective, same logit deltas). The change
is behaviour-preserving for the whole package, not only the cache path.
>=0.6) — both nnsight 0.6.3 and 0.7.0(with nnterp 1.3.0) pass the full check above.