Skip to content

cuda: share prompt steps with running replies by default (decode-share 0.25) - #3486

Merged
ashhart merged 7 commits into
ashhart:mainfrom
bikepresentball:fix/3397-decode-share-default
Nov 20, 2026
Merged

ashhart merged 7 commits into
ashhart:mainfrom
bikepresentball:fix/3397-decode-share-default

Conversation

@bikepresentball

@bikepresentball bikepresentball commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Change (4 files + changelog)

LaneHost.Info.default_decode_share (?f64, null) stays: the flag wins, the env's TENSORFOLD_PREFILL_SHARE beats an engine default and never arms the chunk cap, an engine default arms long fills only, other backends pass null. The CUDA engine passes 0.25.

The conditional (this revision): an engine default arms only while a filling prompt has Share.default_arm_rows (32,768) rows or more left. Past the threshold the long prompt shares its steps beside live decoders and takes the 512-row chunk hint, exactly as --decode-share 0.25 does; below it the prompt fills whole at main's pace, so no measured short-prompt cell pays anything. Share.defaulted marks an engine-armed host so longStep, srptStep and capRows gate on the prompt's remaining rows; Share.env_share marks the env's share so an explicit TENSORFOLD_PREFILL_SHARE=1 holds the default off. The flag shares every long prompt, unchanged.

Receipt (same GB10, base commit vs this branch, Qwen3.8-27B MLX-4bit + DFlash2 @50307d4c, temperature 0, both binaries built from source)

The review's bar and its numbers, client-side aggregate tok/s of short prompts (the flag's decode-share 0.25 unconditional made these 77.8 → 71.0; the conditional keeps them at main's):

scenario base (main) conditional armed no slower
short 1×2k warm 34.8 34.6 yes (−0.6%, within run noise)
short 4×2k warm 54.8 53.9 yes (−1.6%, within run noise)

Starvation beside a filling long prompt, decode-phase tok/s of the streams sharing the GPU (4× cold ~126k+):

build starved streams' decode tok/s
base, share off 1.0 / 1.3 / 2.7
conditional armed 8.3 / 8.6 / 14.7 / 26.1

The conditional delivers the flag's cure for the fills that suffer the starvation and costs the short cells nothing.

Exactness

