Training Transformers in Cosine Coefficient Space
Organizations: Illumina, San Diego, CA, USA
Abstract
Linear layers hold most of a transformer's parameters. We replace each linear layer with one that stores out of two-dimensional DCT coefficients per weight matrix and reconstructs the full matrix through an inverse DCT at every forward pass; the coefficients are the trainable parameters. A 4-layer, 128-dim transformer trained from scratch on character-level Shakespeare reaches validation loss at , against for a standard dense baseline -- a gap of at half the trainable parameter count, within the terminal-epoch variation of the dense run. A rank-48 LoRA factorization at the same trainable parameter count reaches only (). The structural advantage of sparse-coefficient over low-rank parameterizations at matched is qualitative. We identify rank flexibility as the mechanism. A random orthonormal basis matches the DCT within noise at , and a compression sweep through and shows that subspaces that can host high-rank matrices keep the loss low, while subspaces that flatten into a low-rank block (zigzag-selection variants) converge onto the observed stable rank and the loss line of the rank-48 LoRA reference in lock-step. Among these orthonormal bases, the DCT is preferred because its separable fast transform admits a fused reconstruction kernel: the materialized weight matrix never leaves on-chip memory, so the parameter saving translates into a bandwidth saving as well.
Figures & tables
| Method | Params | % of dense | Val loss | vs. dense |
|---|---|---|---|---|
| standard | 818,048 | 100% | 1.580 | |
| dct_zigzag (primary) | 424,832 | 52% | 1.604 | |
| dct_random | 424,832 | 52% | 1.616 | |
| rand_zigzag | 424,832 | 52% | 1.584 | |
| rand_random | 424,832 | 52% | 1.593 | |
| lora_r48 (matched ) | 424,832 | 52% | 1.801 |
| Method | Params | Val loss | Params | Val loss | ||
| standard | 818,048 | 1.580 | 818,048 | 1.580 | ||
| dct_zigzag (primary) | 110,260 | 2.048 | 70,940 | 2.198 | ||
| dct_random | 110,260 | 1.827 | 70,940 | 1.950 | ||
| rand_zigzag | 110,260 | 1.989 | 70,940 | 2.052 | ||
| rand_random | 110,260 | 1.837 | 70,940 | 1.954 | ||
| standard | dct_zz | dct_rnd | rand_zz | rand_rnd | lora_r48 | |
|---|---|---|---|---|---|---|
| 8.4 | 27.5 | 39.5 | 29.8 | 38.5 | 14.8 | |
| 8.4 | 18.8 | 47.3 | 18.3 | 46.5 | 14.8 | |
| 8.4 | 14.2 | 42.0 | 13.6 | 42.7 | 14.8 |
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 528 papers