Skip to content

vLLM resolves unset sampling params from the model's generation_config.json, not neutral defaults #3497

Open

Description

@terrykong

Summary

vLLM resolves any unset sampling parameter on an incoming OpenAI request from the model's generation_config.json, not from neutral defaults. NeMo-RL never overrides this, so an omitted top_p / temperature / top_k / min_p / repetition_penalty silently picks up a model-specific value that differs from policy.generation.*.

For RL this is worse than ordinary drift: top-p/top-k truncate and renormalize the distribution, which changes the logprobs. NeMo-RL mirrors that into the training forward pass — dtensor_policy_worker builds TrainingSamplingParams from generation_cfg["top_p"/"top_k"] and _apply_top_k_top_p_filtering rescales the logits only when _need_top_p_filtering sees top_p != 1.0. If the engine actually samples at a different top_p than the config records, the train-side rescaling replicates the wrong distribution and the mismatch is invisible.

Mechanism

Against the pinned vllm==0.25.1:

  1. top_p: float | None = None — an omitted field stays None.
  2. if (top_p := self.top_p) is None: top_p = default_sampling_params.get("top_p", ...) — the neutral 1.0 is only the last fallback. Same pattern for temperature, top_k, min_p, repetition_penalty.
  3. default_sampling_params = self.model_config.get_diff_sampling_param().
  4. config = {} if src == "vllm" else self.try_get_generation_config() — docstring: "vLLM's neutral defaults if generation_config="vllm", the model's defaults if generation_config="auto"".
  5. generation_config: str = "auto" is the default, and NeMo-RL passes neither generation_config nor override_generation_config into AsyncEngineArgs (grep of nemo_rl/ → 0 hits).

Concretely, Qwen/Qwen3-30B-A3B-Instruct-2507 (used by examples/nemo_gym/grpo_qwen3_30ba3b_instruct.yaml) ships top_p: 0.8, top_k: 20, temperature: 0.7, while the gym recipes set top_p: 1.0 / top_k: null / temperature: 1.0.

Not always the case — introduced by vLLM v0.8.0

vLLM ModelConfig.generation_config effect
≤ v0.7.3 Optional[str] = None get_diff_sampling_param returns {} — the model's file is ignored
≥ v0.8.0 str = "auto" the model's generation_config.json is read

Current mitigation is partial

The async OpenAI server guard is what stands between this and a silent off-policy rollout, and it covers the parameters unevenly:

Note the guard only protects the async OpenAI-server path; it is not a general property of the engine.

Proposed fix

Pass generation_config="vllm" when constructing AsyncEngineArgs (and the sync engine equivalent), so unset parameters resolve to vLLM's neutral defaults instead of per-model values. That removes the whole class rather than patching one parameter at the guard, and makes policy.generation.* the single source of truth — which is what the train-side logprob rescaling already assumes.

Worth deciding explicitly whether any model-default behavior is wanted for validation rollouts before changing it globally.

(Surfaced during the review of #3401.)

Activity

  1. added
    bug
    on Aug 5, 2026
  2. benjamin05wilson commented on Aug 5, 2026

    @benjamin05wilson

    Supporting data for the repetition_penalty case, and an argument that it makes the engine-level fix the only viable one rather than merely the cleaner one.

    How far off-policy it actually puts you

    Measured on Qwen/Qwen2.5-0.5B-Instruct, whose generation_config.json ships repetition_penalty: 1.1. Sampled with the penalty active and everything else neutral, then scored the same tokens two ways — plain log_softmax of the logits (what the trainer differentiates) and log_softmax after transformers' own RepetitionPenaltyLogitsProcessor (what actually drew the token), so the sampling distribution is exactly the one generation used. 32 sequences, 8,209 completion tokens:

    statistic value
    tokens with ratio exactly 1 14.1%
    tokens off by >1% 58.8%
    tokens off by >10% 37.7%
    geometric mean 0.895
    p1 / p99 0.131 / 2.959

    The arithmetic mean is 1.0003, which is why it shouldn't be quoted alone — a thin right tail offsets a fat left one. The distortion is also signed rather than symmetric: the penalty suppresses tokens already in context, so the sampler systematically favours tokens the policy scores lower.

    For scale against the numerical-mismatch literature, which the TIS/MIS machinery exists to correct: Thinking Machines report KL ~0.001 for corrected kernel nondeterminism, and Fang & Khazi measure KL 0.001 → 0.033 for Qwen3's shipped top_p/top_k/temperature. A single inherited repetition_penalty sits well above the noise those corrections were built for.

    Why repetition_penalty can't be handled at the guard

    The top_p/top_k cases have a train-side escape hatch — they're truncate-and-renormalise, so _apply_top_k_top_p_filtering can replicate the sampling distribution in the forward pass, which is what makes strict comparison at the guard sufficient.

    No equivalent exists for repetition_penalty. It's stateful and history-dependent: the penalty applied to token t depends on which tokens already appear in that sequence's context, so reproducing it train-side would mean replaying per-sequence generation history through the logits at every position. That isn't a rescaling, and there's no mask to replay.

    So for this parameter specifically, extending the guard is a dead end and generation_config="vllm" is the only fix that closes it. Same conclusion you reached, just with a mechanism that rules out the alternative rather than deprioritising it.

    Reproduction for both measurements: https://github.com/benjamin05wilson/rl-velocity — scripts/measure_importance_ratio.py and scripts/audit_vllm_config.py. Environment: vLLM 0.26.0, transformers 5.14.1, torch 2.11.0+cu130, sm_120.

    One adjacent note in case it's useful for the sync path: transformers has the same inheritance behaviour, and v5 made it quieter — the v4 warning ("generation_config default values have been modified...") and the use_model_defaults=False opt-out are both gone in 5.14.1, so an unset field on GenerationConfig now resolves against the checkpoint with no diagnostic.

  3. lonexreb commented on Nov 30, 2026

    @lonexreb
    Contributor

    #5006 fixed this on main.

    • vLLM workers now default to generation_config="vllm" (vllm_worker.py#L243-L252). An unset sampling field therefore gets vLLM's neutral value, not the one from the model's generation_config.json. A generation_config set in vllm_kwargs is still respected.
    • The hosted chat endpoint fills unset fields from the matching sampling profile via on_policy_sampling (chat_server.py#L907-L931).

    I'm closing my #3685, which this replaces. I think this issue can be closed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accuracybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions