Skip to content

bench: kernel-level SC MSE profiling + ablation tooling#21

Open
heroarmor wants to merge 1 commit into
change/scramble-defaults-onfrom
bench/sc-mse-profiling
Open

bench: kernel-level SC MSE profiling + ablation tooling#21
heroarmor wants to merge 1 commit into
change/scramble-defaults-onfrom
bench/sc-mse-profiling

Conversation

@heroarmor
Copy link
Copy Markdown
Collaborator

Adds a bench/ directory with a unit-level error harness for sc_matmul vs the exact a @ b.T, on real operand tensors captured from a model (no model forward in the sweep loop).

Contents

file role
capture_real_tensors.py hook a HF model's Linears, dump (a,b) operand pairs
mse_profile.py per-config error sweep (MSE/RMSE/max abs/rel_fro/cosine)
ablation.py stoc_len × halve × scramble grid, mean MSE + scramble-effect / halve-cost summaries
README.md method, usage, results table, findings

Fixed: per_row, bipolar, sc_prec=8, chunk_d=128. Calls clear_rng_cache() before every measured matmul (cache isn't keyed by scramble mode).

Findings (Llama-3.1-8B operands, mean MSE over 21 tensors)

  • Scramble (bitrev ≳ counter ≫ off) is increasingly essential as the stream shortens: +0% @256 → +378% @64+1063% @16 MSE if removed. No-op at 256 (sanity control).
  • halve (RNG grid 256→128) is free / a net win for bipolar (−44% MSE @256, ≈0% elsewhere) — magnitudes only span 2^(prec-1) levels.
  • Best config across the grid: halve + bitrev.

Captured .pt (1.3 GB) and run logs are .gitignored — regenerate with capture_real_tensors.py.

🤖 Generated with Claude Code

Adds bench/ with a unit-level error harness for sc_matmul vs exact a @ b.T on
real operand tensors captured from a model:

  * capture_real_tensors.py - hook a HF model's Linears, dump (a, b) pairs
  * mse_profile.py          - per-config error sweep (MSE/RMSE/maxabs/rel_fro/cos)
  * ablation.py             - stoc_len x halve x scramble grid, mean MSE + summaries
  * README.md               - method, usage, results table, findings

Findings (Llama-3.1-8B operands): scramble (bitrev>=counter>>off) is
increasingly essential as the stream shortens (+1063% MSE @ stoc_len=16 if
removed); halve (RNG grid 256->128) is free/net-win for bipolar; best config is
halve+bitrev across the grid.

Captured .pt and run logs are gitignored (regenerable).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

3 participants