Skip to content

qwen4_exp CUDA: feed row_s from stand-alone passes so --decode-share sizes them - #248

Closed
simon-lin88 wants to merge 1 commit into
ashhart:mainfrom
simon-lin88:decode-share-row-s
Closed

simon-lin88 wants to merge 1 commit into
ashhart:mainfrom
simon-lin88:decode-share-row-s

Conversation

@simon-lin88

Copy link
Copy Markdown
Contributor

Follow-up to #230 (includes the patch posted there, plus a pass-width cap).

Problem

--decode-share is accepted on CUDA Flash Next (CUDA_DECODE_SHARE = True) but is silently a no-op on NVFP4 checkpoints. Two stacked causes:

  1. pass_limit() early-returns the full row count while row_s is None, and row_s is only calibrated by _timed() in the mixed-round path — which never runs when converges() is False (NVFP4 registers experts kernel "nvfp4"), because a stand-alone pass's timing goes through _joined() and never reaches _timed().
  2. Once calibration works, the share can drive passes down to 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() feeds row_s the same EMA a mixed round would, so pass_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)

  • Decoding stream's median inter-delta gap while the other request prefills: ~1.33 s → ~76 ms; two concurrent 30K-token requests finish in the same wall time as the default (whole-pass) schedule.
  • 0.6.1 vs 0.6.2 A/B on the same prompt: 20.0 vs 20.5 tok/s (no change), and the counting-prompt upper bound reproduces at 60-64 tok/s — the patch only re-times passes, outputs are unchanged (row splitting doesn't touch the math).

Happy to adjust the cap value or move it behind an option if you'd rather size it differently.

…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
@jschmied

jschmied commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

The 512 limit reads as a floor in its comment but is written as a cap:

https://github.com/ashhart/TensorFold/blob/1670b61/src/tensorfold/families/qwen4_exp/cuda/multi.py#L237-L238

if limit > 512: limit = 512 turns every larger share-sized pass into 512 rows. tests/test_flashnext_prompt_pieces.py::test_both_planner_paths_bound_live_pieces_and_restore_idle_width catches it: it fails on this branch ([(…, 0, 512)] == [(…, 0, 960)], line 105) and passes on v0.6.2. limit = max(limit, 512) would match the comment and keep the 960.

Written with AI assistance (Claude Code).

@ashhart

ashhart commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Thank you, @simon-lin88. Feeding row_s from stand-alone prompt passes, so --decode-share sizes them, is in TensorFold 0.6.4 under your name: https://github.com/ashhart/TensorFold/releases/tag/v0.6.4

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 pass_limit sizes each pass from the measured times. This closes #230. On a DGX Spark the combined Flash Next stack (#202, #201, #254, #248, #268) matched one-token decoding in 12 of 12 cells, with prompt speed at parity. Thank you for the careful work.

@ashhart ashhart closed this Oct 3, 2026
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 25, 2026
…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]>
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 25, 2026
…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]>
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 26, 2026
…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.
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 27, 2026
…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.
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 27, 2026
…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.
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 27, 2026
…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]>
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 27, 2026
…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]>
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 27, 2026
…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]>
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 27, 2026
…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]>
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 28, 2026
…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]>
javierbits added a commit to javierbits/TensorFold that referenced this pull request Oct 28, 2026
…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]>
ashhart pushed a commit to javierbits/TensorFold that referenced this pull request Oct 30, 2026
…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]>
ashhart pushed a commit that referenced this pull request Oct 30, 2026
…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]>
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.

3 participants