Skip to content

feat(drama3): batch CUDA prompt prefill in bounded rounds - #1120

Closed
plotarmordev wants to merge 1 commit into
ashhart:mainfrom
plotarmordev:drama3/prefill-rows
Closed

plotarmordev wants to merge 1 commit into
ashhart:mainfrom
plotarmordev:drama3/prefill-rows

Conversation

@plotarmordev

Copy link
Copy Markdown
Contributor

What this changes

Batch CUDA prompt prefill into bounded chunks through the existing lane rounds, with fixed prompt-offset boundaries and a scheduler return after each chunk. The default is 128 rows; TF_DRAMA_PREFILL_ROWS=1 restores single-row behaviour, and the generation tool's --max-rows controls ordinary CUDA prefill.

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision:
    Feature 307583a2acccbe60c2c7bcd31149e44841ab4678 on drama3/prefill-rows, based on d1018b31. Public native-CUDA generation receipt: one GB10, built-in voice, a 645-row public text prompt, 1024 generated frames and 4 repeats per arm. Framework versions and checkpoint revision are not recorded in the public summary. Metal was not qualified.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false:
    Public PCM hashes show single-row patch equals stock; default equals explicit 128 equals the repeated 128 run byte-for-byte. Batched PCM differs from single-row PCM: the default changes output bytes versus 1.1.1. Dense projections switch from GEMV reductions to tiled GEMM reductions, and attention QK, softmax and weighted-value sums are regrouped; BF16 inputs/outputs and FP32 accumulation are retained. This is not a claim of chunk-invariant bits or audio-quality equivalence. If the maintainer prefers opt-in batching rather than a changed default, that policy would preserve release output behaviour by default.
  • Decode speed before and after, from tools/bench_openai.py:
    Not run; the native generation receipt below measures first audio and total generation time, not OpenAI decode throughput.
  • Prompt speed before and after: the cold first request's ttft_s from tools/bench_cache.py --require-cold on a long prompt, or "n/a" with the reason when the change cannot reach prompt processing:
    Cold-cache serving TTFT was not measured; native first-audio medians are reported below instead.
  • Tests run, with pass, fail and skip counts:
    CPU qualification for 307583a2: the final combined build reported 230/230 steps succeeded, 753/755 tests passed and 2 skipped, with other successful tests cached; the changed Drama host artifact passed 29/29. Python comparator tests passed 5/5. Earlier invocations reported 3026/3040 passed with 14 skipped, then 2166/2176 passed with 10 skipped; these are separate invocation counts, not additive totals. The public summary reports all repetition, metric and output-equality checks passing. Both public replay runs, at 64 and 128 rows, fail with the separate codec chunk-width ReplayMismatch; no replay pass is claimed. Replay at these capacities needs the separate poison-ordering fix PR (drama3/replay-stock-fix, 3aa77ad3).
  • Not run, and why:
    No new build or test run for this draft. Metal, other CUDA hardware, oracle fidelity, audio quality, concurrent/draft exactness and cold-cache serving benchmarks are not established by this public native-generation receipt. No GPU kernel was edited.

Medians from the public summary; device peak is the reported device allocation peak, not host memory:

Arm First audio (s) Total (s) Device peak (GB)
Stock 18.2 47.5 41.67
Single-row patch 18.3 47.5 41.11
64 rows 1.15 30.5 41.16
Explicit 128 rows 0.75 30.1 41.21
Default (row option omitted; 128 rows) 0.76 30.2 41.21

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt.
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Thanks @plotarmordev. 18.2 s to 0.76 s for first audio is a big win, and we want it in.

The plan:

  • We're carrying your commit onto current main with your authorship intact, plus a maintainer child that keeps the single-row path as the CUDA default. That path matches stock byte for byte, as your receipt shows, so 1.1.4's default audio is unchanged.
  • TF_DRAMA_PREFILL_ROWS=128 (and the tool's --max-rows) opts in to the batched path.
  • Metal keeps its current behaviour.
  • After that, we'll run a GB10 cell on the batched path: repeats equal, concurrent equal to solo, and a speech quality check against single-row. If it holds, batching becomes the default in the next release.

No action needed from you unless you'd rather we kept 64 rows as the opt-in example.

- Synthema, Ash's AI Assistant.

@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Landed on main as beff255, with a maintainer child (a6cbfbb) that keeps one prompt row a chunk as the CUDA default, as planned, thank you @plotarmordev. Default audio stays byte-identical to stock. TF_DRAMA_PREFILL_ROWS=128 (and the tool's --max-rows) opts in to batched prefill: first audio 0.76 s instead of 18.2 s on your receipt. We'll run the GB10 cell on the batched path next (repeats, concurrent equal to solo, speech quality); if it holds, batching becomes the default.

- Synthema, Ash's AI Assistant.

@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

This shipped in TensorFold 1.1.4: https://github.com/ashhart/TensorFold/releases/tag/v1.1.4

Thank you @plotarmordev for the contribution.

- Synthema, Ash's AI Assistant.

@ashhart ashhart added the landed Landed on main by the maintainers; the commits keep the contributor's authorship label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

landed Landed on main by the maintainers; the commits keep the contributor's authorship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants