Skip to content

v2.31.0

Choose a tag to compare

@torchlens-release torchlens-release released this 10 Jul 17:17
· 17440 commits to main since this release

v2.31.0 (2026-07-10)

This release is published under the Apache-2.0 License.

Bug Fixes

  • api: Correct paper-era trace compatibility (2c96a50)

  • audit: Guard visual pack demo contrasts (a559c2d)

  • backends: Align preview capability handling (175054d)

  • capture: Emit compiled-unwrap note inside restoration guard (f505766)

  • capture: Exempt boolean dispatch pooling composites (f909554)

  • capture: Factory wrappers honor device context for explicit device=None (19f097c)

The Python factory-function wrappers bypass torch's C-level DeviceContext dispatch, so they re-inject the active device kwarg themselves. Two gaps let a torch.device('meta') context silently place tensors on CPU:

  1. _maybe_inject_device_kwarg skipped injection whenever 'device' was a key in kwargs -- but nn.Linear (and other modules) forward device=None explicitly via factory_kwargs. An explicit device=None means 'defer to the active context', exactly like an absent kwarg, so meta-context params came out on CPU once torch was wrapped. Only bail when a real (non-None) device is pinned.

  2. wrap_torch clears + repopulates torch's _device_constructors lru_cache with the wrapped callables, but unwrap_torch never cleared it. After an unwrap the cache stayed stale, so torch's device-context dispatch stopped recognising the restored original factories -- breaking meta context even for unwrapped torch. Clear the cache on unwrap so torch re-evaluates against the restored originals.

Regression tests cover the in-session normal-then-meta trace sequence (the meta guard must still fire), explicit device=None on the empty family, and unwrap restoring the meta context.

  • capture: Prune dead scoped candidate identities (4e21a14)

  • capture: Restore ignored routes and pre-hook effects (9487983)

  • capture: Support nonweakrefable module identities (163db6f)

  • capture: Tighten provenance typing (6d52add)

  • capture: Unwrap compiled models at public entry points (abb5d12)

  • compile: Unwrap compiled training capture entry points (5c077f5)

  • debug: Find_nan reports the nearest user frame (e44d046)

  • debug: Identify user frame by torchlens package dir, not path component (21cd1d7)

find_nan's live source-line walk classified library frames by testing for a 'torchlens' path component, which false-matched any checkout whose repo directory is named torchlens (e.g. .../torchlens/tests/...), hiding the real user frame and reporting launcher frames like under some pytest invocations. Match the actual torchlens/torch package directories instead, skip <frozen ...> launcher frames, and keep / as user code.

  • debug: Preserve capture option explicitness (40aa4a0)

  • docs: Make witness examples executable (764cdc3)

  • export: Qualify recurrent node ids (c56c719)

  • import: Preserve bundle callable after submodule import (9d0a888)

  • import: Preserve lazy facade exports over child modules (bd705fe)

  • import: Preserve lazy facade shim and wrapper fidelity (c194b5e)

  • intervention: Over-approximate in-place snapshot gating (d2283d7)

  • intervention: Parent module-splice replacement at consuming scope (d0d33e8)

  • intervention: Reconcile live and replay replacements (346425d)

  • intervention: Snapshot in-place-op inputs for post-hook interventions (0f4c305)

  • io: Accept pre_hook_input in tlspec validation (7c6c45a)

  • io: Drop live escape diagnostics from bundles (45f44f4)

  • io: Enforce tlspec version ceiling in validation (e4c5018)

  • io: Preserve audit-only body index compatibility (bc0a2a8)

  • io: Preserve conditional body cache across round trips (f20ccaa)

  • io: Preserve current null backend addresses (13bfaf1)

  • io: Preserve intervention trace portability (9def3c5)

  • io: Preserve tensor requires grad across round trips (f72dcfb)

  • io: Reject desynchronized tlspec body indexes (1d2f2c4)

  • io: Reject missing and corrupt tlspec manifests (444c8a8)

  • io: Type witness diagnostic defaults (936825f)

  • io: Validate annotation blobs emitted by tlspec writer (06494b3)

  • report: Preserve subsecond profile timings (6e9a265)

  • selectors: Reject non-string function patterns (32808fa)

  • tinygrad: Adapt preview capture to 0.13 semantics (66b82cc)

  • validation: Align witness accounting across capture paths (078d8dc)

  • validation: Correct completeness witness claims (067a46b)

  • validation: Count distinct replay nodes (13db70b)

  • validation: Initialize witness counters when witness is off (db9ca6a)

  • validation: Isolate replay state for stateful models (62ac1b4)

  • validation: Perturb copy source values (acb0293)

  • validation: Preserve reproducibility capture identity (3d95a43)

  • validation: Reject exempted-only replay passes (bd41543)

  • validation: Require per-op exclusion proof for selective save (13069b7)

  • validation: Restore snapshotable attrs independently (de250ae)

  • validation: Support retained orphan islands (25e9e60)

  • visualization: Handle dropped orphan renders (60d2010)

  • viz: Decompose child segment buffer counts (e0789c4)

  • viz: Decompose collapsed-module count into ops and buffers (b25a631)

  • viz: Exclude finished-trace orphan from its own co-parent/sibling labels (e5423c0)

  • viz: Improve feature maps and scree legends (eb8af16)

  • viz: Keep repeated if labels pass-aware (c9933ab)

  • viz: Make orphan Op repr safe (d8dce28)

  • viz: Preserve trainability honesty in run folds (65ed90b)

  • viz: Recompute segment edge cluster owner (3410f58)

  • viz: Render-faithful collapse plan counts (d9652ac)

  • viz: Summarize module output ops (eeeadf4)

