Skip to content

fix(mla): keep DCP outputs head-major for safe BMM - #147

Merged
lukealonso merged 1 commit into
local-inference-lab:dev/gilded-gnosisfrom
voipmonitor:fix/gg-head-major-dcp-output-20260721
Jul 21, 2026
Merged

fix(mla): keep DCP outputs head-major for safe BMM#147
lukealonso merged 1 commit into
local-inference-lab:dev/gilded-gnosisfrom
voipmonitor:fix/gg-head-major-dcp-output-20260721

Conversation

@voipmonitor

Copy link
Copy Markdown

Summary

Fixes the GLM MLA DCP output layout so the V up-projection BMM no longer consumes a strided view backed by tight DCP/A2A allocation memory.

This is the vLLM side of the fix. It depends on local-inference-lab/sparkinfer#54, which teaches the PCIe DCP pool and sparse MLA scratch planner to accept/write head-major BHD views.

Root Cause

A guarded repro showed that cuBLAS can read ahead to the next 64 KiB boundary for the _v_up_proj strided torch.bmm pattern. That is normally safe with PyTorch caching allocator segments, but unsafe when the DCP producer returns a tight custom/IPC allocation with no mapped tail page.

The rejected alternatives were:

  • cloning DCP outputs before _v_up_proj: correct, but adds decode-copy overhead;
  • tail-padding every relevant custom allocation: correct for the pool path, but costs memory/KV and does not cover every producer uniformly;
  • changing cuBLAS algorithms: tested against the guarded repro and did not avoid read-ahead.

This PR keeps the logical tensor contract as BHD, but makes DCP outputs physically head-major. _v_up_proj then gets the same logical shape while its head-major transpose is backed by safe contiguous storage, without adding a hot-path clone.

Changes

  • Add reduce_scatter_head_major to the DCP group coordinator and CUDA communicator.
  • Request head-major output from cp_lse_ag_out_rs for MLA DCP merge output.
  • Preserve packed token-major and capacity-strided head-major layouts in the B12X PCIe DCP path.
  • Allocate NCCL fallback DCP output as head-major storage with a BHD transposed view.
  • Teach B12X sparse MLA workspace borrowing to expose dense output as head-major when needed.
  • Add unit coverage for supported BHD layouts and the head-major reduce-scatter request.

Validation

Targeted tests:

  • Docker CPU/unit: tests/distributed/test_dcp_a2a.py::test_b12x_lse_reduce_preserves_supported_layouts, tests/v1/attention/test_b12x_mla_dcp_workspace.py::test_cp_lse_ag_out_rs_requests_head_major_output -> passed
  • CUDA-specific unit could not run from a raw source mount because the container lacks the matching source-built vllm._C_stable_libtorch extension; the same test passed earlier in the overlay image built from this patch stack.

E2E overlay validation on 8x RTX PRO 6000 Blackwell, GLM 5.2 Luke NVFP4, TP8, MTP0, A16, MAX_NUM_SEQS=1, GRAPH=6, InstantTensor:

DCP Decode CC1 mean KV cache Notes
1 87.1776 tok/s 576,256 tokens no regression vs clean baseline
2 72.6942 tok/s 1,096,704 tokens no Xid; 100k loop smoke completed 20 iterations, CJK 0
4 71.6411 tok/s 2,209,024 tokens no Xid; 100k single-shot smoke completed, CJK 0

Kernel/server log checks after long-context smoke found no Xid, FAULT, illegal, CUBLAS, CUDA error, or traceback entries.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@voipmonitor, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 278a8470-c667-4417-88c7-0c9672686d17

📥 Commits

Reviewing files that changed from the base of the PR and between 73e4a8c and a75e500.

📒 Files selected for processing (8)
  • tests/distributed/test_dcp_a2a.py
  • tests/v1/attention/test_b12x_mla_dcp_workspace.py
  • vllm/distributed/device_communicators/cuda_communicator.py
  • vllm/distributed/parallel_state.py
  • vllm/model_executor/layers/attention/mla_attention.py
  • vllm/v1/attention/backends/mla/b12x_mla_sparse.py
  • vllm/v1/attention/ops/common.py
  • vllm/v1/attention/ops/dcp_alltoall.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lukealonso
lukealonso merged commit 6a2edcf into local-inference-lab:dev/gilded-gnosis Jul 21, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants