Skip to content

[Engine] Inkling 2: pick the prompt batch size from free VRAM - #320

Draft
okada-shogo wants to merge 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/prompt-batch-auto
Draft

okada-shogo wants to merge 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/prompt-batch-auto

Conversation

@okada-shogo

@okada-shogo okada-shogo commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Branch: okada-shogo/PolyStrata port/prompt-batch-auto, one commit 0f8a702 on simplex/main 36e654b.

Problem and result

A bigger prompt batch reads long prompts much faster, but its buffers take VRAM from the expert cache. A fixed
--prompt-batch 4096 reads 8K prompts about 65% faster on an RTX 2070 Super. But it makes 302-token prompts 22%
slower and decode 3-12% slower, because 2.4 GiB of the 4.4 GiB cache is gone for the whole run.

--prompt-batch auto is now the default for Inkling 2. --prompt-batch N works as before.

  • One CUDA card: short prompts keep calls of 1,024 tokens. A read of 2,048 tokens or more borrows VRAM from the
    expert cache for calls of up to 4,096, and gives it back before the answer starts. This also works with the
    DSpark drafter.
  • ROCm on native Linux: a read of about 4,000 tokens or more gets its own buffers for calls of 4,096 tokens,
    out of the expert cache. They are freed, and the cache refilled, when the read ends.
  • Everywhere else (WSL2, Windows, layer splits, batch slots): one batch for the run. It is 4,096 when every
    expert fits in VRAM beside it, else 1,024.

Prompt tok/s, mean of 3 runs (warm server, kv fp16):

Card Model Measure main this PR alone Change
RTX 2070 Super 8 GB IQ4_NL prompt 2K 494.5 559.7 +13.2%
RTX 2070 Super 8 GB IQ4_NL prompt 8K 608.3 965.4 +58.7%
RTX 2070 Super 8 GB IQ4_NL prompt 32K 625.7 888.8 +42.1%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 8K 596.8 991.0 +66.0%
RTX 2070 Super 8 GB IQ4_NL + DSpark prompt 8K 395.7 611.2 +54.5%
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 8K 1290.5 2089.2 +61.9%
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 32K 1185.2 1985.1 +67.5%
RX 9070 XT 16 GB (native Linux) UD-Q2_K_XL prompt 8K 1382.5 2467.2 +78.5%

302-token prompts (and 2K on AMD) are within ±1% of main, apart from one slow run (−2.1%).

Decode after the prompt, 5 rounds (tok/s, mean):

Card Model Measure main this PR alone Change
RTX 2070 Super 8 GB IQ4_NL decode after 8K 35.2 35.8 +1.5%
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 8K 42.9 43.1 +0.4%
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 8K 59.3 58.7 −0.9%
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 32K 53.8 53.7 −0.2%

On the RX 9070 XT the 8K change goes with the text: −1.2% to −2.3% on chat and code, +2.5% on prose. After a long
read the cache is refilled with its most used experts, not exactly the set main keeps. With the drafter, decode
after 8K is +11.7%.

All speed tables, each run (tok/s)

Decode reruns, 5 rounds, each run (tok/s). The RX 9070 XT runs are on the texts chat, code, prose, chat, code.

Card Model Measure Build Run 1 Run 2 Run 3 Run 4 Run 5
RTX 2070 Super 8 GB IQ4_NL decode after 8K main 35.3 35.2 35.2 35.2 35.2
RTX 2070 Super 8 GB IQ4_NL decode after 8K this PR 35.9 35.7 35.8 35.8 35.6
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 8K main 43.2 43.0 43.0 42.6 42.8
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 8K this PR 43.2 43.1 43.1 43.0 43.0
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 8K main 59.6 57.7 61.0 60.6 57.5
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 8K this PR 58.6 56.4 62.5 59.9 56.3
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 32K main 54.8 51.8 55.5 54.6 52.4
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 32K this PR 54.5 51.5 56.6 54.5 51.4

Prompt (tok/s, mean of 3 runs)

