Skip to main content
What you’ll learn: how to configure Miles + SGLang + Megatron for bit-wise reproducible RL training. Same inputs → identical outputs across reruns, machines, and time. Reproducibility matters more than people admit: it’s the only way to A/B test changes in a system this complex. If you can’t trust that “I changed flag X and reward went up”, you’re flying blind.

How it works

Bit-wise reproducibility requires three independent stacks to be deterministic:
  1. Inference (SGLang) — every kernel must be deterministic.
  2. Training (Megatron-LM) — same.
  3. Communication (NCCL) — algorithm choice and CUBLAS workspace can be non-deterministic by default.
Miles ships verified configurations that switch all three into deterministic mode.

Quick start

We use the smallest Miles model (Qwen2.5-0.5B) on GSM8K so the loop fits in 5 minutes and you can reproduce the bit-stability check yourself.

1. Disable FA3

Flash-Attention 3 currently has non-deterministic backward kernels. Drop it:

2. Set the deterministic flags

3. Set the env vars (Ray env_vars)

4. Download + convert + run

5. Verify

Run twice, then:
The hashes should match exactly. If they don’t, something escaped the deterministic configuration — see troubleshooting below.

What’s deterministic and what isn’t

Troubleshooting

Cost of determinism

Roughly: Total: ~25% slower for full bit-wise determinism. Worth it for debugging, science, and A/B tests; usually disabled for production runs.

When to disable determinism

  • Production training runs where the cost is too high.
  • When you’ve already nailed the result and want maximum throughput.
  • On hardware that doesn’t support deterministic kernels.
For most other cases — keep it on while developing. The hours you save when “I swear that worked yesterday” stops being a phrase you say will pay back the throughput many times over.

References