Technical report · DPO-Mini · 2026
Measuring the cost of a fixed reference
A correctness and performance study of Direct Preference Optimization. Caching reduced complete benchmark time by 11.70% against a shared-base reference, with matching observed training trajectories.
Research question
How much does caching save once the full cost is counted?
DPO compares a policy’s preference scores with a fixed reference. Recomputing that reference costs time; keeping a second model resident costs memory. Precomputing scores can reduce repeated work, but the cache itself has a construction cost. The study measures those costs separately and checks that the strategies preserve the tested computation.
Engineering focus
An independent implementation of the original sigmoid DPO objective, explicit completion-token masking, validated reference caches, deterministic checkpoint resume, and a controlled comparison of three reference strategies. DPO and caching are established methods; the contribution here is the implementation, audit and measurement.
Experimental design
A stronger baseline separates sharing from caching.
Comparing a cache only with a separately resident reference mixes two changes: reference computation and model residency. Adding the shared-base strategy makes B versus C the relevant comparison for caching. A versus B measures the reference implementation strategy.
Separate reference
Keep a second frozen model in memory and recompute reference scores during training.
Shared frozen base
Use the policy’s frozen base with its LoRA adapter temporarily disabled. Recompute reference scores without retaining a second model.
Cold shared-base cache
Use the shared base to compute training-reference scores once, inside each trial process, then read them from a validated cache.
- Model
- SmolLM2-135M-Instruct · rank-16 LoRA · 921,600 trainable parameters
- Hardware
- AMD Ryzen 5 PRO 7540U · 30.67 GiB RAM · Windows 11
- Execution
- CPU FP32 · four computation threads · seed 42
- Data
- Filtered UltraFeedback Binarized · 256 / 64 / 64 train / validation / test pairs
- Timing workload
- 5 warm-up + 20 measured updates · 16 pairs per update · 3 trials per strategy
- Matched conditions
- Initial state, data order, optimiser, schedule and backend · balanced orders ABC / BCA / CAB
Results
The training gain remains useful after paying for the cache.
The cache took a median 228.976 seconds to construct. Including that cost, the process took 1,013.617 seconds versus 1,147.964 seconds for the shared-base reference. The larger training-only reduction describes the part of execution where reference scores are already available.
Zero-based scale. Each cold-cache process includes its own reference precomputation.
| Reference strategy | Training block, s | Whole process, s | Training RSS, MiB |
|---|---|---|---|
| A: Separate reference | 901.831897.240–902.195 | 1,151.4781,145.515–1,159.711 | 2,632.42,623.5–2,637.2 |
| B: Shared frozen base | 902.774896.044–907.790 | 1,147.9641,142.434–1,159.711 | 2,098.92,098.3–2,102.8 |
| C: Cold shared-base cache | 609.977609.702–611.667 | 1,013.6171,013.588–1,014.831 | 2,095.72,095.6–2,101.3 |
The training block covers 320 processed pairs after 80 warm-up pairs. Whole-process time includes loading, warm-up, cache construction and adapter endpoint output. Held-out evaluation, generation and full learning checkpoints are outside this benchmark. RSS is sampled during training; it is not whole-process peak memory. Percentage reductions use the ratio of medians.
Most of the memory saving came from sharing the base.
Replacing the separate reference with a shared base lowered median training RSS by 533.5 MiB. Caching then changed it by only 3.2 MiB, with overlapping trial ranges. The large A-to-C memory difference cannot be attributed to caching alone.
Correctness
Numerical checks exposed a real qualification.
Both the working and fresh-environment core suites passed all 19 tests. Shared-base reference invariants and matched short trajectories also passed. However, the actual pretrained comparison with TRL 0.24.0 exceeded the original FP32 tolerances. That failure remains part of the result.
What matched
- Reference scores before and after policy-adapter updates.
- Frozen base parameters and buffers, optimiser membership, and state restoration after exceptions.
- Short three-strategy loss traces and adapter tensors, with zero reference forwards in cached training.
- Complete update traces and canonical model-state hashes across all nine timing runs.
Where FP32 diverged
- Pretrained score differences reached 6.4087e−4 and loss differences reached 1.6809e−5.
- The trained-adapter gradient difference was 2.0103e−6, narrowly above the original 2e−6 bound.
- Input IDs, masks and logits matched; different score-reduction arithmetic caused the discrepancy.
- Separate FP64-reduction diagnostics recovered identical adapter gradients. This does not establish full TRL Trainer equivalence.
Interpretation
Timing boundaries change the conclusion.
The earlier sixteen-update learning workflow included evaluation, generation and a checkpoint. It took 1,518.458 seconds without caching and 1,409.365 seconds with caching: a 7.18% reduction. Its recorded aggregate stages reconcile that saving, while finer historical phase attribution remains unresolved. A new instrumented replay measures its own detailed costs; those measurements are not retroactively assigned to the earlier run.
The single paired learning seed ended at test DPO loss 0.690726, with 39 of 64 strict-positive preference margins and no ties. This small objective-level change does not establish better human preference, helpfulness or truthfulness. The timing trials describe one nonexclusive CPU host, and the short exploratory generations have no completed human ratings.
Reproducibility
Inspect the implementation and recalculate the results.
The repository includes source, tests, a dependency lockfile, configurations, per-trial numeric evidence and the report’s tables. Its offline verification and report-only commands run without retraining. The clean-environment check covered the core suite, pinned upstream comparisons, short pretrained trajectories and report regeneration; it did not repeat the complete timing campaign. Weights, full datasets and large checkpoints must be obtained separately for pretrained reruns.