Repository navigation
Conversation
This branch has not been deployed
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.
Long offloaded prefills revisit the decoder stack for every token chunk, streaming the same expert layers repeatedly. This adds
--prefill-layer-major, disabled by default: each decoder layer processes all internal chunks before the next layer starts, allowing streamed experts to be reused. In the bounded 32K comparison below, first-text latency fell from 21.913 s to 11.030 s with the same quantized kernel.Scope and state handling
offload, pinned PLE, one pending text request, and new-token length greater than the existing prefill budget and at most 32,768. Unsupported configurations retain ordinary chunked execution, including the default disk PLE backend.--max-prefill-lengthremains the internal chunk size. The outer request owns checkpoint planning; internal chunks preserve absolute cached positions and project that plan. Conv, recurrent and PLE state advance in chunk order within each layer; the outer batch context is restored on success and exceptions.Related problem: #579. The loop ordering is informed by Layered Prefill; this does not implement its full stall-free scheduler. #578's kernel optimization and #577's host checkpoint bank are separate contributions and are not included.
Target-model comparison
Tested candidate:
63858faa584ddd623d5ea1728e26270e0c7f649b; frozen upstream baseline:9c635a157798da4aa43e6d051e92620521ed1858. Three services ran sequentially: baseline, candidate flag off, candidate flag on. All used the same environment, model files, synthetic prompts, 4K internal chunks, 2,700 expert slots, pinned PLE and upstream Triton NVFP4 kernel. Client concurrency was 1.Each median contains two scored 32,012-token cold requests, each generating 128 tokens. First-text latency is measured from immediately before HTTP to the first nonempty completion-text SSE event. The last column includes prefill and is not steady-state decode throughput. Baseline-to-enabled latency reduction is 49.67% (1.987x latency ratio). These synthetic samples establish a bounded result, not a statistical confidence estimate or a general workload claim. H2D bytes and peak VRAM were not measured.
Nine generation calls ran per arm: two unscored 512-token warmups, one short functional check, then three cold/continuation pairs. The first long pair warmed up long-shape JIT and was excluded from performance scoring in advance. The remaining two cold requests supplied the table. Every request used
temperature=0,max_tokens=128,ignore_eos=true, and ended withlength.All nine corresponding native 128-token ID sequences matched across the three arms, including flag off against baseline. Cold requests admitted zero cached tokens. Each 32,077-token continuation reused 32,000 tokens and prefetched the remaining 77. IDs and cache counts were observed at the scheduler's existing CPU reply seam, without adding GPU synchronization. Logs confirmed enabled cold prefills used a single 32,012-token outer prefill; baseline/off used seven 4,096-token chunks plus a 3,340-token tail. This is limited target-model coverage, not an exhaustive equivalence, cancellation or concurrent-serving gate.
Run lifecycle caveat: all three timed arms and all 27 requests completed before a post-run GPU-idle cleanup check recorded
failed_harness. That terminal status is retained. A subsequent read-only check found the GPU idle; production was restored and two official-SDK smoke requests passed against its frozen reference, without measurement reruns. The table reports completed timed arms, not a claim that the entire control harness passed. Independent review found no remaining blocker in those measured-arm results.Upstream subsequently merged #670 and #685; submission-time main is
f02fbb16a213f5c81094e4017c988d41f0164141. Git's merge-tree check is clean. This branch preserves the exact tested commit; the merged result with those two newer CPU/hybrid changes has not been GPU-tested.Environment and reproduction
uv pip checkand native imports passed.qwen4_expconfiguration. No MTP enabled. The same files were used for all arms.Use the same dependency-conformant environment and native build for both worktrees. Measured serve arguments follow;
TREEselects the frozen baseline or candidate source. Add--prefill-layer-majoronly for the enabled candidate. CPU affinity is specific to this host.Exact synthetic prompt construction and request/timing protocol
Generate text using the same checkpoint tokenizer; no chat template is applied:
On a fresh service, send
shortthree times, then each(cold, continuation)pair in order, sequentially. Score only the botanical and cartography cold requests. POST/v1/completionsusing this payload for each text:{ "model": "Qwen3.8-Flash-Next-NVFP4", "prompt": "<text>", "temperature": 0, "max_tokens": 128, "ignore_eos": true, "stream": true, "stream_options": {"include_usage": true} }Use a monotonic clock immediately before HTTP; save SSE through its end. Record the first nonempty
choices[].textevent and full-response duration. Require[DONE],finish_reason=length, andusage.completion_tokens=128; verify prompt counts and cache reuse. Compare corresponding native token IDs in addition to API text. The measurement client used Python'surllib.requeston the same host. A separate read-only observer captured IDs fromDetokenizeMsgand counts fromPromptAdmittedMsg; that experiment instrumentation is not part of this runtime patch.CPU validation
On the exact candidate in the isolated Linux environment, with CUDA hidden: 50 passed (pytest 9.1.1):
CUDA_VISIBLE_DEVICES='' python -m pytest -q \ tests/engine/test_layer_major_tracks.py \ tests/scheduler/test_scheduler_chunked_prefill.py \ tests/scheduler/test_cost_accounting_core.py \ tests/scheduler/test_abort_inflight_prefill.pyCoverage includes default-off and unsupported-mode fallback (including disk/missing PLE configuration), the 32K eligibility boundary, absolute cached offsets, outer checkpoint projection, incoming conv/recurrent/PLE state, one prefill-cache initialization, and context restoration after exceptions. CLI help and the three freshly built native extension imports also passed. Source and measurement evidence received independent review.