Four concurrent distinct ~143k-token prompts (distinct text removes #3397's identical-prompt race from the comparison), same branch build, temperature 0: each stream's full reply under the armed default against the same request with the share held off (TENSORFOLD_PREFILL_SHARE=1). All four streams byte-identical: sha256 and token counts match on every stream (5632/6519/6070/4300 completion tokens each side — long replies, not 512-token stubs).

Costs, stated plainly

An armed long fill's first token comes later (the documented --decode-share trade, now scoped to fills past the threshold): in the 4× cold cohort the filling prompts' TTFTs ran +141→+867 s armed against +143→+679 s off. Short prompts' TTFTs are unchanged (they never arm).

Tests

Host tests in lane_host_decode_share_test.zig: the default arms the share and the cap past the threshold and never below it (both sides of 32,768 in capRows, and a live longStep beside a decoder that shares and owes the round above the threshold and stays whole and debt-free below it); the flag and the env beat the default; an env share of 1 holds it off. Lean check: 0 new findings against the base commit; lane_host.zig and lane_host_fill.zig stay at 600 lines or under (the 600-line commit @ashhart landed on this branch is preserved). The full host suite passes except the pre-existing failing step that fails identically on the base commit.

@ashhart

ashhart commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@bikepresentball, thank you. we applied the series to main and read the resolution order end to end: the flag wins, the environment's
prefill-share keeps its time-only meaning and never arms the chunk cap, and an engine default arms only when
neither of those is set. The new tests cover each of those cases, and we ran the lane host's host suite on an
x86 box: everything passes except a set of model-folder snapshot tests that fail identically on unpatched main
on that box, so they are not yours.

Three things must change before this can move. The two new comments over the line limit have to come down to
one line each - the project's rule is one-line comments. The exactness receipt needs the comparison that
actually pins token equality: each stream's tokens under the armed default against the same request with the
share off, on the same build, per stream - identical concurrent prompts inside one run can't show this, because
your own note shows main's identical-prompt race makes that non-deterministic. And the main arm of the tables
should be a build of the base commit rather than the stock release binary, or a note that the two are the same
commit.

On the default itself: your own tables show the short-prompt aggregate falling from 77.8 to 71.0 tok/s and the
filling prompt's first token arriving up to 21 seconds later. A default that makes a measured cell slower does not land,
even when every token is equal, so please keep the share off by default, with the flag and the environment setting as
the opt-in. CI's zig job fails at this head on the lean check, which is the two long comments above.

  • Synthena (Ash's Agent)

ashhart added a commit to bikepresentball/TensorFold that referenced this pull request Nov 17, 2026
)

The series takes zig/src/core/lane_host.zig to 601 lines on main 25de9d7 (lean 222). The comment above the
decode-share resolution becomes the trailing comment of its first line; no code changes.
@bikepresentball

Copy link
Copy Markdown
Contributor Author

Built per your word, at the branch head (c016af2): the CUDA engine's default arms only past 32,768 remaining rows, so the short cells the review held against a default stay at main's — 1×2k 34.6 vs 34.8 tok/s, 4×2k 53.9 vs 54.8 aggregate (within run noise, against the unconditional default's 77.8 → 71.0) — and the starvation past the threshold is cured as the flag cures it (starved streams 8.3-26.1 tok/s armed against 1.0-2.7 off). The exactness receipt is the comparison you named: four concurrent distinct ~143k-token prompts, same build, share armed against TENSORFOLD_PREFILL_SHARE=1 — all four streams byte-identical, sha256 and token counts (5,632/6,519/6,070/4,300 tokens each side). The env keeps its never-arms ruling; an explicit 1 holds the default off; the flag shares every long prompt unchanged. Host tests cover both sides of the threshold in capRows and a live longStep; lean shows 0 new findings and the 600-line commits hold. The PR description now carries the revised change, tables and costs.

@bikepresentball
bikepresentball force-pushed the fix/3397-decode-share-default branch from c016af2 to e759c55 Compare November 17, 2026 11:40
bikepresentball pushed a commit to bikepresentball/TensorFold that referenced this pull request Nov 17, 2026
)

The series takes zig/src/core/lane_host.zig to 601 lines on main 25de9d7 (lean 222). The comment above the
decode-share resolution becomes the trailing comment of its first line; no code changes.
@bikepresentball

Copy link
Copy Markdown
Contributor Author

Independent corroboration landed on #3397: Razumasu's paired GB10 matrix (official 1.2.9 binary) shows the same mechanism and direction as the PR's tables — starved-stream decode recovering (3.72 to 9.43 tok/s staggered), every matched pair's completion text identical across the off/on arms, and the TTFT cost — matching this PR's same-build per-stream receipts from a second box.

@bikepresentball

Copy link
Copy Markdown
Contributor Author

/atc exchange c7b7127ec0b69582f23a49133a390b3e7a4776bb0e8066d10d3c99fdb73504f9

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Hi @bikepresentball, thank you. The comments are one line each, the exactness receipt now compares each stream under the armed default with the same request with the share off on one build and with distinct prompts, and the tables say both arms are built from source. The 32,768-row threshold keeps the short cells at main's pace, with the flag and TENSORFOLD_PREFILL_SHARE keeping their meanings. What remains is our check on our GB10: short 1-, 2- and 4-stream decode and TTFT against a base-commit build, plus the long-fill starved-stream cells and their per-stream token hashes. No further change is needed from you.

  • Synthena

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @bikepresentball. The source and receipt requests are resolved, and no new engine change is needed. The 600-line limit covers source files, not the changelog, so the long changelog entry is fine as it is.

What remains is ours: a GB10 check of short 1-, 2- and 4-stream decode and time to first token, plus long-fill starvation, with each stream's token hashes matched against a base build. We will run it and post the result here.

  • Synthena

@AIFlowML

Copy link
Copy Markdown
Contributor

I trial-merged e8babf4a cleanly into 767d3d75. On M5 Max with Zig 0.17.0, test-prefill-service-host, test-glm-scheduling-host and test-flashnext-scheduling-host passed alongside a focused scratch target for lane_host_decode_share_test.zig (200 tests total).

The first boundary detail I would clarify is that the default arms at 32,768 or more rows remaining with a live decoder. In the existing cap fixture I added the neighboring values: 32,767 gives no cap, while 32,768 and 32,769 give the 512-row cap. The flag and environment precedence cases also ran. The description currently says “more than” 32,768. These were host checks, so the GB10 throughput, latency and token-hash comparisons remain open.

Igor Lessio - AIFLOW LABS

@bikepresentball

Copy link
Copy Markdown
Contributor Author

Right — the description's current wording already states it that way ("arms only while a filling prompt has Share.default_arm_rows (32,768) rows or more left"), and the capRows fixture pins both neighbors: 32,767 stays whole, 32,768 and 32,769 arm with the 512-row cap. Nothing to change on our side; thanks for the boundary check.

  • bikepresentball

bikepresentball and others added 7 commits November 20, 2026 19:56
LaneHost.Info gains default_decode_share (?f64, null): the flag wins, the
env's TENSORFOLD_PREFILL_SHARE wins over it (and never opts into the chunk
cap), other backends pass null. LaneHost.init resolves: the flag unchanged;
no flag plus an engine default with no env share arms the default's
complement and offers the cap (the chunk-invariant gate unchanged); an env
share keeps its time-only meaning; the env's row budget survives, as under
the flag. The CUDA engine opts in at 0.25 (ashhart#3397 receipt, cold 128k beside
fills: default 6.9-8.5 tok/s; 0.25: 58.6-69.1, 4x+, sha-identical outputs,
TTFT unchanged). Host tests in lane_host_decode_share_test.zig style fail
to compile on main (no such field).
The CUDA engine no longer arms a default decode-share: the flag and
TENSORFOLD_PREFILL_SHARE stay the only opt-ins, so no measured cell pays
the short-prompt cost unasked. LaneHost.Info.default_decode_share and the
resolution order stay (flag > env > engine default > null), covered by the
host tests. New comments trimmed to the 120-column lean rule.
)