Card Model Measure main this PR alone Change
RTX 2070 Super 8 GB IQ4_NL prompt 302 221.8 221.8 0%
RTX 2070 Super 8 GB IQ4_NL prompt 2K 494.5 559.7 +13.2%
RTX 2070 Super 8 GB IQ4_NL prompt 8K 608.3 965.4 +58.7%
RTX 2070 Super 8 GB IQ4_NL prompt 32K 625.7 888.8 +42.1%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 302 274.0 268.1 −2.1%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 2K 558.4 741.3 +32.7%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 8K 596.8 991.0 +66.0%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 32K 595.4 976.3 +64.0%
RX 9070 XT 16 GB IQ4_NL prompt 302 607.6 605.2 −0.4%
RX 9070 XT 16 GB IQ4_NL prompt 2K 1200.8 1199.2 −0.1%
RX 9070 XT 16 GB IQ4_NL prompt 8K 711.3 709.8 −0.2%
RX 9070 XT 16 GB IQ4_NL prompt 32K 948.9 948.5 0%
RX 9070 XT 16 GB UD-Q2_K_XL prompt 302 593.9 596.9 +0.5%
RX 9070 XT 16 GB UD-Q2_K_XL prompt 2K 1276.6 1835.9 +43.8%
RX 9070 XT 16 GB UD-Q2_K_XL prompt 8K 1271.2 2371.2 +86.5%
RX 9070 XT 16 GB UD-Q2_K_XL prompt 32K 1190.2 2130.0 +79.0%

Decode (256 tokens after the prompt; tok/s, mean of 3 runs)

Card Model Measure main this PR alone Change
RTX 2070 Super 8 GB IQ4_NL decode after 302 42.5 42.2 −0.6%
RTX 2070 Super 8 GB IQ4_NL decode after 8K 34.8 35.5 +2.0%
RTX 2070 Super 8 GB IQ4_NL decode after 32K 30.2 31.2 +3.5%
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 302 48.1 47.5 −1.1%
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 8K 41.2 42.8 +3.8%
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 32K 34.6 35.0 +1.4%
RX 9070 XT 16 GB IQ4_NL decode after 302 53.3 53.2 −0.2%
RX 9070 XT 16 GB IQ4_NL decode after 8K 44.5 44.7 +0.4%
RX 9070 XT 16 GB UD-Q2_K_XL decode after 302 60.4 60.3 −0.1%
RX 9070 XT 16 GB UD-Q2_K_XL decode after 8K 57.1 56.6 −0.9%

Setup:

  • RTX 2070 Super: Ryzen 5 3600XT, CUDA 12.9, warm server (one 302-token request first, then the measured one),
    kv fp16.
  • RX 9070 XT: Salad container, ROCm 7.2.4, Linux, one 302-token request first, kv fp16.
    • IQ4_NL keeps 1,024 there: not every expert fits (2,425 of 3,072 in VRAM, on main and on this PR).
    • UD-Q2_K_XL gets 4,096 for the whole run: every expert fits (3,072 of 3,072 on both).

RX 9070 XT on native Linux (Fedora, amdgpu, ROCm 7.2.4 container, Ryzen 7 7800X3D, --threads 11; tok/s.
IQ4_NL: mean of 3 runs, one each on a chat, a code and a prose text. UD-Q2_K_XL: median of 3 rotated runs.)

Card Model Measure main this PR alone Change
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 302 562.6 565.9 +0.6%
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 2K 1278.0 1277.0 −0.1%
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 8K 1290.5 2089.2 +61.9%
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 32K 1185.2 1985.1 +67.5%
RX 9070 XT 16 GB (native Linux) UD-Q2_K_XL prompt 302 667.3 673.2 +0.9%
RX 9070 XT 16 GB (native Linux) UD-Q2_K_XL prompt 2K 1410.6 2006.2 +42.2%
RX 9070 XT 16 GB (native Linux) UD-Q2_K_XL prompt 8K 1382.5 2467.2 +78.5%
RX 9070 XT 16 GB (native Linux) UD-Q2_K_XL prompt 32K 1259.0 2207.5 +75.3%
Card Model Measure main this PR alone Change
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 302 63.0 63.1 +0.2%
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 2K 61.7 61.9 +0.3%
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 8K 59.9 59.5 −0.7%
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 32K 54.4 54.3 −0.1%
RX 9070 XT 16 GB (native Linux) UD-Q2_K_XL decode after 302 65.4 65.5 +0.2%
RX 9070 XT 16 GB (native Linux) UD-Q2_K_XL decode after 8K 61.7 61.5 −0.3%
  • IQ4_NL: 2,375 of 3,072 experts in VRAM on both sides. The 8K and 32K reads take calls of 4,096: 3.75 GiB of the
    cache is cut for the read in 30-48 ms and refilled after it. 2K reads keep 1,024: on HIP, calls of 2,048 do not
    pay for the cut and refill (2K −7.8% when allowed).
  • UD-Q2_K_XL: every expert fits beside a batch of 4,096, so 4,096 is kept for the run.
  • The first RX 9070 XT tables are from a Salad container, where the card is reached through WSL2's /dev/dxg. There
    IQ4_NL keeps 1,024 (see Limits).

