Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

autotune: device signature from torch.version.hip (CUDA exposes gcnArchName as the device name), ship only dense-tune lines beyond the seed

YanissAmz644467fb59ed
diff --git a/exllamav3/util/tune_cache.py b/exllamav3/util/tune_cache.py
index 4d39cf1..e2e0e07 100644
--- a/exllamav3/util/tune_cache.py
+++ b/exllamav3/util/tune_cache.py
@@ -76,7 +76,7 @@ def signature(device: int | None = None) -> dict:
import torch
d = torch.cuda.current_device() if device is None else device
pr = torch.cuda.get_device_properties(d)
- arch = getattr(pr, "gcnArchName", None)
+ arch = getattr(pr, "gcnArchName", None) if torch.version.hip else None # CUDA builds expose the attribute too (device name)
cc = arch.split(":")[0] if arch else f"sm{pr.major}{pr.minor}"
slug = re.sub(r"[^a-z0-9]+", "-", pr.name.lower()).strip("-")
return dict(name=pr.name, cc=cc, sms=pr.multi_processor_count, device_index=d,
diff --git a/tools/qualify/stages.py b/tools/qualify/stages.py
index dae1815..7600bbd 100644
--- a/tools/qualify/stages.py
+++ b/tools/qualify/stages.py
@@ -128,9 +128,9 @@ def job_autotune(c: Ctx) -> dict:
if not recs:
raise RuntimeError("autotune: the replay produced no tuning records (does this build have the GEMM autotuner?)")
tdir.mkdir(exist_ok=True)
- dense = scratch / "dense_gemm_tune.txt"
- if dense.is_file() and dense.stat().st_size:
- shutil.copy(dense, tdir / f"{sig['file']}.dense.txt")
+ dense_new = _new_dense_lines(scratch / "dense_gemm_tune.txt", Path(__file__).resolve().parents[2] / "exllamav3/model/dense_gemm_tune_seed.txt")
+ if dense_new: # lines the shipped seed did not hold (serve start copies the seed into the scratch file)
+ (tdir / f"{sig['file']}.dense.txt").write_text("\n".join(dense_new) + "\n")
tc.write_records(tdir / f"{sig['file']}.bin", recs)
man = dict(schema=1, signature=sig, records=len(recs), records_at_load=at_load, load_s=round(load_s, 1), wall_s=round(time.time() - t0, 1),
sessions=sessions, ctx=ctx, sweep=sweep, cmd=argv, engine_git=_git(c.repo), pack_index_sha=c.meta.get("index_sha"))
@@ -140,6 +140,14 @@ def job_autotune(c: Ctx) -> dict:
plan_points=len(sweep), wall_s=man["wall_s"], sweep_failed=[s for s in sweep if not s["ok"]])
+def _new_dense_lines(tuned: Path, seed: Path) -> list:
+ key = lambda ln: tuple(ln.split()[:6])
+ have = {key(l) for l in seed.read_text().splitlines() if len(l.split()) == 7} if seed.is_file() else set()
+ if not tuned.is_file():
+ return []
+ return [l for l in tuned.read_text().splitlines() if len(l.split()) == 7 and key(l) not in have]
+
+
def _git(repo) -> str | None:
try:
return subprocess.run(["git", "-C", str(repo), "rev-parse", "--short", "HEAD"], capture_output=True, text=True, timeout=10).stdout.strip() or None
diff --git a/tools/qualify/tests/test_autotune.py b/tools/qualify/tests/test_autotune.py
index c63278a..4d4a2a6 100644
--- a/tools/qualify/tests/test_autotune.py
+++ b/tools/qualify/tests/test_autotune.py
@@ -152,3 +152,14 @@ class TestPlan(unittest.TestCase):
for be, want in (("cuda", "todo"), ("rocm", "todo"), ("mlx", "skip")):
st = {s.name: s for s in planmod.build_plan(meta, dict(backend=be, sessions=[1]), {})}
self.assertEqual(st["autotune"].status, want, be)
+
+
+class TestDenseNew(unittest.TestCase):
+ def test_only_lines_beyond_the_seed(self):
+ import stages
+ with tempfile.TemporaryDirectory() as d:
+ d = Path(d)
+ (d / "seed.txt").write_text("a 1 2 3 4 5 9\n")
+ (d / "t.txt").write_text("a 1 2 3 4 5 9\nb 1 2 3 4 5 8\n")
+ self.assertEqual(stages._new_dense_lines(d / "t.txt", d / "seed.txt"), ["b 1 2 3 4 5 8"])
+ self.assertEqual(stages._new_dense_lines(d / "none.txt", d / "seed.txt"), [])