[GG] MLA: preallocate absorbed projection weights before dequant scratch#156
Conversation
|
Warning Review limit reached
Next review available in: 34 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)
✨ Finishing Touches🧪 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 |
Allocate the persistent W_UV/W_UK_T pair before dequantization scratch while preserving existing storage on reloads. Resolve the source device across unquantized and packed linear layouts and cover the ordering and pointer contracts with CPU tests. Assisted-by: OpenAI Codex <noreply@openai.com>
1f4702a to
b7710b5
Compare
|
Rebased the single preallocation commit onto current dev/gilded-gnosis (b07bef7) and resolved the overlap with the merged direct absorbed-BMM path by applying preallocation only inside the existing materialized fallback. Focused CPU tests pass (2 passed, 2319 deselected); Ruff and format checks pass. |
Summary
Allocate the persistent MLA absorbed projection pair (
W_UVandW_UK_T) before materializing temporary dequantization storage. This keeps long-lived tensors out of the allocator holes created by per-layer dequant scratch.Compared with #148, this clean replacement also:
weight,qweight,weight_packed, wrapped base layers, parameters, or buffers instead of assumingkv_b_proj.weight;prefer_copy=True, preserving CUDA-graph-visibledata_ptrvalues;.weight, allocation-before-dequant ordering, first-load storage adoption, and reload pointer stability.Why
The original allocation order materializes each persistent absorbed pair after the dequant scratch has churned the CUDA allocator. The validation attached to #148 measured reserved-but-unallocated memory falling from 0.577 to 0.225 GiB per GPU at GLM-5.2 TP4 geometry when the persistent pair is allocated first.
This PR intentionally supersedes #148 instead of building on it: #148 is stacked on unrelated #145/#146 changes. No upstream open PR matched searches for
W_UK_T W_UV preallocateorMLA dequant scratch fragmentation. #154 is related but not a duplicate: it releases B12X-owned source storage after absorption, while this PR controls allocation order. The two branches apply without a source conflict.CodeRabbit feedback from #148
Accepted and strengthened:
.weight;prefer_copy=Trueand reload-safe pointer preservation.Not ported:
kv-scales/README.md, because that file belongs to the unrelated glm52: calibrated NVFP4 MLA KV outer scales + serve wiring #145 stack and is outside this clean PR.Validation
Compatibility validation with #154's focused tests:
6 passed.The predecessor's GLM-5.2 TP4/DCP4 model validation for the same allocation-order change reported:
No numerical operation or runtime weight layout changes in this replacement.
AI assistance
OpenAI Codex assisted with implementation and validation. The human submitter must review every changed line and be able to explain and defend the allocator, reload, and device-selection contracts before merge.