On the RTX 2070 Super, the UD-Q2_K_XL 302 row comes from one slow run of this PR (258.6 tok/s). main also had slow
runs in its third round, which inflate the UD-Q2_K_XL 2K and decode-after-8K changes. The per-run tables show
both.

With the DSpark drafter (RTX 2070 Super, IQ4_NL, --draft-model dspark-Inkling-2-Mini-Q8_0.gguf; tok/s, mean of
3 runs). With the drafter's VRAM taken, auto reads long prompts in calls of 2,048.

Card Model Measure main this PR alone Change
RTX 2070 Super 8 GB IQ4_NL + DSpark prompt 2K 397.8 573.4 +44.1%
RTX 2070 Super 8 GB IQ4_NL + DSpark prompt 8K 395.7 611.2 +54.5%
RTX 2070 Super 8 GB IQ4_NL + DSpark decode after 8K 49.3 55.1 +11.7%

Each run: prompt (tok/s)

Card Model Measure Build Run 1 Run 2 Run 3
RTX 2070 Super 8 GB IQ4_NL prompt 302 main 223.3 223.2 219.0
RTX 2070 Super 8 GB IQ4_NL prompt 302 this PR 222.9 222.2 220.4
RTX 2070 Super 8 GB IQ4_NL prompt 2K main 494.8 494.4 494.3
RTX 2070 Super 8 GB IQ4_NL prompt 2K this PR 559.6 559.7 559.9
RTX 2070 Super 8 GB IQ4_NL prompt 8K main 608.1 608.4 608.3
RTX 2070 Super 8 GB IQ4_NL prompt 8K this PR 967.3 964.6 964.3
RTX 2070 Super 8 GB IQ4_NL prompt 32K main 628.8 622.3 626.0
RTX 2070 Super 8 GB IQ4_NL prompt 32K this PR 891.3 889.2 886.0
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 302 main 276.4 271.3 274.2
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 302 this PR 275.6 258.6 270.2
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 2K main 593.0 591.6 490.7
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 2K this PR 742.3 740.7 740.8
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 8K main 610.5 607.6 572.4
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 8K this PR 1011.2 1011.7 950.1
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 32K main 597.2 595.4 593.6
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 32K this PR 980.2 980.1 968.7
RX 9070 XT 16 GB IQ4_NL prompt 302 main 606.1 608.6 608.1
RX 9070 XT 16 GB IQ4_NL prompt 302 this PR 605.0 603.0 607.7
RX 9070 XT 16 GB IQ4_NL prompt 2K main 1200.2 1198.9 1203.2
RX 9070 XT 16 GB IQ4_NL prompt 2K this PR 1198.0 1194.6 1204.9
RX 9070 XT 16 GB IQ4_NL prompt 8K main 710.7 710.7 712.4
RX 9070 XT 16 GB IQ4_NL prompt 8K this PR 708.0 711.3 710.0
RX 9070 XT 16 GB IQ4_NL prompt 32K main 948.2 950.0 948.5
RX 9070 XT 16 GB IQ4_NL prompt 32K this PR 948.3 948.9 948.4
RX 9070 XT 16 GB UD-Q2_K_XL prompt 302 main 594.4 593.3 594.1
RX 9070 XT 16 GB UD-Q2_K_XL prompt 302 this PR 598.2 594.3 598.1
RX 9070 XT 16 GB UD-Q2_K_XL prompt 2K main 1276.2 1272.6 1281.1
RX 9070 XT 16 GB UD-Q2_K_XL prompt 2K this PR 1841.7 1830.0 1836.1
RX 9070 XT 16 GB UD-Q2_K_XL prompt 8K main 1273.2 1269.1 1271.4
RX 9070 XT 16 GB UD-Q2_K_XL prompt 8K this PR 2371.6 2371.7 2370.2
RX 9070 XT 16 GB UD-Q2_K_XL prompt 32K main 1190.3 1190.4 1189.9
RX 9070 XT 16 GB UD-Q2_K_XL prompt 32K this PR 2129.3 2131.8 2128.8