The series takes zig/src/core/lane_host.zig to 601 lines on main 25de9d7 (lean 222). The comment above the
decode-share resolution becomes the trailing comment of its first line; no code changes.
LaneHost arms the CUDA engine's 0.25 default only while a filling prompt
has default_arm_rows (32,768) left: past it the long prompt shares its
steps beside live decoders and takes the 512-row chunk hint, exactly as
--decode-share 0.25 does; below it the prompt fills whole at main's pace,
so the short-prompt cells the review measured pay nothing. The flag keeps
sharing every long prompt; the env keeps its time-only meaning and never
arms the cap (env_share marks it, so an explicit 1 holds the default off).
Host tests cover the threshold on both sides of capRows and longStep.
zig fmt + the 600-line rule forced the resolution out of lane_host.zig; the module carries fromDecode/withDecode/resolved/capped; no behavior change (same precedence: flag wins, env beats a default and never arms the cap, a default arms past Share.default_arm_rows); the glm/flashnext test call sites migrate to capRows' 2-arg form with each stream's live remaining rows.
@ashhart
ashhart force-pushed the fix/3397-decode-share-default branch from e8babf4 to b8ce2d6 Compare November 20, 2026 19:57
@ashhart
ashhart merged commit eb37bb8 into ashhart:main Nov 20, 2026
11 checks passed
ashhart added a commit that referenced this pull request Nov 20, 2026
The series takes zig/src/core/lane_host.zig to 601 lines on main 25de9d7 (lean 222). The comment above the
decode-share resolution becomes the trailing comment of its first line; no code changes.
@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thank you @bikepresentball. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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