Repository navigation
[Bugfix][ROCm] Stream-order AITER MLA FP8 prefill PS metadata updates - #5
Closed
amd-mghanimi wants to merge 42 commits into
Closed
amd-mghanimi wants to merge 42 commits into
amd-mghanimi wants to merge 42 commits into
Conversation
aiter.get_ps_metadata_v1 plans the FP8 MLA prefill schedule on the host and writes the result into the caller's device tensors with blocking hipMemcpy that is not ordered on the current stream. The builder passed the persistent fp8_ps_* device buffers directly, and every step's metadata aliases them. With async scheduling the builder for step N+1 runs while step N's prefill kernels (mla_prefill_ps_asm_fwd + mla_reduce_v1, once per layer) are still queued, so step N can execute with step N+1's work/reduce maps. On ROCm 10 this faults the GPU (write to a read-only page near address 0x6c000) at a deterministic point of an 8k/1k MC=32 Kimi-K3 run; when the indices stay in bounds it silently corrupts prefill attention. Plan into two pinned host staging slots instead and copy to the device buffers with non_blocking copy_ on the current stream, which orders the update after all previously launched kernels. A slot is reused only after its previous H2D copy completed (CUDA event). num_partial_tiles is read from the host plan, removing the per-prefill-step GPU sync (.item()). work_metadata is not written by the host planner and stays on device. Signed-off-by: Mehdi Ghanimifard <mehdi.ghanimifard@amd.com>
The FP8 MLA prefill builder plans into pinned host buffers and copies them to the device on the current stream. Check that aiter.get_ps_metadata_v1 accepts host outputs and produces the same plan as device outputs. Signed-off-by: Mehdi Ghanimifard <mehdi.ghanimifard@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Owner
Author
|
Opened upstream as vllm-project#58887 (fixes vllm-project#58886). |
It exercises AITER behavior rather than vLLM code and needs gfx950 with AITER. Signed-off-by: Mehdi Ghanimifard <mehdi.ghanimifard@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Allocate one CUDA event per pinned staging slot at init and record it again after each copy, instead of creating a new event every prefill step. Signed-off-by: Mehdi Ghanimifard <mehdi.ghanimifard@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: simondanielsson <simon.danielsson99@hotmail.com>
…-project#59348) Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com> Signed-off-by: Avishek Goswami <86944690+GOavi101@users.noreply.github.com> Co-authored-by: Avishek Goswami <avishek.goswami@ibm.com>
…lm-project#58528) Signed-off-by: Akash kaothalkar <akash.kaothalkar@ibm.com> Co-authored-by: Akash kaothalkar <akash.kaothalkar@ibm.com> Co-authored-by: Antigravity <antigravity@google.com> Co-authored-by: Li, Jiang <jiang1.li@intel.com>
…llm-project#55781) Signed-off-by: Ronald1995 <ronaldautomobile@163.com> Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: aoshen02 <aoshen@inferact.ai>
…ject#59398) Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vllmellm <vllm.ellm@embeddedllm.com>
Signed-off-by: Djordje Ramic <djoramic@amd.com> Co-authored-by: Andreas Karatzas <akaratza@amd.com>
…ject#58797) Signed-off-by: Mathew Odden <modden@redhat.com> Co-authored-by: opencode+glm-5.3+vllm <opencode+glm-5.3+vllm@example.com>
…ading for TP >1 (vllm-project#58083) Signed-off-by: Akash kaothalkar <akash.kaothalkar@ibm.com> Co-authored-by: Akash kaothalkar <akash.kaothalkar@ibm.com> Co-authored-by: Antigravity <antigravity@google.com> Co-authored-by: Li, Jiang <jiang1.li@intel.com>
…llm-project#48133) Signed-off-by: Francesco Fusco <ffu@zurich.ibm.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Luka Govedič <ProExpertProg@users.noreply.github.com>
…#50030) Signed-off-by: aoshen02 <aoshen@inferact.ai> Signed-off-by: S1ro1 <matej.sirovatka@gmail.com> Co-authored-by: aoshen02 <aoshen@inferact.ai> Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com>
…oject#59399) Signed-off-by: apex-mochen <2756823972@qq.com>
Signed-off-by: Taimys <ffy2281693949@gmail.com> Signed-off-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com> Co-authored-by: Taimys <ffy2281693949@gmail.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…s enabled (vllm-project#59195) Signed-off-by: Jakub Zakrzewski <jzakrzewski@nvidia.com> Co-authored-by: Codex <codex@openai.com>
…riance tested models (vllm-project#54441) Signed-off-by: Yuval Luria <yluria@redhat.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…sing VSX (vllm-project#59149) Signed-off-by: Rukhaiya <bibirukhaiya123@gmail.com> Co-authored-by: Li, Jiang <jiang1.li@intel.com>
…project#59357) Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com> Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
…roject#59315) Signed-off-by: Juan Pérez de Algaba <jperezde@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
…roject#57172) Signed-off-by: Michal Ganczarenko <michal.ganczarenko@intel.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Anna Mayne <anna.mayne@arm.com> Co-authored-by: Li, Jiang <jiang1.li@intel.com>
…roject#57168) Signed-off-by: Jakub Zakrzewski <jzakrzewski@nvidia.com> Co-authored-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Bugen Zhao <i@bugenzhao.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Julien Darve <jdarve@NVIDIA.com> Signed-off-by: Bugen Zhao <i@bugenzhao.com>
…9379) Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com> Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
…lm-project#59029) Signed-off-by: Giulio De Pasquale <git@depasquale.giugl.io> Co-authored-by: Isotr0py <2037008807@qq.com>
Signed-off-by: QiuChunshuo <qiuchunshuo@huawei.com> Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
Signed-off-by: Juan Pérez de Algaba <jperezde@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
…workers (vllm-project#59200) Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… single Triton kernel (vllm-project#58008) Signed-off-by: simondanielsson <simon.danielsson99@hotmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…nd round the expert-group count to a kernel that exists (vllm-project#55368) Signed-off-by: Sergei Shliapnikov <sergei.shliapnikov@amd.com>
…llm-project#59271) (vllm-project#59373) Signed-off-by: Yida Weng <84164537+YidaWeng@users.noreply.github.com> Co-authored-by: Grok <grok@x.ai>
…t#59428) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
vllm-project#50300) Signed-off-by: jperezde <jperezde@redhat.com> Signed-off-by: Juan Pérez de Algaba <jperezde@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Purpose
Fix a GPU memory fault (
Memory access fault ... Write access to a read-only page, address~0x6c000-0x6f000) in the ROCm AITER MLA backend with FP8 KV cache and async scheduling. It
also removes a likely source of silent prefill attention corruption on the same path.
aiter.get_ps_metadata_v1plans the FP8 MLA prefill schedule on the host. It then writes theplan into the caller's device tensors with blocking
hipMemcpythat is not ordered on thecurrent stream
(aiter
v1_2_host.cuhL395-L418).AiterMLAMetadataBuilder._build_fp8_prefill_ps_metadatapasses the persistentfp8_ps_*device buffers directly, and every step's metadata aliases those buffers(L901-L941).
With async scheduling, step N+1 is built while step N's prefill kernels
(
mla_prefill_ps_asm_fwd+mla_reduce_v1, one launch per layer) are still queued. Step Ncan then run with step N+1's work/reduce maps. The existing
.item()sync onreduce_indptr[-1]comes after the rewrite, so it does not help.This PR plans into two pinned host staging slots and copies them to the device buffers with
copy_(non_blocking=True)on the current stream. That orders the update after everypreviously launched kernel. A slot is reused only after its previous copy has completed
(CUDA event).
num_partial_tilesis read from the host plan, which removes one GPU sync perprefill step.
work_metadatais not written by the host planner and stays on device.Only
rocm_aiter_mla.pycallsget_ps_metadata_v1in vLLM.Test plan
Kimi-K3, TP8, MI355X,
vllm/vllm-openai-rocm:nightly-rocm100-29468dde…(ROCm 10), dummyweights, FP8 KV,
max_num_batched_tokens=16384,max_num_seqs=256, FULL_AND_PIECEWISE,async scheduling.
sglang.bench_servingrandom 8k/1k, max concurrency 32, 1024 prompts.Test result
Crash: unpatched vs this PR on the same request stream
Each row pairs runs from the same environment. Whether a given request stream triggers the
fault varies, so every fix run is paired with an unpatched run that faults on that stream.
--enforce-eager)Diagnostics on the seed-4 stream, all unpatched otherwise:
torch.cuda.synchronize()beforeget_ps_metadata_v1--no-async-schedulingRegression checks
--enforce-eager, 1024 promptsAccuracy (real weights,
niah_single_2, 4k, a single run on each build)Suggestive, not conclusive: single runs.
Long context (real weights,
niah_single_2,num_concurrent=32, a single run on each build):No accuracy change at long context (within single-run noise).
Full sweep with real weights (this PR)
12-cell serving sweep plus GPQA and NIAH, real weights, default
max_num_seqs, FP8 KV,FULL_AND_PIECEWISE, async scheduling. All 12 cells completed with no fault.
sglang.bench_serving)sglang.test.run_eval, thinking on, 32k max tokens)niah_single_2, 64k,num_concurrent=32niah_single_2, 128k,num_concurrent=32Related: DSpark startup fault (vllm-project#58814)
vllm-project#58814 reports a GPU memory fault in the Kimi-K3 DSpark draft (stale KV cache
pointers after the startup profiling pass). This A/B checks whether this PR also covers it.
Kimi-K3 TP8 + DSpark (K=5,
TRITON_MLAdraft), ROCm 10 nightly29468dde, real weights,FULL_AND_PIECEWISE, async scheduling.
max_num_seqs=8, 8k/1k MC4Memory access fault ... Reason: Unknownat a high address (matches vllm-project#58814)max_num_seqs=128), 8k/1k MC4/8/16/32Conclusion: the two faults are independent. vllm-project#58814's fault is fixed by vllm-project#58814 and not by this
PR. It happens at startup, at a high address, with reason "Unknown". This PR's fault is a write
to a read-only page near address 0x6c000, while serving. Also, the code this PR changes only
runs with an FP8 KV cache, so it cannot affect d1/d2.
Standalone reproducer (no server, one GPU)
Plans batch A (one 8175-token prefill) into the persistent buffers, queues A's
mla_prefill_ps_asm_fwd+mla_reduce_v1behind a GPU delay on a non-blocking stream, thenimmediately plans batch B (three prefills) into the same buffers from the host.
copy_on the stream)Plan equivalence
Host-vs-device plan equivalence was verified on MI355X with a standalone script (all 5 shapes
byte-identical). No unit test is added: the check exercises AITER rather than vLLM code.
Still to run before marking ready
Notes for reviewers
runtimes, the stream-less blocking
hipMemcpyinget_ps_metadata_v1does not wait for iton either, and the standalone reproducer above faults on both. In serving, the overlap
(next plan built while the previous prefill is still pending) happens about equally often on
both, about 9% of prefill steps. The difference is what the copy does then. On ROCm 7.2 most
of those plan updates (about 55 of 80 per rank) only return after the in-flight prefill has
finished, so the runtime happens to order them. On ROCm 10 they return in under 1 ms, while
the prefill is still reading. Which runtime change causes this is not pinned down yet (the
two images ship very different HIP runtime builds). Either way it is accidental ordering,
not a guarantee.
request 78:
AMD_SERIALIZE_COPY=1(copies wait for already-queued work) andGPU_MAX_HW_QUEUES=1(every stream shares one in-order hardware queue).v1_2_devicepath): ROCm/aiter#5879.change workspace sizing.