[PR #2911] [Engine] prefill: a fixed --prefill above 65280 tokens is capped, 65536 stopped the engine at the first longer prompt (#2743) #4329

Open
opened 2026-11-07 15:34:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2911
Author: @ischencheng
Created: 10/17/2026
Status: 🔄 Open

Base: main ← Head: fix/prefill-chunk-cap


📝 Commits (1)

  • 7281c11 prefill: a fixed --prefill above 65280 tokens is capped, 65536 stopped the engine at the first longer prompt (#2743)

📊 Changes

1 file changed (+9 additions, -0 deletions)

View changed files

📝 src/program/generate.cpp (+9 -0)

📄 Description

Problem and result

With a fixed --prefill 65536, the first prompt longer than 65536 tokens stops the engine with iq_embed_rows: invalid argument (#2743). The token embedding launches one grid row per token of the chunk, and a grid's y is at most 65535. It still happens on 0.2.1.3.

With this change a named chunk above 65280 (the largest multiple of 256 under the limit) is read as 65280, with one line at start. The same prompt is then read instead of ending the engine. --prefill auto (at most 32768) and every named chunk up to 65280 are unchanged.

#2743. This is #2911 after the 0.2.0-beta reset. The commit still applies to main without a rebase.

Approach

One cap where --prefill is parsed (src/program/generate.cpp, +9 lines).

Reading the code I found two launches with one grid row per token: iq_embed_rows and gdn_l2_kernel in gdn_conv. Tiling just those two also worked on IQ2_XS. But other packs and the layer split reach more per-token launches that I cannot test, so one cap covers them all. 65280 and 65536 read at the same speed.

SYCL has its own generate.cpp and is not changed.

Validation

Passed:

  • cbfd5b92 (0.2.1.3, engine 0.1.46.2), Linux, one L40S 46 GB (sm_89), driver 610.57.04, IQ2_XS native pack, --max-context 131072 --kv int8. Each start: a short chat, then the same 70,433-token word list with two codes (one in each 65280-token chunk), then the short chat again.
engine --prefill 70K prompt reply
main 65536 engine exit 1, iq_embed_rows: invalid argument, HTTP 503 -
main 65280 4400 tok/s BLUE-4417, RED-9052
this PR (run 1) 65536, read as 65280 4363 tok/s BLUE-4417, RED-9052
this PR (run 2) 65536, read as 65280 4415 tok/s BLUE-4417, RED-9052

With this PR at 65536 the engine lends the same 21242 slots as main at 65280, and the short replies, the long reply and the drafts accepted (8 of 15) are the same. Speeds are single runs.

  • HIP: src/program/generate.cpp of cbfd5b92 compiles for gfx1201 (ROCm 7.0 image, CPU-only container), on main and with this PR, 131 warnings each.

Failed: none observed.

Not run: Windows; the reporter's NVFP4 pack; a HIP card; a layer split; the Metal build (it compiles the same generate.cpp; I did not set up metal-cpp); SYCL (its own copy, not changed); Qwen3.6 (strata-q36, a separate program).

Limits

A prompt chunk is now at most 65280 tokens. The per-token grid launches themselves are left as they are.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2911 **Author:** [@ischencheng](https://github.com/ischencheng) **Created:** 10/17/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/prefill-chunk-cap` --- ### 📝 Commits (1) - [`7281c11`](https://github.com/Niko1221/Strata/commit/7281c11a2ed00b3542f111b13b4734dc40c7f2fa) prefill: a fixed --prefill above 65280 tokens is capped, 65536 stopped the engine at the first longer prompt (#2743) ### 📊 Changes **1 file changed** (+9 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/program/generate.cpp` (+9 -0) </details> ### 📄 Description ## Problem and result With a fixed `--prefill 65536`, the first prompt longer than 65536 tokens stops the engine with `iq_embed_rows: invalid argument` (#2743). The token embedding launches one grid row per token of the chunk, and a grid's y is at most 65535. It still happens on 0.2.1.3. With this change a named chunk above 65280 (the largest multiple of 256 under the limit) is read as 65280, with one line at start. The same prompt is then read instead of ending the engine. `--prefill auto` (at most 32768) and every named chunk up to 65280 are unchanged. ## Related discussion #2743. This is #2911 after the 0.2.0-beta reset. The commit still applies to `main` without a rebase. ## Approach One cap where `--prefill` is parsed (`src/program/generate.cpp`, +9 lines). Reading the code I found two launches with one grid row per token: `iq_embed_rows` and `gdn_l2_kernel` in `gdn_conv`. Tiling just those two also worked on IQ2_XS. But other packs and the layer split reach more per-token launches that I cannot test, so one cap covers them all. 65280 and 65536 read at the same speed. SYCL has its own `generate.cpp` and is not changed. ## Validation **Passed:** - `cbfd5b92` (0.2.1.3, engine 0.1.46.2), Linux, one L40S 46 GB (sm_89), driver 610.57.04, IQ2_XS native pack, `--max-context 131072 --kv int8`. Each start: a short chat, then the same 70,433-token word list with two codes (one in each 65280-token chunk), then the short chat again. | engine | `--prefill` | 70K prompt | reply | |---|---|---|---| | main | 65536 | engine exit 1, `iq_embed_rows: invalid argument`, HTTP 503 | - | | main | 65280 | 4400 tok/s | `BLUE-4417, RED-9052` | | this PR (run 1) | 65536, read as 65280 | 4363 tok/s | `BLUE-4417, RED-9052` | | this PR (run 2) | 65536, read as 65280 | 4415 tok/s | `BLUE-4417, RED-9052` | With this PR at 65536 the engine lends the same 21242 slots as main at 65280, and the short replies, the long reply and the drafts accepted (8 of 15) are the same. Speeds are single runs. - HIP: `src/program/generate.cpp` of `cbfd5b92` compiles for gfx1201 (ROCm 7.0 image, CPU-only container), on main and with this PR, 131 warnings each. **Failed:** none observed. **Not run:** Windows; the reporter's NVFP4 pack; a HIP card; a layer split; the Metal build (it compiles the same `generate.cpp`; I did not set up metal-cpp); SYCL (its own copy, not changed); Qwen3.6 (`strata-q36`, a separate program). ## Limits A prompt chunk is now at most 65280 tokens. The per-token grid launches themselves are left as they are. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4329
No description provided.