Skip to content

fix(benchmarks): remove hooks via HookPoint instead of bogus add_hook handle#1426

Open
danra wants to merge 1 commit into
TransformerLensOrg:devfrom
danra:fix_benchmark_hooks_cleanup
Open

fix(benchmarks): remove hooks via HookPoint instead of bogus add_hook handle#1426
danra wants to merge 1 commit into
TransformerLensOrg:devfrom
danra:fix_benchmark_hooks_cleanup

Conversation

@danra

@danra danra commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description

HookPoint.add_hook returns None, but the benchmark helpers stored its return value as a "handle" (silencing mypy with behind an if handle is not None guard). Since the value was always None, the guard was always false and the capture hooks were never removed.

Track the HookPoint that was registered on and clean up via hook_point.remove_hooks() (dir="bwd" for backward hooks), matching the existing idiom in TransformerBridge.run_with_cache.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

… handle

HookPoint.add_hook returns None, but the benchmark helpers stored its
return value as a "handle" (silencing mypy with
behind an `if handle is not None` guard). Since the value was always None,
the guard was always false and the capture hooks were never removed.

Track the HookPoint that was registered on and clean up via
hook_point.remove_hooks() (dir="bwd" for backward hooks), matching the
existing idiom in TransformerBridge.run_with_cache.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@danra danra changed the title fix(benchmarks): remove hooks via HookPoint instead of bogus add_hook… fix(benchmarks): remove hooks via HookPoint instead of bogus add_hook handle Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant