Files
Strata/include/strata/core/reader_room.hpp
T
Niko1221 4c8faae99d engine: keep the picture reader's room in the reserve in the resident RAM mode
In the resident RAM mode (--resident-experts, --resident-budget-gib, which
setup writes for Unsloth's UD-Q4_K_XL below about 71 GB of RAM and for the
low-RAM mode, or the start's own fallback when RAM is short for the arena)
the expert cache refuses the server's VRAM command ("VRAM: not with the
resident low-RAM mode"). With the on-demand reader and only setup's 700 MiB
reserve, the reader then found about 425 MiB free and every picture went to
the processor reader: 7.67 / 6.15 / 1.49 / 1.43 s against 2.06 / 0.93 /
0.41 / 0.37 s with the room held back (l620, IQ3_S, card held to 32 GB,
--resident-budget-gib 40).

The engine knows that mode before it sizes the cache, so there it keeps the
reader's 2,048 MiB in the reserve (strata/core/reader_room.hpp, applied
once after the arena / file pass loop, before the cache is sized; the mode
is not entered later). Only an engine with --vision, --vram-elastic,
--serve and the resident RAM mode changes; a larger reserve is never
lowered. One engine log line says it; no setting, nothing for the user.

Gate on l620 (same setup, 3 starts each, alternating):
- new default with the rule: the reader on the card in 3 of 3 starts
  (1,509 MiB), 12,068 slots, pictures 2.06-2.45 / 0.91-1.08 / 0.39-0.59 /
  0.37-0.55 s, text 1,714-1,722 / 3,867-3,882 tok/s at 2K / 8K;
- old default: the reader on the card in 3 of 3, 12,068 slots, pictures
  2.07-2.37 / 0.91-1.09 / 0.39-0.59 / 0.37-0.55 s, text 1,719-1,740 /
  3,873-3,889 tok/s.
Without the resident mode nothing changes: the same 12,719 slots, the same
answers to the same prompts and pictures, the shrink path as before, the
rule's line absent (one start each, engine before and after).

Test: reader_room_test (ctest; the rule's eight input combinations and the
larger-reserve case).
2026-11-11 17:04:23 +01:00

27 lines
2.0 KiB
C++

#pragma once
// The picture reader's room when the expert cache cannot give it (owner 11-11, item "picture reader on demand, no reserve up front").
//
// On one NVIDIA card the server starts the GPU picture reader with the first picture and asks the engine's expert cache to make the
// reader's room then (`VRAM <reserve>`, --vram-elastic); before the first picture nothing is held back beyond the reserve setup wrote
// (700 MiB). In the resident RAM mode (the RAM copy of the experts the cache does not hold: --resident-experts, --resident-budget-gib,
// or the start's own fallback when RAM is short for the arena) the engine refuses that command ("VRAM: not with the resident low-RAM
// mode"), so the reader would find about 0.4 GiB free and go to the processor (measured on l620, IQ3_S on a card held to 32 GB:
// pictures 1.4-7.7 s on the processor against 0.4-2.1 s on the card). The engine knows that mode before it sizes the cache, so there it
// keeps the reader's room in the reserve, as before the change: the server then finds it free and starts the reader on the card.
// The mode is decided once, at start (the arena / file pass loop); nothing enters it later.
namespace strata::core {
/// The reader's room, the same number as the server's VISION_RESERVE_MIB (serve/server.py) and the reader's elastic_mib.
inline constexpr int kReaderRoomMib = 2048;
/// The VRAM reserve the expert cache is sized with. `vision`: the engine serves pictures (--vision); `vram_elastic`: the cache was
/// asked to give the reader its room on demand (--vram-elastic); `ram_copy_mode`: the resident RAM mode, in which the cache refuses
/// to resize. Only all three together raise the reserve, and never above what was asked when that is larger.
inline int reader_room_reserve_mib(int reserve_mib, bool vision, bool vram_elastic, bool ram_copy_mode) {
if (vision && vram_elastic && ram_copy_mode && reserve_mib < kReaderRoomMib) return kReaderRoomMib;
return reserve_mib;
}
} // namespace strata::core