Skip to content

feat(vllm): support per-token-head FP8 KV cache - #5028

Merged
yuki-97 merged 6 commits into
mainfrom
orybakov/fp8-per-token-head
Nov 5, 2026
Merged

yuki-97 merged 6 commits into
mainfrom
orybakov/fp8-per-token-head

Conversation

@rybakov

@rybakov rybakov commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Add dynamic FP8 KV-cache storage for vLLM rollouts through policy.generation.vllm_cfg.kv_cache_dtype=fp8_per_token_head. K and V receive independent scales per token and KV head at cache-write time; static policy KV-scale synchronization is skipped during refit.

Require FP8 precision and a vLLM build supporting this cache dtype, and reject ModelOpt real_quant. Raise an error for explicitly incompatible attention backends, including attention_config.backend. Preserve user backend settings; when none is specified, let vLLM select or reject the backend.

Usage

policy:
  generation:
    vllm_cfg:
      precision: fp8
      kv_cache_dtype: fp8_per_token_head
    vllm_kwargs:
      attention_backend: TRITON_ATTN

This configures rollout storage only. It does not change policy training attention or Mamba state caches.

Validation

Tested the updated source under /lustre/fsw/portfolios/llmservice/users/orybakov/941/fp8-per-token-head-review on OCI with PyTorch 2.13.0+cu130 and vLLM 0.29.0.

  • All affected unit modules (test_vllm_config.py, test_vllm_fp8_quantization.py, test_vllm_backend.py): 324 passed, Slurm job 8559254.
  • Extended test_vllm_generation_with_megatron_training with kv_cache_dtype=fp8_per_token_head for Megatron tensor parallel sizes 1 and 2. The new cases explicitly select Triton, refit from Megatron, train, and check eight-token generation plus finite log probabilities before and after training.
  • Both new integration cases: 2 passed, Slurm job 8562451 on OCI GB200. Uses Qwen/Qwen2.5-0.5B with Megatron tensor parallel sizes 1 and 2.
  • Removed the standalone functional test files and their L1 suite entry; coverage lives in the existing integration test.
  • Python syntax, shell syntax, and git diff --check pass.

Pre checks

  • Read contributor guidelines.
  • Added and ran unit and functional tests.
  • Updated documentation and exemplar/reference configurations.

@copy-pr-bot

copy-pr-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@rybakov

rybakov commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 63133b0

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Nov 2, 2026

@guyueh1 guyueh1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three suggestions on configuration, backend selection, and functional coverage.

@guyueh1 guyueh1 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 3, 2026
@guyueh1

guyueh1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/ok to test 9ddf59a

@guyueh1 guyueh1 added CI:L0 Run doctests and unit tests and removed CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Nov 3, 2026
guyueh1
guyueh1 previously approved these changes Nov 3, 2026
@rybakov

rybakov commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test e564cf4

guyueh1
guyueh1 previously approved these changes Nov 3, 2026
@rybakov
rybakov force-pushed the orybakov/fp8-per-token-head branch from e564cf4 to 248629d Compare November 3, 2026 21:55
@rybakov
rybakov force-pushed the orybakov/fp8-per-token-head branch from 248629d to 6c85d84 Compare November 4, 2026 01:44
@rybakov

rybakov commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1543159

@yuki-97 yuki-97 added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L0 Run doctests and unit tests labels Nov 4, 2026

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding dynamic per-token-head FP8 KV-cache storage for vLLM rollouts.

The reported GB200 validation with Megatron TP sizes 1 and 2 makes the exercised refit and generation cases clear.

Scope: Configuration, cache-scale handling, documentation and integration coverage in #5028, at 1543159

Checked:

  • Dynamic cache scales — the static scale patch and synchronization paths exclude the new format (fp8.py:249).
  • Configuration validation — incompatible precision, ModelOpt real_quant and explicitly incompatible attention backends fail early (config.py:283–299).
  • Integration coverage — the new cases require eight generated tokens and finite log probabilities (test_vllm_generation.py:4444–4454).

Remaining comments are on:

  • GB200 regression coverage with a recipe, metric checks and suite registration.

CI: Let's use CI:Lfast by default since it includes the end-to-end generation/refit test.

Generated by Codex

Comment thread examples/configs/grpo_math_1B.yaml Resolved
guyueh1
guyueh1 previously approved these changes Nov 4, 2026
@guyueh1

guyueh1 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/ok to test 6a655ae

@yuki-97
yuki-97 enabled auto-merge (squash) November 5, 2026 02:35
@yuki-97
yuki-97 merged commit d82b79c into main Nov 5, 2026
95 checks passed
@yuki-97
yuki-97 deleted the orybakov/fp8-per-token-head branch November 5, 2026 04:30
isomap added a commit to isomap/RL that referenced this pull request Nov 5, 2026
Conflicts:
- grpo.py: keep _validate_val_sampling and accept trtllm as main (NVIDIA-NeMo#4123)
  does. The TRT-LLM server picks the train or validation profile by
  temperature/top_p like the vLLM one, so the val_top_k rule applies to
  both; main's "val_top_k is not supported" check is dropped.
- loss_input.py: keep the replay/non-replay split; pass main's (NVIDIA-NeMo#4973)
  reuse_logits_storage on the non-replay logprob call.
- vllm/config.py: keep resolve_vllm_logprobs_mode and main's
  resolve_vllm_kv_cache_dtype (NVIDIA-NeMo#5028).
- test_model_utils.py: keep both sides' new tests.
- interfaces.py comment and test_setup_accepts_val_sampling_on_gym_path
  updated to the val_top_k rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Hayate Iso <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants