mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
A Models-page Load on a unified-memory chip (Strix Halo) keeps the reserve setup wrote, as strata launch does
QAGUI-STRIX 11-09: the app's resource profiles rewrote setup's --vram-reserve-mib 700 to 1024 (2048 with pictures): the display-card floor (#2065, a card whose driver pages its memory to RAM) was applied to a chip whose memory is the RAM. On a uma card the reserve is now the one setup wrote (the profile baseline), on both profiles and with pictures on or off; none when setup wrote none (the engine's default). --pool-workers stays with "Leave room for my work". tests/snapshot/test_strix_app_reserve.py: the Models-screen Load (work and performance) and strata launch start the same engine line on Windows Strix Halo from setup's config, apart from --pool-workers. app_driver.mjs takes STRATA_SNAPSHOT_APP_ARGS for it (goldens unchanged).
This commit is contained in:
1 parent
731b40fedc
commit
ecccc359dd
4 files changed
+107
-4
No files matched your search
@@ -36,6 +36,11 @@ export function defaultReserves(config,hardware,baselineReserve=0){
|
||||
/* A card that shares the PC's memory (Strix Halo, other APUs) has no memory of its own to keep a fifth of: that fifth is RAM, and "Leave 20% for my work" already keeps it
|
||||
* through the RAM budget. A fifth of the shared pool here held back 16 GB of expert cache for nothing (#3510); the display floor stays. */
|
||||
const shared=placed.length>0&&placed.some(g=>g.uma===true||g.unified===true);
|
||||
/* A chip that shares the PC's memory has no memory of its own for the driver to page out of (#2065 is a display card's), so the display floor and the
|
||||
* pictures floor have no reason there: the reserve is the one setup wrote into the run config (Windows Strix Halo: 700, strata_control/setup_config.py
|
||||
* UMA_WIN_RESERVE_MIB, pictures on or off), on both profiles. Setup wrote none (Linux): none, the engine's own default. A Models-page Load used to make it
|
||||
* 1024, 2048 with pictures, and the Terminal started the same model with 700 (QAGUI-STRIX 11-09). null = keep no --vram-reserve-mib. */
|
||||
if(shared)return {work:baselineReserve>0?baselineReserve:null,performance:baselineReserve>0?baselineReserve:null};
|
||||
/* "work" keeps a fifth of the card, but on a card of 16 GB or less no more than 1536 MiB: a fifth of 12 GB (2457) cost 20% of the speed against 1536, which already leaves 1.1 GiB of VRAM free after the load (RTX 5070, Gyro-S 64K, 5 pairs; notes-023-tune.md). */
|
||||
const fifth=gpuMemory.length?Math.floor(Math.min(...gpuMemory)*1024*.2):0,cap=gpuMemory.length&&Math.min(...gpuMemory)<=16?1536:Infinity;
|
||||
return {work:gpuMemory.length&&!headless&&!shared?Math.max(safety,Math.min(fifth,cap)):safety,performance:safety};
|
||||
@@ -75,7 +80,7 @@ export function resourceSettings(config,hardware,profile,model={},values={}){
|
||||
// Preserve calibrated worker counts and the installation's safety/vision reserve.
|
||||
/* A reserve the person set is theirs, 0 included: no floor and no share of the card (#3215 #3270). Without one the card gets the safety default (defaultReserves). */
|
||||
const reserve=asked!==null?asked:defaults[profile];
|
||||
remove('--vram-reserve-mib');args.push('--vram-reserve-mib',String(reserve));
|
||||
remove('--vram-reserve-mib');if(reserve!==null)args.push('--vram-reserve-mib',String(reserve));
|
||||
// RAM: "leave 20% for my work". An engine that knows the setting (RAM_KEEP_MIN_ENGINE and newer) is asked to keep W GiB of the RAM free, W = ramKeepGib(RAM), as the env STRATA_RAM_KEEP_GIB: it decides from
|
||||
// the RAM that is free at its start, not from the PC's total, using the full RAM copy of the experts (the arena) only if W GiB stay free after it and otherwise keeping the hottest experts in a RAM copy
|
||||
// that leaves max(W, its own safety headroom) free. An env variable and not the flag --ram-keep-gib, so that an engine without the setting never meets an argument it does not know. The engine in use
|
||||
@@ -99,7 +104,7 @@ export function resourceSettings(config,hardware,profile,model={},values={}){
|
||||
if(!(env??config.env)?.STRATA_RESIDENT_HEADROOM_GIB){env={...(env??config.env??{}),STRATA_RESIDENT_HEADROOM_GIB:String(Math.ceil(ram*.2))};ramHeadroom=true;}
|
||||
}
|
||||
}
|
||||
return {args,vram_reserve_mib:reserve,...(asked!==null?{}:{ui_reserve_applied:reserve}),...(env?{env}:{}),ui_resource_baseline:{...baseline,ramBudget,ramHeadroom,ramKeep}};
|
||||
return {args,vram_reserve_mib:reserve??undefined,...(asked!==null?{}:{ui_reserve_applied:reserve??undefined}),...(env?{env}:{}),ui_resource_baseline:{...baseline,ramBudget,ramHeadroom,ramKeep}};
|
||||
}
|
||||
|
||||
/** The RAM, in GiB, "Leave 20% for my work" asks the engine to keep free: a fifth of the PC's RAM rounded up, never under 5 or over 8
|
||||
|
||||
@@ -199,7 +199,7 @@ test('a card that shares the PC memory does not hold back a fifth of the shared
|
||||
const original={gpu:0,args:['--max-context','131072','--pool-workers','10'],vision:{gpu:true}};
|
||||
const shared={cpu:{cores:16},ram_gb:128,gpus:[{index:0,vram_gb:82,uma:true,name:'AMD Radeon 8060S'}]};
|
||||
const apu=resourceSettings(original,shared,'work');
|
||||
assert.equal(apu.vram_reserve_mib,2048,'the display floor with pictures, not 20% of 82 GB (16 GB)');
|
||||
assert.equal(apu.vram_reserve_mib,undefined,'not 20% of 82 GB (16 GB); and since 0.2.14 no app floor either: setup wrote none, so none (tests/strix-reserve-app.test.mjs)');assert.equal(apu.args.includes('--vram-reserve-mib'),false);
|
||||
const discrete=resourceSettings(original,{cpu:{cores:16},ram_gb:128,gpus:[{index:0,vram_gb:82,name:'a card'}]},'work');
|
||||
assert.equal(discrete.vram_reserve_mib,Math.floor(82*1024*.2),'a card with its own memory keeps its fifth');
|
||||
});
|
||||
|
||||
@@ -96,7 +96,9 @@ try {
|
||||
native.state();
|
||||
for (let i = 0; i < 100 && !probe; i++) await new Promise(r => setTimeout(r, 20)); // the host asks once, at its first state; the Load must start after the answer
|
||||
if (probe) { await probe.catch(() => {}); await new Promise(r => setTimeout(r, 100)); }
|
||||
const args = which === 'models' ? { model: tag, values: { drafting: 'auto' } } : { model: tag };
|
||||
// STRATA_SNAPSHOT_APP_ARGS (JSON): more of what the Models screen passes (resourceProfile, vision), for the tests that need it; the golden runs leave it unset
|
||||
const extra = process.env.STRATA_SNAPSHOT_APP_ARGS ? JSON.parse(process.env.STRATA_SNAPSHOT_APP_ARGS) : {};
|
||||
const args = { ...(which === 'models' ? { model: tag, values: { drafting: 'auto' } } : { model: tag }), ...extra };
|
||||
const job = await until(native.operation('load', args));
|
||||
if (job.state !== 'done') { console.error('Load ended in state ' + job.state + ': ' + (job.error ?? '')); exitCode = 3; }
|
||||
const fetchLog = join(root, 'shim-fetches.jsonl');
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
"""QAGUI-STRIX 11-09 (APP-WIN item 3): on Windows Strix Halo the app's Models-screen Load rewrote the reserve setup wrote (700) to 1024, 2048 with pictures,
|
||||
while `strata launch` started the same model with 700. The app's Load ("Leave room for my work" and "Full performance", what the Models screen passes)
|
||||
now starts the engine as `strata launch` does, from the run config setup writes; the only difference allowed is the work profile's --pool-workers (the
|
||||
profile's meaning) and the variables it sets (allowlist.ENV_BY_DESIGN, STRATA_RAM_KEEP_GIB).
|
||||
|
||||
python -m pytest tests/snapshot/test_strix_app_reserve.py -q (needs Node, as the app entries of the snapshot do)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from tests.snapshot.driver import drive, drive_app, drive_launch # noqa: E402
|
||||
from tests.snapshot.matrix import machine, model_set # noqa: E402
|
||||
from tests.snapshot.world import World # noqa: E402
|
||||
|
||||
NODE = os.environ.get("STRATA_SNAPSHOT_NODE") or shutil.which("node")
|
||||
|
||||
|
||||
def flag(argv: list[str], name: str):
|
||||
return argv[argv.index(name) + 1] if name in argv else None
|
||||
|
||||
|
||||
def without(argv: list[str], name: str) -> list[str]:
|
||||
out, skip = [], False
|
||||
for a in argv:
|
||||
if skip:
|
||||
skip = False
|
||||
continue
|
||||
if a == name:
|
||||
skip = True
|
||||
continue
|
||||
out.append(a)
|
||||
return out
|
||||
|
||||
|
||||
def setup_reserve(model: str) -> str:
|
||||
"""The reserve setup itself writes on this class (strata_control/setup_config.py, driven by the snapshot's setup entry)."""
|
||||
args = drive("strix_halo_win", model, "setup")["config_file"]["args"]
|
||||
return flag(args, "--vram-reserve-mib")
|
||||
|
||||
|
||||
def world_with_setup_reserve(model: str, reserve: str) -> World:
|
||||
world = World(machine("strix_halo_win"), model_set(model)).build()
|
||||
cfg = json.loads(world.config_path.read_text(encoding="utf-8"))
|
||||
if "--vram-reserve-mib" not in cfg["args"]:
|
||||
cfg["args"] += ["--vram-reserve-mib", reserve]
|
||||
world.config_path.write_text(json.dumps(cfg, indent=1), encoding="utf-8")
|
||||
return world
|
||||
|
||||
|
||||
@unittest.skipIf(not NODE, "no Node: the app's Load runs in Node")
|
||||
class StrixAppReserve(unittest.TestCase):
|
||||
maxDiff = None
|
||||
|
||||
def engine(self, model: str, reserve: str, entry: str, app_args: dict | None = None) -> dict:
|
||||
world = world_with_setup_reserve(model, reserve)
|
||||
try:
|
||||
if entry == "launch":
|
||||
with world.patched():
|
||||
rec = drive_launch(world)
|
||||
else:
|
||||
with mock.patch.dict(os.environ, {"STRATA_SNAPSHOT_APP_ARGS": json.dumps(app_args or {})}):
|
||||
rec = drive_app(world, "models")
|
||||
self.assertNotIn("failed", rec, json.dumps(rec.get("failed")))
|
||||
return rec["engine"]
|
||||
finally:
|
||||
world.close()
|
||||
|
||||
def test_the_models_screen_load_keeps_setups_reserve_and_starts_as_launch_does(self):
|
||||
for model in ("ud_q4_k_xl", "iq3_s"):
|
||||
reserve = setup_reserve(model)
|
||||
self.assertEqual(reserve, "700", "setup's own reserve on Windows Strix Halo")
|
||||
launch = self.engine(model, reserve, "launch")
|
||||
self.assertEqual(flag(launch["argv"], "--vram-reserve-mib"), "700")
|
||||
for profile in ("work", "performance"):
|
||||
with self.subTest(model=model, profile=profile):
|
||||
app = self.engine(model, reserve, "app", {"resourceProfile": profile, "vision": "no", "values": {"drafting": "auto"}})
|
||||
self.assertEqual(flag(app["argv"], "--vram-reserve-mib"), "700", "the app keeps what setup wrote (it wrote 1024)")
|
||||
self.assertEqual(without(app["argv"], "--pool-workers"), without(launch["argv"], "--pool-workers"), "the same engine line")
|
||||
if profile == "performance":
|
||||
self.assertIsNone(flag(app["argv"], "--pool-workers"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user