Change the Product, Keep the Parameters: Associative Algebra Layers for Transformers
Organizations: DAIMLD, Moscow, Russia · Artificial Intelligence Research Institute, Moscow, Russia
Abstract
Fast matrix multiplication algorithms keep the product fixed and search for a cheaper way to evaluate it. We instead ask whether a Transformer's learned projections can use a different, cheaper product altogether. Building on an associative-algebra construction that replaces ordinary matrix multiplication with a sparser interaction table over the same weight blocks, we construct a family with quadratic arithmetic in the matrix dimension when the physical block size remains fixed, and derive finite-shape constraints for GPU execution. The construction is provably optimal for its bilinear rank by the Alder--Strassen bound and can be realized as row-typed rectangular projections compatible with causal masking and KV-cached decoding. We provide an empirical test of this approach by training two approximately 110M-parameter decoder-only Transformer LMs from the same recipe and 12.3B-token budget, differing only in their feed-forward layer: one uses ordinary dense matrix multiplication and the other uses the associative-algebra product. Across four prompt domains, the algebraic model achieves a 6.2--7.8% increase in end-to-end generation throughput, while obtaining lower scores on all three reported downstream metrics. We treat these results as a feasibility and trainability check for the proposed approach at small scale, leaving further investigation to future work.
Figures & tables
| Model shape | Block | Dense s | Q s | Speedup | ||
|---|---|---|---|---|---|---|
| Qwen3-1.7B | 2048 | 75.7 | 24.9 | / | ||
| Qwen3-4B | 2048 | 160.6 | 51.1 | / | ||
| Qwen3-8B | 2048 | 320.7 | 63.6 | / | ||
| Qwen3-30B-A3B expert | 2048 | 13.2 | 8.4 | / | ||
| DeepSeek-V3 expert | 2048 | 82.3 | 28.3 | / | ||
| Qwen3-32B | 2048 | 849.2 | 167.8 | / |
| Domain | Dense tok/s | Algebraic tok/s | Gain |
|---|---|---|---|
| Code | 987.8 | 1054.5 | 6.8% |
| Math | 991.4 | 1060.6 | 7.0% |
| QA | 958.6 | 1033.1 | 7.8% |
| WMT ru–en | 985.9 | 1047.1 | 6.2% |
| Task | Metric | Dense | Algebraic |
|---|---|---|---|
| GSM8K | EM, flexible | 3.18 | 2.20 |
| IFEval | Instance, loose | 34.5 | 31.1 |
| MBPP | pass@1 | 6.60 | 3.80 |
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
| Quantity | Value |
|---|---|
| Decoder blocks | 12 |
| Model width | 768 |
| FFN width | 1536 |
| Attention heads | 32 |
| Context length | 1536 |
| Vocabulary size | 50,257 |
| Domain | Mean prompt | Mean response | Measurements | Mean speed | 95% CI margin |
|---|---|---|---|---|---|
| tokens | tokens | tok/sec | tok/sec | of error | |
| Code | 42.9 | 195.5 | 987.5, 988.2, 987.6 | 987.8 | 1.0 |
| Math | 54.3 | 223.8 | 990.1, 993.7, 990.3 | 991.4 | 5.0 |
| QA | 17.1 | 92.6 | 954.0, 962.8, 959.0 | 958.6 | 11.0 |
| WMT ru–en | 263.8 | 190.0 | 988.0, 986.0, 983.7 | 985.9 | 5.2 |
| Domain | Mean prompt | Mean response | Measurements | Mean speed | 95% CI margin |
|---|---|---|---|---|---|
| tokens | tokens | tok/sec | tok/sec | of error | |
| Code | 42.9 | 182.4 | 1055.5, 1053.7, 1054.2 | 1054.5 | 2.2 |
| Math | 54.3 | 227.8 | 1058.9, 1061.9, 1060.9 | 1060.6 | 3.8 |
| QA | 17.1 | 110.8 | 1031.9, 1034.6, 1032.6 | 1033.1 | 3.5 |
| WMT ru–en | 263.8 | 204.9 | 1047.3, 1048.0, 1046.0 | 1047.1 | 2.6 |
| Domain | Relative speedup (%) |
|---|---|
| Code | 6.8 |
| Math | 7.0 |
| QA | 7.8 |
| WMT ru–en | 6.2 |
| Task | Metric | Dense | Algebraic |
|---|---|---|---|
| GSM8K | EM, flexible-extract | 0.0318 0.0048 | 0.0220 0.0040 |
| MBPP | pass@1 | 0.0660 0.0111 | 0.0380 0.0086 |
| IFEval | Instruction-level loose accuracy | 0.3453 | 0.3106 |
| Model shape | Dense s | Algebra s | Speedup (warm / flushed) | |||
|---|---|---|---|---|---|---|
| Qwen3-1.7B | 2048 | 6144 | 1 | 30.2 | 8.7 | / |
| Qwen3-1.7B | 2048 | 6144 | 2048 | 273.7 | 107.4 | / |
| Qwen3-4B | 2560 | 9728 | 1 | 49.1 | 10.4 | / |
| Qwen3-4B | 2560 | 9728 | 2048 | 539.3 | 193.8 | / |
| Qwen3-8B | 4096 | 12288 | 1 | 83.6 | 12.6 | / |
| Qwen3-8B | 4096 | 12288 | 2048 | 1031.9 | 247.3 | / |
| Model shape | Direction | Dense | Algebra | Speedup |
|---|---|---|---|---|
| Qwen3-1.7B | up | 225.6 | 177.0 | |
| Qwen3-1.7B | down | 223.8 | 127.0 | |
| Qwen3-4B | up | 455.9 | 341.6 | |
| Qwen3-4B | down | 465.9 | 280.2 | |
| Qwen3-8B | up | 912.0 | 465.0 | |
| Qwen3-8B | down | 954.0 | 372.6 |
| Model shape | Dense s | Algebra s | Speedup (warm / flushed) | |||
|---|---|---|---|---|---|---|
| Qwen3-1.7B | 2048 | 6144 | 1 | 9.5 | 3.8 | / |
| Qwen3-1.7B | 2048 | 6144 | 2048 | 75.7 | 24.9 | / |
| Qwen3-4B | 2560 | 9728 | 1 | 14.0 | 4.1 | / |
| Qwen3-4B | 2560 | 9728 | 2048 | 160.6 | 51.1 | / |
| Qwen3-8B | 4096 | 12288 | 1 | 30.7 | 4.4 | / |
| Qwen3-8B | 4096 | 12288 | 2048 | 320.7 | 63.6 | / |
| Block | Dense ms | Q ms | Speedup | |||
|---|---|---|---|---|---|---|
| 2048 | 32 | 0.849 | 0.168 | / | ||
| 64 | 0.829 | 0.232 | / | |||
| 128 | 0.779 | 0.248 | / | |||
| 256 | 0.789 | 0.266 | / | |||
| 8192 | 32 | 3.290 | 0.583 | / | ||
| 64 | 3.290 | 0.523 | / |
| Dense ms | Q ms | Speedup (warm / flushed) | |||
|---|---|---|---|---|---|
| 4096 | 128 | 32 | 0.210 | 0.044 | / |
| 4096 | 256 | 16 | 0.205 | 0.058 | / |
| 8192 | 128 | 64 | 1.773 | 0.166 | / |
| 8192 | 256 | 32 | 1.729 | 0.225 | / |
| 16384 | 128 | 128 | 13.881 | 0.689 | / |
| 16384 | 256 | 64 | 13.999 | 0.991 | / |
| Law | Forward | Training | |
|---|---|---|---|
| Quantity | Dense | |
|---|---|---|
| KV cache scalars | ||
| Projection MACs | ||
| Score MACs | ||
| Value MACs |
| Dataset | Records |
|---|---|
| GSAI-ML/ReFusion | 2881860 |
| openbmb/UltraData-SFT-2605 | 2651052 |
| MBZUAI/LaMini-instruction | 2540109 |
| OLMo-Coding/starcoder-python-instruct | 1087321 |
| nvidia/Nemotron-Post-Training-Dataset-v2 | 1145725 |
| nvidia/Nemotron-RL-knowledge-mcqa | 611930 |
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 528 papers