ggml-meta, sched : allocate a meta transport ring at each device's share - #9
Open
Piggidragon wants to merge 1 commit into
Open
Piggidragon wants to merge 1 commit into
Piggidragon wants to merge 1 commit into
Conversation
A meta buffer sizes every simple buffer for the whole tensor, so under split mode tensor each device allocated the full ring although it holds only its share of the heads. ggml_backend_meta_get_shares returns, per device, the largest share of a set of compute leaves, and ggml_backend_meta_alloc_buffer_shares allocates each simple buffer at that share, placing a tensor at X*share rounded up to the alignment. The share includes one alignment per entry, so rounded neighbours do not overlap, and binding asserts that a tensor fits. The scheduler applies the budget to the largest share and the headroom check to each device's own share, and grows the ring when a plan needs a larger share than it holds. Assisted-by: Claude Opus 5
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.
Overview
Follow-up to #8: under
-sm tensor, each device now allocates only its share of the transport ring instead of the whole ring.A meta buffer sizes every simple buffer for the whole tensor and places a tensor at the same offset on each device. A device that holds half the heads therefore allocated the full ring.
ggml_backend_meta_get_shares(buft, tensors, n, shares): for each device, the largest fraction (in 1/65536) of the given compute leaves it holds. The split state is taken through an empty compute meta buffer.ggml_backend_meta_alloc_buffer_shares(buft, size, shares): allocates simple bufferjatsize * share_j. A tensor at meta offsetXlands atX * share_j, rounded up to the alignment. The share includes one alignment per entry, so rounded neighbours cannot overlap, and binding asserts that the tensor fits. The meta size stayssize, so the scheduler's layout andggml_backend_tensor_allocchecks are unchanged.Testing
RTX 4070 + RTX 3060, CUDA + NCCL,
-sm tensor -nkvo --kv-cpu-pinned, q8_0 KV.The share is the largest over the entries, so a layer that puts all of its KV heads on one device costs that device the whole slot, as on gemma-4's first device here.
This moves where the default 128 MiB budget declines. At 32k context on Qwen3.8 a slot is 70.7 MiB:
Output is unchanged against #8, with the same hashes:
64e86551f7ef1638; gemma-45525e3f5ac7337d7(50,50) and4f8986fb3655a567(55,45)LLAMA_KV_SM=tensor, depths 0 and 1): all 8 tasks identical to sched, ggml-meta : pipeline the host KV delivery under split mode tensor #8125cb9c2082d36cf(-sm tensor, depths 0/1/4),db661b7a08686b97(-sm layer),17f946c340db110b(-sm none)test-llama-archs -s 1on 2, 3 and 4 CUDA devices, andtest-alloc, passRequirements
Assisted-by:commit trailer.🤖 Generated with Claude Code
https://claude.ai/code/session_0145V8xvxxUQMUVbg6ZiCZMg
🤖 Generated with Claude Code