Quick Takeaway
This function is used to solve offline scenarios through algorithmic adaptations, e.g. TIS/MIS. We included 3 rollout correction algorithms:- decoupled, 3-policies PPO with rollout importance sampling
- direct rollout policy overwriting in the standard PPO
- pure REINFORCE loss (without PPO clipping) with rollout importance sampling
--use-tis: use this flag to turn on TIS/MIS for rollout correction (details in Algorithms).
You may specify the IS/RS configs with a config file using --custom-config-path.
--use-rollout-logprobs: When use this flag, the logprobs will not be recomputed by training engine - rollout log probs will be directly used in PPO/GRPO loss.
--get-mismatch-metrics: When you don’t want to add TIS/MIS, but still want to monitor the mismatch-related metrics (e.g. rollout-training KL). It will only return mismatch metrics but not change the loss in any way.
Algorithms
We give examples of the algorithms for solving the training-inference mismatch issue.[Baseline: No Mismatch Correction] Standard PPO
This is the basic PPO algorithm with potentially training-inference mismatch issue when the output of SGLang and Megatron does not exactly match.Bypassing PPO importance sampling
Like REINFORCE, we directly use the rollout engine’s log probs as the old policy in offline PPO’s importance sampling, rather than the recomputed log-probs from the training engine. Advantages:- Efficiency: skip
log_probrecomputation on training engine. Reduce one expensive forward pass on all the generated trajectories.
Decoupled, 3-policy PPO Importance Sampling
Decoupled PPO achieves batch-independent PPO by decoupling two roles: Proximal Policy (anchor policy for PPO clipping, control update size) and Behavior Policy (for off-policy correction in importance sampling). Therefore, there are totally 3 roles engaged in this mode, target policy , proximal policy , and behavior policy . is recomputed with Megatron at the beginning of each training step. Advantages:- Achieves batch size invariance and efficient stale data utilization
- Enables accurate off-policy metrics monitoring
APIs of Algorithms
You may choose from above algorithms with the two command-line flags below. They are the only CLI flags this feature adds; everything in Configs and Recommended Settings is a key in the YAML file you pass to--custom-config-path.
--use-rollout-logprobs: True if only use rollout_log_probs to compute the loss, bypassing old_log_probs calculated by training engine;
--use-tis: True if apply importance sampling/rejection sampling to loss.
Configs and Recommended Settings
When choosing to use importance sampling or rejection sampling for mismatch correction (--use-tis enabled, Algorithm 2 & 3), you may specify the IS modes and applied levels.
Config keys
These are not command-line flags. They live in the YAML file the run points at with--custom-config-path, and mis.py reads them off the parsed config. The reference file
is mis.yaml, wired up like this:
use_tis: Enable importance sampling. The IS weight will be multiplied by the policy gradient loss.
tis_mode: Mode for IS. Allowed mode: truncate, clip, mask.tis_lower_bound,tis_upper_bound: Bounds for IS weights.tis_level: Allowed levels: token, sequence, geometric. See explanations below.tis_batch_normalize: Normalize IS weights to mean=1.0 across batch
use_rs: Enable rejection sampling. When choosing to use rejection sampling, the tokens/sequences with an IS weight out of threshold will be directly masked. Those rejected tokens/sequences will not be considered for loss averaging.
rs_lower_bound,rs_upper_bound: Bounds for RS. Unset falls back to thetis_bounds.rs_level: Allowed levels: token, sequence, geometric. See explanations below.rs_veto_threshold: Sequence-level rejection threshold for catastrophic mismatches
Importance Sampling
For both IS and RS, we provided 3 levels: token, sequence, geometric. Token Level (default): Computes importance weights independently for each token: Characteristics: Biased but computationally simple, suitable for most scenarios Sequence Level: Uses the product of all token weights as the sequence weight: Characteristics: Unbiased but high variance, suitable for sequence-level optimization Geometric Level: Uses geometric mean to compute sequence weight: Characteristics: Biased but low variance, balances bias and varianceRejection Sampling
Token Level: Reject tokens with IS weight out of threshold Sequence Level: Reject sequences with mean IS weight out of threshold Geometric Level: Reject sequences with geometric mean IS weight out of threshold- Extremely selective: Requires near-perfect policy match
- High rejection rate: Only suitable for very slight distribution shifts
- Prevents catastrophic updates from tokens with near-zero probability under
- Independent of IS/RS settings
Mismatch Metrics
These metrics help diagnose policy divergence and guide hyperparameter tuning. Which ones you get depends on the correction function in use. The built-in one (vanilla_tis_function, used when --custom-tis-function-path is unset) reports only
tis, tis_clipfrac and tis_abs. Everything below comes from mis.py, so it needs
the --custom-tis-function-path wiring shown above.
All names below are logged under the train/ namespace, and every key mis.py produces
carries a mis_ prefix that its wrapper adds on the way out — so training_log_ppl
reaches wandb as train/mis_training_log_ppl. The two exceptions, marked in the tables,
come from miles itself and are not prefixed.
Mismatch Monitoring Metrics
These metrics quantify the difference between training and rollout policies.mis.py
computes them whenever rollout_log_probs are available, whether or not IS/RS correction
is actually applied.
Usage: These metrics help you monitor policy drift. Large values indicate a significant mismatch between the training and rollout engines.
IS/RS Correction Metrics
These metrics track importance sampling weights and corrections. They are only computed when--use-tis is enabled.
When using --custom-tis-function-path pointing to MIS implementation (e.g., mis.py), additional fine-grained metrics become available. Under the shared mis_ prefix, the tis_ and rs_ parts say which stage produced the number.