Native Linux IQ4_NL: Run 1, 2, 3 are the chat, code and prose texts.

Card Model Measure Build Run 1 Run 2 Run 3
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 302 main 511.2 505.2 671.5
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 302 this PR 515.6 507.2 674.8
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 2K main 1236.7 1217.7 1379.6
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 2K this PR 1237.7 1218.3 1374.9
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 8K main 1266.1 1289.5 1369.4
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 8K this PR 2066.7 2078.2 2122.7
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 32K main 1168.2 1197.1 1231.5
RX 9070 XT 16 GB (native Linux) IQ4_NL prompt 32K this PR 1971.3 1985.5 1998.6

With the DSpark drafter:

Card Model Measure Build Run 1 Run 2 Run 3
RTX 2070 Super 8 GB IQ4_NL + DSpark prompt 2K main 398.9 396.3 398.3
RTX 2070 Super 8 GB IQ4_NL + DSpark prompt 2K this PR 576.6 566.4 577.3
RTX 2070 Super 8 GB IQ4_NL + DSpark prompt 8K main 394.0 396.9 396.2
RTX 2070 Super 8 GB IQ4_NL + DSpark prompt 8K this PR 612.3 611.4 610.0

Each run: decode (tok/s)

Card Model Measure Build Run 1 Run 2 Run 3
RTX 2070 Super 8 GB IQ4_NL decode after 302 main 42.5 42.6 42.3
RTX 2070 Super 8 GB IQ4_NL decode after 302 this PR 42.3 42.6 41.7
RTX 2070 Super 8 GB IQ4_NL decode after 8K main 34.8 34.9 34.8
RTX 2070 Super 8 GB IQ4_NL decode after 8K this PR 35.6 35.5 35.5
RTX 2070 Super 8 GB IQ4_NL decode after 32K main 30.4 30.1 30.0
RTX 2070 Super 8 GB IQ4_NL decode after 32K this PR 31.4 31.2 31.1
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 302 main 48.0 48.1 48.1
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 302 this PR 47.6 47.2 47.8
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 8K main 42.7 42.5 38.4
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 8K this PR 42.9 43.0 42.4
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 32K main 35.3 35.4 33.0
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 32K this PR 36.0 35.4 33.7
RX 9070 XT 16 GB IQ4_NL decode after 302 main 52.7 53.2 54.0
RX 9070 XT 16 GB IQ4_NL decode after 302 this PR 53.8 53.2 52.6
RX 9070 XT 16 GB IQ4_NL decode after 8K main 44.6 44.6 44.4
RX 9070 XT 16 GB IQ4_NL decode after 8K this PR 44.8 44.7 44.6
RX 9070 XT 16 GB UD-Q2_K_XL decode after 302 main 60.9 61.3 59.0
RX 9070 XT 16 GB UD-Q2_K_XL decode after 302 this PR 60.8 60.8 59.4
RX 9070 XT 16 GB UD-Q2_K_XL decode after 8K main 57.4 57.9 56.1
RX 9070 XT 16 GB UD-Q2_K_XL decode after 8K this PR 57.6 57.2 55.1

Native Linux IQ4_NL: Run 1, 2, 3 are the chat, code and prose texts.

Card Model Measure Build Run 1 Run 2 Run 3
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 302 main 63.3 61.1 64.6
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 302 this PR 63.5 61.1 64.7
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 2K main 61.9 60.2 63.1
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 2K this PR 62.2 60.4 63.1
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 8K main 59.8 57.9 61.1
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 8K this PR 59.1 56.6 62.7
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 32K main 54.8 52.3 55.5
RX 9070 XT 16 GB (native Linux) IQ4_NL decode after 32K this PR 54.7 51.4 56.8

With the DSpark drafter:

