RL-N02 · Published Note ✓ Done ~6 min read ← Back to Fine-Tuning & RL · 2026-12-01

Compiler-Feedback Retries Beat Blind Resampling on Fortran/OpenMP Code — and Stack With Fine-Tuning

Runtime GuardCortheon-ModeledFortran / OpenMPPaired A/B/C

API: Tinker (Thinking Machines' hosted API, free tier) + our runtime guard · Models: Base Inkling-2-Mini & FT-Mini (our LoRA fine-tune) · Experiment: 2026-12-01

TL;DR & Highlights

Before spending reinforcement learning (RL) compute to train away bad syntax, missing OpenMP pragmas, and placeholder stubs, we tested a problem-agnostic runtime guard modeled on Cortheon (an open-source code-guard runtime) across 86 Fortran/C++/OpenMP tasks (688 paired rollouts). Comparing Arm A (First try), Arm B (Guided retry with compiler/linter stderr), and Arm C (Blind retry with the same call budget), the guard never sees the grading tests yet lifted frozen Inkling-2-Mini by +18.3 percentage points (pp) on passing tests (68.6% → 86.9%) and +27.0 pp on passing tests + clean code (45.4% → 72.4%) with zero regressions. Stacking the guard on top of our fine-tuned model (FT-Mini) pushed clean-code pass rates higher still, to 75.6% overall and 77.5% on OpenMP.

  • Not just extra compute (Arm B vs Arm C): At the exact same 1.82 calls per task on average (first try + up to 2 retries) and slightly fewer tokens (12,440 vs 12,477), guided retry beat blind retry by +14.24 pp on passing tests + clean code across all 86 tasks (p < 0.0001) and +28.75 pp on OpenMP tasks.
  • Zero regressions across 688 rollouts: First tries that pass the guard are never retried, so a regression can only happen if the guard raises a false alarm on already-working code. There were none (+63 fixed / −0 broken on Base Mini; +64 / −0 on FT-Mini), and weights stay unchanged so there is nothing to forget.
  • Guard + Fine-Tuning stack: On the first try alone (Arm A), FT-Mini matched Base Mini (68.6% vs 68.6% passing tests). With guided retries (Arm B), FT-Mini hit 75.58% passing tests + clean code (vs 72.38% Base), 77.50% on OpenMP (vs 71.25% Base), and solved 4/6 hard tasks (vs 2/6 Base).
  • Honest scope & limits: Fortran/C++/OpenMP support is our own fork (merged as PR #18 in Cortheon v2.6.0). The guard cannot catch the remaining ~6–10% on Fortran/C++ and OpenMP that compile cleanly yet still fail the tests due to physics or math logic bugs — that narrow residual is where post-training belongs.

1. Controlled A / B / C Setup (Never Sees Grading Tests)

All three arms start from the exact same first-try sample per task (4 samples per task, temperature 0.8, top_p = 0.95, reasoning effort 0.2 API setting, 24,576 max tokens, no system prompt) across 86 scientific-computing tasks: a Fortran/C++ held-out set (40 tasks), an OpenMP set (40 tasks), and a Hard set (6 tasks) — 344 rollouts × 2 models = 688 paired rollouts, run on Tinker's free tier ($0.00).

We score two models: frozen Base Mini (Inkling-2-Mini) and FT-Mini (our rank-32 LoRA fine-tune of Inkling-2-Mini trained via self-distillation on Fortran/C++ scientific-coding facts; internal checkpoint ID in Section 5). Every rollout is graded on two metrics: Passes tests (passes the hidden task test suite verify.py) and Passes tests + clean code (passes the hidden tests and has zero placeholder stubs, dead code, or missing OpenMP pragmas).

  • Arm A — First try (no guard): The model's first response is graded directly.
  • Arm B — Guided retry (guard + error text, up to 2 retries): Our runtime guard (internal name: flumah) checks the draft without ever seeing verify.py: (1) strict compilation (gfortran / ifx / g++ / mpicxx), (2) static anti-slop checks (catching placeholder stubs, dead code, missing OpenMP pragmas, silent error swallowing, broken markdown code blocks), and (3) a standalone compile-and-smoke-run check where applicable. When a draft fails, the guard hands back the first ~25 lines of compiler/linter stderr. A unit test confirms the guard code never references verify.py.
  • Arm C — Blind retry (same trigger, same calls, no error text): Gives the model 1 or 2 extra calls matching Arm B on the exact same failed first tries, filtered by the exact same guard checks, but with zero error text. This separates true compiler-guided repair from simple best-of-N sampling.
Paired A, B, C pass rates for Base Inkling-2-Mini and FT-Mini across 86 Fortran/C++/OpenMP tasks showing Arm A First Try, Arm B Guided Retry, and Arm C Blind Retry
Figure 1. Left: All 86 tasks (344 rollouts per model) comparing Arm A (First try), Arm B (Guided retry), and Arm C (Blind retry) in sequential order with fixed per-arm colors. Right: Per-suite breakdown on Base Inkling-2-Mini, plus the FT-Mini + Arm B callout.

2. Headline & Per-Suite Results (n = 688 Rollouts)

Significance uses exact two-sided McNemar tests on paired rollouts. pass@4 is the count of tasks solved in at least 1 of 4 samples.

Headline Summary — All 86 Tasks (344 Rollouts per Model)

ModelMetricArm A
(First try)
Arm B
(Guided retry)
Arm C
(Blind retry)
B vs A
(fixed / broken)
B vs C
(p-value)
pass@4
A / B / C
Base MiniPasses tests68.60%86.92%84.01%+18.31 pp (+63/−0, p < 0.0001)+2.91 pp (0.087)77 / 82 / 82
Base MiniPasses tests + clean45.35%72.38%58.14%+27.03 pp (+93/−0, p < 0.0001)+14.24 pp (<0.0001)57 / 77 / 66
FT-MiniPasses tests68.60%87.21%82.56%+18.60 pp (+64/−0, p < 0.0001)+4.65 pp (0.009)78 / 84 / 83
FT-MiniPasses tests + clean44.48%75.58%59.30%+31.10 pp (+107/−0, p < 0.0001)+16.28 pp (<0.0001)62 / 79 / 72
Full per-suite breakdown (Fortran/C++ 40, OpenMP 40, Hard set 6)

Base Inkling-2-Mini

Task Set (tasks / n)MetricArm AArm BArm CB vs A (p)B vs C (p)pass@4 A/B/C
Fortran/C++ held-out (40/160)Passes tests76.88%90.00%87.50%+13.12 pp (<0.0001)+2.50 pp (0.289)39/40/40
Fortran/C++ held-out (40/160)Tests + clean68.75%83.75%81.88%+15.00 pp (<0.0001)+1.88 pp (0.664)38/39/40
OpenMP set (40/160)Passes tests70.00%94.38%90.00%+24.38 pp (<0.0001)+4.38 pp (0.144)37/40/40
OpenMP set (40/160)Tests + clean28.12%71.25%42.50%+43.12 pp (<0.0001)+28.75 pp (<0.0001)18/37/25
Hard set (6/24)Passes tests4.17%16.67%20.83%+12.50 pp (0.250)−4.17 pp (1.000)1/2/2

FT-Mini (LoRA rank-32 fine-tune)

Task Set (tasks / n)MetricArm AArm BArm CB vs A (p)B vs C (p)pass@4 A/B/C
Fortran/C++ held-out (40/160)Passes tests75.62%90.62%86.88%+15.00 pp (<0.0001)+3.75 pp (0.070)39/40/40
Fortran/C++ held-out (40/160)Tests + clean65.62%84.38%78.75%+18.75 pp (<0.0001)+5.62 pp (0.023)38/40/40
OpenMP set (40/160)Passes tests70.00%93.12%87.50%+23.12 pp (<0.0001)+5.62 pp (0.078)36/40/40
OpenMP set (40/160)Tests + clean29.38%77.50%46.88%+48.12 pp (<0.0001)+30.63 pp (<0.0001)23/38/29
Hard set (6/24)Passes tests12.50%25.00%20.83%+12.50 pp (0.250)+4.17 pp (1.000)3/4/3

3. How the Guard and Fine-Tuning Stack

  • Cheap syntax and stub cleanup belongs in the runtime, not the weights: Trying to train away compiler errors, Fortran line-length slips, and missing OpenMP pragmas with single-turn RL costs multiple training runs and risks out-of-domain forgetting (see our earlier note where RL backfired, RL-N01). The deterministic guard cleared +18.3 pp on passing tests and +27.0 pp on clean code on the frozen base model at zero training cost, and eliminated all empty answers (no final code: 5/344 → 0/344 on both models).
  • Fine-tuning stacks cleanly with guided retries: On the first try alone, FT-Mini matched Base Mini (68.60% vs 68.60% passing tests). When the guard triggered on a failed draft, FT-Mini repaired 114 / 177 (64.4%) vs Base Mini's 99 / 173 (57.2%) — a +7.2 pp gap (p = 0.189, Fisher exact test, not statistically significant on its own, vs 26.6–31.1% for blind retries) — lifting OpenMP clean-code pass rate from 71.25% → 77.50% and solving 4/6 Hard-set tasks (vs 2/6 on Base). On the tiny Base Hard set (n = 24), blind retry edged guided retry (20.83% vs 16.67%, p = 1.000).
  • Same call budget, slightly fewer tokens than blind retries: Both Arm B and Arm C averaged 1.82 calls per task (Fortran/C++ 1.34–1.40, OpenMP 2.08–2.15, Hard set 2.88). Guided retries used slightly fewer total tokens than blind retries (12,440 vs 12,477 on Base; 12,480 vs 12,609 on FT-Mini).

4. Limits & Follow-Up Negative Result (Patch Retry vs Full Rewrite)

What the guard cannot fix: On Fortran/C++ and OpenMP, the remaining ~6–10% that still fail the tests already compile cleanly (and on OpenMP, 22–29% still fail the stricter clean-code bar). Those remaining test failures are silent numerical divergence, wrong boundary conditions, or parallel logic bugs — the right narrow target for multi-turn RL from execution feedback (RLEF).

Negative result — targeted SEARCH/REPLACE patch retries vs full-file rewrites (80 tasks, 640 paired rollouts): We tested whether asking Inkling-2-Mini to output small SEARCH/REPLACE patch hunks on retry would save tokens and time versus rewriting the whole file. On short single-file scientific solvers, full-file rewrites won on both speed and tokens:

Model (80 tasks / 320 rollouts)Passes tests
(Patch vs Rewrite, p)
Tests + clean
(Patch vs Rewrite, p)
Retry tokens
(Patch vs Rewrite)
Retry wall time
(Patch vs Rewrite)
Base Mini90.62% vs 90.31% (1.000)77.19% vs 76.25% (0.784)4,886 vs 4,709 (+3.8%)33.5s vs 30.9s (0.92×)
FT-Mini88.75% vs 91.25% (0.152)76.25% vs 79.38% (0.229)5,325 vs 4,759 (+11.9%)41.3s vs 36.0s (0.87×)

Local serving check pending: All paired runs here ran on Tinker's free tier; reproducing the same guard loop on our local engine (tubo) and llama.cpp is our next step.

5. Upstream Credits & Open Contribution

  • Cortheon inspiration & upstream PR: Our Fortran/C/C++/OpenMP/MPI guard is modeled on Ash Hart's ashhart/Cortheon runtime. Because compiled HPC support is not yet in Cortheon's main branch, we built our own fork for this study and opened ashhart/Cortheon PR #18 (feat(guard,tools): add C, C++, Fortran, OpenMP, and MPI support, 33/33 new unit tests, 273 total suite tests passing).
  • Models: Base model from Thinking Machines Lab (thinkingmachines/Inkling-2-Mini), evaluated alongside our rank-32 LoRA fine-tune (internal checkpoint ID: F1-SDFT-s40).
  • About Cold-Serve Labs: Independent AI research lab making local models practical on everyday consumer hardware. Contact: hello@coldservelabs.com · @Coldservelabs · GitHub.