Repository navigation
Fix prefill size - #711
Merged
Merged
Fix prefill size#711
Conversation
Ying1123
force-pushed
the
ying-prefill-fix
branch
from
July 24, 2024 10:40
6196b0b to
9f0f230
Compare
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
Closes the gap my own sgl-project#423 analysis named: BlobStore.put(session_id, blob) took no class, and TieredGdnBlobStore bound ONE tier at construction, so every blob from a store went to the same place regardless of what losing it would cost. The sgl-project#423 recommendation -- reconstructible bulk to the slow tier, non-reconstructible state to the fast durable one -- was therefore unbuildable. WHAT CHANGED put() gains `volatility` and `tier_hint`, both optional. Resolution order: explicit hint, explicit per-class map, sgl-project#407 registry, default tier. BACKWARD COMPATIBLE BY CONSTRUCTION: volatility=None resolves to the default tier, so an unclassified put is the pre-sgl-project#711 path byte-for-byte and no caller is forced to classify. Pinned by a test that a legacy put is NOT re-routed even when a class map exists. THE SAFETY RULE FROM sgl-project#423, ENFORCED: non-reconstructible state with no durable tier configured STAYS LOCAL rather than shipping to the generic default. Losing it kills the request, so in-process is strictly safer than a tier that can lose it independently -- local dies only with the process, which is already fatal for the session. An unknown class is refused LOUDLY. A typo must not silently pick the default tier; that is exactly the failure this ticket removes, reappearing as a spelling mistake. A BUG THIS FEATURE COULD EASILY HAVE INTRODUCED, caught and fixed: pop() read from self._tier while put() may now write to a per-class tier, so a blob on the durable tier would have been reported unrecoverable. The manifest now records the DESTINATION and pop reads from the tier that wrote it. Pinned by a round-trip test through a non-default tier. Failure fallback preserved per class: a refusing tier still means "stay local", not "lose the blob". 11 hermetic tests including the CAN-FAIL on the single-tier world -- with one tier and no class map both classes resolve to the same destination, which is the defect, pinned so the gap cannot silently reopen. Note on lint: the new annotations follow the file's existing typing.Optional/ Dict style rather than collections.abc. The file is uniformly the older style; mixing would be worse than matching. Baseline findings unchanged in kind.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…the manifest desk-build DESIGN FIRST, and the design's first move is to notice what is already built. The sgl-project#706 canonical store IS a per-token-content snapshot of exactly the two things a conversation checkpoint needs: {hash} for a token's KV (all attention layers, geometry-free, cut at read time) and {hash}.mamba for the GDN state, both keyed by content alone and therefore already surviving a phase flip and a reboot. So slice 1 designs no payload format. What was missing is the SESSION level: which pages, which blob, at which position, under which sampling and template state. DESIGN_410_session_checkpoints.md carries the full document. THE sgl-project#212 LESSON IS THE LOAD-BEARING CONSTRAINT, not a caveat. A KV-only prefix is worth ZERO usable tokens on this hybrid checkpoint (sgl-project#703 re-derived it structurally and pinned it: the storage hit is the MINIMUM across pools with mamba registered TRAILING_PAGES, and the device-side match advances only at nodes carrying mamba_value). Three rules follow, and the module ENFORCES all three rather than documenting them: 1. the GDN anchor is REQUIRED on a hybrid model and refused at WRITE time -- a manifest describing a prefix that resolves to nothing is a bug best caught where it is created, not at branch; 2. a checkpoint may only claim a position where state exists. With --mamba-checkpoint-interval that is an absolute grid, so the position is SNAPPED DOWN and BOTH positions are recorded: a checkpoint that quietly covers fewer tokens than asked for is a wrong answer, not a rounding. A request that snaps to 0 is refused outright; 3. completeness is VERIFIED against the store before a branch seeds anything, because a manifest holds references and the tiers evict. FORMAT: versioned (refuse unknown versions rather than best-effort parse -- that refusal is what makes sgl-project#411 a converter question instead of a silent field-drop), deterministic serialisation so a manifest hashes reproducibly, and CONTENT-ONLY: a test asserts the serialised form contains no tp_rank, tp_size, pp_rank, pp_size or layer anywhere. That is what sgl-project#706 earned and what makes a manifest portable across phases, rigs and reboots. API + REFUSALS (sgl-project#510 canon, ADMIN_OPTIONAL on all four -- the level 51 existing state-changing routes use): POST /session_checkpoint, /session_branch, /session_rewind, GET /session_checkpoints. Mid-generation policy defaults to REFUSE (a checkpoint taken while tokens are appended describes a moving target and its tail pages may not be in the store yet); the permissive mode quiesces first, never snapshots concurrently. "Branch from a non-checkpoint" is impossible by construction rather than by check: branch takes a checkpoint_id, and those exist only for manifests that were written and verified. TIER TARGET: the manifest is metadata and does NOT live in the KV tiers; the payload it references follows the existing sgl-project#407 ladder with no new mechanism, with TieredGdnBlobStore (sgl-project#711) as the blob-half precedent. Named consequence, not smuggled: a checkpoint stays branchable only while its references survive eviction. PINNING them is slice 2 work. DESK BUILD (mem_cache/session_manifest.py): the versioned manifest, build with grid-snapping and the stateless refusal, deterministic dumps/loads, verify_against_store, verify_model_identity, and seed_plan -- the ordered fetch list a branch executes, verified UP FRONT, with the recurrent state fetched LAST so its absence can never look like a completed seed. Not built and not pretended: the radix prefix insert and blob restore themselves need live pools. Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 18 new, 168 in the family. The completeness half runs against the REAL backend in canonical mode, three PP stages writing real pages, so sgl-project#706's invisible-until-complete rule is part of what is tested: a page only two of three stages wrote counts as MISSING, not as partial. The named red-first case -- a manifest whose page was evicted must refuse at branch rather than seed a silent partial prefix -- is test_a_manifest_whose_page_was_evicted_refuses_at_branch, with its sgl-project#212 twin test_a_missing_gdn_blob_refuses_too. BYTE-GATE SPECED, NOT RUN (section 7 of the design): A-vs-A first to establish the determinism floor, then straight-through generation vs checkpoint-branch- continue, compared as token IDS not text -- a divergence at P+1 is a state-restore bug, a later one is a sampling/template bug, which is why the comparison is per-token. Judge ids, never timing: the draft pool starts cold after a branch by design (sgl-project#706 C7). BOOT DEPENDENCIES, explicit (design section 8): canonical store flags + file backend + page_size 1; hierarchical cache with the disk tier; --mamba-checkpoint-interval for the grid; the flip+hicache boot sgl-project#719 makes safe (plus its second host pool) if checkpoints cross phases; deterministic sampling for the byte-gate itself. CAN-FAIL PROOF (mutation applied, suite re-run, reverted): S1 the sgl-project#212 rule dropped (a stateless hybrid manifest is allowed) -> test_a_hybrid_checkpoint_without_state_is_refused_at_build S2 no grid snapping (the checkpoint claims an off-grid position) -> test_the_position_snaps_down_to_the_grid_and_says_so, test_a_checkpoint_before_the_first_grid_point_is_refused S3 branch skips verification -> test_a_manifest_whose_page_was_evicted_refuses_at_branch, test_a_missing_gdn_blob_refuses_too (the named red-first case and its sgl-project#212 twin, and only those) S4 unknown format_version parsed best-effort -> test_an_unknown_version_is_refused_not_best_effort_parsed S5 the recurrent state fetched FIRST instead of last -> test_the_plan_is_the_branch_order, test_a_complete_checkpoint_verifies_and_plans S6 model identity mismatch tolerated -> test_a_foreign_model_identity_is_refused, and ONLY that one Restored tree re-verified green after every mutation (18 passed). Regression, same env, base c3e9487 vs this commit: unit/mem_cache 940 failed / 779 passed -> 940 failed / 925 passed (+146)
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.
No description provided.