Repository navigation
qwen4_exp CUDA: feed row_s from stand-alone passes so --decode-share sizes them - #248
simon-lin88 wants to merge 1 commit into
Conversation
…sizes them row_s is only calibrated by _timed() in the mixed-round path, which never runs when converges() is False (NVFP4 checkpoints register kernel 'nvfp4'), so pass_limit() always returned the full row count and --decode-share stayed a no-op. A stand-alone pass now updates row_s the same way a mixed round would. On a DGX Spark with Flash Next NVFP4 (--parallel 3 --decode-share 0.1), the decoding stream's median delta gap while another request prefills drops from ~1.33 s to ~111 ms (whole-pass) / ~76 ms with a 512-row pass cap applied separately; outputs are unchanged. Fixes part of ashhart#230
|
The 512 limit reads as a floor in its comment but is written as a cap:
Written with AI assistance (Claude Code). |
|
Thank you, @simon-lin88. Feeding row_s from stand-alone prompt passes, so Two changes from your PR: when #141 split the scheduler, the row_s update moved into the prompt-fill module, and the fixed 512-row pass cap is not in, because |
…lies (ashhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed — the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves: the reply's share x sets the prompt's p to its complement (0 keeps whole prompts, the CUDA default; the env stays as the lower override and the flag wins), and it rides api.Open and api.Info to every lane host. ashhart#248's pass cap maps onto the chunk level: while a share is active and replies are decoding, a filling prompt's chunks cap at 512 rows (Share.short_rows) through prefill_step's max_rows hint, honored by the core wrappers and the family backends (qwen3_5, glm, flashnext CUDA and HIP, dory, gemma4, kolibri1); without a share or without live decoders the engines keep their own cuts. ashhart#248's row_s estimator has no native analog — the debt is owed from measured wall time, so a stand-alone step needs no calibration. Co-authored-by: simon-lin88 <[email protected]>
…lies (ashhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed — the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves: the reply's share x sets the prompt's p to its complement (0 keeps whole prompts, the CUDA default; the env stays as the lower override and the flag wins), and it rides api.Open and api.Info to every lane host. ashhart#248's pass cap maps onto the chunk level: while a share is active and replies are decoding, a filling prompt's chunks cap at 512 rows (Share.short_rows) through prefill_step's max_rows hint, honored by the core wrappers and the family backends (qwen3_5, glm, flashnext CUDA and HIP, dory, gemma4, kolibri1); without a share or without live decoders the engines keep their own cuts. ashhart#248's row_s estimator has no native analog — the debt is owed from measured wall time, so a stand-alone step needs no calibration. Co-authored-by: simon-lin88 <[email protected]>
…lies (ashhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed — the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves: the reply's share x sets the prompt's p to its complement (0 keeps whole prompts, the CUDA default; the env stays as the lower override and the flag wins), and it rides api.Open and api.Info to every lane host. ashhart#248's pass cap maps onto the chunk level: while a share is active and replies are decoding, a filling prompt's chunks cap at 512 rows (Share.short_rows) through prefill_step's max_rows hint, honored by the core wrappers and the family backends (qwen3_5, qwen27 metal, glm, flashnext CUDA and HIP, dory, gemma4, kolibri1); without a share or without live decoders the engines keep their own cuts. ashhart#248's row_s estimator has no native analog — the debt is owed from measured wall time, so a stand-alone step needs no calibration. Co-authored-by: simon-lin88 <[email protected]> Rebased on 3f1d669: jschmied's ashhart#1303 moved qwen27 metal's prompt fill into prefill_step chunks, so the max_rows hint re-points at qwen27_slots.prefillStep/chunk (the cap shortens a chunk; the cut grid, marks and decode spans still win), and the lane-host inits that the KV-pages admission reshaped keep the flag beside the served count.
…lies (ashhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed — the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves: the reply's share x sets the prompt's p to its complement (0 keeps whole prompts, the CUDA default; the env stays as the lower override and the flag wins), and it rides api.Open and api.Info to every lane host. ashhart#248's pass cap maps onto the chunk level: while a share is active and replies are decoding, a filling prompt's chunks cap at 512 rows (Share.short_rows) through prefill_step's max_rows hint, honored by the core wrappers and the family backends (qwen3_5, qwen27 metal, glm, flashnext CUDA and HIP, dory, gemma4, kolibri1); without a share or without live decoders the engines keep their own cuts. ashhart#248's row_s estimator has no native analog — the debt is owed from measured wall time, so a stand-alone step needs no calibration. Co-authored-by: simon-lin88 <[email protected]> Rebased on 3f1d669: jschmied's ashhart#1303 moved qwen27 metal's prompt fill into prefill_step chunks, so the max_rows hint re-points at qwen27_slots.prefillStep/chunk (the cap shortens a chunk; the cut grid, marks and decode spans still win), and the lane-host inits that the KV-pages admission reshaped keep the flag beside the served count.
…lies (ashhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed — the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves: the reply's share x sets the prompt's p to its complement (0 keeps whole prompts, the CUDA default; the env stays as the lower override and the flag wins), and it rides api.Open and api.Info to every lane host. ashhart#248's pass cap maps onto the chunk level: while a share is active and replies are decoding, a filling prompt's chunks cap at 512 rows (Share.short_rows) through prefill_step's max_rows hint, honored by the core wrappers and the family backends (qwen3_5, qwen27 metal, glm, flashnext CUDA and HIP, dory, gemma4, kolibri1); without a share or without live decoders the engines keep their own cuts. ashhart#248's row_s estimator has no native analog — the debt is owed from measured wall time, so a stand-alone step needs no calibration. Co-authored-by: simon-lin88 <[email protected]> Rebased on 3f1d669: jschmied's ashhart#1303 moved qwen27 metal's prompt fill into prefill_step chunks, so the max_rows hint re-points at qwen27_slots.prefillStep/chunk (the cap shortens a chunk; the cut grid, marks and decode spans still win), and the lane-host inits that the KV-pages admission reshaped keep the flag beside the served count.
…shhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
…shhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
…shhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
…shhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
…shhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
…shhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
…shhart#840) The ashhart#840 row (Python ashhart#248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
…840) The #840 row (Python #248, @simon-lin88): the native parser refused --decode-share outright, while the mechanism it feeds already existed: the lane host's debt share (lane_host_fill.zig) keyed off TENSORFOLD_PREFILL_SHARE only. The flag now serves. Its share x is the reply's: the prompt's p becomes the complement (0 keeps whole prompts, the CUDA default), and the value rides api.Open and api.Info to every lane host that serves it. TENSORFOLD_PREFILL_SHARE keeps its existing meaning, the prompt's share of a fill step's wall time: time only. The 512-row fill cap is a per-family declaration, not a global policy. Backend.chunk_invariant (default false; drafted, the recorder and the CUDA host wrapper copy it) says a family's prompt fill gives the same tokens at any chunk cut, and the cap fires only with an explicit flag plus that declaration beside live decoders, at its own decode_cap_rows (no longer Share.short_rows). Every real family keeps false until per-family device token-hash qualification lands, so qwen CUDA exactness holds by construction: chunks never leave the cold grid unless a qualified family opts in. GLM CUDA's chunk driver ignores the hint outright: its chunks sit on the 2048 grid and the share works by time, so BadChunk cannot come from the share. The harnesses show the gate both ways: with the flag active a gated family's chunk starts ride the CUDA 2048 grid (glm/prefill_test.zig, with a grid guard mirroring cuda_engine.zig) and its chunk ends equal the cold plan exactly (flashnext), while an opted-in declaration moves the hint to 512 and reproduces the off-grid BadChunk. A prefix-wait waiter with an active share is released by the leader's cut within its bound, replies equal to the no-share run. Tests clear TENSORFOLD_PREFILL_SHARE before reading a default share (the suite is green with the env set) and pin the env's time-only meaning: env buys debt, never chunk caps. The macOS glm/backend.zig call and the GLM and Flash Next schedule harnesses take the third prefillStep argument. Co-authored-by: simon-lin88 <[email protected]>
Follow-up to #230 (includes the patch posted there, plus a pass-width cap).
Problem
--decode-shareis accepted on CUDA Flash Next (CUDA_DECODE_SHARE = True) but is silently a no-op on NVFP4 checkpoints. Two stacked causes:pass_limit()early-returns the full row count whilerow_sisNone, androw_sis only calibrated by_timed()in the mixed-round path — which never runs whenconverges()is False (NVFP4 registers experts kernel"nvfp4"), because a stand-alone pass's timing goes through_joined()and never reaches_timed().PASS_MIN(128 rows), where big prompts lose prefill throughput (measured: ~120K-token prompts dropped to ~1237 tok/s effective with 192-row passes, vs ~1637 with a 512-row cap, on a DGX Spark).Change
_pass()feedsrow_sthe same EMA a mixed round would, sopass_limit()can size the next pass._pass_rows()caps share-sized passes at 512 rows (only when live and share > 0), keeping passes wide enough to stay efficient.Measured (DGX Spark, Flash Next NVFP4, --parallel 3, --decode-share 0.1)
Happy to adjust the cap value or move it behind an option if you'd rather size it differently.