Repository navigation
[Bugfix][KV Connector][ROCm] MoRIIO READ: skip zeroing READ destinations for mixed-precision caches - #62313
[Bugfix][KV Connector][ROCm] MoRIIO READ: skip zeroing READ destinations for mixed-precision caches#62313benenzhu wants to merge 2 commits into
Conversation
…ons for mixed-precision caches Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Taoyu Zhu <zhutaoyu97@gmail.com>
|
/ci run |
|
✅ Triggered Buildkite CI #95808 for commit |
whx-sjtu
left a comment
There was a problem hiding this comment.
Thanks for the fix! overall lgtm.
|
|
||
|
|
||
| def test_attention_only_read_skips_zeroing_in_every_group(): | ||
| """Mixed-precision attention-only hybrids zero pages in every READ group.""" |
There was a problem hiding this comment.
Nit: the docstring says these models "zero pages in every READ group", but the test asserts the opposite (READ pages are dropped from the zeroing list).
| """Mixed-precision attention-only hybrids zero pages in every READ group.""" | |
| """Attention-only READ skips zeroing its destinations in every group.""" |
| ): | ||
| # Hybrid models zero recycled attention pages that held Mamba state. | ||
| # Host-submitted READs overwrite these pages and can race zeroing. | ||
| if self.mode == MoRIIOMode.READ and scheduler_output.new_block_ids_to_zero: |
There was a problem hiding this comment.
Nit: this filter now runs on every READ-mode step for mixed-precision models, including the prefill side where _reqs_need_recv is always empty, and copies new_block_ids_to_zero for nothing. Checking _reqs_need_recv first skips that.
| if self.mode == MoRIIOMode.READ and scheduler_output.new_block_ids_to_zero: | |
| if ( | |
| self.mode == MoRIIOMode.READ | |
| and self._reqs_need_recv | |
| and scheduler_output.new_block_ids_to_zero | |
| ): |
| b | ||
| for _, block_ids in self._reqs_need_recv.values() | ||
| for b in block_ids[0] | ||
| for group in (block_ids[:1] if self._has_mamba else block_ids) |
There was a problem hiding this comment.
Question: Is the condition now overly loose? IIUC zeroing happens either if it's mamba or if using mixed precision kv. Can we check that instead so it aligns full with needs_kv_cache_zeroing?
Ideally we would use needs_kv_cache_zeroing directly so we don't have to mirror the check as that will cause drifts in the future, not sure if that's possible though
|
This pull request has merge conflicts that must be resolved before it can be |
|
Close cause no PD machine now. |
Overview
#59164 removes synchronous MoRIIO READ destinations from
new_block_ids_to_zero, but only for models with Mamba layers.needs_kv_cache_zeroingis also true for mixed-precision attention caches (#47574). DeepSeek-V4 is one: its MLA cache isuint8(fp8_ds_mla) and its compressor state cache isfloat32. Its READ destinations are still zeroed on the compute stream, and the zeroing can run after the RDMA READ has landed. This PR applies the same exclusion to every READ group of models without Mamba layers.Claims
Validation
test_update_state_drops_decode_recompute_tail_block(the non-Mamba cases now expect the exclusion) + newtest_attention_only_read_skips_zeroing_in_every_grouptest_moriio_connector.py+test_moriio_kv_layout.py+test_moriio_hma_scheduler.py(ROCm, MI350X, mori installed)PYTHONPATH. The main column runs main's code against this PR's test file.torch.cuda.current_stream().synchronize()instart_load_kv, before the READs are posted. We did not A/B the race itself. The nodes are not available right now; I will add an E2E accuracy run (with and without this change) before marking the PR ready.Details
Flow (decode side, one step,
--async-scheduling).new_block_ids_to_zero.build_connector_metakeeps the list unchanged, because_has_mambais False.update_requestsqueueskv_block_zeroer.zero_block_idson the current stream. The stream is still running the previous step's forward, so the zeroing kernel waits behind it.pre_forward->start_load_kvposts the RDMA READs from the host. The NIC writes the pages directly and does not wait on the stream.Fix.
build_connector_metasubtracts the READ destinations of every group when the model has no Mamba layers. The Mamba path keepsblock_ids[:1], the aligned attention pages. This is the exception thatKVConnectorBase_V1.build_connector_metaalready documents for synchronous READ connectors.Why skipping the zeroing is safe here.
block_lenbytes per block (compute_block_transfer_offsets), so each destination page becomes a byte copy of the prefiller's page. The prefiller zeroed that page when it allocated it._await_reads_issued_this_step; [Bugfix][KV Connector][ROCm] MoRIIO READ: await every read before the forward #60808 makes this unconditional), so no kernel reads a destination page before the READ has landed._reqs_need_recvholds only the aligned destination blocks. The decode-side recompute tail is not a READ destination, so it stays in the zeroing list (covered by the existing test).Alternative considered. A stream sync before posting READs (what our internal build does) also closes the race. It makes the host wait for the previous forward on every step that receives KV, so the READs cannot overlap it. The exclusion needs no synchronization.
Related PRs.
block_ids[: len(self._attn_group_ids)]and keeps the_has_mambacondition. The two compose. Whichever lands second needs a one-line rebase.skip_zeroing_group_ids([Bugfix][Core] Exempt exactly the blocks an async KV load writes from zeroing #59504).Duplicate check. I searched open PRs for
moriio zeroing,moriio zero,new_block_ids_to_zero,READ destinations zeroingandmoriio mixed precision, and checked the diffs of #60867, #60808, #61726 and #54301. Only #60867 touches this exclusion, and only for Mamba hybrids.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.
AI assistance (Claude Code) was used to prepare this change.