Instrument model boundaries
Hooks synchronize the accelerator at layer entry and exit, recording start time, duration, shapes, phase, and device without changing model code.
LayerLens reveals exactly when each transformer layer executes—from prompt prefill through every KV-cache decode step—so inference bottlenecks become visible, measurable, and comparable.
Gate and up projections consume the same activation. Product Atlas computes each bit-identical x[j] × weight value once, then routes it to every matching output in both matrices. The operation count fell 76.97% on a real Qwen3.5 BF16 MLP pair.
The new profiler walks from exact BF16 bit patterns through sigmoid and SiLU, activation coordinates and tiles, sibling matrix products, attention heads, blocks, and the layer stack. It keeps candidates only when both the dependency boundary and measured wall time make sense.
LayerLens captured native BF16 inputs and outputs from Qwen3.5, then replayed each projection with no cache, an exact memory cache, and a persistent SQLite cache. The early projection saved work; the contextual projection did not. Admission is decided per module from measured wall time.
LayerLens precomputed every possible 8-bit significand product, then used real Qwen weights and activations. Parallel direct lookup beat native elementwise multiplication, but sign/exponent reconstruction and unfused accumulation erased the gain in the complete projection.
LayerLens now simulates a bounded full-block LRU cache, then groups queued requests by the longest reusable prefix. It reports the layer-token evaluations an engine can skip without storing prompt text.
$ layerlens-cache-plan workload.json \
--block-size 4 \
--capacity-blocks 4 \
--layers 24
FCFS 0 / 2304 layer-token ops avoided
PREFIX 1152 / 2304 layer-token ops avoided
ORDER 0 → 2 → 4 → 1 → 3 → 5
Use the built-in collectors, embed the Python API, or publish a third-party adapter. Installed adapters appear in the same CLI automatically—without changing LayerLens source.
$ layerlens-capture --list-runtimes ollama vllm my-runtime $ layerlens-capture \ --runtime my-runtime \ --model provider/model \ --prompt "Benchmark prompt" \ --output traces/run.json
Hooks synchronize the accelerator at layer entry and exit, recording start time, duration, shapes, phase, and device without changing model code.
Step zero represents prompt prefill and first-token latency. Every following step isolates one KV-cache decode pass.
Portable JSON traces make model, runtime, hardware, and configuration comparisons reproducible and easy to share.