Repository navigation
GLM CUDA: gather and sample shared verification windows together - #4698
Draft
MaverickKB wants to merge 1 commit into
Draft
MaverickKB wants to merge 1 commit into
MaverickKB wants to merge 1 commit into
Conversation
Contributor
|
sm_120 cross-check (RTX 5060 Ti, live), head
|
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.
What this changes
GLM CUDA already runs the target forward for several verification windows together. It then gathers the vocabulary shards, samples, synchronizes and reads tokens back separately for each window. This change gathers all rows once when every window in the step is sampled and the step has no grammar masks. Each row carries its own sequence's sampling rule and absolute position. The existing CUDA row sampler can split the vocabulary into 8,192-entry slices. Its scratch reuses the gather staging buffer after the strided copies on the same stream.
Ordinary single-stream top-k sampling also uses the row sampler. Grammar draws and single-stream unrestricted-vocabulary draws retain the previous call. Mixed greedy/sampled windows continue selecting each window separately. The patch changes no CUDA kernel or draft-acceptance rule.
95ae4081770ff36fc83d16a5be7d166bdee005fa.92073e9f1ff614d4853e6e6201a8f6c3c645faef.Device receipt
A checkpoint-free, single-GPU driver fixture used the actual GLM vocabulary width of 154,880, BF16 logits, temperature 0.7, top-p 1 and top-k 20. Each sample included metadata upload, draw, stream synchronization and token download. The interval started with full logits already on the GPU. The legacy column runs one draw and one readback per stream. The other columns use the same input rows, with each stream's seed and absolute position keyed separately. The table gives the median of 16 timed repetitions after two warmups, rotating variant order each repetition.
Both kernel variants matched the legacy token ID on all 2,580 checked rows. The checks included broad, peaked, tied and partially masked logits, independent seeds and positions, mixed top-k rules, top-p/min-p, and fallback outside the sliced kernels' supported top-k range. Device: NVIDIA GB10, SM121, Linux aarch64, driver 580.178.04. The same
sample.fatbinwas used for all three variants (SHA-25658b81ee0c449be7a1aa6976f1a31f37b3e2e5a1678bbc53cd29931c969556b19).The new regression is part of the existing
tf-cuda-test sampleentrypoint. I ran its GLM case independently on the GB10. It invokes the actual GLM Zig adapter, splits each vocabulary across two locally emulated shards, gathers three rows from one window and five from a second, and compares all 32 picks over four distributions against the two serial draws. It passed with both per-window temperatures and top-k rules active.Checks and remaining gates
zig build test-glm-logprobs-host test-glm-structured-host compile-glm-native-open --summary all: 15 tests passed. The host coverage includes per-sequence row keys and the existing NCCL recording interposer for two ranks and uneven three-rank vocabulary splits.zig fmt --checkon all touched Zig files andgit diff --checkpassed. The repository lean checker found 165 inherited findings on both main and head, zero new.Coordination
atc overlap --jsonreported capped coverage and seven file overlaps. A paginated GitHub check covered 401 open PRs and 46 that shared paths, with 57 per-file three-way comparisons on each PR's merge base. The separate source comparisons found these integration points:cuda: skip unused sample probability outputs for GLM and MiniMax #4665 removes the unused probability buffer from the original draw. This PR keeps that change independently applicable in behavior. Its initializer and launch edits need a manual merge with this branch's sampler fields. Retain cuda: skip unused sample probability outputs for GLM and MiniMax #4665's null probability argument on the legacy draw and this branch's row-sized rule/position buffers. Its GPU sample-test changes merge cleanly.
GLM-5.3-Flash CUDA: shared rounds draft MTP for every stream at once #2856 batches the native MTP proposal head, including an indexed row gather and one scalar-rule draw per chained row. This patch covers the packed target-verification rows. Its sampler allocation and appended host-test hunks need reconciliation, preserving the metadata stride of each entrypoint.
cuda: TF_CUDA_HOST_WFE, opt-in WFET waits for the RoCE proxy and GLM token readbacks #2922 adds an optional host wait to sampled readback. Carry its wait into the packed readback when combining the changes.
flashnext: a lone stream's copy window takes the width the boot check proves #4075 and docs: the optimization ledger's cells for PRs that landed since, and lfm2_moe's CUDA column #4580 touch adjacent optimization-ledger table text. Keep the participating families' cells when resolving the table. GLM CUDA: skip native MTP prompt history with DFlash2 #4695 and lanes: rank GLM CUDA prefills by their resident prefix #4696 merge cleanly on shared files.
Shared target sampling is measured with fixed rows and identical output IDs.
Per-sequence RNG keys and position coverage run in existing test entrypoints.
No kernel, weight format or precision change.
Whole-model exactness and end-to-end performance on main and head.