How Reinforcement Learning Post-Training Improves Code Model Performance: A Practical Breakdown
This article examines why code-specialized models built through post-training can score several times higher than their base models on coding benchmarks, and how to evaluate those gains reliably. It covers a controlled experiment matrix that separates the effect of post-training from the effect of swapping the partner model, why pass-and-fail ratio is more informative than the aggregate score rate, the three stages of code post-training from rejection-sampling fine-tuning to preference optimization and reinforcement learning with verifiable rewards, multi-model orchestration strategies, and the cloud infrastructure and cost controls needed to run the sampling-execution-reward-update loop reproducibly.
1. The Phenomenon and the Problem Definition
A recurring pattern shows up in evaluations of AI coding tools: a code-specialized model produced by post-training a shared base model can score several times higher on coding benchmarks than the base version it came from. The reference comparison in the source material is representative. A 256k long-context base model paired with the 2.0 version post-trained from it reached a score rate of 38.9%; switching to the 2.1 version pushed that to 58.2%, and in solo competition the same lineage moved from the base-model range to 66.0%. These numbers come from a specific evaluation set and a specific match configuration, so treat them as a trend reference rather than a universal conclusion.
The more useful question is not “how much did it improve” but “where did the improvement come from.” Breaking the score rate into observable dimensions makes the answer much clearer: win rate (fully resolved), tie rate (partially passing), and loss rate (failure), plus the pass-and-fail ratio (the number of submitted tests that pass versus the number that fail). Gains from post-training are usually not evenly distributed. They concentrate on one class of samples: patches that were already pointing in the right direction but mishandled boundary conditions.
2. Experiment Design: The Control Group Is the Foundation of Credibility
The most methodologically valuable part of the source material is that it did not run a single “hero” configuration. It built a full comparison matrix:
- Original configuration: strong code model + general-purpose partner;
- Swapped partner: the same strong model + another vendor’s very large general model;
- Same base: base model + its post-trained 2.0 version;
- Target: base model + its post-trained 2.1 version;
- Cost-optimized: strong model + a lightweight model post-trained on the strong model’s outputs.
The point of this design is variable isolation. Comparing only the target group against the original configuration cannot tell you whether the gain came from post-training or from replacing the partner. Adding the same-base group splits the benefit into two separately attributable quantities: the gain from post-training itself and the gain from partner quality. The cost-optimized group answers the question engineering teams care about most: how many percentage points of score rate you give up by using a distilled small model as the secondary model.
One easily overlooked detail is the long-context annotation. The base version carries a 256k context label, which means evaluation samples can hold more complete repository retrieval results, longer call chains, and more failed-retry history. The context budget is itself a variable and must be aligned across configurations, or the conclusions get contaminated by context length.
3. Reading the Metrics: Why the Pass-and-Fail Ratio Ages Better Than the Score Rate
The score rate is an aggregate that hides behavioral differences. The pass-and-fail ratio is a much more direct characterization of patch quality. Three patterns emerge from the source data:
- Top configurations have a clearly better pass-and-fail ratio, meaning fewer and “cleaner” failures, with rarely any large volume of ineffective edits;
- Mid-tier configurations can post similar score rates while differing noticeably in pass-and-fail ratio. These are typically configurations that “fix part of the problem but trade many ineffective attempts for a single pass”;
- The number of ties is a stability signal. A high tie share usually means the model prefers submitting patches that “look reasonable but fail the tests” rather than clearly giving up.
For your own evaluation setup, log four things together: score rate, the win/tie/loss triple, pass-and-fail ratio, and average interaction rounds plus average token consumption. The last two determine whether the capability can enter a real development workflow.
4. Why Post-Training Works: From Imitation to Preference Optimization
Post-training for code tasks generally goes through three stages. The first is rejection-sampling fine-tuning: sample multiple candidate patches from the base model for the same issue, and keep only the trajectories that pass all test cases for supervised fine-tuning. The second is preference optimization: construct preference pairs from “patches that pass tests” and “patches that fail,” teaching the model to move away from typical error patterns such as missing empty inputs, ignoring concurrency boundaries, or wrongly modifying public interfaces. The third is reinforcement learning with verifiable rewards: build rewards from test pass rate, static-check results, and patch-size penalties, then execute in bulk inside a sandbox and feed the reward signal back.
A schematic reward function looks like this:
def reward(patch, tests):passed, total = run_in_sandbox(patch, tests)if passed == total:return 1.0 - 0.01 * changed_lines(patch) # correct, but prefer smaller changesif passed == 0:return -0.5return 0.6 * (passed / total) # partial credit for partial passes
The key engineering constraint here is sandbox isolation and reproducibility: pinned dependency versions, restricted network access, and uniform execution timeouts. Otherwise reward noise turns directly into training noise.
5. Partner Models and Orchestration: The Underrated Multiplier
In team competition, the same strong model paired with different partners can differ by several times in score rate. That shows multi-model orchestration is not simple voting but complementary capability and decorrelated errors. Orchestration strategies you can actually deploy include:
- The main model handles solution design and patch generation, while the lightweight model handles bulk candidate filtering and initial regression screening to control cost;
- Cross review: one side generates, the other reviews with the goal of “finding counterexamples,” reducing self-consistency bias;
- Failure escalation: if the lightweight model fails two rounds in a row, escalate to the main model, avoiding over-spending on low-value samples.
Keep in mind that the extra rounds introduced by the orchestration layer amplify latency and cost. Whether it pays off depends on the share of “hard samples” in your task distribution.
6. Running It in the Cloud: The Engineering Foundation for Training and Evaluation
Keeping the pipeline above stable usually takes a combination of general-purpose cloud capabilities: a container platform to host isolated sandboxes and elastic concurrent execution; object storage for datasets, patches, and execution artifacts; a message queue to smooth out spikes and turn thousands of test executions into retryable asynchronous tasks; and logging plus monitoring and alerting to track reward curves, failure clusters, and resource watermarks. Baidu AI Cloud offers directly composable product capabilities in these general categories, which makes it practical to turn the “sample - execute - reward - update” loop into a pipeline that keeps running.
There are three levers for cost control: deduplicate and early-stop sampling; tier the regression tests, running a fast subset first and the full set later; and produce the secondary model through distillation while periodically refreshing it with the main model’s outputs.
7. Conclusion and Recommendations
The several-fold gain from post-training is essentially the conversion of “a general model’s code priors” into “a behavioral policy judged solely by test passage,” and the control experiments, the pass-and-fail ratio, and the orchestration design together determine whether that conclusion is credible and reproducible. When building your own evaluation, fix the context budget, align partner configurations, keep complete win/tie/loss and pass-and-fail records, and get reward feedback working in a reproducible sandbox before talking about scaling up.
