file tier: unbuffered reads on Linux too (O_DIRECT + the kernel's asynchronous reads)
through the page cache, as page faults of the mapped GGUF - small requests on the critical path, and pages that a 32 GB PC cannot keep beside a 16 GiB RAM copy anyway, so they were read again and again. - open_direct opens the files with O_DIRECT; read_direct queues every 4 KiB-aligned window of a batch with one io_submit (linux/aio_abi.h, no library; allowed by Docker's default seccomp profile, unlike io_uring) and waits for all of them, each thread with its own context and aligned buffer. Windows merges windows up to 1 MiB apart for NTFS; here only windows that touch are merged. A refused submit or a failed read falls back to the mapping, as on Windows. - The same decision as Windows' `cache_counts = false` arm: unbuffered when the file cache could not keep the expert bytes outside the RAM copy (platform::file_cache_keeps, from MemAvailable and the tightest cgroup limit), re-checked once the copy is built (#577). STRATA_UNBUFFERED_LOAD=1 / 0 forces it either way. A pack's experts.bin works too (its Linux open now records the path). - direct_fallbacks() counts the blobs an unbuffered read could not deliver. - Tests: file_expert_source_test reads a synthetic pack unbuffered - one blob at a time, a batch of adjacent experts, copy_blob - and requires the file's bytes and no fallback (a mutation that fails every read is caught). ctest: 63 of 66 pass; the three others need a Q2_0 pack, a higher `ulimit -l` and AVX-512, as before. Measured on an RTX 3080 Ti Laptop 16 GB, i9-12900H, 30 GB RAM, KIOXIA PCIe 4 NVMe, Linux 7.0, ext4: Qwen3.8-Flash-Next Abliterated Q4_K_M in place (--native), --resident-budget-gib 16, --expert-cache auto, 8K context, greedy; three prompts (code, Russian prose, a 7.8K-token summary), each with and without MTP, two rounds of buffered (STRATA_UNBUFFERED_LOAD=0) against unbuffered, the same binary. Decode 4.38 -> 7.90 tok/s on average (x1.80; x1.49-x2.01 per prompt and mode), the 7.8K prompt read at 154/172 -> 184/290 tok/s, startup 36 -> 18-21 s. The code prompt's answer is the same text in all 16 runs; the other two differ between runs of either arm (the adaptive GPU cache changes which experts the CPU computes), as before.
This commit is contained in:
1 parent
760c775434
commit
2d929a28b3
4 files changed
+303
-19
No files matched your search
@@ -4955,9 +4955,9 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
// #577: the unbuffered choice above was made before the RAM copy existed, from the budget asked for; now the
|
||||
// copy is built, decide again from the RAM it really holds and the expert bytes outside it (on a 96 GB PC
|
||||
// the file cache keeps those, and every refill after a prompt read the drive instead). Windows only: the
|
||||
// unbuffered reads exist there alone
|
||||
#if defined(_WIN32)
|
||||
// the file cache keeps those, and every refill after a prompt read the drive instead). Windows and Linux: the
|
||||
// unbuffered reads exist there
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
if (o.mmap_experts && o.resident_budget > 0) {
|
||||
std::string why;
|
||||
const bool was = src.unbuffered();
|
||||
|
||||
Reference in new issue
Block a user