Skip to content

[Bugfix][Quantization] Reuse online NVFP4 MoE kernel across reloads - #50074

Open
S1ro1 wants to merge 1 commit into
vllm-project:mainfrom
S1ro1:fix/online-nvfp4-reload-kernel
Open

[Bugfix][Quantization] Reuse online NVFP4 MoE kernel across reloads#50074
S1ro1 wants to merge 1 commit into
vllm-project:mainfrom
S1ro1:fix/online-nvfp4-reload-kernel

Conversation

@S1ro1

@S1ro1 S1ro1 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Purpose

Online NVFP4 MoE models re-run process_weights_after_loading whenever fresh BF16 weights are loaded and quantized in place. _setup_kernel currently also replaces the MoE kernel and quantization-config objects on every reload. Compiled and captured execution paths still reference the original kernel object, so replacing it can leave reloads executing against stale state and eventually produce non-finite outputs.

This change keeps the online NVFP4 MoE kernel and its quantization config stable for the lifetime of the layer. Weight conversion and process_weights_after_loading remain outside the guard and still run on every reload, so each fresh set of BF16 weights is quantized and installed as before.

Related to #41670 and #48902, but not a duplicate: this covers online NVFP4 and deliberately preserves per-reload weight processing.

AI assistance (OpenAI Codex) was used for investigation, implementation, and test drafting. I reviewed and understand the change.

Test Plan

  • Add a focused lifecycle test that calls _setup_kernel twice and verifies:
    • weight conversion runs twice;
    • processed weights are installed twice;
    • the MoE kernel is constructed once;
    • the quantization config is constructed once.
  • Run formatting and lint checks on the changed files.
  • Run paired five-step Prime-RL jobs with online NVFP4, piecewise CUDA graphs, two ETP=4 inference replicas, and a BF16 trainer. The jobs differ only by this fix.

Test Result

  • uvx ruff check tests/quantization/test_online.py vllm/model_executor/layers/quantization/online/nvfp4.py: passed.
  • uvx ruff format --check tests/quantization/test_online.py vllm/model_executor/layers/quantization/online/nvfp4.py: passed.
  • Focused lifecycle check in the deployment environment: two conversions, two weight-processing calls, one kernel construction, and one quantization-config construction.

Paired end-to-end result:

Run Steps completed Non-finite rollout errors
With fix 5 0
Without fix 5 16 at step 5 (11.1% of that rollout batch)

The fixed run completed all five reloads without an invalid response. The control first returned non-finite values after repeated reloads and recorded 16 provider errors in its fifth persisted batch.

No documentation change is needed because this restores the existing online-reload contract.


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR is described.
  • The test plan is provided.
  • Test and paired end-to-end results are provided.
  • No documentation update is required.

Assisted-by: OpenAI Codex

Signed-off-by: S1ro1 <matej.sirovatka@gmail.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify

mergify Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @S1ro1.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Aug 8, 2026
@aoshen02

Copy link
Copy Markdown
Collaborator

@S1ro1 Could you please resolve the conflict?

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

Labels

bug Something isn't working needs-rebase quantization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants