[GG] fix(ds4): preserve compressed MLA page stride - #212
Conversation
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe B12x cache page view now exposes the exact logical payload, validates contiguous payload rows, preserves physical strides for packed allocations, and rejects strides smaller than the payload. Tests cover contiguous, padded, and invalid storage layouts. ChangesB12x cache page payload and stride handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
vllm/models/deepseek_v4/nvidia/b12x.py (1)
82-116: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winValidate page payload strides before exposing cached KV pages.
The 2D branch accepts page stride
stride(0) < page_nbytes, which lets page rows overlap. Thetorch.as_stridedbranch accepts non-contiguous intra-page layouts, so the 1D payload can include bytes outside the logical token rows. Requirestride(0) >= page_nbytesfor every rank and add checks/tests for a 2D overlapping layout and a multidimensional gapped layout.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@vllm/models/deepseek_v4/nvidia/b12x.py` around lines 82 - 116, Update the cache validation around the 2D and multidimensional branches to require page stride(0) to be at least page_nbytes, rejecting overlapping rows for 2D tensors. Before creating the as_strided page_view, also validate that the source layout is contiguous within each page (stride(1) == 1) so gapped multidimensional layouts cannot expose bytes outside the logical payload; preserve the existing valid packed-block stride behavior and add coverage for both invalid layouts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/models/deepseek_v4/test_b12x_cache_page_view.py`:
- Line 46: Update the pytest.raises match pattern in the relevant test to use a
raw string literal, changing the existing "page stride .* is smaller" pattern
while preserving the same regex and exception assertion.
In `@vllm/models/deepseek_v4/nvidia/b12x.py`:
- Around line 57-64: In vllm/models/deepseek_v4/nvidia/b12x.py at lines 57-64,
add Google-style `Args:` and `Returns:` sections to the docstring. The `Args:`
section should document the page_size parameter and the `Returns:` section
should describe the return value. At lines 72-76, add Google-style `Args:`,
`Returns:`, and `Raises:` sections, documenting the parameters, what the
function returns, and the validation failures mentioned in the existing
docstring text under the `Raises:` section. Follow the Google-style Python
docstring format with consistent formatting and type annotations.
---
Outside diff comments:
In `@vllm/models/deepseek_v4/nvidia/b12x.py`:
- Around line 82-116: Update the cache validation around the 2D and
multidimensional branches to require page stride(0) to be at least page_nbytes,
rejecting overlapping rows for 2D tensors. Before creating the as_strided
page_view, also validate that the source layout is contiguous within each page
(stride(1) == 1) so gapped multidimensional layouts cannot expose bytes outside
the logical payload; preserve the existing valid packed-block stride behavior
and add coverage for both invalid layouts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 05671282-ec36-491c-9580-254a9fbfae96
📒 Files selected for processing (2)
tests/models/deepseek_v4/test_b12x_cache_page_view.pyvllm/models/deepseek_v4/nvidia/b12x.py
Summary
Export the DeepSeek-V4 compressed MLA cache as its logical payload view while preserving the allocator's physical page stride.
Companion SparkInfer PR: local-inference-lab/b12x#106
Root cause
A 64-token DeepSeek-V4 page contains 37,376 payload bytes (
64 * 584). The existing adapter unconditionally exposed the 37,440-byte SGLang-padded width. The 0731 checkpoint can instead receive a valid contiguous vLLM allocation whose physical page stride ends at 37,376 bytes, so forcing the padded view rejects or exceeds that allocation.Implementation
[pages, page_size * 584]as the logical viewstride(0)for packed/padded allocationsValidation
tests/models/deepseek_v4/test_b12x_cache_page_view.py: 3 passedSummary by CodeRabbit