Neural Spectral Capacity with Residual Context for Heterogeneous Resource Allocation within Transformers
Organizations: Department of Computer Science, City University of Hong Kong
Abstract
Predicting relative trained performance from architectural specifications can guide design when training costs limit experimentation. Neural Spectral Capacity (NSC) provides such a heuristic, but scores projections independently and assigns identical scores to compatible reorderings of the same layer configurations. We introduce Residual-Aware Neural Spectral Capacity (ResNSC) for Transformers, using a specification-derived statistical reference for accumulated residual updates to determine the input and residual-state statistics in each projection's capacity calculation, while retaining additive evaluation without data or instantiated weights. When residual widths vary, earlier choices affect later scores, so we augment NSC's allocator (NSC-DP) with residual history beyond its layer-and-budget state. ResNSC-DP jointly allocates residual and feed-forward widths under a resource budget, with certified bounds on the best numerically evaluated ResNSC score within a specified finite candidate set. At the 121M and 374M pretraining scales, selected architectures achieve lower mean perplexity than uniform, variable-width, and tapered allocations on FineWeb-Edu, WikiText-2, and LAMBADA at comparable parameter budgets. In inherited-weight LLaMA-7B pruning using the LoNAS supernet, ResNSC-DP improves eight-task average accuracy over NSC by 3.28--5.46 percentage points across eight matched parameter budgets. Paired reversals preserve the projection shapes and NSC scores yet worsen performance in both settings, exposing performance differences hidden by position-independent scoring. The code for this work is available at https://github.com/Optima-CityU/neural-spectral-capacity.
Figures & tables
| Branch index | Projection | Shape | Input | Noise |
|---|---|---|---|---|
| Q, K, V | ||||
| O | ||||
| gate, up | ||||
| down |
| 121M | 374M | ||||||
|---|---|---|---|---|---|---|---|
| Method | PPL | WikiText-2 | LAMBADA | PPL | WikiText-2 | LAMBADA | Avg8 |
| ResNSC (ours) | 19.39 ( 0.01) | 51.13 ( 0.21) | 202.8 ( 13.5) | 13.60 ( 0.002) | 31.20 ( 0.03) | 53.0 ( 0.4) | 44.60 ( 0.07) |
| uniform | 20.25 ( 0.02) | 55.47 ( 0.07) | 262.9 ( 13.7) | 14.27 ( 0.002) | 33.82 ( 0.05) | 76.2 ( 2.0) | 44.07 ( 0.19) |
| VWT | 19.48 ( 0.06) | 52.33 ( 0.15) | 252.6 ( 35.7) | 13.65 ( 0.002) | 31.99 ( 0.08) | 70.6 ( 2.1) | 44.26 ( 0.11) |
| TLM | 20.38 ( 0.02) | 55.43 ( 0.53) | 252.1 ( 8.5) | 14.43 ( 0.001) | 34.19 ( 0.02) | 78.1 ( 0.6) | 43.73 ( 0.05) |
| NSC | 20.00 ( 0.03) | 53.40 ( 0.31) | 221.4 ( 10.1) | 13.82 ( 0.003) | 32.40 ( 0.11) | 66.9 ( 1.9) | 44.26 ( 0.09) |
| Scoring rule | Profile | PPL | WikiText-2 | LAMBADA |
|---|---|---|---|---|
| ResNSC (full) | 19.39 ( 0.01) | 51.04 ( 0.20) | 211.2 ( 2.3) | |
| w/o residual context | (identical to NSC) | 20.00 ( 0.01) | 53.25 ( 0.21) | 233.6 ( 1.7) |
| Depth only | 19.85 ( 0.01) | 52.85 ( 0.21) | 205.9 ( 2.5) | |
| Mean history only | 20.20 ( 0.01) | 54.61 ( 0.20) | 229.5 ( 2.7) | |
| w/o propagated spectrum | 19.72 ( 0.01) | 52.72 ( 0.20) | 197.5 ( 3.3) |
| Method | Params | BoolQ | PIQA | SIQA | HSwag | WGrnd | ARC-e | ARC-c | OBQA | Avg 8 | Cost |
|---|---|---|---|---|---|---|---|---|---|---|---|
| LoNAS-SuperNet | 6.74 B | 66.02 | 77.58 | 72.93 | 57.49 | 66.85 | 78.41 | 62.29 | 76.20 | 69.72 | — |
| SNIP | 5.44 B | 61.93 | 69.21 | 64.99 | 41.26 | 62.04 | 66.50 | 52.47 | 67.40 | 60.73 | 22 min |
| SynFlow | 5.23 B | 61.13 | 70.24 | 63.25 | 45.94 | 59.98 | 66.84 | 51.88 | 66.20 | 60.68 | 23 min |
| GradNorm | 5.50 B | 61.31 | 70.78 | 67.35 | 46.33 | 62.59 | 69.02 | 55.03 | 67.20 | 62.45 | 22 min |
| W-PCA | 5.69 B | 63.82 | 70.95 | 67.91 | 49.24 | 62.75 | 69.57 | 56.40 | 70.00 | 63.83 | 45 min |
| NSC | 5.69 B | 64.01 | 72.85 | 68.94 | 51.30 | 64.72 | 72.43 | 58.70 | 70.80 | 65.47 | 1 s |
| Benchmark | (NSC / ResNSC) | (NSC / ResNSC) | Distinct (NSC / ResNSC) | |
|---|---|---|---|---|
| FlexiBERT | 500 | 0.695 / 0.692 | 0.884 / 0.883 | 297 / 421 |
| GPT-2 | 200 | 0.849 / 0.854 | 0.968 / 0.970 | 200 / 200 |
| AutoFormer-Small | 1,001 | 0.658 / 0.719 | 0.852 / 0.907 | 952 / 1,001 |
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Meaning |
|---|---|
| , | Block index and branch index; attention has , FFN has . |
| Embedding width, number of blocks, number of attention heads, and complete residual-state width. | |
| Active residual width and FFN intermediate width of block . | |
| Active residual width (shared by reading and writing) and latent width of branch . | |
| Actual residual state and specification-derived reference-power ledger before branch . | |
| Generic source and noise covariances in . |
| Projection | Scored matrix shape | Entry variance | Upstream reference for a write |
|---|---|---|---|
| Q, K, V | None | ||
| O | , , | ||
| gate, up | None | ||
| down | , , normalized gate |
| Context | Read difference (%) | Write difference (%) | |
|---|---|---|---|
| Isotropic | 64 | 0.176 | 0.444 |
| Nonuniform history | 64 | 0.222 | 0.397 |
| Zero source directions | 64 | 0.337 | 0.647 |
| SiLU-gated | 64 | 0.165 | 0.562 |
| Isotropic | 128 | 0.135 | 0.203 |
| Nonuniform history | 128 | 0.135 | 0.260 |
| Instance | Objective | Rel. gap |
|---|---|---|
| 121M joint | 59,330.78 | 0 |
| 374M joint | 133,930.49 | 0 |
| Method | 121M loss | 374M loss |
|---|---|---|
| ResNSC | 2.96496 ( 0.00067) | 2.61025 ( 0.00017) |
| uniform | 3.00813 ( 0.00109) | 2.65818 ( 0.00011) |
| VWT | 2.96922 ( 0.00286) | 2.61367 ( 0.00016) |
| TLM | 3.01478 ( 0.00108) | 2.66964 ( 0.00006) |
| NSC | 2.99598 ( 0.00134) | 2.62640 ( 0.00019) |
| Reverse | 3.00905 ( 0.00233) | 2.67282 ( 0.00005) |
| Method | LMB | PIQA | HSwag | WGrnd | ARC-e | ARC-c | SIQA | BoolQ | Avg8 |
|---|---|---|---|---|---|---|---|---|---|
| ResNSC (ours) | 29.26 [-1pt] 0.16 | 64.89 [-1pt] 0.33 | 35.49 [-1pt] 0.20 | 50.41 [-1pt] 0.59 | 54.53 [-1pt] 0.42 | 25.06 [-1pt] 0.26 | 37.17 [-1pt] 0.16 | 59.97 [-1pt] 0.96 | 44.60 [-1pt] 0.07 |
| uniform | 26.69 [-1pt] 0.26 | 64.56 [-1pt] 0.22 | 34.16 [-1pt] 0.08 | 52.57 [-1pt] 0.21 | 52.46 [-1pt] 0.40 | 26.11 [-1pt] 0.34 | 37.22 [-1pt] 0.18 | 58.76 [-1pt] 0.36 | 44.07 [-1pt] 0.19 |
| VWT | 27.03 [-1pt] 0.32 | 65.38 [-1pt] 0.35 | 35.94 [-1pt] 0.30 | 50.51 [-1pt] 0.96 | 53.68 [-1pt] 0.76 | 26.39 [-1pt] 0.47 | 36.51 [-1pt] 0.34 | 58.66 [-1pt] 0.55 | 44.26 [-1pt] 0.11 |
| TLM | 26.24 [-1pt] 0.16 | 63.13 [-1pt] 0.36 | 33.87 [-1pt] 0.06 | 50.75 [-1pt] 0.36 | 52.57 [-1pt] 0.51 | 25.63 [-1pt] 0.34 | 36.18 [-1pt] 0.22 | 61.46 [-1pt] 0.23 | 43.73 [-1pt] 0.05 |
| NSC | 27.74 [-1pt] 0.36 | 64.42 [-1pt] 0.14 | 35.27 [-1pt] 0.14 | 50.33 [-1pt] 0.79 | 53.04 [-1pt] 0.21 | 25.74 [-1pt] 0.27 | 36.51 [-1pt] 0.38 | 61.07 [-1pt] 0.27 | 44.26 [-1pt] 0.09 |
| Reverse | 25.76 [-1pt] 0.21 | 64.16 [-1pt] 0.45 | 33.62 [-1pt] 0.06 | 52.07 [-1pt] 0.84 | 53.31 [-1pt] 0.48 | 25.26 [-1pt] 0.09 | 35.55 [-1pt] 0.06 | 53.12 [-1pt] 1.72 | 42.86 [-1pt] 0.18 |
| Task ID | Dataset | Split | Reported metric |
|---|---|---|---|
| wikitext | WikiText-2 ( Merity et al., 2017 ) | test | word PPL |
| lambada_openai | LAMBADA ( Paperno et al., 2016 ) | test | PPL, accuracy |
| piqa | PIQA ( Bisk et al., 2020 ) | validation | accuracy |
| hellaswag | HellaSwag ( Zellers et al., 2019 ) | validation | normalized accuracy |
| winogrande | WinoGrande (XL) ( Sakaguchi et al., 2020 ) | validation | accuracy |
| arc_easy | ARC-Easy ( Clark et al., 2018 ) | test | accuracy |
| Method | 121M | 374M |
|---|---|---|
| ResNSC | 121,188,640 | 373,799,936 |
| Uniform | 121,262,720 | 373,867,520 |
| VWT | 121,275,680 | 373,859,200 |
| TLM | 121,262,720 | 373,867,520 |
| NSC | 120,898,560 | 373,847,040 |
| Reverse | 121,189,280 | 373,801,216 |
| Layer | ResNSC | uniform | VWT | TLM | NSC | Reverse | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1120 | 1536 | 640 | 1760 | 864 | 3456 | 640 | 2624 | 640 | 1312 | 480 | 672 |
| 2 | 1280 | 1760 | 640 | 1760 | 768 | 3072 | 640 | 2624 | 800 | 1088 | 480 | 672 |
| 3 | 1280 | 1760 | 640 | 1760 | 704 | 2816 | 640 | 2560 | 800 | 1088 | 480 | 672 |
| 4 | 960 | 1312 | 640 | 1760 | 608 | 2432 | 640 | 2464 | 800 | 1088 | 480 | 672 |
| 5 | 960 | 1312 | 640 | 1760 | 544 | 2176 | 640 | 2336 | 800 | 1088 | 480 | 672 |
| Layer | ResNSC | uniform | VWT | TLM | NSC | Reverse | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1792 | 3712 | 1024 | 2816 | 1408 | 5632 | 1024 | 4224 | 1280 | 3520 | 512 | 1056 |
| 2 | 2048 | 4224 | 1024 | 2816 | 1312 | 5248 | 1024 | 4224 | 1280 | 2656 | 512 | 1056 |
| 3 | 2048 | 4224 | 1024 | 2816 | 1216 | 4864 | 1024 | 4160 | 1280 | 2656 | 512 | 1056 |
| 4 | 2048 | 4224 | 1024 | 2816 | 1152 | 4608 | 1024 | 4096 | 1280 | 2656 | 512 | 1056 |
| 5 | 1536 | 3168 | 1024 | 2816 | 1056 | 4224 | 1024 | 4032 | 1280 | 2656 | 512 | 1056 |
| Method | Params | BoolQ | PIQA | SIQA | HSwag | WGrnd | ARC-e | ARC-c | OBQA | Avg 8 | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| NSC best | 5.690 B | 64.01 | 72.85 | 68.94 | 51.30 | 64.72 | 72.43 | 58.70 | 70.80 | 65.47 | — |
| NSC A | 5.572 B | 64.01 | 72.42 | 68.17 | 51.26 | 64.09 | 72.52 | 58.53 | 70.60 | 65.20 | — |
| NSC B | 5.538 B | 63.73 | 72.42 | 68.27 | 51.05 | 63.46 | 72.18 | 58.79 | 71.20 | 65.14 | — |
| NSC C | 5.487 B | 63.61 | 72.25 | 67.50 | 50.69 | 63.38 | 72.18 | 58.87 | 72.00 | 65.06 | — |
| NSC D | 5.453 B | 63.73 | 72.03 | 66.73 | 49.95 | 63.85 | 71.34 | 58.19 | 70.80 | 64.58 | — |
| NSC E | 5.420 B | 63.15 | 71.49 | 67.71 | 49.73 | 63.69 | 71.30 | 57.08 | 71.00 | 64.39 | — |
| Layer indices by FFN width | |||||||
| Method | Budget | Params (B) | 11008 | 9632 | 8256 | 6880 | 5504 |
| ResNSC | best | 5.690 | 1–9 | 10–13 | 14–18 | 19–26 | 27–32 |
| ResNSC | A | 5.572 | 1–8 | 9–12 | 13–16 | 17–23 | 24–32 |
| ResNSC | B | 5.538 | 1–8 | 9–11 | 12–16 | 17–22 | 23–32 |
| ResNSC | C | 5.487 | 1–7 | 8–11 | 12–15 | 16–21 | 22–32 |
| ResNSC | D | 5.453 | 1–7 | 8–10 | 11–14 | 15–21 | 22–32 |
| NSC | ResNSC | Params | |||||
|---|---|---|---|---|---|---|---|
| Benchmark | |||||||
| FlexiBERT | 0.6946 | 0.8843 | 0.6921 | 0.8833 | 0.4846 | 0.6763 | -0.0009 |
| GPT-2 | 0.8488 | 0.9681 | 0.8543 | 0.9698 | 0.6386 | 0.7943 | +0.0018 |
| AutoFormer-Tiny | 0.6119 | 0.8106 | 0.5717 | 0.7786 | 0.4691 | 0.6347 | -0.0320 |
| AutoFormer-Small | 0.6580 | 0.8519 | 0.7192 | 0.9070 | 0.7885 | 0.9414 | +0.0551 |
| PW accuracy (%) | ||||||
|---|---|---|---|---|---|---|
| Benchmark | Pairs | NSC | ResNSC | NSC | ResNSC | (pp) |
| FlexiBERT | 26,769 | 75.15 | 74.98 | 0.5031 | 0.4997 | -0.17 |
| GPT-2 | 1,721 | 77.28 | 78.27 | 0.5456 | 0.5654 | +0.99 |
| AutoFormer-Tiny | 372,469 | 75.32 | 72.51 | 0.5063 | 0.4503 | -2.80 |
| AutoFormer-Small | 130,265 | 67.42 | 66.16 | 0.3483 | 0.3232 | -1.25 |