Repository navigation
Conversation
harmya
marked this pull request as ready for review
September 23, 2026 21:30
harmya
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
September 23, 2026 21:30
harmya
commented
Sep 23, 2026
|
|
||
| def resolve(self, device: torch.device) -> int: | ||
| if self.bytes is None: | ||
| self.bytes = mqa_logits_budget_bytes( |
Contributor
Author
There was a problem hiding this comment.
using existing helper here
Contributor
Author
|
@Oasis-Git Hi, since #39095 got merged, here is follow up to use the free-memory-aware budget |
4 of 5 tasks
Contributor
|
Thanks @harmya. Closing this because you have 6 PRs open and none updated in 7 days, over our soft cap of 5 for idle PRs. Reopen the two or three you most want reviewed - a short active set moves faster than a long idle one. Some directories moved recently, so an older branch may need retargeting: |
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.
Continued in #47363 with the remaining fixes adapted to current upstream. GitHub rejected reopening this PR.
Motivation
DSV4 dense prefill still uses a fixed 2 GiB score budget. This switches it to the existing free-memory-aware helper.
While checking this, I also found that the sparse publisher keeps the previous score tile alive while allocating the next one. A 2 GiB score budget used 4.38 GiB of peak additional memory in the B200 test below.
Modifications
mqa_logits_budget_bytes()once per forward. Pass that budget to each indexer layer and the replay tail.mqa_logits_rows_per_chunk().Small inputs do not query free memory. Capture uses the helper's static budget.
Scoring precision is unchanged. Every row still sees its full context.
The budget covers temporary indexer memory. It is not a limit on total model memory. Small inputs and the minimum kernel row count keep their existing behavior. Free memory can change later in the forward.
Accuracy Tests
49 CPU tests, 9 B200 GPU tests and all-file pre-commit passed. These include the existing nonpaged-indexer and replay-metadata tests. The new lifetime test fails when the explicit tile release is removed. GPU tests check selection correctness and peak allocation at aligned and unaligned context lengths.
The existing replay-tail test sometimes misses its 98% overlap threshold. After seeing 501/512 on the patch, I repeated it eight times per version on the same GPU. Upstream had the same miss once, the patch had none. The threshold is unchanged.
Speed Tests and Profiling
Candidate selection on one B200, against upstream
954458567. 16K query rows, 32 heads, blocks of 8, 2048 candidate blocks and 512 token picks per row. Median of 10 warm calls across two runs in reverse order. Each run used a fresh process. No model loaded.Peak extra memory is the increase in PyTorch allocated memory during the call, including the returned candidate tensors. The free-memory run used
mem_fraction_static=0.8and the default free-memory fraction of0.2. That gave a 7.13 GiB budget on this mostly empty GPU.At 2 GiB, the patch uses less memory and takes more tiles. With room available, it uses larger tiles. It does not always use less memory.
CI States
Latest PR Test (Base): ❌ Run #35924130383
Latest PR Test (Extra): ❌ Run #35924130100
Latest PR Test (AMD ROCm 10): ❌ Run #35924130110