PrecisionPatch: teaching a 4B model to propose floating-point fixes that a verifier can certify
Team lead: @dorakingx · White Circle Halo Competition, track ft-hf · 2026-12-03
Code: github.com/dorakingx/halo, branch precisionpatch · Model: doraking/precisionpatch-qwen3-4b-lora · Data: doraking/precisionpatch-data
What and why
sqrt(x+1) - sqrt(x) loses almost every significant bit for large x; 1/(sqrt(x+1) + sqrt(x)) is the same real
function and stays accurate. Tools such as Herbie find rewrites like this by search. Recent work prompted large LLMs
for the same job and found that their rewrites were often not equivalent: they changed constants, dropped branches or
shrank the input domain (Nguyen et al., arXiv 2604.04854).
We asked a narrower question: if a small model may only edit what is safe to edit, and every answer is checked by an independent verifier, does post-training it with Halo on verified rewrites make it useful?
Method
Task. A program over 1–3 binary64 variables (+ - * / sqrt log exp log1p expm1 fabs, optional guards x < c).
The model sees the program with guards fixed and constants referred to by ID, the input box of each branch and the
current error, and answers with JSON: a new body per branch, or "keep". It cannot touch guards, constants or domains.
Verifier (the part that makes an answer count).
- The answer must parse in a restricted grammar (no new literals beyond small integers, no new branches).
- It is certified only if a chain of sound rewrite rules (57, each with side conditions proved by interval arithmetic on the branch's box) turns the original into it; a different real value at any checked input is a proof of non-equivalence and rejects it.
- Error is
log2(1 + ULP distance)against the correctly rounded binary64 value of the original real expression, enclosed with arb or mpmath interval arithmetic (the two backends agree bit for bit on 15,488 reference values). The candidate is chosen on 256 probe inputs and scored once on 4,096 disjoint audit inputs.
An answer is an effective improvement if it is certified, lowers the audit mean error by at least max(0.1 bit, 10%), does not raise the 95th percentile and creates no NaN/inf.
Data and split. 915 FPCore programs from FPBench and Herbie's benchmark suite give 310 eligible tasks, 301 after removing exact duplicates. Tasks are grouped by expression skeleton (up to commutativity and variable renaming) and source function, and whole groups go to one split: 54 test tasks in 40 groups, 10 dev tasks, the rest train. The training set (1,471 rows) uses train tasks and generated variants only; each answer is the rule-search or Herbie candidate the verifier certified, or "keep". Generated tasks that collide with any dev/test task were dropped.
Training. Qwen/Qwen3-4B-Instruct-2507 (rev cdbee75f), LoRA r 64 on all projections, 2 epochs, Halo 1.3.0
scripts/training/sft.py, one H200 on Hugging Face Jobs: 42 optimizer steps, about 90 seconds per run.
Protocol. The design, split and analysis were fixed and committed before the test split was opened. Each method proposes up to 8 candidates (1 greedy + 7 sampled); 3 training seeds × 3 sampling seeds for SFT, 3 sampling seeds for the base model.
Results (held-out test split, 54 tasks, 40 groups)
| Method | effective-improvement rate (k = 8) |
|---|---|
| Base model | 0.000 |
| Base model, two worked examples in the prompt | 0.019 |
| After Halo SFT | 0.113 |
| Rule beam search over the same rewrite rules (no LLM) | 0.167 |
| Herbie 2.3, outputs inside the same contract | 0.074 |
Paired per-task differences with 95% group-bootstrap intervals:
- SFT − Base: +0.113 [+0.029, +0.218] — the pre-registered primary contrast, positive.
- SFT − few-shot Base: +0.095 [−0.002, +0.206]; SFT − rule search: −0.053 [−0.167, +0.051]; SFT − Herbie: +0.039 [−0.039, +0.128] — all intervals contain 0.
- Per training seed (k = 8, mean of 3 sampling seeds): 0.130, 0.105, 0.105. The released adapter is training seed 0, the recipe's seed fixed at design time, so the evaluation command below gives 0.130 for it and 0.000 for the base model.

What changed in the model: 58% of the base model's answers were valid in the answer grammar and none was certified; after SFT
97% are valid and 10.7% of all candidates are certified. On 7 of 54 tasks SFT finds an effective fix (for example
exp(a·x) − 1 → expm1(a·x), log(1 + eˣ) → log1p(eˣ), sqrt(x+1) − sqrt(x) → 1/(sqrt(x+1) + sqrt(x))).
What this does not show. The fine-tuned model is not better than a plain rule search over the same rules; the
search solves 9 tasks, 5 of them the same. Herbie's own outputs improve more programs numerically, but most of them
use new constants, fma or Taylor approximations and fall outside the contract. The benchmarks are public, so "held
out" means held out from our training, not unseen by the base model.
Reproduce
# in the Halo image (hopper-1.3.0), from the repository root
python scripts/training/sft.py simulation/configs/sft_qwen3_4b_lora_teacher_v1.yaml --seed=0 --report_to=none
python simulation/scripts/eval_model.py --model doraking/precisionpatch-qwen3-4b-lora --split test --sampling-seed 0
python simulation/scripts/eval_model.py --model Qwen/Qwen3-4B-Instruct-2507 --split test --sampling-seed 0
The baselines and the pre-registered analysis: simulation/scripts/pilot.py and simulation/analysis/main_analysis.py.
Third-party material
- Model: Qwen/Qwen3-4B-Instruct-2507, revision
cdbee75f17c01a7cc42f958dc650907174af0554(Apache-2.0). - Benchmarks: FPBench
408c85c0and Herbiebench/884621aa(MIT). Baseline and teacher: Herbie 2.3. - Libraries: Halo 1.3.0, python-flint 0.7.1, mpmath 1.3.0.
Platforms used
- Hugging Face Jobs: all training and evaluation, 1× H200, 1.1 GPU-hours in total ($5.50 of competition credits); a private storage bucket for code and checkpoints.
- Hugging Face Hub: model and dataset repositories, and this writeup.
- Herbie, the rule search and the analysis ran on a laptop CPU.