Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: johnmarktaylor91/torchlens
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.22.0
Choose a base ref
...
head repository: johnmarktaylor91/torchlens
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.0
Choose a head ref
  • 4 commits
  • 9 files changed
  • 2 contributors

Commits on Mar 13, 2026

  1. feat(decoration)!: lazy wrapping — import torchlens has no side effects

    BREAKING CHANGE: torch functions are no longer wrapped at import time.
    Wrapping happens lazily on first log_forward_pass() call and persists.
    
    Three changes:
    
    1. Lazy decoration: removed decorate_all_once() / patch_detached_references()
       calls from __init__.py. _ensure_model_prepared() triggers wrapping on
       first use via wrap_torch().
    
    2. Public wrap/unwrap API:
       - torchlens.wrap_torch() — install wrappers (idempotent)
       - torchlens.unwrap_torch() — restore original torch callables
       - torchlens.wrapped() — context manager (wrap on enter, unwrap on exit)
       - log_forward_pass(unwrap_when_done=True) — one-shot convenience
       Old names (undecorate_all_globally, redecorate_all_globally) kept as
       internal aliases.
    
    3. torch.identity fix: decorated identity function now stored on
       _state._decorated_identity instead of monkey-patching torch.identity
       (which doesn't exist in PyTorch type stubs). Eliminates 2 mypy errors.
    
    Tests updated: 75 pass including 12 new lifecycle tests.
    johnmarktaylor91 committed Mar 13, 2026
    Configuration menu
    Copy the full SHA
    b5da8b8 View commit details
    Browse the repository at this point in the history
  2. fix(decoration): cast mode.device to str for mypy return-value check

    CI mypy (stricter torch stubs) catches that mode.device returns
    torch.device, not str. Explicit str() cast satisfies the Optional[str]
    return type annotation.
    johnmarktaylor91 committed Mar 13, 2026
    Configuration menu
    Copy the full SHA
    45c0ff3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e734beb View commit details
    Browse the repository at this point in the history
  4. chore(release): 1.0.0

    semantic-release committed Mar 13, 2026
    Configuration menu
    Copy the full SHA
    bd9ca16 View commit details
    Browse the repository at this point in the history
Loading