- Static Weight Patches: Mitigating Periodic Retrieval Weak Spots in Chunked KV Compression via Zero-Gradient Weight Editing
Static Weight Patches: Mitigating Periodic Retrieval Weak Spots in Chunked KV Compression via Zero-Gradient Weight Editing
Author: Xuyao Zhang (ORCID: 0009-0005-9421-6199) · Gaoping No. 4 Middle School · xuyao.zhang@outlook.com
Status: Preprint (2026)
Links: Preprint PDF (Zenodo) · GitHub Code Repository · Project Page · Hugging Face Patches
Overview
This preprint studies how to mitigate the periodic retrieval weak spots (phase sensitivity) that Zhu et al. (arXiv:2609.36322) reported in chunked KV-cache compression (including DeepSeek-V4 and Qwen3-0.6B). On a 552.47M-parameter ResCSA C0 checkpoint (1.75B tokens, seed 42), a checkpoint-specific 9-tensor zero-gradient weight edit lifts worst-phase retrieval accuracy by +6.07 to +20.00 percentage points across five held-out list suites and improves natural-text repeat recall by +1.51 pp (+4.20 pp at boundary phase 7; +1.78 pp over matched-corpus SFT) with 0/45 downstream alerts. Transfer to DeepSeek-V4 remains untested.
This repository distributes four lightweight, pure .safetensors static weight patches (4 or 9 edited self_attn tensors each, 8.50–24.75 MiB per file) for the ResCSA C0 (1.75B tokens, seed 42) checkpoint released by wsedoc/phase-sensitive-kv (c0-1p75b/seed-42.pt).
- No pickle
.ptfiles and no full multi-GB base checkpoints are distributed here. Users download the unmodified base checkpoint (c0-1p75b/seed-42.pt, SHA-256a1b6c19884e8ccd3570bff48b748a85920aed00083470dc591b51f8e0153b543) directly fromwsedoc/phase-sensitive-kvand apply any.safetensorspatch with zero PyTorch runtime hooks and bit-exact SHA-256 verification. - Architecture vs. Pretraining Token Budget: Every
ResCSA C0checkpoint (W=8, S=8, T=16) uses a Qwen3-0.6B Transformer architecture and tokenizer pretrained from scratch (552,468,928/552.47Munique parameters, including7,799,232compression parameters above the544.67MFullAttnreference; serializedstate_dictcounts708,051,392due to tied embeddings). The labels1.75B(1,749,942,272tokens) and3.5B(3,499,884,544tokens) denote pretraining token budgets, not model parameter counts. Only the Qwen3-0.6B architecture and tokenizer were used upstream; this work makes no claim of evaluating Alibaba's official pretrained Qwen3-0.6B weights.
Released .safetensors Patches
All four patches use patch_mode = "replace_bf16", leave all 56/56 per-layer QK-RMSNorm tensors (q_norm.weight, k_norm.weight) bit-exact unchanged (max_abs_diff == 0.0), require 0 forward/backward hooks, and reproduce the paper's exact bfloat16 patched_state_dict_sha256 on CPU:
Patch File (patches/) |
Role in Paper | Modified / Unchanged Tensors | File Size (Bytes) | File SHA-256 (16-Hex) | Verified patched_state_dict_sha256 |
|---|---|---|---|---|---|
c0_bespoke_fwCalOnly_9tensor.safetensors |
Primary zero-gradient 9-tensor edit (FineWeb-Edu covs. only) | 9 / 470 (12.98M params) |
25,953,760 |
55aa835a9d299ead |
9522d30b531e45cf865e72fa72f4aaa9fb525f33c3b1f7cd899386f1e5bec34e |
c0_bespoke_withProt_9tensor.safetensors |
Side-by-side frozen Phase 3 variant (26/26 holdout_v3 pass) |
9 / 470 (12.98M params) |
25,953,760 |
8825c72673f424fc |
d0279d1aaef67114d5f08e823ca762d77daf4fb19b3d2f890c082cb7e8acafad |
c0_c13_4tensor.safetensors |
General PhaseWSP v1.1.1 (C13) failure case (5/10 gates) |
4 / 475 (4.46M params) |
8,913,816 |
75a41740d3cb03b4 |
46fa5abc750bed80b70a3350fd2e4cf666b53d2aca49199a449c422b07572110 |
sft_same9_fwcal_ce_9tensor.safetensors |
Post-hoc matched-corpus 9-tensor gradient SFT control (fw_cal CE) |
9 / 470 (12.98M params) |
25,953,752 |
94a7c81c175dd6ef |
25bf85df7bf46e7a98f594c01e3d3e74aa5f7005622b95b7eed5d3ad017ef5f5 |
Full 64-hex SHA-256 digests and per-tensor shapes/dtypes are recorded in SHA256SUMS.txt and patch_manifest.json.
Base checkpoint (c0-1p75b/seed-42.pt): file SHA-256 a1b6c19884e8ccd3570bff48b748a85920aed00083470dc591b51f8e0153b543, clean bfloat16 state_dict SHA-256 ac04fa7193575385bedfaea1f954013cbdfb6e280fecb53150b00f11b0a4357f (479 tensors).
Quick Usage & Bit-Exact Verification
Because the upstream c0-1p75b/seed-42.pt checkpoint wraps a pickled rescsa config object, always verify the base file SHA-256 before deserializing and use the included standalone apply_patch_example.py loader (which runs on CPU without requiring rescsa to be installed):
# 1. Download upstream base checkpoint (not redistributed here)
hf download wsedoc/phase-sensitive-kv c0-1p75b/seed-42.pt --local-dir models/phase-sensitive-kv
# 2. Verify base file SHA-256 BEFORE deserializing, apply .safetensors patch, and verify bit-exact state_dict SHA-256
python apply_patch_example.py \
--base-ckpt models/phase-sensitive-kv/c0-1p75b/seed-42.pt \
--patch-path patches/c0_bespoke_fwCalOnly_9tensor.safetensors \
--check-base-sha256 \
--verify-only
Or in Python (using apply_patch_example.py's standalone loader, which verifies the base .pt SHA-256 before deserializing and requires no rescsa installation):
from pathlib import Path
from apply_patch_example import apply_and_verify
patched_sd, report = apply_and_verify(
Path("models/phase-sensitive-kv/c0-1p75b/seed-42.pt"),
Path("patches/c0_bespoke_fwCalOnly_9tensor.safetensors"),
check_base_sha256=True,
)
assert report["ok"] and report["total_hooks"] == 0 and report["qk_norm_max_abs_diff"] == 0.0
Or with the full verification CLI in the GitHub code repository:
python src/wsp/apply_patch.py \
--base-ckpt models/phase-sensitive-kv/c0-1p75b/seed-42.pt \
--patch-path patches/c0_bespoke_fwCalOnly_9tensor.safetensors \
--expected-sha256 9522d30b531e45cf865e72fa72f4aaa9fb525f33c3b1f7cd899386f1e5bec34e \
--check-base-file-sha256 \
--verify-only
Summary of Verified Paper Results (ResCSA C0, 1.75B tokens, seed 42)
1. Mechanistic Edit Structure & Zero-Gradient Scope
- Clean
ResCSA C0 (1.75B tokens, seed 42)(W=8) falls to3.00%accuracy at boundary phase 7 (Prefix) despite95.0%–100.0%target-slot linear probe readability (97.1%–100.0%pre-norm), implicating read-path routing bottlenecks, a low-rankL17common-mode floor, and destructive saboteur heads. - The 9-tensor closed-form edit applies: (1) rank-2
L17common-mode attenuationP = I - 0.60 U_2 U_2^T(retaining40%amplitude /16%squared norm inspan(U_2), left-multiplied asD_ck PonL17 c_kandPonL17 q_projheads{0,1,2,4,14}), (2) compressed-only RoPE-band key rescaling onL13andL21c_k, and (3) uncentered-second-moment Ridge-filteredW_Ocarrier/saboteur balancing onL17, L13, L21, L24, L20. - Zero-gradient scope disclosure: "Zero-gradient" refers strictly to executing the locked static edit without backpropagation or optimizer states. Prior mechanistic diagnosis and structural/hyperparameter discovery used labeled FIT/DEV retrieval feedback (
1.51 hGPU across88DEV configs, plus unpriced interactive cloud AI usage). ChoosingfwCalOnlyas the primary display variant was a paper-writing decision (not pre-registered);withProtis reported side-by-side with its original26/26Phase 4holdout_v3acceptance intact.
2. Core Benchmark Comparison (Post-Freeze holdout_v3, xtask_v1, fw_holdout_v3)
Model (1.75B tokens, seed 42) |
holdout_v3 Prefix (%) |
holdout_v3 OOD-L300 (%) |
holdout_v3 OOD-L650 (%) |
FW-Repeat (%) |
FW-Repeat Ph7 (%) |
Prose (%) |
Code (%) |
FineWeb Full ΔPPL |
|---|---|---|---|---|---|---|---|---|
C0 Clean (Base) |
37.12 |
47.66 |
47.76 |
82.49 |
79.60 |
7.06 |
1.38 |
15.72 (base) |
fwCalOnly (primary, 9 tensors) |
47.79 (+10.67) |
56.03 (+8.36) |
57.65 (+9.89) |
84.00 (+1.51) |
83.80 (+4.20) |
10.06 (+3.00) |
3.16 (+1.79) |
+0.74% |
withProt (side-by-side, 26/26 pass) |
48.68 (+11.55) |
55.86 (+8.20) |
57.15 (+9.39) |
84.00 (+1.51) |
83.80 (+4.20) |
9.88 (+2.81) |
3.21 (+1.84) |
+0.74% |
C13 (general 4-tensor, failure case) |
33.88 (-3.24) |
44.50 (-3.16) |
44.24 (-3.53) |
82.59 (+0.10) |
80.50 |
7.46 (+0.40) |
1.40 (+0.02) |
+0.14% |
LoRA r8-read (Best LoRA, NIAH+NL) |
100.00 (+62.88) |
94.09 (+46.43) |
92.31 (+44.55) |
82.61 (+0.13) |
80.20 |
7.91 (+0.85) |
3.60 (+2.23) |
+0.16% |
sft_bespoke_9tensor (NIAH+NL) |
99.71 (+62.59) |
82.82 (+35.16) |
78.76 (+31.00) |
82.66 (+0.18) |
80.00 |
8.41 (+1.35) |
2.46 (+1.09) |
+0.05% |
sft_same9_fwcal_ce (post-hoc control) |
--- |
--- |
--- |
82.23 (-0.26) |
79.10 |
--- |
--- |
-0.01% |
FullAttn (Indep. Ref., 544.67M) |
64.26 |
58.44 |
56.25 |
85.16 |
85.60 |
3.39 |
14.24 |
15.58 (ref) |
- Synthetic
holdout_v3(5 suites) & Honest LoRA Comparison:fwCalOnlylifts worst-phase accuracy on all5/5suites by+6.07to+20.00 pp(suite-mean+6.43to+12.99 pp;withProt: worst-phase+6.23to+20.50 pp, suite-mean+6.97to+13.96 pp). Both narrow full-phase range on3/5suites (e.g., Prefix50.97 -> 38.50 / 39.03 pp) and widen range on2/5(InSeq23.47 -> 33.27 / 34.17 pp,OOD-L65057.10 -> 61.30 / 61.70 pp). All four list-supervised LoRAs attain higher list accuracy (91.53%–100.00%;lora_r8_read92.31%–100.00%) and a smaller best-to-worst phase gap thanfwCalOnlyon all5/5suites (0.00–28.80 pp;lora_r8_read0.00–21.00 pp). - Natural-Text Transfer (
xtask_fw_natural_repeat,94–389tokens, mean180.7):fwCalOnlyimproves accuracy by+1.51 pp [+1.11, +1.91](Ph7 +4.20 pp [+2.90, +5.50], gold NLL-0.0774), narrowing56.5%overall (70.0%Ph7) of the observed Clean–FullAttn gap, compared to+0.13to+0.19 ppfor list LoRA/SFT (all 4 LoRA overall 95% CIs cross zero) and-0.26 pp [-0.41, -0.12]for post-hocsft_same9_fwcal_ce(fwCalOnlyleadssft_same9_fwcal_ceby+1.78 pp [+1.36, +2.21],+4.70 pp [+3.40, +6.00]onPh7, and-0.0818gold NLL). - Counterfactual Evidence Dependence (Task C,
N=8,000): Swapping the prior repeated bigram(A, B) -> (A', B')yieldsPE_acc = 30.22 pp(84.00% -> 53.78%) vs. Clean28.18 pp, givingDiD_acc = +2.05 pp [+1.55, +2.56](Ph7 +4.50 pp,DiD_NLL = +0.103;withProt+1.96 pp,Ph7 +4.60 pp). Wide CIs vs.FullAttn(-0.49 [-2.34, +1.41]) preclude claimingFullAttnequivalence. - Public Downstream Capability Shifts and Pre-Registered Degradation Alerts (Task B) & Perplexity: Across 5 zero-shot benchmarks (LAMBADA-OpenAI, HellaSwag, PIQA, ARC-Easy, SciQ) × 5 models (
45checks:25 acc + 20 acc_norm),0/45pre-registered alerts and0significant drops occur (Holm-25 min adj.p = 0.4970). FineWeb-Edufw_holdout_v3token-weighted perplexity rises by+0.74%Full (+0.74%Suffix forfwCalOnly,+0.75%forwithProt), retaining99.18%(local_t16) /99.71%(ctx512) remote-context gain (withProt:99.14%/99.63%). - Compute & Memory Accounting (Single NVIDIA RTX 5080): Locked
fwCalOnlyrebuilds in24.01 sGPU solve /34.76 scold-start E2E at1.53 GiBpeak allocated VRAM (torch.cuda.max_memory_allocated()), paired with its inherited1.51 h(88DEV configs) discovery cost (excluding unpriced cloud AI usage; vs.1.56 hfor all four LoRA grids and148.8 sfor the 6-checkpoint CE control sweep). Merged LoRA and SFT also deploy with0hooks and identical theoretical forward FLOPs (no latency benchmark claims).
Limitations & Scope Boundaries
- Single-Checkpoint Bespoke Scope:
fwCalOnlyandwithProtwere discovered and evaluated solely onResCSA C0 (1.75B tokens, seed 42). FixedC13passed10/10on two dev-seen checkpoints (3.5B tokens, seed 42and1.75B tokens, seed 43) but failed5/10on unseen1.75B tokens, seed 42, showing that weak-spot circuits are checkpoint-specific and cross-checkpoint automation remains open. - Residual Periodicity & Synthetic Trade-Offs: Periodic weak spots are mitigated rather than eliminated (
InSeqandOOD-L650ranges widen); supervised LoRA achieves substantially higher synthetic list accuracy and smaller list phase gaps on all5/5suites. - Perplexity & Discovery Cost:
fwCalOnly/withProtincur+0.74%FineWeb-Edu PPL (vs.-0.01%forsft_same9_fwcal_ce), and fast locked-recipe rebuild times (24.01 s/34.76 s) must always be read alongside the1.51 h(88-config) discovery phase. - Statistical & Corpus Scope: Pointwise 95% cluster-bootstrap CIs (
B=2,000) reflect test-sample uncertainty for fixed weights, prescription, and protocol—not seed, checkpoint, or discovery variance.xtask_fw_natural_repeatcovers filtered94–389token passages (mean180.7) with unverified pretraining corpus overlap, andxtask_v1shifts distance, length, and answer space jointly.
Transparent AI Assistance Disclosure
AI coding and reasoning agents—together with human-directed interactive large language models (including the Gemini and GPT families, without fabricating unlogged sub-version identifiers)—were used extensively throughout this research project for mechanistic diagnosis, experimental iteration, implementation, analysis, manuscript drafting, and independently implemented computational verification (AI-agent audits of manifests, zero-hook integrity, and recomputed statistics—not third-party human audits). Every quantitative claim and patch checksum is grounded in executed code and saved experimental artifacts. The human author directly reviewed all core scientific claims, numerical summaries, figures, and limitations and takes full academic and ethical responsibility for this release.
Citation
@misc{zhang2026periodicweakspots,
author = {Zhang, Xuyao},
title = {Mitigating Periodic Retrieval Weak Spots in Chunked {KV} Compression via Zero-Gradient Weight Editing},
year = {2026},
howpublished = {Preprint},
url = {https://doi.org/10.5281/zenodo.24652968},
note = {Code: \url{https://github.com/xuyao-zhang/periodic-weak-spots-wsp}; Weight patches: https://huggingface.co/BeichenSi/periodic-weak-spots-wsp}
}
License & Third-Party Notices
Released under the MIT License (Copyright (c) 2026 Xuyao Zhang). The derived .safetensors weight patches retain the full upstream phase-sensitive-kv MIT license text (Copyright (c) 2026 ShengenWu), bundled verbatim at licenses/LICENSE_phase-sensitive-kv.txt. See THIRD_PARTY_NOTICES.md for full licenses and attributions covering all six upstream assets (Qwen3-0.6B Apache-2.0 architecture/tokenizer, phase-sensitive-kv MIT, Periodic-Weak-Spots MIT, FineWeb-Edu ODC-BY 1.0, High-Quality English Sentences ODC-BY 1.0, and lm-evaluation-harness MIT plus Task B benchmarks).
Model tree for BeichenSi/periodic-weak-spots-wsp
Base model
wsedoc/phase-sensitive-kv