# StepProbe ๐Ÿ”ฌ **Step-Level Diagnosis of Reasoning under Weight Quantization, with Diagnosis-Driven Interventions** > Where exactly does reasoning break when you quantize a thinking model? This repository hosts the code, paper, and released experiment artefacts for the manuscript: > *StepProbe: Step-Level Diagnosis of Reasoning under Weight Quantization, > with Diagnosis-Driven Interventions* > Tran Huy Hoang Son. Submitted to *Neurocomputing*, 2026. The full PDF lives at [`paper/main.pdf`](paper/main.pdf); the LaTeX source, the highlights file, and the two appendices (LLM-judge prompts and qualitative error-type examples) are under [`paper/`](paper/). ## What StepProbe does StepProbe is a diagnostic-plus-intervention framework that answers three questions about quantized reasoning LLMs: 1. **Where** in the chain-of-thought does reasoning first fail? 2. **What type** of error dominates at each bit-width? 3. **Can we fix it** with minimal, diagnosis-driven intervention? The framework introduces three step-level metrics: | Metric | Meaning | |---|---| | **FFS** โ€” First Failure Step | Step index where the quantized chain first diverges | | **ECR** โ€” Error Cascade Rate | Fraction of post-FFS steps that are also incorrect | | **SSR** โ€” Step Survival Rate | Probability that the chain is still correct at depth d | โ€ฆplus a 4-way error-type taxonomy (conceptual / methodological / executional / logical), and two downstream interventions (targeted QLoRA fine-tuning; training-free FP16 prompt-prefix injection). ## Headline findings (paper ยง5) - **>85% of failed traces fail in the first three reasoning steps** โ€” damage is concentrated at the chain's *opening*, not distributed evenly. - **Conditional cascade rate >0.90** on the harder benchmarks (MATH-500, GPQA-Diamond): once a quantized chain breaks, it almost never recovers. - **Methodological errors dominate**, not conceptual: under GPT-4o-mini re-classification, methodological accounts for 54โ€“60% of failed steps; conceptual is only ~9%. - **Targeted QLoRA recovers up to +7.6 pp** on Qwen-family cells; the diagnosed-vs-random selection gap is +1.8 pp (significant; honestly reported as small relative to the overall recovery). - **Training-free prompt-prefix injection adds +7.6 pp at k=4** under a leak-controlled ablation, matching the QLoRA comparator at k=2. ## Repository layout ``` StepProbe/ โ”œโ”€โ”€ paper/ # LaTeX manuscript + highlights + form โ”‚ โ”œโ”€โ”€ main.tex # Source (elsarticle, Neurocomputing target) โ”‚ โ”œโ”€โ”€ main.pdf # Compiled paper (44 pp) โ”‚ โ”œโ”€โ”€ highlights.txt # Editorial-Manager highlights file (5 bullets) โ”‚ โ””โ”€โ”€ references.bib # 38 references โ”œโ”€โ”€ stepprobe/ # Core package โ”‚ โ”œโ”€โ”€ segment.py # CoT step segmentation (rule-based) โ”‚ โ”œโ”€โ”€ align.py # DTW step alignment โ”‚ โ”œโ”€โ”€ diagnose.py # Per-step scoring + LLM-judge prompts โ”‚ โ”œโ”€โ”€ metrics.py # FFS / ECR / SSR computation โ”‚ โ””โ”€โ”€ restore.py # QLoRA targeted fine-tuning โ”œโ”€โ”€ scripts/ # Top-level runners and figure generators โ”‚ โ”œโ”€โ”€ run_inference.py โ”‚ โ”œโ”€โ”€ run_eval.py โ”‚ โ”œโ”€โ”€ compute_ci.py # Bootstrap CIs + paired sig tests โ”‚ โ”œโ”€โ”€ eval_accuracy.py โ”‚ โ”œโ”€โ”€ make_paper_figures.py # Figs 1, 2, 3, 4, 5, 11โ€“13 + Table 4 โ”‚ โ”œโ”€โ”€ make_ablation_figure.py # Fig 9 โ”‚ โ”œโ”€โ”€ make_baselines_figure.py# Fig 10 โ”‚ โ”œโ”€โ”€ make_lr_sweep_figure.py # Fig 12 โ”‚ โ”œโ”€โ”€ make_multi_seed_figure.py# Fig 13 โ”‚ โ”œโ”€โ”€ make_prefix_injection_figure.py # Fig 14 โ”‚ โ”œโ”€โ”€ rediagnose_error_types.py โ”‚ โ””โ”€โ”€ validate_classifier.py โ”œโ”€โ”€ run_*.sh # Experiment launchers (one per ablation) โ”œโ”€โ”€ configs/default.yaml โ”œโ”€โ”€ requirements.txt โ””โ”€โ”€ figures/paper/ # Final figure PDFs referenced by main.tex ``` ## Reproducing the paper The released `results/` and `logs/` directories are *not* in this repository (too large for git). To reproduce from scratch you need a single 24-GB GPU and roughly 24 hours of compute. ```bash # 0. Install dependencies pip install -r requirements.txt # 1. Main matrix (Table 4): 4 models ร— 3 benchmarks ร— 6 conditions bash run_all.sh # 2. Ablation: silver-bullet dataset size N (Table 5) bash run_ablation.sh # 3. Sampling-strategy baselines (Table 6) bash run_baselines.sh # 4. Llama LR sweep (Fig 12) bash run_llama_lr_sweep.sh # 5. Multi-seed robustness (Fig 13) bash run_multi_seed.sh # 6. Prompt-prefix injection (Fig 14, Table 7) bash run_prompt_prefix.sh # 7. Render all paper figures + tables from results/metrics/ python scripts/make_paper_figures.py --metrics results/metrics \ --output figures/paper --primary-model r1-qwen-7b \ --primary-benchmark math500 ``` The full paper PDF rebuilds with: ```bash cd paper && tectonic main.tex # or: latexmk -pdf main.tex ``` ## Quick demo (no GPU required) For a 20-problem dry run on a small model: ```bash python scripts/run_eval.py \ --model deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B \ --benchmark gsm8k --quant-methods bnb_nf4 --quick ``` ## Models, benchmarks, quantization **Models tested in the paper** (24-GB-VRAM-friendly in 4-bit): - DeepSeek-R1-Distill-Qwen-{1.5B, 7B, 14B} - DeepSeek-R1-Distill-Llama-8B - Qwen2.5-7B-Instruct (non-reasoning control / primary intervention cell) **Quantization methods**: AWQ, GPTQ, BitsAndBytes NF4 (SmoothQuant supported but not part of the main matrix.) **Benchmarks**: GSM8K, MATH-500, GPQA-Diamond. ## Hardware All experiments ran on a single NVIDIA RTX 3090 Ti (24 GB). ## Citing If you use StepProbe, please cite the paper: ```bibtex @article{son2026stepprobe, title = {StepProbe: Step-Level Diagnosis of Reasoning under Weight Quantization, with Diagnosis-Driven Interventions}, author = {Tran Huy Hoang Son}, journal= {Neurocomputing}, year = {2026}, note = {Under review} } ``` ## License MIT โ€” see [`LICENSE`](LICENSE).