Two-Phase Reasoning-Boundary WSP Recoup Update
[!TIP] Updated Inference Routing (
two_phase_wsp_router.py, presetq38_tp_balanced): Applies Phase-1 reasoning settling inside<think>/<|channel>thoughtwith explicit Phase-2 answer-budget reservation, then zeroes Phase-1 accelerators at the closing boundary before enabling targeted Phase-2 adapters (with native/v1/chat/completionspassthrough at[0]scales for untargeted tasks).
| Benchmark | Base | Prior HF | Two-Phase Recoup | Delta vs Base | Delta vs Prior HF |
|---|---|---|---|---|---|
Mobile Agent (38) | 36/38 | 37/38 | 35/38 | -1 | -2 |
Established (85) | 66/85 | 68/85 | 78/85 | +12 | +10 |
Combined (123) | 102/123 | 105/123 | 113/123 (91.9%) | +11 | +8 |
tbench20 (20) | 6/20 | 8/20 | 8/20 | +2 | +0 |
- Decode Speed (
llama-serverlogn >= 20):6.52 tok/s| Parity Gate (0scales):3/3| GGUF:Qwen3.8-27B-UD-Q4_K_M.gguf - Two-Phase CLI / Router:
scripts/two_phase_wsp_router.py&scripts/run_wsp_two_phase.py - Full Empirical Trace:
benchmarks/two_phase_recoup_results.json
hf download jstarks/Qwen3.8-27B-Weight-Space-Programming scripts/two_phase_wsp_router.py scripts/run_wsp_two_phase.py --local-dir ./qwen38_27b-recoup
python ./qwen38_27b-recoup/scripts/run_wsp_two_phase.py --server-url http://127.0.0.1:8089 --prompt "Solve 5x - 7 = 18. Put your answer in \\boxed{}."
Qwen3.8-27B-Weight-Space-Programming (WSP v2.4 — 4-Subspace Mid + Late Architecture)
Training-free, closed-form Multi-Subspace Weight-Space Programming (WSP) for Qwen/Qwen3.8-27B (64 layers, hidden_size = 5120, intermediate_size = 17408, $16 \times [3\times\text{Gated DeltaNet} + 1\times\text{Gated Full Attention}]$) — zero gradient descent, zero fine-tuning, synthesized in 47 seconds on a single workstation.
1. Key Highlights & 4-Way Factorial Ablation (123 Live Benchmark Tasks)
- Root-Cause Spectral Discovery (
probe_qwen38_subspaces.py): Across the upper Full-Attention and Pre-Terminal layers ([47, 51, 55, 59, 62, 63]) ofQwen/Qwen3.8-27B, the top-64 singular directions ofmlp.down_projexhibit a 28.1% to 45.0% stronger cosine alignment with the self-doubt/hesitation subspace (Wait,Should,Or,Maybe,Alternatively,verify,test) than with the</think>termination token (248069). This single spectral bias explains both primary baseline failure modes:- Circular
<think>deliberation loops that exhaust token budgets on InterCode-NL2Bash, GSM8K, HumanEval, and Anti-Sycophancy (Suite D). - Post-solution self-doubt ("Should I verify it? Let me run a simple test") triggering unnecessary
exectool calls on pure coding tasks (Suite E:restraint_1_reverse_ll).
- Circular
- Exact SwiGLU Receptor & Woodbury Dual-Space Ridge Surgery (
build_qwen38_subspaces_v2.py,build_midlayer_subspace4.py): Using exact SwiGLU receptor states $\hat{x}j = \text{unit}(\text{SiLU}(W{\text{gate}} \hat{h}j) \odot (W{\text{up}} \hat{h}j))$ and the Woodbury Dual-Space Nullspace-Anchored Ridge Identity: $$\Delta W_s^{(l)} = \tilde{Y}{\text{aug}}^\top \left(X_{\text{aug}} X_{\text{aug}}^\top + \lambda_{\text{reg}} I_m\right)^{-1} X_{\text{aug}}, \qquad X_{\text{aug}} = \begin{bmatrix} X_s \ \sqrt{\lambda_{\text{null}}}, X_{\text{null}, s} \end{bmatrix} \in \mathbb{R}^{m \times 17408}$$ we invert an $m \times m$ ($160 \times 160$) Gram matrix instead of a dense $17408 \times 17408$ matrix, cutting synthesis time by 30× (1419.0s$\rightarrow$30.8s–47.7s) and reducing cross-subspace/nullspace leakage by 25× (to0.11%–0.31%across all 13 edited layers). - 2×2 Factorial Ablation (
Nonevs.Dynamic Late-Layer Routing Onlyvs.Mid-Layer Full-Attention Edit Onlyvs.Both):
| Condition | Mid-Layer S4 (Layers 19–43) | Dynamic Late Routing (Layers 47–63) | 38-Task Mobile Agent Suite | 85-Task Established Benchmarks | Combined 123-Task Score | Delta vs. None |
|---|---|---|---|---|---|---|
1. None (Unedited Base Qwen3.8-27B) | Off (0.0) | Off (0, 0, 0) | 36/38 (94.7%) | 65/85 (76.5%)* | 101/123 (82.1%) | Baseline (22 errors) |
| 2. Dynamic Routing Only | Off (0.0) | On (<0.1ms Router) | 37/38 (97.4%) | 66/85 (77.6%) | 103/123 (83.7%) | +1.6% (-2 errors) |
| 3. Mid-Layer Edit Only (Static) | On (1.0) | Off (0, 0, 0) | 35/38 (92.1%) | 64/85 (75.3%) | 99/123 (80.5%) | -1.6% (+2 errors) |
| 4. Both (Mid-Layer + Dynamic Routing) | On (0.65–0.85) | On (<0.1ms Router) | 37/38 (97.4%) | 68/85 (80.0%) | 105/123 (85.4%) | +3.3% (-18.2% errors) |
*Evaluated with normalized JSON Schema ("type": "float" $\rightarrow$ "number" in BFCL v3 Irrelevance); raw unnormalized baseline is 102/123 (82.9%).
2. Granular Per-Suite Benchmark Breakdown (123 Tasks)
| Benchmark Suite | Tasks | 1. None (Base) | 2. Dynamic Routing Only | 3. Mid-Layer Edit Only | 4. Both (Mid-Layer + Dynamic) | Key Mechanism & Synergy in Both |
|---|---|---|---|---|---|---|
| Suite A: Shell Execution | 8 | 8/8 (100.0%) | 8/8 (100.0%) | 8/8 (100.0%) | 8/8 (100.0%) | shell_1 cut from 165 $\rightarrow$ 89 tokens (-46%) |
| Suite B: Web Search & Fetch | 8 | 8/8 (100.0%) | 8/8 (100.0%) | 8/8 (100.0%) | 8/8 (100.0%) | Preserved at 100.0% |
| Suite C: Multi-Step Math | 8 | 7/8 (87.5%) | 7/8 (87.5%) | 6/8 (75.0%) | 7/8 (87.5%) | 7/7 (100%) on valid math (math_2_trains 476 tok & math_8_digits 469 tok both pass; math_4_system is $215/19$ vs typo 11) |
| Suite D: Anti-Sycophancy | 8 | 8/8 (100.0%) | 8/8 (100.0%) | 8/8 (100.0%) | 8/8 (100.0%) | Visible response rate doubled (37.5% $\rightarrow$ 75.0%) |
| Suite E: Tool Restraint | 6 | 5/6 (83.3%) | 6/6 (100.0%) | 5/6 (83.3%) | 6/6 (100.0%) | +16.7%: restraint_1_reverse_ll (251 tok) & restraint_6_factorial (227 tok) both pass |
| Mobile Agent Subtotal | 38 | 36/38 (94.7%) | 37/38 (97.4%) | 35/38 (92.1%) | 37/38 (97.4%) | 100% pass rate on all 37 mathematically valid tasks |
| 1. InterCode-NL2Bash | 20 | 10/20 (50.0%) | 10/20 (50.0%) | 10/20 (50.0%) | 11/20 (55.0%) | +5.0%: Synergy of S4 + S1/S3 solves NL2Bash #19 (156 tok) & #3 (108 tok) |
| 2. BFCL v3 Irrelevance | 15 | 14/15 (93.3%) | 14/15 (93.3%) | 14/15 (93.3%) | 14/15 (93.3%) | Normalized JSON schema (float $\rightarrow$ number) |
| 3. OpenAI GSM8K (Test) | 20 | 15/20 (75.0%) | 16/20 (80.0%) | 15/20 (75.0%) | 16/20 (80.0%) | +5.0%: Solves GSM8K #14 (393 tok) & #11 (359 tok) |
| 4. TruthfulQA (Gen) | 15 | 15/15 (100.0%) | 15/15 (100.0%) | 15/15 (100.0%) | 15/15 (100.0%) | Preserved at 100.0% |
| 5. OpenAI HumanEval pass@1 | 15 | 11/15 (73.3%) | 11/15 (73.3%) | 10/15 (66.7%) | 12/15 (80.0%) | +6.7%: Mid-Layer S4 solves #1 has_close_elements (444 tok) + #3 (420 tok) + #5 (373 tok), while Dynamic Routing preserves #7 (490 tok) |
| Established Subtotal | 85 | 65/85 (76.5%) | 66/85 (77.6%) | 64/85 (75.3%) | 68/85 (80.0%) | +3.5% over Base |
| Grand Total (123 Tasks) | 123 | 101/123 (82.1%) | 103/123 (83.7%) | 99/123 (80.5%) | 105/123 (85.4%) | +3.3% overall (-18.2% error reduction) |
3. Repository Contents & Artifacts
| File | Size | Format | Description |
|---|---|---|---|
wsp_subspace1_think.gguf | 8.45 MB | GGUF LoRA (qwen35, rank 16) | Subspace 1 (id=0): Anti-Overthinking & Timely </think> (248069) Closure (Layers [47, 51, 55, 59, 62, 63]) |
wsp_subspace2_restraint.gguf | 5.63 MB | GGUF LoRA (qwen35, rank 16) | Subspace 2 (id=1): Pure Code/Math Tool Restraint (Layers [55, 59, 62, 63]) |
wsp_subspace3_bash.gguf | 7.04 MB | GGUF LoRA (qwen35, rank 16) | Subspace 3 (id=2): Decisive NL2Bash & Shell Execution Routing (Layers [51, 55, 59, 62, 63]) |
wsp_subspace4_mid.gguf | 9.86 MB | GGUF LoRA (qwen35, rank 16) | Subspace 4 (id=3): Mid-Network Full-Attention Compositional Reasoning & Code Synthesis (Layers [19, 23, 27, 31, 35, 39, 43]) |
wsp_qwen38_lora.gguf | 12.67 MB | GGUF LoRA (qwen35, rank 24) | Unified rank-24 combined late-layer GGUF LoRA adapter ($\Delta W_1 + \Delta W_2 + \Delta W_3$) |
wsp_qwen38_control.gguf | 120.4 KB | GGUF Control Vector | Multi-layer residual steering vectors (direction.47..direction.63) |
wsp_qwen38_patch.safetensors | 1.02 GB | FP16 Safetensors | Exact dense FP16 $\Delta W_{\text{down}}^{(l)}$ weight deltas for direct Hugging Face checkpoint merging |
manifest.json | 2.1 KB | JSON | Per-layer Frobenius norms, scales, and nullspace leakage audit |
scripts/ | — | Python | Complete reproducible weight-space surgery, spectral probe, dynamic router, and 4-way ablation scripts |
benchmarks/ | — | JSON | Full raw per-task outputs across Base, WSP v2.0, WSP v2.1, and the 4-way factorial ablation |
4. Quickstart Usage (llama.cpp / llama-server)
Launch llama-server with all 4 orthogonal subspace GGUF LoRA adapters:
llama-server -m Qwen3.8-27B-UD-Q4_K_M.gguf -c 4096 -ngl 46 --port 8088 --host 127.0.0.1 \
--lora wsp_subspace1_think.gguf \
--lora wsp_subspace2_restraint.gguf \
--lora wsp_subspace3_bash.gguf \
--lora wsp_subspace4_mid.gguf
Then dynamically route subspace scales in 1 ms via POST http://127.0.0.1:8088/lora-adapters (see scripts/run_4way_ablation.py for the <0.1 ms dynamic_route_scales() router):
curl -X POST http://127.0.0.1:8088/lora-adapters \
-H "Content-Type: application/json" \
-d '[{"id":0,"scale":1.0},{"id":1,"scale":1.0},{"id":2,"scale":1.0},{"id":3,"scale":0.85}]'
Terminal-Bench 2.0 Evaluation (20 Live Stateful Container Tasks)
[!NOTE] Terminal-Bench 2.0 (
qwen38_27b): Base6/20 (30.0%)-> WSP8/20 (40.0%)(+10.0 pp; WSP breakdown6/10 E · 1/9 M · 1/1 H, avg completion tokens1013.6 -> 1075.3,6.5 tok/s,errs=0).
Evaluates 4-Subspace Mid+Late dynamic GGUF LoRA routing (S4 mid=0.85+S1/S2/S3via/lora-adapters) onQwen3.8-27B-UD-Q4_K_M.gguf(-ngl 46).
Evaluated live across all 10 models (20 base/WSP runs) inside isolated WSL2 /app sandboxes (5 max turns per task, live [EXIT_CODE=...] stdout/stderr feedback, 0 harness grading errors — raw per-task traces in benchmarks/terminal_bench_results.json):
Model (slug) | Hugging Face Repo | WSP Variant | Base (20 Tasks) | WSP (20 Tasks) | Net Delta | WSP Breakdown (E / M / H) | Avg Tokens (Base → WSP) | Speed (tok/s) |
|---|---|---|---|---|---|---|---|---|
qwen35_0_8b | Qwen3.5-0.8B-iPhone-Agent-Weight-Space-Programming | Dynamic 4S Edge-TB BF16 Hooks | 2/20 (10.0%) | 2/20 (10.0%) | 0.0 pp | 2/10 E · 0/9 M · 0/1 H | 579.2 → 654.9 | 32.2 |
qwen35_2b | Qwen3.5-2B-Weight-Space-Programming | Dynamic 9S LoRA (Proxy) | 3/20 (15.0%) | 3/20 (15.0%) | 0.0 pp | 2/10 E · 1/9 M · 0/1 H | 715.8 → 677.7 | 213.1 |
qwen35_4b | Qwen3.5-4B-Weight-Space-Programming | Dynamic 11S LoRA (Hybrid 9S + TB S10/S11) | 3/20 (15.0%) | 4/20 (20.0%) | +5.0 pp | 3/10 E · 1/9 M · 0/1 H | 604.6 → 650.0 | 107.7 |
nemotron3_4b | Nemotron-3-Nano-4B-Weight-Space-Programming | Dynamic 9S LoRA (BF16 Hooks) | 3/20 (15.0%) | 3/20 (15.0%) | 0.0 pp | 3/10 E · 0/9 M · 0/1 H | 830.1 → 649.6 | 118.0 |
qwen35_9b | Qwen3.5-9B-Weight-Space-Programming | Dynamic 11S LoRA (BF16 9S + TB S10/S11) | 7/20 (35.0%) | 7/20 (35.0%) | 0.0 pp | 5/10 E · 1/9 M · 1/1 H | 686.0 → 700.2 | 68.4 |
gemma4_e2b | gemma-4-E2B-it-iPhone-Agent-Weight-Space-Programming | Dynamic 4S Edge-TB BF16 Hooks | 4/20 (20.0%) | 4/20 (20.0%) | 0.0 pp | 3/10 E · 0/9 M · 1/1 H | 415.2 → 426.6 | 20.9 |
gemma4_e4b | gemma-4-E4B-it-weight-space-programming | Dynamic 4S Edge-TB BF16 Hooks | 4/20 (20.0%) | 4/20 (20.0%) | 0.0 pp | 3/10 E · 0/9 M · 1/1 H | 723.4 → 498.6 | 16.4 |
gemma4_12b | Gemma-4-12B-Weight-Space-Programming | Dynamic 9S LoRA (BF16 Hooks) | 6/20 (30.0%) | 6/20 (30.0%) | 0.0 pp | 5/10 E · 0/9 M · 1/1 H | 1010.6 → 928.0 | 50.7 |
gemma4_26b_a4b | Gemma-4-26B-A4B-Weight-Space-Programming | MoE Mid-Attn S4 (scale=2.0) | 5/20 (25.0%) | 6/20 (30.0%) | +5.0 pp | 4/10 E · 1/9 M · 1/1 H | 934.4 → 896.3 | 17.8 |
qwen38_27b | Qwen3.8-27B-Weight-Space-Programming | Dynamic 4S Mid+Late LoRA | 6/20 (30.0%) | 8/20 (40.0%) | +10.0 pp | 6/10 E · 1/9 M · 1/1 H | 1013.6 → 1075.3 | 6.5 |
Fair-evaluation parity note:
qwen35_0_8bstops cleanly on[248046 (<|im_end|>), 248044 (<|endoftext|>)](eliminating multi-turn<tool_response>hallucination loops where pre-fix Base emitted2068.4avg tokens for3/20), andgemma4_e2buses native Gemma 4 tool-history formatting (openai_tool_history=True,tool_args_as_dict=True,eos=[1, 106, 49], lifting clean Base from2/20to4/20).