Repository navigation
[Bugfix][DeepSeek V4.1] Inject Engram at pipeline stage entry - #62208
Merged
ZJY0516 merged 2 commits intoOct 19, 2026
Merged
Conversation
wangyicong52
force-pushed
the
fix/dsv41-engram-stage-entry
branch
from
October 17, 2026 17:36
9a818ef to
6ef3cb0
Compare
8 tasks
Apply the entry-layer Engram to the residual stream before mHC pre when a non-initial NVIDIA pipeline stage starts on an Engram layer. Add a non-identity regression test and wire it into model CI. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: wangyicong <wangyicong@bytedance.com>
wangyicong52
force-pushed
the
fix/dsv41-engram-stage-entry
branch
from
October 19, 2026 06:33
523b4c3 to
9e381e1
Compare
wangyicong52
marked this pull request as ready for review
October 19, 2026 14:30
wangyicong52
requested review from
AndreasKaratzas,
DarkLight1337,
Harry-Chen,
khluu and
ywang96
as code owners
October 19, 2026 14:30
|
✅ @wangyicong52, CI is now available for this PR.
|
Member
|
/ci run |
|
✅ Triggered Buildkite CI #95966 for commit ℹ️ This PR is 94 commits behind upstream |
reputationly
added a commit
to reputationly/vllm-backport
that referenced
this pull request
Oct 21, 2026
上游来源:vllm-project/vllm#62208 (8a1c02efca),适配点:本仓模型目录为 deepseek_v4_1;只改 residual is None 且 x 为 3D 的段入口分支,2D 首层分支不变。 Co-authored-by: DSH Agent <dsh-agent@local> Signed-off-by: DSH Agent <dsh-agent@local> Signed-off-by: reputationly <197039020@qq.com>
3 of 5 tasks
Morrowmake
pushed a commit
to Morrowmake/vllm-cmp170hx
that referenced
this pull request
Oct 26, 2026
Upstream's decoder layer now applies the Engram to the hc stream a pipeline stage receives when that stage starts on an Engram layer (vllm-project#62208); the sm80 layer mirrors that forward, so it does the same before its mHC pre.
bantianyue
pushed a commit
to bantianyue/vllm
that referenced
this pull request
Oct 28, 2026
…roject#62208) Signed-off-by: wangyicong <wangyicong@bytedance.com> Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: vllm-agent <claw@inferact.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
DeepSeek-V4.1 applies trained Engram modules at configured transformer layers. If a pipeline partition starts a non-initial stage on one of those layers, the stage-entry control-flow branch calls mHC pre directly and bypasses the normal Engram branch. Certain valid PP partitions can therefore silently skip an Engram operation for every request. The real DeepSeek-V4.1-Flash configuration triggers this at layer 14 with
VLLM_PP_LAYER_PARTITION=14,26.This PR restores the missing NVIDIA operation by applying the local stage-entry Engram after receiving the previous stage's completed residual stream and before mHC pre.
AMD is affected by the same issue. We currently only have access to NVIDIA hardware, so this PR fixes only the NVIDIA implementation for now.
Claims
pre_mix, selected Engram hash column, mask, and existing no-hash behavior.Validation
Environment
vllm/vllm-openai:nightly-49cb2bbf71cfd36ee5aa33d1e184b1cddff55294.vLLM launch
Both arms used identical arguments:
VLLM_PP_LAYER_PARTITION=14,26 \ VLLM_MOE_SKIP_PADDING=1 \ vllm serve /models/DeepSeek-V4.1-Flash \ --host 0.0.0.0 \ --port 18001 \ --served-model-name deepseek-v4.1-flash \ --language-model-only \ --tokenizer-mode deepseek_v41 \ --attention-backend FLASHMLA_SPARSE_DSV41 \ --kv-cache-dtype fp8_ds_mla \ --block-size 64 \ --tensor-parallel-size 4 \ --pipeline-parallel-size 2 \ --decode-context-parallel-size 1 \ --prefill-context-parallel-size 1 \ --distributed-executor-backend mp \ --enable-expert-parallel \ --all2all-backend allgather_reducescatter \ --engram-config '{"cpu_offload":true}' \ --moe-backend humming \ --max-model-len auto \ --max-num-batched-tokens 8192 \ --max-num-seqs 64 \ --gpu-memory-utilization 0.9 \ --no-enable-prefix-caching \ --no-swa-bounded-replay \ --enforce-eager \ --no-async-schedulingVerify Engram execution at the pipeline boundary
This check verifies that layer 14 executes its trained Engram module before mHC pre when it is the first layer of a pipeline stage.
We compared three configurations using the real DeepSeek-V4.1-Flash checkpoint:
14,26): the configuration that exposes the bug. The first stage contains 14 layers, so the second stage starts at layer 14.14,26): the same pipeline partition with the fix applied, tested independently on both H20 nodes.Each configuration received the same fixed 256-token prompt and generated two tokens, each constrained to a single allowed token ID. This kept the token sequence fixed across configurations. Each configuration was run twice in eager mode.
Was layer 14's Engram actually executed?
14,26)14,26) — both nodesThe unpatched PP=2 configuration had valid Engram hashes and masks available at layer 14, but never called its Engram module. The missing operation was therefore caused by the stage-entry control flow.
Did mHC receive the correct tensor?
We recorded SHA-256 checksums of the full tensors at the pipeline handoff, Engram input/output, and mHC pre input. These checksums track tensor contents; they are separate from the token hashes used by Engram.
For every TP rank, measured step, and repeat, the checks confirmed these paths:
These comparisons verify the data flow within each run; they do not require bitwise-identical outputs between PP=1 and PP=2.
Did Engram make a measurable change?
For runs that executed Engram, we measured the difference between its input and output at layer 14:
The update RMS is
RMS(Engram output − Engram input). These nonzero differences confirm that skipping this trained Engram module changes the tensor passed to mHC pre.This check confirms that the affected PP partition skips a trained Engram operation and that this PR restores it before mHC pre on both tested nodes. It does not establish an accuracy improvement: captured logits varied across repeated runs and nodes by an amount comparable to the patch effect. The GSM8K results below report the separate end-to-end accuracy evaluation.
Full GSM8K comparison
Both configurations used PP=2 (
14,26) with identical evaluation settings: 4-shot, temperature 0, seed 42, and a maximum of 8,192 output tokens.Seven questions were correct only without the patch, and seven only with it; aggregate accuracy was unchanged.
We have not observed an end-to-end accuracy loss in this GSM8K evaluation. However, the confirmed omission of a trained Engram operation remains a correctness bug with potential model-quality impact that this benchmark has not demonstrated.
The focused regression test and full pre-commit suite also passed.
Details
At the end of a pipeline stage, the previous rank completes its final mHC post and sends the full 3-D residual stream together with
pre_mix. The next stage starts withresidual=None, assigns that received stream toresidual, and calls mHC pre directly. Because normal Engram injection lives in the followingelif, an Engram on the stage's first layer is silently skipped.This change injects the local Engram after accepting the completed stream and before mHC pre. It does not repeat the previous stage's post or alter first-layer embeddings, in-stage Engram execution, or batches without Engram hashes.
The real DeepSeek-V4.1-Flash configuration has Engram layers 1 and 14. A pipeline partition beginning its second stage at layer 14 can therefore reach this path. Open PR searches for the same Engram pipeline-stage fix found no direct duplicate; related PCP work such as #62183 does not implement this injection.
AI assistance was used for implementation support and a read-only Codex CLI review. Human line-by-line review is still required before requesting maintainer review.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.