--- license: apache-2.0 base_model: Qwen/Qwen3-4B-Instruct-2507 library_name: peft pipeline_tag: text-generation tags: - lora - numerical-analysis - floating-point - halo - white-circle-halo-competition datasets: - doraking/precisionpatch-data --- # PrecisionPatch: Qwen3-4B LoRA for verified floating-point accuracy fixes **Made for the White Circle Halo Competition (track `ft-hf`).** A LoRA adapter for [`Qwen/Qwen3-4B-Instruct-2507`](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507) (revision `cdbee75f`), post-trained with [Halo](https://github.com/whitecircle/halo) 1.3.0 to rewrite small numerical expressions so that they are more accurate in IEEE-754 binary64 **without changing their real-number meaning**. The model receives a protected program (guards and constants fixed, constants by ID, input box per branch) and answers with JSON: `{"edits": {"b0": ""}}`, or `{"edits": {}}` to keep the program. An independent verifier decides whether an answer counts: it must parse in a restricted grammar, be **certified** equal to the original by a chain of sound rewrite rules on the branch's input box, and lower the error (bits = log2(1 + ULP distance) against a correctly rounded reference) on held-out inputs. ## Result (pre-registered analysis, held-out test split) 54 test tasks in 40 expression groups (FPBench + Herbie benchmark problems never used for training data, prompts or checkpoint choice). Effective-improvement rate at k = 8 candidates (1 greedy + 7 sampled): | Method | rate | |---|---| | Qwen3-4B-Instruct-2507 (Base) | 0.000 | | Base with two worked examples (few-shot) | 0.019 | | **SFT, mean of 3 training x 3 sampling seeds (pre-registered primary)** | **0.113** | | **This adapter (training seed 0), 3 sampling seeds** | **0.130** | | Rule beam search over the same rewrite space (no LLM) | 0.167 | | Herbie 2.3, guard-fixed, outputs inside the same contract | 0.074 | Paired differences with 95% group-bootstrap intervals: SFT − Base +0.113 [+0.029, +0.218] (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 contain 0). **The adapter clearly helps the base model, but it is not better than a simple rule search over the same rewrite rules.** Certified candidates: SFT 0.107, Base 0.000. ## Training - Halo 1.3.0 (`competition` branch), `scripts/training/sft.py`, recipe `simulation/configs/sft_qwen3_4b_lora_teacher_v1.yaml` (LoRA r 64, alpha 128, all attention and MLP projections, lr 1e-4 cosine, 2 epochs, packing, max length 2048), seed 0. - One H200 on Hugging Face Jobs; 42 optimizer steps. - Data: [`doraking/precisionpatch-data`](https://huggingface.co/datasets/doraking/precisionpatch-data), `teacher_v1` (1,471 rows from the train split only: 885 certified edits, 585 explicit keeps). Teacher answers come from a rule search and Herbie, filtered by the same verifier; no LLM generated training data. ## Evaluate From a checkout of the project's code (Halo image, no extra install): ```bash python simulation/scripts/eval_model.py --model doraking/precisionpatch-qwen3-4b-lora --split test --sampling-seed 0 ``` The adapter is loaded on the base model and revision recorded in `adapter_config.json`. Training seeds 1 and 2 scored 0.105 each; this adapter is seed 0, the recipe's seed fixed before the test split was opened. ## Limits - Only expressions with 1–3 variables over `+ - * / sqrt log exp log1p expm1 fabs`, with guards that compare a variable with a constant. Certification covers only the verifier's rule set. - The public benchmarks may be part of the base model's pre-training data: "held out" means held out from this post-training, not unseen. - Not a tool for repairing production code; the verifier, not the model, is what makes an answer trustworthy. ## License Adapter: Apache-2.0, as the base model. Code: Apache-2.0 (separate from Halo). Benchmarks: FPBench and Herbie (MIT).