Conversation
loc_space_scale re-derived, from dcp_size, a shape the allocator object already carries -- and the draft is handed that allocator. The target builds it widened (size * dcp_size, page_size * dcp_size), so allocator.page_size // get_schedule().page_size is the same number by construction. Effect: the draft pool path no longer reads DCP at all. The only remaining attn_dcp_size reads in the configurator are in allocator construction, which runs on the target (the draft's allocator is passed in). So "DCP is off for drafts" becomes a complete ground truth for pool shape, and a draft-scoped DCP context cannot desync the pool from the allocator it shares. Also follows an allocator that widens differently: SWA / HiSparse are built with the unscaled page_size, where the old dcp_size derivation scaled anyway. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The allocator's free list ends at page num_pages, whose base is exactly `size` (clear() skips page 0), so it hands out slots up to size + allocator.page_size. A pool over-allocates only its own page_size past size. A replicated draft indexes those locs untranslated, so the two page sizes must agree or the last page's tail addresses rows that do not exist -- silent, and only at near-full occupancy: with an 8-way DCP group and a 64-slot base page that is 448 nonexistent rows. Reading the shape off the allocator (previous commit) makes the mismatch unreachable by construction; this asserts it at boot so a future independent derivation of pool_page_size fails loudly instead of corrupting KV again. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
pool_page_size composes loc_space_scale, so a SimpleNamespace only satisfies the leaf reads and raises AttributeError on the composition. Verified on hardware: loc_space_scale already returned 4 -- the production logic was right, the harness was not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1a45b4d moved allocator construction from self.server_args.dcp_size to get_parallel().attn_dcp_size, but this test injects a server_args stand-in only. With no DCP group attn_dcp_size is 1, so the dcp_size=4 iteration built an unwidened allocator: "AssertionError: 1024 != 4096", reproducible at the migration tip with the later commits absent. Override the cause instead of the effect, per the runtime-context idiom. Belongs in sgl-project#33925; carried here so this branch's suite is green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The invariant and the arithmetic are what a reader needs; the originating deployment is not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kpham-sgl
force-pushed
the
kpham/proto-loc-space-from-allocator
branch
from
August 7, 2026 05:52
2d3be98 to
ca419d9
Compare
Owner
Author
|
Superseded by sgl-project#33955 — same commits, opened in the main repo and stacked on the upstream mirror of sgl-project#33925's branch. |
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.
Draft, stacked on sgl-project#33925 (
dcp-reads-via-get-parallel) so the diff shows only the delta. Two commits.Why this belongs with sgl-project#33925
loc_space_scalere-derives, fromdcp_size, a shape the allocator object already carries — and the draft is handed that allocator:size * dcp_size,page_size * dcp_sizeloc_space_scalesize * dcp_size,page_size * dcp_sizeEqual by construction. So the draft can read the shape instead of recomputing it:
That matters for sgl-project#33925 specifically. On
maintodayloc_space_scalereadsserver_args.dcp_size, which aget_parallel()-scoped override cannot reach. sgl-project#33925 moves it ontoget_parallel()— after which anything that neutralizes DCP for a draft (e.g. a draft-scoped context, under discussion for sgl-project#32858) would silently computepage_size * 1and desync the draft pool from the allocator it shares with the target.After this change the draft pool path reads no DCP value at all. The only remaining
attn_dcp_sizereads in the configurator are in allocator construction, which runs on the target (if token_to_kv_pool_allocator is None; the draft's is passed in).The assert
PagedTokenToKVPoolAllocator.clear()skips page 0, so the free list ends at pagenum_pageswhose base is exactlysize— it hands out slots up tosize + allocator.page_size. A pool over-allocates only its ownpage_sizepastsize. A replicated draft indexes those locs untranslated, so if its pool pages smaller than the allocator does, that final page's tail addresses rows which do not exist:Silent, and only reachable at near-full occupancy — which is why this class of fault reads as stochastic. Under an 8-way DCP group with a 64-slot base page that is 448 nonexistent rows per request that reaches the last page.
The target is safe by arithmetic accident, not by design. It translates (
loc // dcp_size), which scales the allocator's overshoot down by exactly the same factor. Only the raw-indexing draft is exposed.Commit 1 makes the mismatch unreachable by construction; commit 2 asserts it at boot so a future independent derivation of
pool_page_sizefails loudly instead of corrupting KV again. Layer 1 alone is only as durable as nobody re-deriving — and the original defect was a derivation that looked right.Behaviour change to review
SWATokenToKVPoolAllocatorandHiSparseTokenToKVPoolAllocatorare built with the unscaledpage_size; onlyPagedTokenToKVPoolAllocatoris widened. So for a draft sharing one of those,loc_space_scalenow returns 1 where it previously returneddcp_size. That follows the allocator's actual shape, so I believe it is more correct — the old code scaled against an unwidened allocator — but it is a real change and I have not established whether hybrid-SWA + DCP + draft is reachable.Verified on 8-GPU DCP8 hardware
Red-then-green, on a TP8/DCP8 deployment with a speculative draft worker.
RED —
pool_page_sizereverted to the unwidenedget_schedule().page_size:Fires at draft pool allocation, before any request is served.
GREEN — the change as written: assert silent, draft pool derived from the allocator matches the value the
dcp_sizederivation produced, and a sustained high-occupancy serving benchmark completed all requests with zero server errors, at throughput in line with the previously validated fix. The run held attoken usage 0.97— the occupancy regime where this fault appears — for most of its duration.CPU suite —
test_dcp_layout_unit.py: 10 passed, 0 failed.Running the tests caught two bugs that reading did not:
pool_page_sizecomposesloc_space_scale, so theSimpleNamespacestand-in raisedAttributeError.loc_space_scale(draft) == 4had already passed — production logic right, harness wrong. Fixed in2da12ff985.test_configurator_scales_only_the_virtual_dcp_allocatorfailed1024 != 4096:1a45b4dd5dmoved allocator construction toget_parallel().attn_dcp_sizewhile the test injects only aserver_argsstand-in, so with no DCP group it built an unwidened allocator. Reproduced at the migration tip with this PR's commits absent. Fixed in2d3be98773; that fix belongs in config: route DCP topology reads through get_parallel() sgl-project/sglang#33925. Worth asking why CI missed it — the file is registeredbase-a-test-cpu.Still not verified
sglang-kernelminimums.🤖 Generated with Claude Code