[GH-ISSUE #4683] [Engine] --prefill auto never picks a chunk above the VRAM pick, so long prompts take about 2x longer; btrfs drive speed falls back to 1.5 GB/s #2139

Open
opened 2026-11-04 01:56:59 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @covenator on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4683

Area: Engine
Terminal (prebuilt engine, CUDA 13)

What happened:

  1. The host prefill plan only searches chunk sizes at or below the VRAM pick (src/program/generate.cpp at v0.2.8: for (int64_t c = chunk; c >= 512; c -= 256) at line 8704). Bare --prefill auto is capped at 8192 (prefill_auto_max = 8192, line 706). So when no chunk fits and "fewest passes win", the planner can never choose a larger chunk, even though a larger one wins. At a 117.7K-token prompt, a run took 108-127 s with --prefill auto and 58-64 s with --prefill auto:32768. At 58.6K tokens it was 43-46 s against 30-36 s.
  2. Minor: on_rotational_disk (line 1431) returns -1 on btrfs, because btrfs gives an anonymous st_dev with no /sys/dev/block/MAJ:MIN entry. drive_read_gbps then falls back to an assumed 1.5 GB/s, while about 4.2 GB/s is measured on the same NVMe. This only affects plan pricing.

Smallest steps or command that reproduce it:
Run the same long prompt (about 58K and about 118K tokens) twice, once with --prefill auto and once with --prefill auto:32768, keeping every other flag the same, and compare the prefill wall time. For part 2, put the model on a btrfs filesystem and read the logged drive speed.

Reproduction status: Reproduced every time (several runs at each size). Timings were measured on 0.1.47. The same code is unchanged in v0.2.8 source but has not been re-timed there.

Strata version: 0.1.47 engine (cuda13), code checked against v0.2.8
Graphics card, memory and system: RTX 3090 24 GB, 64 GB DDR5, Ryzen 9 9950X3D, Ubuntu 25.10, model on btrfs NVMe
Model, size and settings: Qwen3.8-Flash-Next IQ3_S pack, --spec 4 --spec-min-p 0.5; within each A/B pair only --prefill changed

Possibly related #3976 (layer-major prefill on a CUDA layer split), #4493 (the drive is not identified for a model in /dev/shm, which looks like the same st_dev lookup as part 2).

Originally created by @covenator on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4683 Area: Engine Terminal (prebuilt engine, CUDA 13) What happened: 1. The host prefill plan only searches chunk sizes at or below the VRAM pick (src/program/generate.cpp at v0.2.8: `for (int64_t c = chunk; c >= 512; c -= 256)` at line 8704). Bare `--prefill auto` is capped at 8192 (`prefill_auto_max = 8192`, line 706). So when no chunk fits and "fewest passes win", the planner can never choose a larger chunk, even though a larger one wins. At a 117.7K-token prompt, a run took 108-127 s with `--prefill auto` and 58-64 s with `--prefill auto:32768`. At 58.6K tokens it was 43-46 s against 30-36 s. 2. Minor: `on_rotational_disk` (line 1431) returns -1 on btrfs, because btrfs gives an anonymous st_dev with no /sys/dev/block/MAJ:MIN entry. drive_read_gbps then falls back to an assumed 1.5 GB/s, while about 4.2 GB/s is measured on the same NVMe. This only affects plan pricing. Smallest steps or command that reproduce it: Run the same long prompt (about 58K and about 118K tokens) twice, once with `--prefill auto` and once with `--prefill auto:32768`, keeping every other flag the same, and compare the prefill wall time. For part 2, put the model on a btrfs filesystem and read the logged drive speed. Reproduction status: Reproduced every time (several runs at each size). Timings were measured on 0.1.47. The same code is unchanged in v0.2.8 source but has not been re-timed there. Strata version: 0.1.47 engine (cuda13), code checked against v0.2.8 Graphics card, memory and system: RTX 3090 24 GB, 64 GB DDR5, Ryzen 9 9950X3D, Ubuntu 25.10, model on btrfs NVMe Model, size and settings: Qwen3.8-Flash-Next IQ3_S pack, --spec 4 --spec-min-p 0.5; within each A/B pair only --prefill changed Possibly related #3976 (layer-major prefill on a CUDA layer split), #4493 (the drive is not identified for a model in /dev/shm, which looks like the same st_dev lookup as part 2).
Author
Owner

@Niko1221 commented on GitHub (Oct 31, 2026):

We timed this on our own card (P100, 57,788-token prompt, two pairs): --prefill auto 172 s, --prefill auto:32768 164 s, about 5% faster, not 2x. That is a different card and model from yours, so it does not settle your numbers. The 8192 cap is deliberate and auto:32768 is the opt-in. We have not changed anything. Could you post the log lines that say which chunk size each run picked?

<!-- gh-comment-id:6547919574 --> @Niko1221 commented on GitHub (Oct 31, 2026): We timed this on our own card (P100, 57,788-token prompt, two pairs): `--prefill auto` 172 s, `--prefill auto:32768` 164 s, about 5% faster, not 2x. That is a different card and model from yours, so it does not settle your numbers. The 8192 cap is deliberate and `auto:32768` is the opt-in. We have not changed anything. Could you post the log lines that say which chunk size each run picked?
Author
Owner

@covenator commented on GitHub (Oct 31, 2026):

I ran it again this morning to get the log lines.

Setup: RTX 3090 24 GB, 64 GB RAM, Strata 0.1.47 cuda13, IQ3_S pack on btrfs on NVMe, --kv int8 --spec 4 --spec-min-p 0.5 --mmap-experts --max-context 73728. I started the engine fresh for each mode, dropped the GGUF from page cache before starting, and sent two ~58.6K prompts. 0 tokens reused on all four.

With --prefill auto:

strata: prefill plan: chunk 8192, ring 96 kept: file set 34.0 GiB does not fit the page cache 26.7 GiB -> about 140.7 GB read from the drive per 32768-token prompt (4 chunks); no option does better (the set cannot fit: fewest passes win)
strata: prefill plan inputs: 46.8 GiB experts, 16.6 GiB in the GPU caches, 0.0 GiB RAM copy (0 lend slots kept), file tier 30.2 GiB; 26.7 GiB available for the page cache; PCIe 13.4 GB/s; drive 1.50 GB/s (assumed); a 32768-token prompt

With --prefill auto:32768:

strata: prefill plan: chunk 32768, ring 96 kept: file set 43.0 GiB does not fit the page cache 26.9 GiB -> about 46.2 GB read from the drive per 32768-token prompt (1 chunks); no option does better (the set cannot fit: fewest passes win)
strata: prefill plan inputs: 46.8 GiB experts, 16.6 GiB in the GPU caches, 0.0 GiB RAM copy (0 lend slots kept), file tier 30.2 GiB; 26.9 GiB available for the page cache; PCIe 13.4 GB/s; drive 1.50 GB/s (assumed); a 32768-token prompt
mode prompt tokens prefill read from drive
auto 58652 60.1 s 313.5 GB
auto 58640 59.5 s 221.9 GB
auto:32768 58642 31.7 s 117.7 GB
auto:32768 58652 29.9 s 79.1 GB

Times are from the prompt N tokens = 0 reused + N read in X ms line, drive reads from the OS read X MB from storage. The second prompt in each pair ran without clearing the cache, so it reads a bit less.

So on this box auto:32768 is about 2x faster. A few things I noticed:

  • Plain auto picks 8192 and says "no option does better" at 140.7 GB, but with auto:32768 the planner itself estimates 46.2 GB for the same prompt. Looks like bare auto never tries chunks above 8192.
  • Both runs say drive 1.50 GB/s (assumed). The pack is on btrfs, so stat gives st_dev 0:29 and /sys/dev/block/0:29 doesn't exist. I think it can't find the NVMe and uses the default. The real speed is much higher (117.7 GB read during a 31.7 s prefill).
  • On your P100 the gap may be small if the file set fits in your page cache, or if the drive is the bottleneck in both modes. The plan lines from your two runs would tell.
<!-- gh-comment-id:6550291859 --> @covenator commented on GitHub (Oct 31, 2026): I ran it again this morning to get the log lines. Setup: RTX 3090 24 GB, 64 GB RAM, Strata 0.1.47 cuda13, IQ3_S pack on btrfs on NVMe, `--kv int8 --spec 4 --spec-min-p 0.5 --mmap-experts --max-context 73728`. I started the engine fresh for each mode, dropped the GGUF from page cache before starting, and sent two ~58.6K prompts. 0 tokens reused on all four. With `--prefill auto`: ``` strata: prefill plan: chunk 8192, ring 96 kept: file set 34.0 GiB does not fit the page cache 26.7 GiB -> about 140.7 GB read from the drive per 32768-token prompt (4 chunks); no option does better (the set cannot fit: fewest passes win) strata: prefill plan inputs: 46.8 GiB experts, 16.6 GiB in the GPU caches, 0.0 GiB RAM copy (0 lend slots kept), file tier 30.2 GiB; 26.7 GiB available for the page cache; PCIe 13.4 GB/s; drive 1.50 GB/s (assumed); a 32768-token prompt ``` With `--prefill auto:32768`: ``` strata: prefill plan: chunk 32768, ring 96 kept: file set 43.0 GiB does not fit the page cache 26.9 GiB -> about 46.2 GB read from the drive per 32768-token prompt (1 chunks); no option does better (the set cannot fit: fewest passes win) strata: prefill plan inputs: 46.8 GiB experts, 16.6 GiB in the GPU caches, 0.0 GiB RAM copy (0 lend slots kept), file tier 30.2 GiB; 26.9 GiB available for the page cache; PCIe 13.4 GB/s; drive 1.50 GB/s (assumed); a 32768-token prompt ``` | mode | prompt tokens | prefill | read from drive | |---|---|---|---| | auto | 58652 | 60.1 s | 313.5 GB | | auto | 58640 | 59.5 s | 221.9 GB | | auto:32768 | 58642 | 31.7 s | 117.7 GB | | auto:32768 | 58652 | 29.9 s | 79.1 GB | Times are from the `prompt N tokens = 0 reused + N read in X ms` line, drive reads from `the OS read X MB from storage`. The second prompt in each pair ran without clearing the cache, so it reads a bit less. So on this box auto:32768 is about 2x faster. A few things I noticed: - Plain auto picks 8192 and says "no option does better" at 140.7 GB, but with auto:32768 the planner itself estimates 46.2 GB for the same prompt. Looks like bare auto never tries chunks above 8192. - Both runs say `drive 1.50 GB/s (assumed)`. The pack is on btrfs, so stat gives st_dev 0:29 and /sys/dev/block/0:29 doesn't exist. I think it can't find the NVMe and uses the default. The real speed is much higher (117.7 GB read during a 31.7 s prefill). - On your P100 the gap may be small if the file set fits in your page cache, or if the drive is the bottleneck in both modes. The plan lines from your two runs would tell.
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#2139
No description provided.