Skip to content

GLM-5.3-Flash CUDA: shared rounds draft MTP for every stream at once - #2856

Open
ashhart wants to merge 3 commits into
mainfrom
lead/glm-shared-mtp-batch
Open

ashhart wants to merge 3 commits into
mainfrom
lead/glm-shared-mtp-batch

Conversation

@ashhart

@ashhart ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner

In a shared round of several streams with MTP drafting, GLM-5.3-Flash on CUDA drafted one stream at a time: an absorb pass, then one-row head passes per level, each with its own host synchronisation in the token draw, and at tensor parallelism a keep and a draft message per stream.

What changes:

  • facts().draft_streams is on for shared MTP. One-stream rounds keep today's path exactly.
  • With two or more drafting streams, Engine.draftShared runs one segmented absorb over the round's streams (each segment updates its own MTP cache and length), then one segmented head pass and one batched draw per level for the streams still chaining: one host sync a level instead of one a stream.
  • One draft_shared wire step (cuda_follow.zig) carries each stream's slot, kept rows, follow ids, depth and prompt flag, so every TP rank commits its kept rows and runs the identical batch in lockstep.

Exactness: drafts only decide how many rows a round verifies, and verify is unchanged. Each stream's drafts and MTP cache also match the serial path: at these row counts the norms, projections, attention and expert kernels are per-row, rank sums are in fixed rank order and expert sums in fixed slot order, and the batched draw uses each stream's own rule and position.

Checks: host tests that shared MTP sets draft_streams and that a fake leader sees one draft message per three-stream round (a planted serial-only fan-out turns it red), plus the recording transport and request-start checks; test-cuda-host and the GLM host steps (407/407), compile-cuda-tests -Dtarget=aarch64-linux-gnu, fmt and lean (no new findings). A zig/tests/cuda batched-against-serial check of drafts and MTP lengths is compiled for the GB10 run.

Still to run before landing: two GB10s at TP=2, GLM-5.3-Flash NVFP4 with MTP, main against this branch at 1 and 4 streams, greedy and seeded, replies equal; the batched-against-serial device check.

For #2822.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

First device result, two GB10s at TP=2, GLM-5.3-Flash NVFP4 with MTP, main against this head (base-new-new-base): every reply identical (52 of 52). Four streams are much faster: chat 85.4/85.7 -> 102.0/102.1 tok/s (+19%) and code 134.2/135.2 -> 144.3/144.4 tok/s (+7%), steady across both runs of each arm. One stream and prompts are level apart from the third run, which was slow on every cell including its 2K prompts (844-1,366 tok/s against about 1,610 in the other three), so the medians' -3% at one stream and -13% at 2K are that run, not the change. A second A/B in the opposite order is queued to confirm one stream is level before it lands.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

Device result on two GB10s at TP=2 (GLM-5.3-Flash NVFP4, MTP, 4 slots, prompt cache off), main's merge-base against ba9601388. Two jobs of four runs each, one ordered base-new-new-base and one new-base-base-new so neither side always gets the first boot.

  • Tokens: equal in every cell of both jobs (52 of 52 each), with concurrent equal to alone and serial.
  • Four streams: chat +19.3% and +19.6%, code +7.2% and +7.8% (85.2 → 101.9 and 134.7 → 145.2 tok/s).
  • One stream: level. The first job's −3% came from one slow run (run 3: code 69.2 and chat 29.5 against 73.5-74.5 and 30.5-30.9 in the other seven), slow on every cell at once. Without it, code is 73.9-74.5 new against 73.0-74.4 base, and chat 30.5-30.9 against 30.7-31.4.
  • Prompt: level at 8K and 32K. The 2K cell moved −13% and +4.6% in the two jobs, the same noise in each direction.

The review fixes in progress (the error path's double commit and the rest) don't touch the shared round's speed. Once they're in and CI is green, this lands.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Status: the review fixes are in. Every keep and cache extent is checked before any state changes, a cohort whose shared dispatch failed is refused until it is released (so a committed prefix can't be applied twice), and absorbs stay inside the served window. This branch now sits on today's main.

There was one conflict. Main moved the layer sums' gather to zig/src/families/glm/cuda_boundary.zig:16, called as Forward.resolve, so this branch keeps main's resolve and drops its own copy of gather. The shared MTP pass now calls f.resolve for its two sums (zig/src/families/glm/cuda_mtp_shared.zig:83 and :91). It is the same per-rank fp32 gather in rank order, over the tensor group's collective when one is installed. No other code changed.

The GLM host steps and the Linux CUDA compile (engine and device tests) pass on the rebased head.

Still to report before this lands: the batched-against-serial device check (glm-mtp-shared-check) on two GB10s at TP=2. The token-equality A/B above ran on the head from before the review fixes.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

/atc exchange b2e20801688443ce995801a3ad1801c5026089fea9238e0aa5ed960057897853

Use one rank step for the shared absorb and each chained level,
with segmented per-stream KV, image slots and sampling positions.
Keep one-stream, alone and DFlash2 dispatch unchanged. Preserve
per-stream chance-buffer intent on the wire.

Add host fanout regressions and an every-rank CUDA oracle with
owned hidden inputs and per-round MTP cache byte comparisons.

Refs #2822
Validate every keep and cache extent before any state changes.
A failed shared dispatch makes its cohort unusable until release,
so a committed prefix cannot be applied twice. Bound absorbs to
the served window and remove the unreachable multi-group path.
Exercise retry refusal, metadata validation and wire edges.

Refs #2822

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