Skip to content

[Bugfix][RL] Load DeepSeek V4 attention sinks through weight_loader - #57798

Closed
Ronald1995 wants to merge 3 commits into
vllm-project:mainfrom
Ronald1995:attn-sink-loader-dsv4-target
Closed

Ronald1995 wants to merge 3 commits into
vllm-project:mainfrom
Ronald1995:attn-sink-loader-dsv4-target

Conversation

@Ronald1995

@Ronald1995 Ronald1995 commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Fix DeepSeek V4 target, MTP, and DSpark sink loading in one model-family PR. The 10 changed call-site files cover CPU/XPU/AMD/NVIDIA target models and XPU/AMD/NVIDIA draft models.

Each site passes its checkpoint tensor and rank head range to load_padded_attn_sink from #57797. TP slicing remains in that helper and happens once. The helper builds the full padded runtime tensor and calls the current parameter loader.

Dependency: #57797. Because the shared helper branch is in a fork, GitHub currently compares this PR with upstream main and also displays the two helper files. The V4-only delta is here. After #57797 merges, this PR can be rebased onto main and its helper files will disappear from Files changed.

Validation

  • The V4-only diff contains 10 model call-site files; ruff check, ruff format --check, and git diff --check pass on the reconstructed combined tree.

  • Static validation on the integrated final tree: ruff check, ruff format --check, git diff --check, and test tethering pass. The source audit passes 28 tests. The new runtime tests have not been executed, as requested.

AI assistance

AI assistance was used.

@mergify

mergify Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--57798.org.readthedocs.build/en/57798/

@mergify mergify Bot added documentation Improvements or additions to documentation deepseek Related to DeepSeek models DSv4 cpu Related to CPU backends bug Something isn't working labels Sep 20, 2026
@Ronald1995
Ronald1995 force-pushed the attn-sink-loader-dsv4-target branch from ad7c401 to 03d130b Compare September 20, 2026 14:18
Ronald1995 pushed a commit to Ronald1995/vllm that referenced this pull request Sep 20, 2026
Checkpoint-backed attention sink parameters are loaded with a bare copy_ in
several model load_weights implementations:

    param.data.copy_(narrow_weight)
    params_dict[name][:n].copy_(narrow_weight)

That write bypasses param.weight_loader, which is the only entry point the
online weight reload path can observe. During RL / online weight update /
layerwise reload the parameter is on meta, so the write lands on the parameter
instance the reload materialized and the framework has no record that the sink
was loaded. Measured through a real layerwise reload cycle, the restored kernel
tensor then holds unwritten storage rather than the new value, and the -inf
padding tail is not re-established either.

Add a design doc specifying the contract (every checkpoint-backed,
online-updatable parameter loads through the parameter's current
weight_loader), the measured failure mode, the 20 confirmed sites across 19
files, the shared padded-sink helper for DeepSeek, and the staged
implementation plan.

Implementation PRs: vllm-project#57797, vllm-project#57798, vllm-project#57799, vllm-project#57800, vllm-project#57801, vllm-project#57803, vllm-project#57804,
vllm-project#57805, vllm-project#57806.

Co-authored-by: AI Assistant <noreply@example.com>
@Ronald1995
Ronald1995 force-pushed the attn-sink-loader-dsv4-target branch 2 times, most recently from f95c283 to db0ce2c Compare September 24, 2026 09:31
@mergify mergify Bot added the dflash label Sep 24, 2026
@Ronald1995 Ronald1995 changed the title [Bugfix][RL] Load DeepSeek V4 target attention sinks through weight_loader [Bugfix][RL] Load DeepSeek V4 attention sinks through weight_loader Sep 24, 2026
@Ronald1995
Ronald1995 force-pushed the attn-sink-loader-dsv4-target branch from db0ce2c to be0177f Compare September 24, 2026 09:41
Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
@Ronald1995
Ronald1995 force-pushed the attn-sink-loader-dsv4-target branch 3 times, most recently from 0b1e7a6 to 555c43f Compare September 24, 2026 15:56
The DeepSeek V4 target, MTP and DSpark loaders all wrote the attention sink
with a bare copy_ after slicing the checkpoint tensor by head range, so a
live reload replaced the runtime parameter with a materialized one whose sink
was never written, and the padded heads lost their -inf tail.

All ten call sites (CPU/XPU/AMD/NVIDIA target and XPU/AMD/NVIDIA draft)
now pass the checkpoint tensor and rank head range to the shared
load_padded_attn_sink helper from the loader package, which takes the slice
once, rebuilds the padded runtime representation and calls the parameter's
current loader.

Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
@Ronald1995
Ronald1995 force-pushed the attn-sink-loader-dsv4-target branch 4 times, most recently from fe9fc69 to 5caa04a Compare September 28, 2026 03:52
Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
@Ronald1995
Ronald1995 force-pushed the attn-sink-loader-dsv4-target branch from 5caa04a to 842d641 Compare September 28, 2026 03:52
@Ronald1995

Copy link
Copy Markdown
Collaborator Author

Verification on H20

Verified commit: 842d6412c1ac5508c141a5d573c09e1c22996771 (this PR's head; it covers 10 DeepSeek V4 call sites (cpu/xpu/amd/nvidia target, xpu/amd/nvidia mtp, xpu/amd/nvidia dspark))
Integration commit: c623df9e4bfe1133a3205b94e2d771ba43876ec7 (attn-sink-integration = #57797 + #57798 + #57801 + #57803 + #57804 + #57805 + #57806)

Environment

  • Cluster: H20 Slurm, node vllm-h20-01, 1x NVIDIA H20-3e (--partition=h20 --gres=gpu:h20:1)
  • Python: $HOME/vllm-shared/prebuilt-venv/bin/python (torch 2.13.0+cu130 + compiled vllm from the shared prebuilt baseline)
  • Pure-Python change, so the verified revision was overlaid onto the prebuilt package with make-overlay.sh; nothing was recompiled.

Results

Suite Where Result
test_attention_sink_load_audit.py (from #57806) head node + GPU node 39 passed
test_attn_sink_reload.py (from #57797) head node (CPU) 18 passed, 2 skipped (CUDA-only)
test_attn_sink_reload.py H20 GPU 20 passed
GPU end-to-end sink reload script H20 GPU 8/8 checks passed

The GPU script drives a real layerwise reload (record_metadata_for_reloading -> initialize_layerwise_reload -> load_weights -> finalize_layerwise_reload) on CUDA tensors and asserts the live update lands in the kernel tensor storage with the -inf padding tail re-established and the storage pointer unchanged:

PASS  live update reaches kernel tensor
PASS  live update re-establishes -inf padding
PASS  kernel tensor storage is stable
PASS  rank 1 live update loads its own heads
ALL GPU SINK CHECKS PASSED

Pre-commit

pre-commit run --files <changed files>
pass1 rc=0 dirty=0
pass2 rc=0 dirty=0

No hook rewrote a file. run-precommit.sh skips the pip-compile hooks because the sandbox cannot reach PyPI; no requirements file is touched here.

Not verified

  • No full-model checkpoint was loaded (no matching weights available), so this is loader/contract-level plus a real GPU reload, not a full-model accuracy run.
  • Single GPU; TP>1 was exercised in-process via distinct rank head ranges, not as a multi-process TP run.

What changed in this revision

@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.

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

Labels

bug Something isn't working cpu Related to CPU backends deepseek Related to DeepSeek models dflash documentation Improvements or additions to documentation DSv4

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant