DepthGraft: Structural Regularization through Hierarchical Cross-Layer KV Reconstruction
Xiaohan Qin, Xiangdong Zhang, Yu Wang, Huaijin Wu, Zhuo Xia, Yebin Yang, Junchi Yan
cs.CL
2026-11-02
DepthGraft rebuilds deep-layer KV from stride-aligned shallow and middle sources. On a 16B MoE, MMLU-Pro rises from 23.86 to 30.86, and KV cache drops by about one third.
Stacking layers on a Pre-LN Transformer, which normalizes before every sublayer, does not automatically put those layers to work. The residual stream is one running sum. Features formed early get diluted by later additions, and deep layers have trouble reading them back. Nominal depth runs ahead of the depth the model can actually use.
A direct link across depth can bypass that sum. Attention Residuals reweights earlier hidden states. MoDA folds previous layers' keys and values into the current attention. Both add compute and memory traffic. KV sharing is the cheaper version: CLA and MLKV reuse one KV inside groups of two or three adjacent layers, while YOCO and FusedKV feed every deeper layer from one or two global anchors. Those designs were built to shrink the cache. Each reuse edge is also a training path: gradients from a deep query reach the source layer's KV projection, and the wiring decides how strong that regularizer is.
Keys and values already move in different directions. A key is updated through softmax scores, so retrieval directions that separate useful tokens get reinforced and the effective rank of K falls during training. Effective rank is the exponential entropy of the normalized eigenvalues; lower means the energy sits in fewer directions. A value is a linear readout of content under the attention weights, so its effective rank rises as the model passes richer information.
If a far layer reuses a source KV, that key serves two query spaces and that value supports two readouts. With enough depth between them, directions shared by both queries are reinforced twice and the key gets sharper. The two value gradients do not compete inside softmax, so together they spread the value matrix over a wider content subspace.
Adjacent layers never open that gap. CLA and MLKV group two or three neighbors, and neighboring queries are highly correlated. In Fig. 3 the key effective rank stays at or above the baseline; the extra gradient is close to a repeated signal. A global anchor does the opposite. Every deep-layer objective lands on one or two sources, gradient norm piles up on the anchors, and layers off the anchor never see this direct path.
DepthGraft cuts the stack into shallow, middle, and deep stages of about one third of the layers each. The first two stages compute KV normally. Deep layer ℓ does not project KV. It rebuilds KV from the shallow source ℓ minus two thirds of the depth and the middle source ℓ minus one third, the same relative slot in each stage. Learned per-channel coefficients scale the two sources, then they are added, with a separate coefficient per KV group. Shallow memory stays closer to lexical and local patterns. Middle memory is more semantic. Key coefficients are tied inside each RoPE rotation pair, so rotary position encoding commutes with the mix and the cache layout is unchanged.
Sources and targets sit one third to two thirds of the depth apart, so the query spaces diverge. The deep stage stores no KV of its own, which removes about one third of the cache. When the middle stage finishes, every KV later prefill needs is already on hand. The stride map is fixed, so a pipeline-parallel placement can avoid extra KV traffic between stages.
Every comparison is trained from scratch on matched data and recipes. Dense models are 0.5B, 1B, and 1.5B. The MoE models use a DeepSeekMoE backbone with SwiGLU, at 3B, 9B, and 16B total parameters, headed A0.5B, A1.5B, and A3B. Both GQA, grouped-query attention, and MLA, the low-rank KV attention used by DeepSeek, are tested.
Dense averages rise by 0.75, 0.85, and 2.42 points. The 1.5B model moves from 28.36 to 30.78. On that run MMLU gains 3.33 (34.81 to 38.14), MBPP gains 5.20 (16.20 to 21.40), and C3 gains 9.46 (44.79 to 54.25). The same tables also fall: 1B ARC-Challenge goes from 31.27 to 27.84, and 0.5B LCBench from 1.22 to 0.52.
GQA MoE average gains are +1.05 at 3B, +2.29 at 9B, and +3.61 at 16B.
| Benchmark | GQA baseline | DepthGraft | Delta |
| MMLU-Pro | 23.86 | 30.86 | +7.00 |
| CMMLU | 40.68 | 47.29 | +6.61 |
| C3 | 70.74 | 77.15 | +6.41 |
| GSM8K | 39.50 | 45.34 | +5.84 |
| HumanEval | 22.56 | 28.05 | +5.49 |
| 12-benchmark avg | 43.43 | 47.04 | +3.61 |
At 9B with MLA the average moves from 36.01 to 39.69, up 3.68, alongside the GQA gain of 2.29 at the same size. The 9B GQA run still drops MMLU-Pro from 20.43 to 19.71 and MBPP from 32.20 to 29.60. All twelve benchmarks rise together only on the 16B model.
Earlier KV-sharing designs are compared on the same 16B recipe, but the average covers seven benchmarks, so the baseline is 42.38 and should not be subtracted from 43.43. CLA/MLKV scores 38.05, YOCO 43.33, FusedKV 45.64, and DepthGraft 47.56. FusedKV's C-Eval of 50.66 is a bit above DepthGraft's 50.00.
A stride-aligned shallow copy with the gradient detached scores 42.86. Opening the gradient reaches 45.30. Adding the middle source reaches 47.56. A two-stage copy scores 43.58, a four-stage three-source layout 45.40, and a four-stage two-source layout 45.33, all below the three-stage, two-source design.
At 128K context and 2K generation, time to first token falls from 611.19 ms to 447.51 ms on 9B MLA (26.8%) and from 2655.90 ms to 1891.80 ms on 16B GQA (28.8%). Time per output token rises by less than 1% at every length tested; at 128K the 16B pair is 7.79 ms versus 7.84 ms. After continued training at 32K with the RoPE base adjusted, RULER averages are 94.8 versus 86.8 at 4K and 82.4 versus 76.2 at 32K. At 32K, variable tracking moves from 37.8 to 76.6 and frequent-word extraction from 64.0 to 74.7, while the multi-query needle task falls from 87.8 to 76.5. Fig. 2 shows a lower key effective rank and a higher value effective rank on nearly every layer.
Under one recipe, adjacent sharing pulls the seven-benchmark average below the plain baseline, global anchors beat that baseline by less, and the hierarchical rebuild scores highest. The cache is about one third smaller, prefill at 128K drops by close to 30%, and decoding barely moves.
The structure has to be fixed before training starts. Deep layers have no KV projection of their own, so a finished checkpoint cannot pick this up. For large pretraining the pipeline detail matters: sources and targets follow a fixed stride, and a matching placement adds no KV communication across stages.
The average gain grows from 0.75 points at 0.5B to 3.61 points at 16B. The largest model measured is the 16B run headed A3B. Whether the slope continues past that point is open.
The geometry argument sits in an appendix and depends on explicit assumptions. The conclusion asks for a tighter theory, a wider search over topologies, and tests at larger pretraining scale.
The main numbers are single runs. The 7-point MMLU-Pro gain has no multi-seed variance. From 0.5B to 9B, ARC-Challenge, MBPP, and MMLU-Pro drop in places, so the average hides task-level losses. Long-context quality stops at continued training on 32K. Latency is measured out to 128K. MLA is shown at 9B; the 16B run is GQA only. An MMLU of 54.21 is an internal score for this recipe. The token budget is in the appendix, and the main figures only show training steps on the order of the plotted range.
The detach run separates forward reuse from the backward path: with the path cut, the score stays near the baseline; with it open, the score jumps. Effective rank moves together with accuracy, and the experiments do not isolate the geometry shift as the cause. The parameter and optimizer cost of the per-channel coefficients is not broken out.