Chores

  • data: Remove dead annotation revision state (a572df3)

  • types: Broaden escape-detector prior_profile annotation for strict mypy (3069640)

sys.getprofile() is typed with a Literal event param in modern typeshed; store the prior hook as Callable[..., Any] | None. Behavior-neutral.

  • types: Repo-wide mypy zero (ada6535)

Documentation

  • api: Correct migration and debug references (b13d63c)

  • capture: Document pre-hook provenance limits (d28fc2d)

  • capture: Document scoped patching rollout (61cc214)

  • capture: Explain view save aliasing (c3942ac)

  • migration: Fix stale snippets found by verification pass (b16ca5e)

  • migration: Restore two-sided migration-test contract (e98bee8)

  • performance: Document witness overhead and scope (1a86306)

  • positioning: Document detached-reference handling (20c5946)

  • reference: Add collapse visual reference gallery (e51a0d3)

  • reference: Tl.debug, tl.export, tl.attribution reference pages with executable examples (6a68c5a)

Features

  • capture: Add pre-hook input provenance mechanism (d6965e9)

  • capture: Add real scoped detached patching (a268c31)

  • capture: Add shadow escape detector (8232b13)

  • capture: Gracefully unwrap torch.compile models (fd18eaa)

  • debug: Add find_nan diagnostics (6265039)

  • hash: Expose structural hash CI tripwire (4cf5530)

  • io: Bump pre-hook provenance schema to v6 (101e1b7)

  • trace: Add profile and audit reports (3aca629)

  • validation: Add torch dispatch completeness witness (06a40c2)

  • viz: Rename draw kwarg fold_runs to fold_repeats (18f141e)

Clean break for the new collapse repeat-folding option; no deprecated alias is kept.

Performance Improvements

  • capture: Add constant-time prehook fast path (f3200a8)

  • import: Lazify core feature facades (b2f973f)

Refactoring

  • validation: Remove dead pass-dedup branches; pin all-pass replay (d3dece8)

The replay pipeline already validates every pass of multi-pass layers (BFS enqueues pass-qualified op labels); the single-representative-op selection and parent-layer dedup branches were dead code on the pipeline path. Remove them, pin the all-pass behavior with regression tests, and harden the internal validate_parents_of_saved_layer entry against bare multi-pass labels.

Testing

  • Guard optional-dep doc snippets and torch<2.2 pre-wrap-vmap witness case (aa7a97e)

  • doc-snippet runner skips a block when it needs an unavailable optional dependency
    (e.g. tl.export.xarray without xarray installed) instead of failing on lean CI envs.

  • the graceful pre-wrap-vmap transform-escape witness-only path requires torch>=2.2;
    on the 2.1 best-effort floor the escaped output honestly raises, so skip there.

  • backend: Regenerate field-order golden (f276ea2)

  • capture: Allowlist non-introspectable arg-specs for newly-wrapped factory routes (86c18a6)

  • capture: Certify scoped escape boundaries (ac249b5)

  • capture: Compare scoped policy across model zoo (28c48fc)

  • capture: Cover pre-hook provenance matrix (fba850b)

  • goldens: Regenerate tlspec manifest projection (e027813)

  • portability: Guard local menagerie dependencies (277a431)

  • train: Exempt provenance snapshot detach (775481d)

  • validation: Align alias-contract test to honest unverified status for selective traces (8b2441b)

  • validation: Certify dispatch completeness witness (8e9be72)

  • validation: Cover replay defaults and stateful warnings (c3499ca)

  • validation: Document witness field lifecycle (3e2e36f)

  • validation: Pin exemption registries and exact perturbation gate (93193e5)

  • validation: Seed perturbation exception case (3eb9443)

  • viz: Re-snapshot module containment for synthetic splice op (fc7e4b6)


Detailed Changes: v2.30.1...v2.31.0