5. Other alignment scenarios¶
Where we are¶
Parts 1 to 4 taught one method through its workflows: finding where two pre-training runs part (part 1), making a rollout engine and a trainer agree (part 2), making one operator invariant (part 3), and keeping the results true when the stack changes (part 4). Many other needs are the same question asked about a different pair of programs: a framework migration, a checkpoint conversion, or a reference model run in an inference engine. This part shows how to apply the method you already have to seven such scenarios. Three of them have their own page, and the other four get a short section on this page.
The idea: say what you compare, on which inputs, and what should hold¶
Every scenario has four parts: a reference, a suspect, the inputs that both receive, and a claim about which outputs should be equal and how strictly. Once you have written those four down, one of the existing workflows applies. Here are a few pairs:
| Pair | Same inputs | What should be equal | What to expect |
|---|---|---|---|
| A checkpoint and its converted copy | none, since nothing is computed | every row of every weight | bitwise equality, always |
| One model in two training frameworks | the data, the weights and the seed | every boundary that both have | bitwise equality, but only after every rounding point is aligned |
| A trainer and a precomputed reference logprob | the same token ids and weights | each token's logprob | bitwise equality once you have engine parity |
| One request sent alone, and the same request inside a busy server | the request | its tokens and logprobs | bitwise equality once serving is batch-invariant |
| The same job on two GPU generations | everything | nothing at the bit level | the bits will differ, so localize instead |
The last row matters as much as the others. Where bitwise equality is not promised, the goal is to find the first operator whose bits differ and make a decision about it, not to reach equality at any cost. So the rule is: before comparing anything, state which two programs you compare, on which inputs, and what you claim should hold. This is the controlled experiment of part 1, with the claim written out explicitly.
The scenarios¶
| Scenario | Workflow to reuse | Tools and skills | What is specific to it |
|---|---|---|---|
| Framework migration and library upgrades | part 1, with the other stack as the reference, plus the rounding-point method of engine parity | determinism_preflight.py, opguard_bridge.py, engine-parity | The two programs' traces do not line up, and each difference is either a bug or a choice |
| Checkpoint conversion and resharding | none, since nothing is computed: first a copy check, then one forward | ckpt_compare.py | Each row keeps its values when the tensor is repacked; whether rows ended up in the right place needs a forward |
| Offline post-training: reference logprobs for SFT and DPO, teacher logits for distillation | part 2 at L4, without sampling | engine-parity, OpGuard's RL records | Which tokens are scored, chat templates, padding |
| Reward models and evaluation | whole model, sampling, regression | bi_audit.py, bi_sampling.py | When a score is near a threshold, one bit can change the decision |
| Deterministic serving | whole model on the engine side; part 3 | bi_audit.py, batch-invariant-kernel | Every serving mode a request can run into |
| Speculative decoding and MTP | sampling, whole model at L3 | bi_sampling.py | Verification processes a chunk of tokens, while decoding processes one |
| Hardware migration and mixed fleets | hardware, localize with OpGuard | sdc_scan.py, bi_suite.py | Bitwise equality is not expected across GPU generations |
Reward models and evaluation¶
Here you want a reward model to give a (prompt, response) pair the same score in any batch, and an evaluation to give the same number when it is run again. A reward model is a whole model with a scalar head, so its output depends on the batch and the mode in the same ways as a policy's does. What differs is how the output is used. A score is compared with a threshold, ranked against other responses, or averaged into a pass rate. A score one bit away from a threshold can therefore change a decision, and a changed decision changes the training signal or the number you report.
How to apply the existing pages:
- Make the reward model invariant like any other model. Audit its operators with bi_audit.py, and compare one pair scored alone with the same pair scored inside batches, padded and packed (whole model).
- Match the engine, if there is one. If the score is computed in an engine and recomputed by the trainer, you are at L4: follow engine parity.
- Make sampling replayable. If the evaluation samples, make its tokens replayable from the logits and a seed (sampling, bi_sampling.py).
- Keep a fixed evaluation set and its scores as a regression entry.
You are done when every pair gets the same score bits at every batch size, and a rerun with a different batch composition gives the same evaluation result.
Not yet shown: no reward model or evaluation harness has been measured here.
Deterministic serving¶
Here you want a request's tokens and logprobs to depend neither on which other requests share its batch (L2) nor on how the server chunks, caches or decodes it (L3). This is the engine side of the whole-model step, as a user experiences it: two identical requests at temperature 0 get different answers because the server happened to be busy in different ways. The causes and the fixes are the same.
How to apply the existing pages:
- Audit the served model, and test every mode a request can run into: a decode batch that keeps changing, chunked prefill, a prefix-cache hit, and preemption (whole model).
- Replace every operator that varies with the batch by an invariant kernel (part 3), and keep the sampler replayable (sampling).
- Measure the cost at your decode batch sizes. If it is too high, offer the invariant path only to the requests that need it, not to all of them.
You are done when each request's logprobs are bit-equal whether it is served alone or under load, in every mode the server uses.
Not yet shown: a production server under real traffic, and serving across several nodes.
Speculative decoding and MTP¶
Here you want a decoder that uses speculation or multi-token prediction (MTP) to emit exactly the tokens and logprobs that the target model emits on its own. Verification runs the target model over several draft tokens at once, much like a short prefill, while plain decoding runs one token at a time. If the two paths round differently, an accepted token's logprob differs from the one plain decoding would give, and the acceptance test itself can flip. The draft model's own numerics affect only speed, not the result, as long as acceptance compares against the target model's own sample.
How to apply the existing pages:
- Make the target model's verification forward equal its decode forward. A chunk against a single token is the L3 case of the whole model, and attention must split the keys the same way in prefill and decode (attention).
- Make acceptance replayable. When drafts are verified by exact equality, speculative decoding gives the same tokens as decoding without a draft (sampling, bi_sampling.py).
- Treat MTP heads that serve as drafts in the same way. An MTP loss used in pre-training belongs to the training step instead (part 1).
You are done when the tokens and the logprob bits are the same with and without speculation, at every draft length.
Not yet shown: a real engine's speculative decoding, and MTP heads.
Hardware migration and mixed fleets¶
Here you want to know which results carry over to new GPUs, and, when two machines disagree, to find where they part. Bitwise equality is not expected across GPU generations, because libraries choose different kernels and accumulation orders for each architecture (hardware). The goal therefore changes from equality to localization. The first operator whose bits differ should be a library GEMM or a reduction whose order the library chooses; anything else is a finding.
How to apply the existing pages:
- Qualify the new hardware: run the regression suite against the committed baselines, and run the SDC scan across groups of devices (hardware, bi_suite.py, sdc_scan.py).
- Compare devices bit for bit within one GPU generation and one software stack. A disagreement there is a fault (SDC).
- Localize across generations. Capture both runs with OpGuard on the same inputs and take the first divergence (localize with OpGuard). Then classify it: either a kernel choice that depends on the architecture, which is expected, or anything else, which you should report.
- Handle RL across generations. With the trainer and the engine on different GPU generations, only kernels whose reduction order is written into their source code can carry over, and even that is untested across architectures. Otherwise, measure the numeric gap and record it as a decision, the way engine parity handles differences that neither side can remove.
You are done when every difference between generations is classified, and the expected ones are recorded together with the stack they belong to.
Not yet shown: the handbook's kernels on other GPU architectures, and an RL run that mixes GPU generations.
What can go wrong¶
Expecting bitwise equality where none is promised
Two GPU generations, or the kernels of two different libraries, are not built to agree to the last bit. Chasing equality there spends your time on differences that are expected. State the claim first, and where the claim is not equality, localize and decide.
Letting a tolerance stand in for a bit check
Outputs that are "close enough" can hide faults that happen to be small. For example, a cast that rounds small weights can leave every logit unchanged on a few inputs (checkpoint conversion). Check copies and recomputations bit for bit, and use a tolerance only for pairs that cannot agree.
Comparing two different computations
A reference logprob scored over different tokens, a chat template applied on one side only, or a score that went through different post-processing all make the numbers differ although nothing is wrong numerically. Before comparing values, check that both sides computed the same thing.
Summary¶
- Every scenario consists of a pair of programs, the inputs they both receive, and a claim. Write those down first.
- A copy must be bitwise equal. Two programs can be made bitwise equal by aligning their rounding points. Across two GPU generations you localize the differences instead of removing them.
- The existing workflows apply unchanged: preflight, capture, first divergence, rounding points, decision, regression.
- Each section states what is not yet shown; treat those items as open.
Go deeper¶
- Pages: framework migration, checkpoint conversion, offline post-training.
- Report: checkpoint conversion, with the planted faults and what each check saw.
- Skills: alignment-pipeline, engine-parity, pretraining-alignment.