Matrix-Free Butterfly Compression
Implementation & benchmark of arXiv:2607.29361 — A recursive butterfly factorization with optimality guarantees
Source paper: A recursive butterfly factorization with optimality guarantees arXiv:2607.29361 ⓘ · analyzed Aug 31, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Compress an existing dense neural-network weight matrix into a recursive butterfly operator using Gaussian sketches of complementary blocks. This is useful for deployment or distillation: the dense model provides an oracle for matrix-vector products, while the compressed model stores only recursive transfer bases and small cores. The generalized Nyström identity gives exact reconstruction for rank-k blocks and a principled approximation route for numerically low-rank blocks.
Formulas
Mathematical statement
For a rank-at-most-k matrix A in R^{2k x 2k}, draw Gaussian test matrices Omega and Psi in R^{2k x alpha k}, where alpha>1 is an oversampling factor. Let U be the top k left singular vectors of A Omega. The paper states that, almost surely, A=U(Psi^T U)^dagger Psi^T A, where dagger is the Moore-Penrose pseudoinverse. For a general neural-network weight W, apply this identity approximately to complementary blocks W(I_{i,ell},I_{j,L-ell}) at each dyadic level, retain k singular directions, and recursively share the resulting bases through B=UXV^T with X_{s,t} in BF(L-2,k). The Gaussian sketches recover the relevant column and row subspaces with probability one in the exact rank-k setting; for real weights, the discarded singular values determine the approximation error.
Implementation notes
Use this as an offline conversion pass for a trained dense Linear layer W, or for a black-box linear operator exposing matvec(W,v) and matvec(W^T,v). Choose L and k, construct dyadic row and column partitions, and process levels ell=L,L-2,...,2. For each required complementary block, draw Gaussian sketches with alpha*k columns: Y_block=W_block Omega_block and Z_block=W_block^T Psi_block. Compute rank-k orthonormal bases U_block=QR_k(Y_block) and V_block=QR_k(Z_block). Estimate the small core by least squares, C=(Psi^T U_block)^dagger(Psi^T W_block), or, when explicit subblocks are available, C=U_block^T W_block V_block. Fold these bases into the block-diagonal outer factors U and V and recurse on the four cores X_{s,t}; at level zero, use the generalized Nyström formula directly on each 2k-by-2k core. The exact identity applies when a block has rank at most k; for real weights, estimate quality using fresh random test vectors and explicit Frobenius error on small layers. Begin with a ViT-Tiny or 4-layer Transformer, compress MLP weights to achieve 4x fewer parameters, and compare dense inference, standard truncated SVD, and butterfly compression. Evaluate operator relative error, validation accuracy, latency, peak memory, and serialized model size. Success means lower latency and memory at the same accuracy, with random-vector operator error predicting downstream accuracy degradation.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Confirmed ✓
Stage 2 · Practical benchmark result: Inconclusive
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 9/10
Built a readable generalized Nyström MVP with a true matrix-free matvec/rmatvec API plus an explicit blockwise compression experiment. Recovery switched from large error at k<rank (1.044, 1.013) to machine precision at k>=3; exact-rank error stayed near 1e-15 across alpha=1 to 4; and perturbation error scaled linearly with noise magnitude with origin-fit R²=0.999999998. The toy block matrix achieved 1.02e-15 relative error with 2x storage reduction, but the prototype was slower than dense copying and global SVD at this tiny scale.
- Agent confidence
- 9/10
- Baseline
- Dense: zero error and 1024 stored values; global rank-8 SVD: relative error 0.4602 and 512 nominal factor values.
- Idea
- Blockwise rank-2 Nyström: relative error 1.02e-15, 512 factor values, versus 1024 dense values; runtime 4.63e-3 seconds. Matrix-free rank-4 exact-rank check: relative error 6.31e-16.
Limitations: The prototype implements matrix-free generalized Nyström and independent dyadic-style blocks, not the paper's complete recursive basis folding into BF(L-2,k) cores. It did not test a trained Transformer or MLP, downstream accuracy, GPU inference latency, serialized formats, adaptive ranks, or realistic noisy neural weights; timing at this tiny scale is not representative.
How to run: python3 run_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.29361)
Ahead of the baseline (−4.0%) but not statistically significant (p=0.7246, wins 5 / 8 paired seeds).
- Benchmark
- Tabular regression (Friedman)
- Model
- mlp_tiny
- Paired seeds
- 8
- Baseline mean
- 15.3926
- Idea mean
- 14.783
- Effect (Δ)
- -0.6096 (−4.0%; negative = idea better)
- Wins
- 5 / 8 paired seeds
- p-value
- 0.7246 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±27.3%
- Mechanism
- Confirmed ✓
- Practical effect
- Inconclusive
- Baseline tuning
- swept over 3 configs
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 9/10
Built and ran matched dense and blockwise butterfly-factorized mlp_tiny systems on the registered tabular Friedman#1 benchmark. The idea reduced parameters by 63.3% and slightly improved mean MSE, but the paired permutation test was not significant (p=0.7246), so there is no demonstrated benchmark win.
- Baseline
- Best dense mlp_tiny, lr=0.006, wd=0.0: test MSE 15.392620921134949 across 8 paired seeds.
- Idea
- BlockButterflyLinear rank=8, lr=0.006, wd=0.0: test MSE 14.783010005950928 across 8 paired seeds; 1809 versus 4929 parameters.
- Paired
- delta_mean=-0.609610915184021, idea_wins=5/8, permutation p=0.7246.
Benchmark result
Ahead of the baseline (−4.0%) but not statistically significant (p=0.7246, wins 5 / 8 paired seeds).
- Benchmark
- Tabular regression (Friedman)
- Model
- mlp_tiny
- Paired seeds
- 8
- Baseline mean
- 15.3926
- Idea mean
- 14.783
- Effect (Δ)
- -0.6096 (−4.0%; negative = idea better)
- Wins
- 5 / 8 paired seeds
- p-value
- 0.7246 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±27.3%
- Mechanism
- Confirmed ✓
- Practical effect
- Inconclusive
- Baseline tuning
- swept over 3 configs
Artifacts
- bench_report.json 3.6 KB View Raw
- matrix_free_butterfly.py 2.1 KB View Raw
- report.md 1.5 KB View
- report_bench_2026-08-31T212027.md 4.9 KB View
- results.json 1.9 KB View Raw
- run_experiment.py 3.7 KB View Raw
- stage2_butterfly_bench.py 6.2 KB View Raw