Card Model Measure Build Run 1 Run 2 Run 3
RTX 2070 Super 8 GB IQ4_NL + DSpark decode after 8K main 48.0 49.8 50.2
RTX 2070 Super 8 GB IQ4_NL + DSpark decode after 8K this PR 55.2 54.8 55.3

Why not a fixed --prompt-batch 4096 (RTX 2070 Super, tok/s, mean of 3 runs)

The "fixed 4096" column is main with --prompt-batch 4096, measured in the same session.

Card Model Measure main fixed 4096 Change
RTX 2070 Super 8 GB IQ4_NL prompt 302 221.1 171.4 −22.5%
RTX 2070 Super 8 GB IQ4_NL prompt 8K 591.9 984.8 +66.4%
RTX 2070 Super 8 GB IQ4_NL decode after 8K 34.5 30.3 −12.1%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 302 271.1 210.6 −22.3%
RTX 2070 Super 8 GB UD-Q2_K_XL prompt 8K 605.9 1013.8 +67.3%
RTX 2070 Super 8 GB UD-Q2_K_XL decode after 8K 42.4 39.9 −5.8%
  • Refilling the cache in the background while the answer is written made the first tokens slow. UD-Q2_K_XL
    decode after 8K was 39.7 tok/s that way, against 42.4 on main.
  • Refilling it at once costs about 200 ms before the first token. Decode then matches main (42.7 tok/s).

Related discussion

none. It follows our own measurement: a plain --prompt-batch 2048 read 8K prompts 13-14% faster, but read
302-token prompts 9-17% slower and kept a smaller expert cache.

Approach

  • Only Inkling 2 uses auto. Every other model treats it as 1024, so its code path does not change.
  • CUDA: at load, the prompt's buffers reserve addresses for the widest batch but take VRAM for 1,024 rows, as
    on main. A read maps more of them, plus the window layers' rings and the products' work memory. The VRAM comes
    from free VRAM or the expert cache, at most three quarters of it. end_read() shrinks it all back and refills
    the cache at once.
  • HIP on native Linux: ROCm cannot lend buffers to the cache, so a long read gets one allocation of its own
    (scratch, products' buffers, window rings). alloc()'s buffers stay in place, so recorded launches stay valid.
    ROCm counts freed VRAM a few ms late, so the free figure after the cut adds the bytes given back.
  • Class: placement + batch split. Calls of more tokens split the sums differently, exactly as
    --prompt-batch N does. Nothing is skipped, and at a fixed batch the output is bit-identical to main.
  • Credit: the idea is the user's: scale the batch with the VRAM, per prompt when the experts don't fit. It
    builds on VecSzn's prompt-buffer lending (lend_prompt() / take_prompt()) and the staging-buffer widening in
    main.

Validation

Passed:

  • Identity: frozen cache (STRATA_FREEZE_EXPERTS=1), once mode, 32 tokens, ids and top-20 probabilities byte
    for byte:
    • This PR at --prompt-batch 1024 vs main: SAME on CUDA (RTX 2070), and on ROCm gfx1201 (RX 9070 XT, native
      and WSL2), with and without the DSpark drafter.
    • Auto vs a fixed batch of the size it picks: SAME on CUDA (2048 and 4096, IQ4_NL and UD-Q2_K_XL, with and
      without the drafter) and on HIP (IQ4_NL).
    • Final commit: CUDA 22/22 SAME, native ROCm 13/13 SAME.
  • Accuracy: the bigger batch's KL against 1,024 is the same size as the accepted --prompt-int8 rounding
    change: 0.002-0.13 on 2K texts, 0.000 on 5K-8K texts. Table below.
  • Speed: the tables above. Builds: CUDA sm_75; HIP gfx1201, gfx1100, gfx1200.
  • Review: three independent reviews; all findings fixed.
Accuracy: KL and top-1 of the bigger batch (RTX 2070, frozen)

Accuracy of the bigger batch. Each row: the run at 1,024 is the reference; the other build is fed the reference's
tokens. KL is over the reference's top 20, mean of 32 steps. The int8 column is the accepted --prompt-int8
rounding change, as a control. The cap−10 column caches 10 fewer experts, as a placement control.

Card Model Text Batch KL batch KL int8 KL cap−10 Top-1 same (batch)
RTX 2070 8 GB IQ4_NL text a, 2K 2048 0.104 0.153 0.033 29/32
RTX 2070 8 GB IQ4_NL text b, 2K 2048 0.126 0.324 0.052 31/32
RTX 2070 8 GB IQ4_NL text c, 2K 2048 0.002 0.001 0.0002 32/32
RTX 2070 8 GB IQ4_NL resume, 5K 4096 0.00001 0.00001 0.000 32/32
RTX 2070 8 GB IQ4_NL resume, 7K 4096 0.000 0.00001 0.000 32/32
RTX 2070 8 GB IQ4_NL 8K 4096 0.000 0.000 0.000 32/32

In each 2K text, one step dominates the mean (max 2.0 and 2.9; medians 0.0005 and 0.010). The int8 control shows
the same pattern on these texts.

The same comparison on the default cache (not frozen), this PR against main's default:

  • RTX 2070 8 GB: 2K texts KL 0.001-0.114, top-1 29-32/32; 5K-8K texts KL at most 0.00004, top-1 32/32. main
    against main is SAME.
  • RX 9070 XT, UD-Q2_K_XL (calls of 4,096): 2K texts KL 0.124 and 0.166; 5K and 8K texts at most 0.00001, top-1
    32/32.

Failed: none observed.

Not run:

  • 24-32 GB cards: calls of more than 4,096 tokens (auto, every expert in VRAM) are untested on any card.
  • Windows, Metal, multi-card layer splits, --batch slots: auto uses 1,024 or a one-time pick there by design.
  • 32K with the DSpark drafter on the RTX 2070 Super: main and this PR both stop with "cudaGraphInstantiate: out of
    memory", main's bug that [Engine] Retry instead of failing when a CUDA graph is out of VRAM #301 fixes.

Limits

🤖 Generated with Claude Code

@okada-shogo
okada-shogo marked this pull request as draft November 24, 2026 19:01
… the default)

