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.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
Merge pull request #30 from Yamz-Labs/fix/bench-health-proxy
Yaniss Amazouzf31982f065ac
diff --cc tools/bench.pyindex 3a636bb,33848da..887e9c7--- a/tools/bench.py+++ b/tools/bench.py@@@ -30,8 -28,8 +30,9 @@@ import shutiimport statisticsimport subprocessimport sys+import sysconfigimport time+ import urllib.parseimport urllib.requestfrom pathlib import Path@@@ -138,75 -136,34 +139,84 @@@ def ram_gib()return "unknown"- def server_compiler(base):- """(compiler line, warning or None) the server reports on /health (the server root, one level above /v1)."""+ def server_compiler(base, model=None):+ """(compiler line, warning or None) the server reports on /health (the server root, one level above /v1).+ Behind a proxy such as llama-swap the root /health is the proxy's own, so /upstream/<model>/health is tried next."""root = re.sub(r"/v1$", "", base)- try:- h = json.load(urllib.request.urlopen(root + "/health", timeout=10))- except Exception:- return "unknown", None- return h.get("hip_compiler") or "unknown (server does not report it)", h.get("hip_compiler_warning")+ paths = ["/health"] + (["/upstream/" + urllib.parse.quote(model) + "/health"] if model else [])+ answered = False+ for path in paths:+ try:+ h = json.load(urllib.request.urlopen(root + path, timeout=10))+ except Exception:+ continue+ if not isinstance(h, dict):+ continue+ answered = True+ if h.get("hip_compiler"):+ return h["hip_compiler"], h.get("hip_compiler_warning")+ return "unknown (server does not report it)" if answered else "unknown", None-def rocm_version():- for f in ("/opt/rocm/.info/version", "/opt/rocm/.info/version-dev"):- if Path(f).is_file():- return Path(f).read_text().strip()- for cmd in ("rocm-sdk version", "hipconfig --version"):- if shutil.which(cmd.split()[0]):- out = sh(cmd)+ROCM_INFO_FILES = ("/opt/rocm/.info/version", "/opt/rocm/.info/version-dev")+SDK_TREE = "_rocm_sdk_devel" # what the rocm-sdk-devel wheel unpacks into site-packages+++def read_version(f):+ """Contents of a version file, stripped, or an empty string when it is missing, empty or unreadable."""+ try:+ return Path(f).read_text().strip()+ except OSError:+ return ""+++def tool_version(cmd):+ """First line printed by `cmd` (`rocm-sdk version`, `hipconfig --version`), run from PATH or, when PATH+ does not have it, from the bin directory of the running interpreter: a venv installs both there, and a+ shell that did not activate it leaves them out of PATH. Empty string when no copy of the tool runs."""+ tool, _, args = cmd.partition(" ")+ for path in (shutil.which(tool), str(Path(sys.executable).parent / tool)):+ if path and Path(path).is_file():+ out = sh(f"{shlex.quote(path)} {args}")if out:return out.splitlines()[0]+ return ""+++def site_packages():+ """Site-packages directories of the running interpreter, from sysconfig and from sys.path."""+ roots = {sysconfig.get_paths().get(k) for k in ("purelib", "platlib")}+ roots |= {p for p in sys.path if p.endswith("site-packages")}+ return sorted(r for r in roots if r)+++def sdk_trees():+ """Candidate roots of a rocm-sdk devel tree: $EXL3_ROCM_SDK, then the wheel of the running+ interpreter, then $EXL3_VENV. Cheap, never raises, empty when none of them is set."""+ trees = [os.environ.get("EXL3_ROCM_SDK")]+ trees += [str(Path(d) / SDK_TREE) for d in site_packages()]+ venv = os.environ.get("EXL3_VENV")+ if venv:+ trees += [str(p) for p in Path(venv).glob(f"lib/python*/site-packages/{SDK_TREE}")]+ return [t for t in trees if t]+++def rocm_version():+ """ROCm version, from the first source that answers: /opt/rocm, then rocm-sdk and hipconfig, then the+ .info/version of a rocm-sdk devel tree (the pip wheel, which a container has instead of /opt/rocm),+ then the HIP version torch was built against."""+ for f in ROCM_INFO_FILES:+ v = read_version(f)+ if v:+ return v+ for cmd in ("rocm-sdk version", "hipconfig --version"):+ v = tool_version(cmd)+ if v:+ return v+ for tree in sdk_trees():+ v = read_version(Path(tree) / ".info" / "version")+ if v:+ return f"{v} (rocm-sdk)"out = sh(f"{sys.executable} -c 'import torch; print(torch.version.hip or \"\")'")return f"HIP {out} (PyTorch)" if out else "unknown"