Skip to content

lanes: rank GLM CUDA prefills by their resident prefix - #4696

Draft
MaverickKB wants to merge 2 commits into
ashhart:mainfrom
MaverickKB:codex/cuda-resident-prefix-prefill-rank
Draft

MaverickKB wants to merge 2 commits into
ashhart:mainfrom
MaverickKB:codex/cuda-resident-prefix-prefill-rank

Conversation

@MaverickKB

@MaverickKB MaverickKB commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

An admitted GLM CUDA continuation can have a longer prompt than a competing cold request and far fewer rows left to compute. With TF_KV_SHARE, the backend used to discover its resident checkpoint at the first fill. Until then the lane host ranked the entire continuation as uncached.

The optional backend hook looks up the deepest usable in-memory checkpoint once at admission. The scheduler uses the estimate to rank fills and classify short suffixes. The first actual fill still locates and acquires the pages. An intervening eviction costs one speculative priority decision, and the next choice uses actual progress. The estimate never updates cache usage or the reported number of completed rows. Aging still lets a waiting cold request run.

Checks on this head

  • Head commit: 0468b87a54f30b368dd2cc51bf9199596a252886.
  • Lean checker: 165 findings on base, 165 on head, zero newly introduced. python3 tools/pr_check.py --base origin/main --pr 4696 reported zero errors and zero warnings.
  • CPU test coverage with Zig 0.17.0 on macOS arm64:
    • zig test -lc --dep lanes --dep sys --dep profile -Mroot=zig/src/core/engine_api.zig --dep sys --dep profile -Mlanes=zig/src/core/lanes/lanes.zig -Msys=zig/src/platform/sys.zig --dep sys -Mprofile=zig/src/core/profile.zig ran the full engine test module. All 753 passed, zero skipped or failed.
    • zig build -j2 test-glm-image-cache-host test-glm-scheduling-host --summary all: 68 passed, zero failed or skipped. The real shared-store host fixture compares estimated and restored depth and verifies that the lookup leaves page availability, store counters and restored state unchanged.
    • zig test -lc --dep lanes -Mroot=zig/src/native/cuda_bound.zig --dep sys --dep profile -Mlanes=zig/src/core/lanes/lanes.zig -Msys=zig/src/platform/sys.zig --dep sys -Mprofile=zig/src/core/profile.zig: both CUDA host forwarding tests passed.
  • The two new lane tests both selected the cold request first with the existing ranking logic. With this change, 128 new rows behind 8,192 cached rows take the first fill ahead of 4,096 cold rows. The second case evicts the checkpoint between admission and fill, verifies the following choice returns to the cold competitor and checks that reported cache credit is zero. Both cases exercise the existing aging bound.
  • CI: GitHub showed no check runs for this head when verified.
  • Hardware checks still open on this exact public head: equal-input CUDA comparisons of token hashes, cold prefill and decode throughput. This is a draft pending that receipt.

Receipt

Workload on a downstream v1.3.4-derived TP=2 deployment Prompt tokens Resident Fresh Server TTFT Client first streamed token
Resume while a different million-token project was filling from cold 1,032,185 1,030,144 2,041 2.880 s 3.292 s
Same continuation sent as part of a pair of warm continuations 1,032,185 1,030,144 2,041 9.351 s 10.117 s

The projects used existing source files. In the first row the lane trace measured 0.672 s from submission to the beginning of the fill and 2.088 s in the fill. Server-reported prefill time was 2.103 s. The concurrent project and arrival order differed in the second run. These are observations on a downstream build with other changes. They cannot establish a speedup or isolate the effect of this patch. The failing-control host tests above isolate the ordering change.

  • Main against branch: the reproducible host comparison above covers fill choice, eviction, wait aging and cache accounting. GPU wall-clock comparison remains open.
  • Boxes and paths: generic lane scheduling and GLM CUDA's TF_KV_SHARE resident store. CPU host tests cover the shared-store query, image content identity, forwarding and scheduling. Other backends leave the optional hook unset.
  • Switch: uses the existing store and scheduling options. There is no new flag.
  • Environment: host receipts used public base 95ae4081, head 0468b87a and Zig 0.17.0. The field observations used GLM-5.3-Flash on two NVIDIA GB10 systems. No GPU kernel, tensor contents or checkpoint revision is involved in the new lookup.
  • Exactness: host tests verify the cached depth against the actual shared-store restore. Public-head GPU token hashes for draft, solo, concurrent and resumed execution remain open.
  • Decode and cold-prefill speed: an identical-hardware main-versus-public-head run has not been collected. No decode, prefill-kernel or aggregate throughput gain is claimed.
  • Licence of new weights: n/a. This change adds no weights.

Checklist

  • Title and description match the head and receipt.
  • New scheduler tests fail on the original ranking and pass with this change, without devices.
  • Added source comments are one line. Measurements stay out of the implementation.
  • Changed files and commit include no deployment paths or machine identifiers.
  • Every token still goes through the lane rounds with the existing draft mode.
  • Hardware token-for-token draft, resume and concurrency comparisons on this public head.
  • Arithmetic and precision are unchanged.
  • Paired hardware throughput checks on this public head.

@MaverickKB

Copy link
Copy Markdown
Contributor Author

Downstream SSD resume receipt

On a downstream TensorFold 1.3.4 build with two GB10 ranks, 1,048,576 context and eight slots, I restarted the workers, verified the page store was empty in RAM, and continued the same long conversation through its desktop client while another real conversation decoded. The two builds restored the same 583,680-token checkpoint, about 7.4 GiB, from the same SSD namespace.

Worker Prompt tokens Restored from SSD Active restore Elapsed restore Engine TTFT Desktop reply recorded
Baseline 588,003 583,680 7.06 s 78.43 s 87.83 s 113.82 s
Background read-ahead 591,082 583,680 3.79 s 82.83 s 96.81 s 115.01 s

The downstream restore change reads and verifies files on a separate thread with 8 MiB of staging. The engine still owns page publication and orders transfers across both ranks. Host checks cover byte-exact restore, corruption, cancellation and GLM rank transport. The binary embeds the same 139 CUDA kernel modules as the baseline.

The later turn had 3,079 more uncached tokens and live decode traffic differed between runs. Active restore work fell by 46%. Elapsed restore and Desktop response time were similar. The book confirmation arrived in the desktop session while the other request was still decoding. This receipt describes the deployed downstream stack. The isolated CUDA comparison on this PR's public head remains open.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant