Repository navigation
Conversation
…opt-in STRATA_PIPED_CONCURRENT_SMB=1) The concurrent read is off beside STRATA_SPLIT_MTP_BATCH because the batched draft K/V (Prefill::draft_kv) would allocate on the read's thread. Its buffers are carved from the prompt path's scratch region and its two uploads fit the slots reserve_uploads already holds; what can allocate is the Q8_0 MMQ: its context is made at first use, and llama.cpp's MMQ takes its stream-k fixup from the context's pool (on devices whose MMQ configs use stream-k). With STRATA_PIPED_CONCURRENT_SMB=1, Prefill::reserve_draft_kv makes the context and grows the pool to the largest fixup (one 128 x 128 tile of floats per SM) before each read, with nothing in flight, beside the existing reserve_prefill / reserve_uploads; concurrent_read_off then no longer names STRATA_SPLIT_MTP_BATCH. Off, nothing changes. batch_read_test covers the new case. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
|
Thanks for the pull request. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to review properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes:
The rules are in CONTRIBUTING.md. |
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.
Summary
STRATA_PIPED_CONCURRENT=1is off besideSTRATA_SPLIT_MTP_BATCH=1(STRATA_PIPED_CONCURRENT is off beside STRATA_SPLIT_MTP_BATCH), because the batched draft K/V (Prefill::draft_kv) would allocate on the read's thread. This adds an opt-in,STRATA_PIPED_CONCURRENT_SMB=1, that removes the allocation and lets the two run together. Off (the default), nothing changes.What allocates
Reading
Prefill::draft_kv:m.region): no allocation;nbx 4 B) go throughup_ring, and are smaller than whatreserve_uploadsalready reserves before the read (TxKx 4 B);mmq::Context(llama.cpp's MMQ): the context is created at first use, and llama.cpp takes its stream-k fixup buffer from the context's pool, which grows at the first larger request.So the MMQ pool is the one thing that can allocate. On devices whose MMQ configs do not use stream-k it never does (in the ggml we build with, all 254 RDNA2 configs have
stream_k = false); on NVIDIA (Volta and newer) and CDNA it can.The change
mmq::Context::reserve_fixup(bytes): takesbytesfrom the pool and gives them back, so a later run that needs at most that much allocates nothing.Prefill::reserve_draft_kv(): creates the MMQ context and grows the pool to the largest fixup, one 128 x 128 tile of floats per SM (nsmx 128 x 128 x 4 B).generate.cpp, withSTRATA_SPLIT_MTP_BATCH=1andSTRATA_PIPED_CONCURRENT_SMB=1, it is called on the drafter's stage before each concurrent read, beside the existingmtp.reserve_prefillandsp.reserve_uploads, with nothing in flight. It logs once:STRATA_PIPED_CONCURRENT_SMB=1: the batched draft K/V (STRATA_SPLIT_MTP_BATCH) runs beside the concurrent read; its MMQ pool is grown before each read.ConcurrentReadSetup::split_mtp_batch_reserved:concurrent_read_offno longer namesSTRATA_SPLIT_MTP_BATCHwhen it is set.batch_read_testcovers the new case (checked that it fails when the new assertion is flipped).Measured
2x RX 6900 XT (gfx1030), ROCm 10.0, Linux. Flash-Next GSQ-RCO IQ3_S, 262144 context,
--kv int8 --kv-resident 32768, layer split with part of the experts in RAM,--spec 3 --spec-min-p 0.7,"parallel": 2,--batch-groups 2 --batch-mtp, greedy. This branch's binary, a fresh engine per arm. Both arms haveSTRATA_PIPED_CONCURRENT=1; "with" addsSTRATA_SPLIT_MTP_BATCH=1 STRATA_PIPED_CONCURRENT_SMB=1.Stability: 9 arms, 0 stalls. In the three full runs (two with, one without), each arm read a 64K prompt while a short request arrived (4 give-ways per arm, short TTFT 8.0-8.1 s), two streams, a hand-off, and a needle test across the yield point (6 of 6 correct).
Prompt read, 3 interleaved pairs (each arm's outputs are token-identical run to run, so these are the same requests):
The cost, which is
STRATA_SPLIT_MTP_BATCHitself and not this change: the draft layer's K/V come from Q8_1 x Q8_0 MMQ instead of the drafter's own mmvq, so the drafts move (asdocs/MULTI_GPU.mdsays). On the same requests, drafts accepted fell from 87.5% to 85.3% (and 84.5% to 82.4% in the full runs, 6 of 6 comparisons lower), and decode was about 3% lower at 4K and 32K, unchanged at 128K. On our rig the two roughly cancel, so we leave it off. On rigs where the prompt read is a larger share, or whereSTRATA_SPLIT_MTP_BATCHgains more, it may be worth it.Not tested
The path this guards: no NVIDIA card here, so the stream-k fixup allocation that this change pre-grows has not been exercised. On gfx1030 the MMQ never takes from the pool, so our runs show the two coexisting, not that the reservation is sufficient on a stream-k device. A run on CUDA with
STRATA_PIPED_CONCURRENT=1 STRATA_SPLIT_MTP_BATCH=1 STRATA_PIPED_CONCURRENT_SMB=1and a few long reads beside a decoding slot would settle it.Developed with an AI coding assistant; every number above was measured on 2x RX 6900 XT (gfx1030), ROCm 10.0, Linux.