A prompt read in calls of more tokens is faster, but the calls' buffers come out of the expert cache.  With
--prompt-batch auto (now strata-poly's default; an explicit N works as before, up to 4096) Inkling 2 keeps
1,024-token calls for short prompts and outside reads, and a long read takes calls of up to 4,096 (8,192 on CUDA
where every expert fits in VRAM), out of free VRAM or the expert cache (at most three quarters of it); end_read()
gives it back and refills the cache at once (narrow_rows()).
- CUDA (VMM): widen_rows() maps more of the prompt's buffers (addresses reserved for the widest batch at load), the
  window layers' rings and the products' work memory.  With the DSpark drafter too.
- HIP on native Linux (no lending on ROCm): a read of about 4,000 tokens or more gets buffers and rings of its own
  for calls of 4,096 (2,048 if 4,096 does not fit), freed after it.  The free VRAM after the cut is counted from
  the bytes given back: ROCm counts them a few ms later.  Not under WSL2 (each cut is a remap stall there) or on
  Windows.
- Elsewhere (WSL2, a layer split, batch slots, Metal): one batch for the run, 4,096 where every expert fits.
Other models resolve auto to 1,024; their paths are unchanged.

Class: placement + batch split (a call's tokens change how sums are split, as --prompt-batch N does).  Same bits at a
fixed batch: --prompt-batch 1024 vs main, frozen, SAME on CUDA sm_75 and ROCm gfx1201 (native and WSL2), with and
without the drafter; auto vs a fixed batch of the size it picks, frozen, SAME.

RTX 2070 Super, IQ4_NL / UD-Q2_K_XL, vs main: prompt 2K +13/+33%, 8K +59/+66%, 32K +42/+64%; decode
-1.1..+3.8%; with the DSpark drafter 2K +44%, 8K +55%.  RX 9070 XT native Linux: IQ4_NL 8K +62%, 32K +68%,
UD-Q2_K_XL 2K +42%, 8K +79%, 32K +75%; decode within 1%.

Idea: the user's (scale the batch with the VRAM, per prompt where the experts do not fit).  Builds on VecSzn's
prompt-buffer lending (lend_prompt()/take_prompt()) and staging-buffer widening in main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@okada-shogo
okada-shogo force-pushed the port/prompt-batch-auto branch from 88c2e93 to 0f8a702 Compare November 25, 2026 01:39
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