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.

depth_profile: hash the written cache pages for the prefill arm exactness probe

YanissAmz40e778a64140
diff --git a/tools/depth/depth_profile.py b/tools/depth/depth_profile.py
index 16c3ab7..d30222f 100755
--- a/tools/depth/depth_profile.py
+++ b/tools/depth/depth_profile.py
@@ -60,7 +60,7 @@ def _main():
ap.add_argument("--ndt-list", default="", help="draft depths to scan in ONE load, interleaved per --reps visit (e.g. 3,4,5,6 = verify rows 4..7); overrides --ndt")
ap.add_argument("--arm", action="append", default=[], help="NAME:K=V,K2=V2 (repeatable): A/B arms of exllamav3.util.knobs switched in this ONE load")
ap.add_argument("--order", default="", help="visit order of the arms, e.g. ABBAAB (default: each arm once, in the order given)")
- ap.add_argument("--arm-eq", action="store_true", help="prefill arms: after each visit run one decode step and md5 its logits (end-to-end bit-identity of that arm's prefill)")
+ ap.add_argument("--arm-eq", action="store_true", help="prefill arms: after each visit md5 the cache pages the chunk wrote (bit-identity of that arm's prefill)")
args = ap.parse_args()
arms = {}
for spec in args.arm:
@@ -267,8 +267,19 @@ def _main():
fwd(chunk_ids, d, prefill=True)
torch.cuda.synchronize(); pacc[(a, d)].append(time.perf_counter() - t)
print(f"[pf] visit {n} arm {a} depth {d}: {1e3 * pacc[(a, d)][-1]:.0f} ms/chunk", flush=True)
- if args.arm_eq: # prefill output is None; the follow-up token reads what the prefill wrote
- eqh = hashlib.md5(fwd(one, d + args.chunk)[0, -1].float().cpu().numpy().tobytes()).hexdigest()[:12]
+ if args.arm_eq: # model.prefill returns None: its only output is the cache pages it wrote
+ p0, p1 = d // PAGE, (d + args.chunk) // PAGE
+ hh = hashlib.md5()
+ for layer in cache.layers.values():
+ shp = getattr(layer, "shape", None)
+ if not shp:
+ continue
+ for name, v in vars(layer).items():
+ if name.startswith("_") or not (isinstance(v, torch.Tensor) and v.is_cuda and
+ v.dim() >= 2 and v.shape[0] == shp[0]):
+ continue
+ hh.update(v[p0:p1].float().contiguous().cpu().numpy().tobytes())
+ eqh = hh.hexdigest()[:12]
RES["points"][str(d)].setdefault("prefill_eq_" + a, {}).setdefault("md5", []).append(eqh)
print(f"[pfeq] visit {n} arm {a} depth {d}: {eqh}", flush=True)
if args.kernels and n < len(arms): # one traced chunk per arm per depth