Skip to content

Commit 34a15a9

Browse files
author
semantic-release
committed
chore(release): 0.5.0
1 parent 58e9ac0 commit 34a15a9

File tree

3 files changed

+92
-2
lines changed

3 files changed

+92
-2
lines changed

CHANGELOG.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,96 @@
11
# CHANGELOG
22

33

4+
## v0.5.0 (2026-02-28)
5+
6+
### Bug Fixes
7+
8+
- **logging**: Revert children_tensor_versions to proven simpler detection
9+
([`ade9c39`](https://github.com/johnmarktaylor91/torchlens/commit/ade9c39f15604459af9134ffcb770ae08238f5cf))
10+
11+
The refactor version applied device/postfunc transforms to the stored value in
12+
children_tensor_versions, but validation compares against creation_args which are always raw. This
13+
caused fasterrcnn validation to fail. Revert to the simpler approach that stores raw arg copies
14+
and was verified passing twice.
15+
16+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17+
18+
- **postprocess**: Gate output node variations on has_child_tensor_variations
19+
([`4106be9`](https://github.com/johnmarktaylor91/torchlens/commit/4106be93168cbff4b346a70f06417556c3444490))
20+
21+
Don't unconditionally store children_tensor_versions for output nodes. Gate on
22+
has_child_tensor_variations (set during exhaustive logging) to avoid false positives and preserve
23+
postfunc-applied tensor_contents.
24+
25+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26+
27+
- **postprocess**: Rebuild pass assignments after loop detection and fix output handler
28+
([`847b2a7`](https://github.com/johnmarktaylor91/torchlens/commit/847b2a79202cee13bf2ba231153b71068cf6311a))
29+
30+
Two fixes:
31+
32+
1. _rebuild_pass_assignments: Multiple rounds of _expand_isomorphic_subgraphs can reassign a node to
33+
a new group while leaving stale same_layer_operations in the old group's members. This caused
34+
multiple raw tensors to map to the same layer:pass label, producing validation failures (e.g.
35+
fasterrcnn). The cleanup step groups tensors by their authoritative layer_label_raw and rebuilds
36+
consistent pass numbers.
37+
38+
2. Output node handler: Replaced the has_child_tensor_variations gate with a direct comparison of
39+
actual output (with device/postfunc transforms) against tensor_contents using tensor_nanequal.
40+
This correctly handles in-place mutations through views (e.g. InPlaceZeroTensor) while preserving
41+
postfunc values for unmodified outputs.
42+
43+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44+
45+
- **validation**: Handle bool and complex tensor perturbation properly
46+
([`dfd2d7b`](https://github.com/johnmarktaylor91/torchlens/commit/dfd2d7be8dce252312235f954446e98357ccfe35))
47+
48+
- Generate proper complex perturbations using torch.complex() instead of casting away imaginary part
49+
- Fix bool tensor crash by reordering .float().abs() (bool doesn't support abs, but float
50+
conversion handles it) - Add ContextUnet diffusion model to example_models.py for self-contained
51+
stable_diffusion test - Update test_stable_diffusion to use example_models.ContextUnet
52+
53+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54+
55+
### Features
56+
57+
- **logging**: Generalize was_getitem_applied to has_child_tensor_variations
58+
([`1177f60`](https://github.com/johnmarktaylor91/torchlens/commit/1177f607bf6406d47424c8b05755aec86d992dcb))
59+
60+
Replace the getitem-specific parent detection with runtime mismatch detection that catches any case
61+
where a parent's tensor_contents diverges from what children actually received (getitem slicing,
62+
view mutations through shared storage, in-place ops after logging, etc.).
63+
64+
Key changes: - Rename was_getitem_applied → has_child_tensor_variations - Detection now compares arg
65+
copies against parent tensor_contents at child-creation time, with transform-awareness (device +
66+
postfunc) - Output nodes now detect value changes vs parent tensor_contents - Use tensor_nanequal
67+
(not torch.equal) for dtype/NaN consistency - Fix fast-mode: clear stale state on re-run, prevent
68+
double-postfunc - Use clean_to and try/finally for _pause_logging safety - Add 6 view-mutation
69+
stress tests (unsqueeze, reshape, transpose, multiple, chained, false-positive control)
70+
71+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72+
73+
### Refactoring
74+
75+
- **loops**: Cherry-pick approved changes from feat/loop-detection-hardening
76+
([`33e0f22`](https://github.com/johnmarktaylor91/torchlens/commit/33e0f223d12aae806799f3853ed6e221b1232274))
77+
78+
- Rename 10 loop detection functions to clearer names (e.g.
79+
_assign_corresponding_tensors_to_same_layer → _detect_and_label_loops,
80+
_fetch_and_process_next_isomorphic_nodes → _advance_bfs_frontier) - Rename 6 local variables for
81+
clarity (e.g. node_to_iso_group_dict → node_to_iso_leader, subgraphs_dict → subgraph_info) - Add
82+
SubgraphInfo dataclass replacing dict-based subgraph bookkeeping - Replace list.pop(0) with
83+
deque.popleft() in BFS traversals - Remove ungrouped sweep in _merge_iso_groups_to_layers - Remove
84+
safe_copy in postprocess_fast (direct reference suffices) - Rewrite _get_hash_from_args to
85+
preserve positional indices, kwarg names, and dict keys via recursive _append_arg_hash helper -
86+
Remove vestigial index_in_saved_log field from TensorLogEntry, constants.py, logging_funcs.py, and
87+
postprocess.py - Fix PEP8: type(x) ==/!= Y → type(x) is/is not Y in two files - Split
88+
test_real_world_models.py into fast and slow test files - Add 12 new edge-case loop detection test
89+
models and test functions
90+
91+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
92+
93+
494
## v0.4.1 (2026-02-26)
595

696
### Bug Fixes

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "torchlens"
7-
version = "0.4.1"
7+
version = "0.5.0"
88
description = "A package for extracting activations from PyTorch models"
99
readme = "README.md"
1010
license = "GPL-3.0-only"

torchlens/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Top level package: make the user-facing functions top-level, rest accessed as submodules."""
22

3-
__version__ = "0.4.1"
3+
__version__ = "0.5.0"
44

55
from .user_funcs import (
66
log_forward_pass,

0 commit comments

Comments
 (0)