transformer_lens.benchmarks.activation_cache module

Activation cache benchmarks for TransformerBridge.

transformer_lens.benchmarks.activation_cache.benchmark_activation_cache(bridge: TransformerBridge, test_text: str, reference_cache: dict[str, Tensor] | None = None, tolerance: float = 0.001) → BenchmarkResult

Benchmark activation cache values against a reference activation snapshot.

Parameters:
  • bridge – TransformerBridge model to test

  • test_text – Input text for testing (must match the snapshot’s prompt)

  • reference_cache – Optional reference activations keyed by hook name (e.g. a golden fixture snapshot). Structural self-check only if None.

  • tolerance – Tolerance for activation comparison

Returns:

BenchmarkResult with cache value comparison details

transformer_lens.benchmarks.activation_cache.benchmark_run_with_cache(bridge: TransformerBridge, test_text: str) → BenchmarkResult

Benchmark run_with_cache functionality (structural self-check).

Parameters:
  • bridge – TransformerBridge model to test

  • test_text – Input text for testing

Returns:

BenchmarkResult with cache functionality details