[GH-ISSUE #4421] [Engine] 0.2.7's PLE residency policy switches on for the Mac once a macOS RAM reading lands (#3541, #3564, #3231) #1969

Closed
opened 2026-11-04 01:55:40 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @oceanio on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4421

What happens
v0.2.7's PLE residency policy (3b34b6c7) keeps the PLE table in RAM when available_host_bytes() says the machine can hold the table, the expert arena and 8 GiB more. On main the Metal engine has no RAM reading (memory guard: the available RAM cannot be read), so the policy never runs on a Mac. Three open PRs add a macOS reading to sample_host_memory() for the memory guard: #3541 (mine), #3564 and #3231. Any one of them also switches the policy on for the Mac.

Measured on an M5 Max (128 GB) with Qwen3.8-Flash-Next IQ3_S, --max-context 262144, --mmap-experts, resident experts. The build was #3541 rebased onto v0.2.7, before I kept the policy off:

  • the log: --ple-io ram chosen by the residency policy (the table is 26.8 GiB, the expert arena still to fill 46.8 GiB and 84.5 GiB of RAM is available);
  • the engine's footprint 5 s after load: 37.45 GiB, against 10.61 GiB with direct reads (v0.2.7's own engine: 16.99);
  • the decode window was ready in 9.0 s instead of 1.9 s;
  • decode speed was about the same (86-97 tok/s on 4 short prompts, against 92-95 with direct reads), and 8 of 8 greedy requests were identical to v0.2.7's.

I did not measure long-prompt prefill on the Mac. That is where the PC gained.

Two things differ on the Mac:

  • With --mmap-experts the experts are not copied into an arena, so the 46.8 GiB in the admission sum is not RAM the engine takes.
  • #3564 and #3231 count inactive pages as available, so with their readings the table is admitted more easily than with #3541's.

Question
Should the policy run on Metal? For now #3541 keeps it off there (allowed = false under STRATA_GPU_METAL, the same as in a build that cannot read the RAM), so the macOS reading serves only the memory guard. If you would rather have it on for the Mac, I can first measure prefill on the M5 Max with the table resident and with direct reads.

Originally created by @oceanio on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4421 **What happens** v0.2.7's PLE residency policy (`3b34b6c7`) keeps the PLE table in RAM when `available_host_bytes()` says the machine can hold the table, the expert arena and 8 GiB more. On main the Metal engine has no RAM reading (`memory guard: the available RAM cannot be read`), so the policy never runs on a Mac. Three open PRs add a macOS reading to `sample_host_memory()` for the memory guard: #3541 (mine), #3564 and #3231. Any one of them also switches the policy on for the Mac. Measured on an M5 Max (128 GB) with Qwen3.8-Flash-Next IQ3_S, `--max-context 262144`, `--mmap-experts`, resident experts. The build was #3541 rebased onto v0.2.7, before I kept the policy off: - the log: `--ple-io ram chosen by the residency policy (the table is 26.8 GiB, the expert arena still to fill 46.8 GiB and 84.5 GiB of RAM is available)`; - the engine's footprint 5 s after load: 37.45 GiB, against 10.61 GiB with direct reads (v0.2.7's own engine: 16.99); - the decode window was ready in 9.0 s instead of 1.9 s; - decode speed was about the same (86-97 tok/s on 4 short prompts, against 92-95 with direct reads), and 8 of 8 greedy requests were identical to v0.2.7's. I did not measure long-prompt prefill on the Mac. That is where the PC gained. Two things differ on the Mac: - With `--mmap-experts` the experts are not copied into an arena, so the 46.8 GiB in the admission sum is not RAM the engine takes. - #3564 and #3231 count inactive pages as available, so with their readings the table is admitted more easily than with #3541's. **Question** Should the policy run on Metal? For now #3541 keeps it off there (`allowed = false` under `STRATA_GPU_METAL`, the same as in a build that cannot read the RAM), so the macOS reading serves only the memory guard. If you would rather have it on for the Mac, I can first measure prefill on the M5 Max with the table resident and with direct reads.
Author
Owner

@oceanio commented on GitHub (Nov 3, 2026):

Thanks: 04e9da60 in v0.2.10 answers the question. The policy stays off on the Mac unless STRATA_PLE_AUTO_RAM=1, and the commit has the prefill measurement I offered (a cold 4K prompt 10.6% slower with the table in RAM).

Checked on v0.2.10 (ffa80d73), which has its own macOS RAM reading. Setup: M5 Max (128 GB), Qwen3.8-Flash-Next IQ3_S, --max-context 262144 --mmap-experts. The engine reads the PLE table directly: the log has PLE direct read probe: ... (fine) and no residency-policy line. Its footprint 5 s after load is 16.99 GiB, as on v0.2.9; with the policy on, it was 37.45 GiB (above).

Closing.

<!-- gh-comment-id:6596329887 --> @oceanio commented on GitHub (Nov 3, 2026): Thanks: 04e9da60 in v0.2.10 answers the question. The policy stays off on the Mac unless `STRATA_PLE_AUTO_RAM=1`, and the commit has the prefill measurement I offered (a cold 4K prompt 10.6% slower with the table in RAM). Checked on v0.2.10 (`ffa80d73`), which has its own macOS RAM reading. Setup: M5 Max (128 GB), Qwen3.8-Flash-Next IQ3_S, `--max-context 262144 --mmap-experts`. The engine reads the PLE table directly: the log has `PLE direct read probe: ... (fine)` and no residency-policy line. Its footprint 5 s after load is 16.99 GiB, as on v0.2.9; with the policy on, it was 37.45 GiB (above). Closing.
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#1969
No description provided.