okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-151-b70 (c765c5f87) into f-split-int283cde2ca3

main
2.2 KiB52 linesraw
1"""sycl/setup_intel.py: the prompt chunk size setup recommends for an Intel card (--prefill).
2
3A Battlemage card (xe driver, not an A-series) with 24 GB or more and a context over 32K (the prompt borrows cache slots) gets
48192; everything else keeps 4096; a chunk size the user put in the config is kept."""
5import importlib.util
6import sys
7from pathlib import Path
8
9ROOT = Path(__file__).resolve().parent.parent.parent
10sys.path.insert(0, str(ROOT))
11_spec = importlib.util.spec_from_file_location("setup_intel", ROOT / "sycl" / "setup_intel.py")
12si = importlib.util.module_from_spec(_spec)
13_spec.loader.exec_module(si)
14
15B70 = dict(vram_gb=32.0, driver="xe", devid="e223")
16A770 = dict(vram_gb=16.0, driver="xe", devid="56a0")
17A750 = dict(vram_gb=8.0, driver="i915", devid="56a1")
18
19
20def prefill_of(ctx, card, extra=()):
21    cfg = {"args": ["--max-context", str(ctx), "--kv", "int8", "--prefill", "auto", *extra]}
22    out = si.to_sycl(cfg, ROOT / "build-sycl-aot" / "strata", 64.0, {}, **card)
23    return si.flag(out["args"], "--prefill")
24
25
26def test_helper_values():
27    assert si.recommended_prefill(32.0, 131072, "xe", "e223")[0] == 8192
28    assert si.recommended_prefill(32.0, 131072, "xe", "e223")[1]          # a plain line says why
29    assert si.recommended_prefill(24.0, 65536, "xe", "e221")[0] == 8192
30    assert si.recommended_prefill(32.0, 32768, "xe", "e223") == (4096, "")   # own prompt buffers: a bigger chunk costs cache slots
31    assert si.recommended_prefill(16.0, 131072, "xe", "e212")[0] == 4096     # under 24 GB
32    assert si.recommended_prefill(16.0, 131072, "xe", "56a0")[0] == 4096     # Alchemist
33    assert si.recommended_prefill(8.0, 131072, "i915", "56a1")[0] == 4096
34
35
36def test_config_battlemage_long_context():
37    assert prefill_of(131072, B70) == "8192"
38
39
40def test_config_battlemage_32k_keeps_4096():
41    assert prefill_of(32768, B70) == "4096"
42
43
44def test_config_other_cards_unchanged():
45    assert prefill_of(131072, A770) == "4096"
46    assert prefill_of(131072, A750) == "4096"
47
48
49def test_user_pick_is_kept():
50    cfg = {"args": ["--max-context", "131072", "--kv", "int8", "--prefill", "16384"]}
51    out = si.to_sycl(cfg, ROOT / "build-sycl-aot" / "strata", 64.0, {}, **B70)
52    assert si.flag(out["args"], "--prefill") == "16384"