Upload 24 files
Browse files- 00_Paretrix-pipeline.py +11 -8
- 13_draft-acceptance-sweep.py +111 -9
- 15_subagent-profile-bench.py +0 -0
- 16_dspark-generator.py +0 -0
- DOCUMENTATION.md +58 -20
- README.md +74 -8
00_Paretrix-pipeline.py
CHANGED
|
@@ -608,9 +608,12 @@ def resolve_workdir(arg,default=None,accept_file=True):
|
|
| 608 |
|
| 609 |
@functools.lru_cache(maxsize=None)
|
| 610 |
def find_llama_binary(name):
|
| 611 |
-
"""llama.cpp binary
|
| 612 |
-
|
| 613 |
-
|
|
|
|
|
|
|
|
|
|
| 614 |
exe=name+(".exe" if os.name=="nt" else "")
|
| 615 |
env_path=os.environ.get(f"LLAMA_{name.upper().replace('-','_')}_PATH")
|
| 616 |
if env_path:
|
|
@@ -620,15 +623,15 @@ def find_llama_binary(name):
|
|
| 620 |
roots=[]
|
| 621 |
if os.environ.get("LLAMA_CPP_DIR"):roots.append(os.environ["LLAMA_CPP_DIR"])
|
| 622 |
for base in(SCRIPT_DIR,os.getcwd()):
|
| 623 |
-
roots+=[os.path.join(base,"llama-cpp"
|
| 624 |
os.path.join(base,"..","llama-cpp"),os.path.join(base,"..","..","llama-cpp")]
|
| 625 |
-
|
| 626 |
-
|
|
|
|
| 627 |
for r in roots:
|
| 628 |
for s in subs:
|
| 629 |
p=os.path.normpath(os.path.join(r,s,exe))
|
| 630 |
-
if
|
| 631 |
-
if hits:return max(hits,key=os.path.getmtime)
|
| 632 |
return shutil.which(name) or shutil.which(exe) or ""
|
| 633 |
|
| 634 |
def binary_find(paths,groups,chunk=1<<24):
|
|
|
|
| 608 |
|
| 609 |
@functools.lru_cache(maxsize=None)
|
| 610 |
def find_llama_binary(name):
|
| 611 |
+
"""llama.cpp binary, the first that exists in the suite's order (15 and 16
|
| 612 |
+
follow it too): LLAMA_<NAME>_PATH, then each root's build/bin/Release (a
|
| 613 |
+
fresh build) before the root itself (a release zip, or the copy a build
|
| 614 |
+
script leaves there), then its other build trees; roots: LLAMA_CPP_DIR,
|
| 615 |
+
./llama-cpp, a nested clone, the suite root, its parents (beside this
|
| 616 |
+
script, then the current folder); then PATH. '' when absent."""
|
| 617 |
exe=name+(".exe" if os.name=="nt" else "")
|
| 618 |
env_path=os.environ.get(f"LLAMA_{name.upper().replace('-','_')}_PATH")
|
| 619 |
if env_path:
|
|
|
|
| 623 |
roots=[]
|
| 624 |
if os.environ.get("LLAMA_CPP_DIR"):roots.append(os.environ["LLAMA_CPP_DIR"])
|
| 625 |
for base in(SCRIPT_DIR,os.getcwd()):
|
| 626 |
+
roots+=[os.path.join(base,"llama-cpp"),os.path.join(base,"llama-cpp","llama-cpp"),base,
|
| 627 |
os.path.join(base,"..","llama-cpp"),os.path.join(base,"..","..","llama-cpp")]
|
| 628 |
+
# A fixed order, never the newest file: a build script copies its binaries to the root while
|
| 629 |
+
# the fresh build sits in build/bin/Release, and the copy's time says nothing of which to run
|
| 630 |
+
subs=(os.path.join("build","bin","Release"),"",os.path.join("build","bin"),os.path.join("build","Release"),"bin","build")
|
| 631 |
for r in roots:
|
| 632 |
for s in subs:
|
| 633 |
p=os.path.normpath(os.path.join(r,s,exe))
|
| 634 |
+
if os.path.isfile(p):return p
|
|
|
|
| 635 |
return shutil.which(name) or shutil.which(exe) or ""
|
| 636 |
|
| 637 |
def binary_find(paths,groups,chunk=1<<24):
|
13_draft-acceptance-sweep.py
CHANGED
|
@@ -20,7 +20,7 @@ Usage:
|
|
| 20 |
python 13_draft-acceptance-sweep.py --model model-Paretrix-Precision-42pc.gguf
|
| 21 |
python 13_draft-acceptance-sweep.py --module dspark-Paretrix-Quality-36pc.gguf --n-max 3,7
|
| 22 |
"""
|
| 23 |
-
import argparse,collections,csv,glob,json,os,re,socket,subprocess,sys,threading,time,urllib.request
|
| 24 |
os.environ.setdefault("TRANSFORMERS_VERBOSITY","error")
|
| 25 |
|
| 26 |
SCRIPT_DIR=os.path.dirname(os.path.abspath(__file__))
|
|
@@ -36,6 +36,12 @@ CSV_FIELDS=["timestamp","model","module","kind","spec","chat","ngl","kv","n_max"
|
|
| 36 |
def _find_server_bin():
|
| 37 |
return PC.find_llama_binary("llama-server") or "llama-server"
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
# Fixed probes: one code, one math, one instruction — deterministic at temperature 0
|
| 40 |
PROMPTS=(
|
| 41 |
"Write a Python function that merges two sorted lists into one sorted list without using sort().",
|
|
@@ -74,7 +80,7 @@ class Server:
|
|
| 74 |
self._th=None
|
| 75 |
|
| 76 |
def __enter__(self):
|
| 77 |
-
self._awake=
|
| 78 |
self.proc=subprocess.Popen(self.cmd,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,
|
| 79 |
text=True,encoding="utf-8",errors="replace")
|
| 80 |
self._th=threading.Thread(target=self._drain,daemon=True)
|
|
@@ -272,7 +278,14 @@ def measure_round(exe,model,module,n_max,n_predict,ngl=99,spec_type=None,ctx=409
|
|
| 272 |
for p in PROMPTS:
|
| 273 |
if _CTX_CACHE["resolved"] is not None and _CTX_PLACEHOLDER in p:
|
| 274 |
p=p.replace(_CTX_PLACEHOLDER,_CTX_CACHE["resolved"])
|
| 275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
time.sleep(0.3)
|
| 277 |
time.sleep(0.5)
|
| 278 |
stats["mean_len"]=stats["mean_len"]/max(1,stats["n_acc"])
|
|
@@ -364,6 +377,25 @@ def _module_kind(path):
|
|
| 364 |
return "draft"
|
| 365 |
|
| 366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
def _trained_block(module):
|
| 368 |
# The trained block lives in the module's metadata (*.block_size — e.g.
|
| 369 |
# dflash.block_size on DSpark/DFlash heads), never in a reference constant
|
|
@@ -399,6 +431,53 @@ def _find_tokenizer_dir(*starts):
|
|
| 399 |
return None
|
| 400 |
|
| 401 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
def main():
|
| 403 |
ap=argparse.ArgumentParser(description="Draft acceptance sweep (MTP · DFlash · DSpark) — writes draft-acceptance.csv")
|
| 404 |
ap.add_argument("pos",nargs="*",default=[],
|
|
@@ -407,7 +486,7 @@ def main():
|
|
| 407 |
help="target GGUF; default: newest model-Paretrix-*.gguf beside this script (L20: pair with the least-quantized affordable target)")
|
| 408 |
ap.add_argument("--module",default=None,
|
| 409 |
help="speculative module GGUF (MTP/DFlash/DSpark); default: newest dspark/dflash/mtp GGUF beside this script")
|
| 410 |
-
ap.add_argument("--n-max",default=
|
| 411 |
ap.add_argument("--spec-type",default=None,
|
| 412 |
help="speculative type list for llama-server (e.g. draft-mtp, or draft-mtp,draft-dflash with --module); a fused model self-carries its MTP head")
|
| 413 |
ap.add_argument("--n-predict",type=int,default=128)
|
|
@@ -593,14 +672,26 @@ def main():
|
|
| 593 |
if a.module and not os.path.isfile(a.module):
|
| 594 |
PC.err(f"module not found: {a.module}")
|
| 595 |
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
# L0 reflex: the trained block lives in the module's metadata, never in a
|
| 597 |
# reference-model constant (Qwen block_size=16 vs nanbeige block_size=7)
|
| 598 |
if a.n_max.strip() in("0",""):
|
| 599 |
if a.module:
|
| 600 |
bs=_trained_block(a.module)
|
| 601 |
if bs:
|
| 602 |
-
|
| 603 |
-
|
|
|
|
|
|
|
| 604 |
else:
|
| 605 |
PC.warn("Could not read a trained block_size from the module — pass --n-max explicitly.")
|
| 606 |
else:
|
|
@@ -614,6 +705,8 @@ def main():
|
|
| 614 |
kv_draft=_norm_kv(a.kv_draft) if a.kv_draft else "q8_0"
|
| 615 |
PC.note(f"KV cache salvos: {', '.join(f'target={k} / draft={kv_draft}' for k in kv_list)}")
|
| 616 |
|
|
|
|
|
|
|
| 617 |
results=[]
|
| 618 |
for kv_t in kv_list:
|
| 619 |
kv_base_label=f"{kv_t}/-"
|
|
@@ -624,7 +717,7 @@ def main():
|
|
| 624 |
thermal_guard(a.csv,base["tps"],os.path.basename(a.model),a.ngl,kv_base_label)
|
| 625 |
append_csv(a.csv,{
|
| 626 |
"timestamp":time.strftime("%Y-%m-%d %H:%M:%S"),"model":os.path.basename(a.model),
|
| 627 |
-
"module":"-","kind":kind,"spec":
|
| 628 |
"chat":int(bool(a.chat or a.probes_from_rollouts)),
|
| 629 |
"ngl":a.ngl,"kv":kv_base_label,"n_max":0,"n_predict":a.n_predict,
|
| 630 |
"accepted":0,"generated":0,"acceptance":0.0,"mean_len":0.0,
|
|
@@ -667,7 +760,7 @@ def main():
|
|
| 667 |
print(" per-domain acceptance: "+" · ".join(f"{d} {v[0]/max(v[1],1):.3f} ({v[2]})" for d,v in sorted(agg.items())))
|
| 668 |
row={
|
| 669 |
"timestamp":time.strftime("%Y-%m-%d %H:%M:%S"),"model":os.path.basename(a.model),
|
| 670 |
-
"module":_mod_label,"kind":kind,"spec":
|
| 671 |
"chat":int(bool(a.chat or a.probes_from_rollouts)),
|
| 672 |
"ngl":a.ngl,"kv":kv_pair_label,"n_max":n_max,"n_predict":a.n_predict,
|
| 673 |
"accepted":st["accepted"],"generated":st["generated"],
|
|
@@ -686,4 +779,13 @@ def main():
|
|
| 686 |
|
| 687 |
|
| 688 |
if __name__=="__main__":
|
| 689 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
python 13_draft-acceptance-sweep.py --model model-Paretrix-Precision-42pc.gguf
|
| 21 |
python 13_draft-acceptance-sweep.py --module dspark-Paretrix-Quality-36pc.gguf --n-max 3,7
|
| 22 |
"""
|
| 23 |
+
import argparse,collections,contextlib,csv,glob,json,os,re,shutil,socket,subprocess,sys,threading,time,urllib.request
|
| 24 |
os.environ.setdefault("TRANSFORMERS_VERBOSITY","error")
|
| 25 |
|
| 26 |
SCRIPT_DIR=os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 36 |
def _find_server_bin():
|
| 37 |
return PC.find_llama_binary("llama-server") or "llama-server"
|
| 38 |
|
| 39 |
+
def _keep_awake():
|
| 40 |
+
# PARETRIX COMMON's reference-counted sleep inhibitor (3.0.1): nested residencies share one OS lock;
|
| 41 |
+
# an older common without it leaves the inhibition to the KeepAwake around main()
|
| 42 |
+
ka=getattr(PC,"keep_awake",None)
|
| 43 |
+
return ka() if ka else contextlib.nullcontext()
|
| 44 |
+
|
| 45 |
# Fixed probes: one code, one math, one instruction — deterministic at temperature 0
|
| 46 |
PROMPTS=(
|
| 47 |
"Write a Python function that merges two sorted lists into one sorted list without using sort().",
|
|
|
|
| 80 |
self._th=None
|
| 81 |
|
| 82 |
def __enter__(self):
|
| 83 |
+
self._awake=_keep_awake();self._awake.__enter__()
|
| 84 |
self.proc=subprocess.Popen(self.cmd,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,
|
| 85 |
text=True,encoding="utf-8",errors="replace")
|
| 86 |
self._th=threading.Thread(target=self._drain,daemon=True)
|
|
|
|
| 278 |
for p in PROMPTS:
|
| 279 |
if _CTX_CACHE["resolved"] is not None and _CTX_PLACEHOLDER in p:
|
| 280 |
p=p.replace(_CTX_PLACEHOLDER,_CTX_CACHE["resolved"])
|
| 281 |
+
try:
|
| 282 |
+
srv.complete(p,n_predict,cache_prompt=cache_prompt)
|
| 283 |
+
except Exception as e:
|
| 284 |
+
# A crashed server explains itself only in its own output: the round error carries its tail
|
| 285 |
+
time.sleep(1.5)
|
| 286 |
+
rc=srv.proc.poll()
|
| 287 |
+
state=f"exited with code {rc}" if rc is not None else "still running"
|
| 288 |
+
raise RuntimeError(f"request failed ({type(e).__name__}: {e}); llama-server {state}, last lines:\n"+srv.tail(60)) from None
|
| 289 |
time.sleep(0.3)
|
| 290 |
time.sleep(0.5)
|
| 291 |
stats["mean_len"]=stats["mean_len"]/max(1,stats["n_acc"])
|
|
|
|
| 377 |
return "draft"
|
| 378 |
|
| 379 |
|
| 380 |
+
def _module_arch(path):
|
| 381 |
+
try:
|
| 382 |
+
import gguf as _gguf
|
| 383 |
+
f=_gguf.GGUFReader(path).fields.get("general.architecture")
|
| 384 |
+
return bytes(f.parts[f.data[0]]).decode("utf-8") if f else None
|
| 385 |
+
except Exception:
|
| 386 |
+
return None
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def _meta_bool(path,suffix):
|
| 390 |
+
try:
|
| 391 |
+
import gguf as _gguf
|
| 392 |
+
for k,f in _gguf.GGUFReader(path).fields.items():
|
| 393 |
+
if k.endswith(suffix):
|
| 394 |
+
return bool(f.parts[f.data[0]][0])
|
| 395 |
+
except Exception:pass
|
| 396 |
+
return False
|
| 397 |
+
|
| 398 |
+
|
| 399 |
def _trained_block(module):
|
| 400 |
# The trained block lives in the module's metadata (*.block_size — e.g.
|
| 401 |
# dflash.block_size on DSpark/DFlash heads), never in a reference constant
|
|
|
|
| 431 |
return None
|
| 432 |
|
| 433 |
|
| 434 |
+
class KeepAwake:
|
| 435 |
+
"""Holds a system-sleep inhibitor while the sweep runs (the display may still turn off)."""
|
| 436 |
+
|
| 437 |
+
def __init__(self,why):
|
| 438 |
+
self.why=why
|
| 439 |
+
self.proc=None
|
| 440 |
+
self.win=False
|
| 441 |
+
|
| 442 |
+
def __enter__(self):
|
| 443 |
+
try:
|
| 444 |
+
if sys.platform=="win32":
|
| 445 |
+
import ctypes
|
| 446 |
+
# Execution state is per thread: set and cleared from the same (main) thread
|
| 447 |
+
self.win=bool(ctypes.windll.kernel32.SetThreadExecutionState(0x80000000|0x00000001))
|
| 448 |
+
elif shutil.which("systemd-inhibit") and shutil.which("tail"):
|
| 449 |
+
# tail --pid exits with this process, so the lock is released even after a hard kill
|
| 450 |
+
self.proc=subprocess.Popen(["systemd-inhibit","--what=idle:sleep","--who=draft-acceptance-sweep",
|
| 451 |
+
f"--why={self.why}","--mode=block","tail",f"--pid={os.getpid()}","-f","/dev/null"],
|
| 452 |
+
stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
| 453 |
+
elif shutil.which("caffeinate"):
|
| 454 |
+
self.proc=subprocess.Popen(["caffeinate","-i","-w",str(os.getpid())],
|
| 455 |
+
stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
| 456 |
+
if self.proc is not None:
|
| 457 |
+
time.sleep(0.3)
|
| 458 |
+
if self.proc.poll() is not None:self.proc=None
|
| 459 |
+
if self.win or self.proc is not None:
|
| 460 |
+
PC.note(f"System sleep blocked: {self.why}")
|
| 461 |
+
else:
|
| 462 |
+
PC.warn("No sleep inhibitor available — the system may suspend during the sweep")
|
| 463 |
+
except Exception as e:
|
| 464 |
+
PC.warn(f"Sleep inhibitor unavailable ({e})")
|
| 465 |
+
return self
|
| 466 |
+
|
| 467 |
+
def __exit__(self,*exc):
|
| 468 |
+
if self.win:
|
| 469 |
+
import ctypes
|
| 470 |
+
ctypes.windll.kernel32.SetThreadExecutionState(0x80000000)
|
| 471 |
+
self.win=False
|
| 472 |
+
if self.proc is not None:
|
| 473 |
+
if self.proc.poll() is None:
|
| 474 |
+
self.proc.terminate()
|
| 475 |
+
try:self.proc.wait(timeout=5)
|
| 476 |
+
except subprocess.TimeoutExpired:self.proc.kill()
|
| 477 |
+
self.proc=None
|
| 478 |
+
return False
|
| 479 |
+
|
| 480 |
+
|
| 481 |
def main():
|
| 482 |
ap=argparse.ArgumentParser(description="Draft acceptance sweep (MTP · DFlash · DSpark) — writes draft-acceptance.csv")
|
| 483 |
ap.add_argument("pos",nargs="*",default=[],
|
|
|
|
| 486 |
help="target GGUF; default: newest model-Paretrix-*.gguf beside this script (L20: pair with the least-quantized affordable target)")
|
| 487 |
ap.add_argument("--module",default=None,
|
| 488 |
help="speculative module GGUF (MTP/DFlash/DSpark); default: newest dspark/dflash/mtp GGUF beside this script")
|
| 489 |
+
ap.add_argument("--n-max",default=None,help="comma-separated n_max values (default: 2,3,4,5 for an EAGLE-3 chain, 3,7,15 otherwise; pass 0 to read the single trained *.block_size from module metadata)")
|
| 490 |
ap.add_argument("--spec-type",default=None,
|
| 491 |
help="speculative type list for llama-server (e.g. draft-mtp, or draft-mtp,draft-dflash with --module); a fused model self-carries its MTP head")
|
| 492 |
ap.add_argument("--n-predict",type=int,default=128)
|
|
|
|
| 672 |
if a.module and not os.path.isfile(a.module):
|
| 673 |
PC.err(f"module not found: {a.module}")
|
| 674 |
return 1
|
| 675 |
+
if a.n_max is None:
|
| 676 |
+
# An EAGLE-3 chain pays one draft forward per drafted token, a block drafter one per block:
|
| 677 |
+
# long n_max values suit DFlash/DSpark blocks, an EAGLE-3 chain peaks near its trained depth
|
| 678 |
+
if (a.spec_type and "eagle3" in a.spec_type) or (a.module and _module_arch(a.module)=="eagle3"):
|
| 679 |
+
a.n_max="2,3,4,5"
|
| 680 |
+
PC.note("EAGLE-3 chain: n_max default 2,3,4,5")
|
| 681 |
+
elif kind in("dspark","dflash") and a.module and _trained_block(a.module):
|
| 682 |
+
a.n_max="0"
|
| 683 |
+
else:
|
| 684 |
+
a.n_max="3,7,15"
|
| 685 |
# L0 reflex: the trained block lives in the module's metadata, never in a
|
| 686 |
# reference-model constant (Qwen block_size=16 vs nanbeige block_size=7)
|
| 687 |
if a.n_max.strip() in("0",""):
|
| 688 |
if a.module:
|
| 689 |
bs=_trained_block(a.module)
|
| 690 |
if bs:
|
| 691 |
+
# anchor-first DSpark (sample_from_anchor) drafts a full block; DFlash denoises block_size-1 masks
|
| 692 |
+
n_tr=bs if kind=="dspark" and _meta_bool(a.module,".sample_from_anchor") else bs-1
|
| 693 |
+
a.n_max=str(n_tr)
|
| 694 |
+
PC.note(f"Module metadata: block_size={bs} → n_max default {n_tr} (the trained block)")
|
| 695 |
else:
|
| 696 |
PC.warn("Could not read a trained block_size from the module — pass --n-max explicitly.")
|
| 697 |
else:
|
|
|
|
| 705 |
kv_draft=_norm_kv(a.kv_draft) if a.kv_draft else "q8_0"
|
| 706 |
PC.note(f"KV cache salvos: {', '.join(f'target={k} / draft={kv_draft}' for k in kv_list)}")
|
| 707 |
|
| 708 |
+
# The context condition rides the spec column (fixed CSV schema): rows at different fills never compare
|
| 709 |
+
spec_label=(a.spec_type or "-")+(f"|fill={a.ctx_fill}" if a.ctx_fill>0 else "")
|
| 710 |
results=[]
|
| 711 |
for kv_t in kv_list:
|
| 712 |
kv_base_label=f"{kv_t}/-"
|
|
|
|
| 717 |
thermal_guard(a.csv,base["tps"],os.path.basename(a.model),a.ngl,kv_base_label)
|
| 718 |
append_csv(a.csv,{
|
| 719 |
"timestamp":time.strftime("%Y-%m-%d %H:%M:%S"),"model":os.path.basename(a.model),
|
| 720 |
+
"module":"-","kind":kind,"spec":spec_label,
|
| 721 |
"chat":int(bool(a.chat or a.probes_from_rollouts)),
|
| 722 |
"ngl":a.ngl,"kv":kv_base_label,"n_max":0,"n_predict":a.n_predict,
|
| 723 |
"accepted":0,"generated":0,"acceptance":0.0,"mean_len":0.0,
|
|
|
|
| 760 |
print(" per-domain acceptance: "+" · ".join(f"{d} {v[0]/max(v[1],1):.3f} ({v[2]})" for d,v in sorted(agg.items())))
|
| 761 |
row={
|
| 762 |
"timestamp":time.strftime("%Y-%m-%d %H:%M:%S"),"model":os.path.basename(a.model),
|
| 763 |
+
"module":_mod_label,"kind":kind,"spec":spec_label+(f"|pmin={a.p_min:g}" if a.p_min>0 else ""),
|
| 764 |
"chat":int(bool(a.chat or a.probes_from_rollouts)),
|
| 765 |
"ngl":a.ngl,"kv":kv_pair_label,"n_max":n_max,"n_predict":a.n_predict,
|
| 766 |
"accepted":st["accepted"],"generated":st["generated"],
|
|
|
|
| 779 |
|
| 780 |
|
| 781 |
if __name__=="__main__":
|
| 782 |
+
# One inhibitor for the whole sweep (tokenizer load and the gaps between residencies included): the
|
| 783 |
+
# common's when it has one (each Server enters it again, reference-counted), else the local fallback
|
| 784 |
+
if hasattr(PC,"keep_awake"):
|
| 785 |
+
with PC.keep_awake():
|
| 786 |
+
PC.note("System sleep blocked: draft acceptance sweep")
|
| 787 |
+
_rc=main()
|
| 788 |
+
else:
|
| 789 |
+
with KeepAwake("draft acceptance sweep"):
|
| 790 |
+
_rc=main()
|
| 791 |
+
raise SystemExit(_rc)
|
15_subagent-profile-bench.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
16_dspark-generator.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
DOCUMENTATION.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# Paretrix Quantization Suite — Documentation
|
| 2 |
|
| 3 |
-
Technical reference for **Paretrix v3.
|
| 4 |
|
| 5 |
---
|
| 6 |
|
|
@@ -48,9 +48,12 @@ A prior orders and spares the measurements; it never prices a shipped plan: ever
|
|
| 48 |
▼ fold (closing step)
|
| 49 |
[arch-paretrix/<arch>-paretrix.json · generic-paretrix.json] → the next model of the family
|
| 50 |
│
|
| 51 |
-
├─▶ Paretrix-modules.py
|
| 52 |
-
├─▶
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 54 |
```
|
| 55 |
|
| 56 |
Orchestrated by `00_Paretrix-pipeline.py`, which resumes from its working folder (the folder holds the state).
|
|
@@ -72,6 +75,8 @@ python 00_Paretrix-pipeline.py MyModel --dry-run
|
|
| 72 |
|
| 73 |
Key flags: `--from {01,02,03}` · `--tier a,b` · `--polish {far,all,held,off}` · `--full-matrix` · `--all-classics` · `--no-audit` · `--no-duel` · `--no-fold` · `--no-modules` · `--module-profile {balanced,compact}` · `--outtype {bf16,f16}` · `--cpu-only` · `--force` · `--keep-going` · `--dry-run`.
|
| 74 |
|
|
|
|
|
|
|
| 75 |
### 3.2 `01_SAFETENSORS-to-BF16-GGUF.py`: conversion
|
| 76 |
|
| 77 |
Converts safetensors into a pristine BF16 GGUF with a **native split**:
|
|
@@ -151,7 +156,7 @@ Sweeps every product in a working folder at the verdict regime: PPL, KLD (vs BF1
|
|
| 151 |
|
| 152 |
### 3.9 `13_draft-acceptance-sweep.py`: A/B acceptance battery
|
| 153 |
|
| 154 |
-
Spawns `llama-server` with and without the module (`[model.gguf] [module.gguf]` or `<working-folder>` positionally, or via `--model` / `--module`; auto-pick selects the newest shipped rung, never a `Candidate` or `Plan`), replays deterministic prompts at temperature 0 inside a 16K context window by default (`--ctx 16384`, `--ctx-fill 16384` minus response space, calibrated to the exact token count through `/tokenize` and `/detokenize`; `--ctx-fill 0` runs short probes, `--ctx-file` supplies a custom prefix, `--cache-prompt` reuses the slot KV cache), and records acceptance, mean length, and throughput per `--n-max`
|
| 155 |
|
| 156 |
### 3.10 `14_gguf-module-fusion.py`: module fusion
|
| 157 |
|
|
@@ -163,19 +168,47 @@ python 14_gguf-module-fusion.py <folder> --mtp [--target <product.gguf>] [--head
|
|
| 163 |
python 14_gguf-module-fusion.py out.gguf main.gguf extra.gguf [...]
|
| 164 |
```
|
| 165 |
|
| 166 |
-
### 3.11 `
|
| 167 |
|
| 168 |
Judges any GGUF as the sub-agent that a larger hosted model delegates to: finding a constant in 100K tokens, mapping which function calls which, extracting a block verbatim, computing, proving, converting a format. The script loads the model through `llama-server`, asks the exercises, scores every answer by code (set arithmetic on an AST, exact keys, executed programs, compiled proofs; no judge model) and writes one registry row per configuration. The protocol lives in [section 13](#13-agent-profile-standard).
|
| 169 |
|
| 170 |
```bash
|
| 171 |
-
python
|
| 172 |
-
python
|
| 173 |
-
python
|
| 174 |
-
python
|
| 175 |
-
python
|
| 176 |
```
|
| 177 |
|
| 178 |
-
Key flags: `--categories` · `--samples` · `--limit` · `--long` / `--no-long` (the repository categories on the long corpus, asked only when it fits whole, and the deep needle) · `--effort` · `--budget {auto,off}` · `--reasoning-cap` · `--sampling` · `--kv` / `--kv-draft` · `--ctx-max` · `--arm` (`auto` follows the passed GGUF: `with-mtp` when given a fused `model-mtp-*` or `--mtp`, `with-draft` / `without-mtp` when given the base `model-*`; `all` runs every arm in `trust` mode) · `--mtp` / `--draft` / `--no-draft` / `--mmproj` · `--chat-template` · `--ladder` · `--traces` · `--exe`. Reports land in `agents-profiles/<repo>/`, the registry in `agents-profiles/agent-profile.csv`, and the comparative Markdown synthesis in `agents-profiles/agent-profile.md`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
---
|
| 181 |
|
|
@@ -343,6 +376,8 @@ The Pareto column of 11's summary (the frontier's rule, §5.8) reads ties at `ma
|
|
| 343 |
|
| 344 |
Block-diffusion speculative drafts convert whole (tokenizer borrowed from the parent checkpoint). `Paretrix-modules.py` quantizes them imatrix-free: bridge (fc/eh_proj) ≥ Q6_K · proposal (markov_w/conf_proj) ≥ Q5_K · vocab tables K-quant · unclassified tensors at Q5_K (the F16 catch-all is never used). The trained block size lives in the module metadata (`*.block_size`); 13 reads it (`--n-max 0`), and mask lengths beyond it were never seen in training.
|
| 345 |
|
|
|
|
|
|
|
| 346 |
### 9.3 MMProj (vision)
|
| 347 |
|
| 348 |
CLIP vision towers quantize through a profile grid (`balanced` / `compact` / `fidelity`). Critical tensors (patch and position embeddings, norms, merger) stay pinned at F32, with a deep-boost on trailing blocks. The `llama-quantize` fallback verifies artifact-vs-plan roles; it caught a historical attn/bridge miss with a divergence of ×1.27.
|
|
@@ -390,7 +425,7 @@ Every script, every depth:
|
|
| 390 |
| `PARETRIX_NO_AWAKE` | `0` / `1` | `0` | `1`: disables OS idle/sleep inhibition (`PC.keep_awake`, `13`, `15`) while `llama.cpp` tools or `llama-server` run. |
|
| 391 |
| `PARETRIX_NO_EVAL_CACHE` | `0` / `1` | `0` | Forces re-measurement in 11. |
|
| 392 |
| `IMATRIX_SOURCE_QUANT` | `<fmt>` / `bf16` | `Q8_0` | Source format for imatrix generation. |
|
| 393 |
-
| `LLAMA_CPP_DIR` / `LLAMA_<NAME>_PATH` | `<path>` | — | Custom llama.cpp binaries. |
|
| 394 |
|
| 395 |
---
|
| 396 |
|
|
@@ -407,13 +442,15 @@ Every script, every depth:
|
|
| 407 |
- **NTFS Xpress8K** compresses BF16 GGUFs and KL bases (~18%). Quantized payloads and the imatrix stay raw, since their high entropy makes decompression a tax with no gain.
|
| 408 |
- **Content-addressed eval cache** (`eval-cache.json` + `PC.fast_content_id`) makes repeated duels, sweeps and byte-identical evaluations instantaneous (10 min → milliseconds); a rerun of the ladder measures only what changed.
|
| 409 |
|
|
|
|
|
|
|
| 410 |
---
|
| 411 |
|
| 412 |
## 13. Agent Profile Standard
|
| 413 |
|
| 414 |
### 13.1 Principle
|
| 415 |
|
| 416 |
-
The bench asks questions with one verifiable answer and checks them with code. The answer keys are recomputed by independent methods at startup (`verify`), live in a `FIXTURES` block that the script cuts out of the copy of itself that the model reads, and stay hidden from the model. The model reads the bench source and this document: the corpus of the document categories is the tool that tests it.
|
| 417 |
|
| 418 |
The bench carries its exercises and needs no external file. Without this document, the corpus is the bench source alone and the document questions are not asked. Up to a 128K window the model reads the bench source and this document, and the exercises turn around the bench. Above it, the long tier reads every file at once — `Paretrix.py` (with a line-number margin), `Paretrix-modules.py`, `03_BF16-GGUF-to-Paretrix.py`, the bench source and this document, about 150K tokens, whole and never trimmed — and the exercises turn around `Paretrix.py` and the bench. The bench source alone feeds the self tier, so the repository natures (line ranges, constants) reach every model whatever its window. The photograph `LaTeX-OCR.jpg` serves its own exercises, the printed formula, the handwritten line and the scene.
|
| 419 |
|
|
@@ -429,7 +466,7 @@ The bench carries its exercises and needs no external file. Without this documen
|
|
| 429 |
| extraction | 5 | Exact source of functions, a configuration block and prose paragraphs | text similarity |
|
| 430 |
| doc_qa | 10 | Questions answered from this document and from the bench source | fact patterns |
|
| 431 |
| needle_max | 5 / rung | The needle rounds on generated Python modules that fill the largest window the model loads, at a half and all of the room the window leaves | exact per place, per rung |
|
| 432 |
-
| repo_map | 5 | On the long corpus (`--long`), around `Paretrix.py` and the bench: callers, transitive callers, direct and route callees, and readers of a constant (a call resolves inside its own file) | AST set |
|
| 433 |
| repo_locate | 10 | Line range of functions and constants of `Paretrix.py`, read from its line-number margin inside the long corpus | each end is worth half; on a multi-line range an end within 2 lines counts as right, a single-line constant cited 1 line off earns half credit |
|
| 434 |
| repo_extract | 5 | Exact copy of functions and configuration blocks of `Paretrix.py` and the bench | text similarity |
|
| 435 |
| repo_qa | 10 | Questions answered from the constants of `Paretrix.py`, `Paretrix-modules.py` and `03_BF16-GGUF-to-Paretrix.py` | fact patterns |
|
|
@@ -457,22 +494,23 @@ Four residencies cover every category, so the model loads once per need and neve
|
|
| 457 |
| self | self_locate, self_qa: the bench source alone, numbered | smallest listed window that holds it with its thinking room (96K typical) |
|
| 458 |
| vision | ocr, ocr_formula; the only residency that loads the projector | 32K (24K when memory is short) |
|
| 459 |
|
| 460 |
-
Windows come from the listed sizes 24K, 32K, 40K, 48K, 64K, 80K, 96K, 128K, 144K, 160K, 176K, 192K, 256K and above; recurrent (GDN, SSM) and sliding-window (SWA) hybrids start at the full window and step down on the post-load VRAM check. A load that exceeds the GPU steps down one listed size. Answer room shrinks before the corpus does, and the standard corpus gives up this document first; the bench source always stays. When the long corpus does not fit whole in a model's window (a 128K model, for instance), the repository categories are skipped, never served an excerpt, so a `repo_*` score always describes the whole corpus; `self_locate` and `self_qa` cover the same natures for every window. The deep needle asks its five questions on generated Python modules, at a half and all of the room that the largest window leaves; the largest rung with every answer right is the capacity of the model, written to the registry. In the long corpus `Paretrix.py` carries its line numbers in a left margin (the self tier numbers the bench), so that a model cites a line without counting it; a bare call resolves to a function of its own file, so two files never share a call edge. A bare `python
|
| 461 |
|
| 462 |
### 13.4 Decoding and reasoning
|
| 463 |
|
| 464 |
Every model starts from the shared base sampler (`top_k=20`, `top_p=0.95`, `repeat_penalty=1.05`), and the temperature follows the category: 0.15 for the transcription and OCR categories, 0.3 elsewhere. On thinking categories, truncation knobs declared in `generation_config.json` (`top_k`, `top_p`, `min_p`) overlay the base defaults while keeping the category temperature and the bench's repeat penalty, and `--sampling` overrides any knob explicitly.
|
| 465 |
|
| 466 |
-
Reasoning effort follows the work: `low` for finding and copying, `medium` for reading, code, math and logic (`--effort high` raises every category). A template that reads `reasoning_effort` receives the level, and every thinking request (except families with custom closing tags) also receives a per-request thinking budget of 8192 or
|
| 467 |
|
| 468 |
-
Output ceilings: 2048 tokens (canary, abstention, defs), 4096 (needle, doc_qa, repo_locate, repo_qa), 8192 (extraction, repo_extract, shell), 10240 (needle_max), 12288 (relations, code, repo_map, math, logic), then 2048 and 1024 without thinking; every thinking category expands its request ceiling up to `budget + 2048` within the free room of the loaded window (and the planner sizes each window on that room, so a tokenizer that packs the corpus just under a listed size keeps the whole budget) so the full 8192 /
|
| 469 |
|
| 470 |
### 13.5 Scoring
|
| 471 |
|
| 472 |
- **Item score** runs from 0 to 1; a category scores the mean of its items. The note is D/10 = 10 × mean, shown as `9.20/10 (9.0★)`.
|
| 473 |
- **Efficiency index** η = 0.5 × (1 / (1 + t / ref) + 1 / (1 + w / (ref / 50))) combines the token brevity and the decoding throughput (t/s) of reasoning over the fully right answers of a mastered thinking category (mean ≥ 0.50 with emitted reasoning), where t is the mean number of generated tokens, w the mean duration in seconds, 50 t/s the reference sub-agent decoding speed (keeping delegated calls inside a 300 s / 5-minute orchestrator prompt-cache TTL), and ref the token reference of that category (256 for canary, needle and abstention · 384 for needle_max · 512 for defs · 1024 for extraction, doc_qa, shell, repo_locate and repo_extract · 2048 for relations and repo_qa · 4096 for code, math, logic and repo_map). A run reports the mean over the categories that have right answers alongside tokens per right answer, decoding t/s and the share of items completed within 300 s, next to D/10 and apart from it. `--aggregate` also prints the index of each category apart, so that two models compare on the categories they share.
|
| 474 |
-
- **Reading the answer**: a judge reads the answer where a sub-agent writes it and scores its content alone, the way an orchestrator receiving it would: the requested key after a lead-in (`Answer: CALLERS=main`), a value kept inside the placeholder's angle brackets (`ANSWER=<…>`), a key left empty above its list, the bare list or the `\boxed{}` result an answer closes on when it never wrote its key, islanders labelled (`A=K`) or spelled out (`knight`), list numbering, a remark after the printed output, a lead-in or a closing remark around a copied function, and a fraction kept with its source's parentheses. A wrong name, value, line or letter keeps its full cost: the tolerance is on the form, never on the content, and `verify` checks both sides on every category.
|
| 475 |
- **Hallucination rate** is the share of absent-element questions (abstention, needle round 3) answered with an invention; `CODE=ABSENT` counts as an abstention.
|
|
|
|
| 476 |
- **Needle position** is the third of the context (1/3, 2/3 or 3/3) where each note sits, measured in tokens on the prompt the model reads; the report lists the score per third.
|
| 477 |
|
| 478 |
### 13.6 Roles
|
|
@@ -481,6 +519,6 @@ Roles read the registry row, and a category that was never measured keeps its ro
|
|
| 481 |
|
| 482 |
### 13.7 Registry and integrity
|
| 483 |
|
| 484 |
-
`agent-profile.csv` holds one row per protocol key (revision, model, arm, KV types, seeds, head, effort, document nodes, template, reasoning cap, sampling). A partial run updates only the cells it measured, and a revision change opens a new protocol. The questions on the files (functions, constants, paragraphs, callers) are drawn by a hash of their names, so an edit elsewhere in a file leaves them in place and models measured weeks apart answer the same ones; their truths are read from the files as they stand. Besides the category means, a row records the windows, the hallucination rate, the efficiency index, the tokens per right answer and the needle score per third. Every completed arm and `--aggregate` write the comparative Markdown synthesis `agents-profiles/agent-profile.md` (configurations, category matrix, efficiency and speed table, per-category efficiency, gap against the reference sub-agent, and best candidate per role).
|
| 485 |
|
| 486 |
`verify` checks the bench without a model: answer keys recomputed by independent methods (programs executed, format keys), the judges' tolerance, the redacted copy free of keys, canaries and needles planted, every category counted on the real corpus (a multiple of 5 items on this host), planner scenarios and document facts. Every answer is echoed to the console as it is scored: the item line carries the verdict, and on a non-perfect item an indented second line gives the expected and received values once, so the category line closes with its summary alone; the run closes with a records table read from the registry, and the shell category executes bash and PowerShell scripts in a scratch folder.
|
|
|
|
| 1 |
# Paretrix Quantization Suite — Documentation
|
| 2 |
|
| 3 |
+
Technical reference for **Paretrix v3.1.0**: the engine, the pipeline, the knowledge base, the measured facts the engine stands on, the modules and the evaluation standard. [README.md](README.md) holds the benchmarks, the ladder table and the quick start; this document refers to it instead of restating it.
|
| 4 |
|
| 5 |
---
|
| 6 |
|
|
|
|
| 48 |
▼ fold (closing step)
|
| 49 |
[arch-paretrix/<arch>-paretrix.json · generic-paretrix.json] → the next model of the family
|
| 50 |
│
|
| 51 |
+
├─▶ Paretrix-modules.py → [mtp / mmproj / dspark / dflash-Paretrix-<Profile>.gguf]
|
| 52 |
+
├─▶ 16_dspark-generator.py → [draft-32K/ · draft-lite/: dspark-<tag>-Paretrix-Balanced.gguf]
|
| 53 |
+
├─▶ 13_draft-acceptance-sweep.py → [acceptance · mean length · speedup per n_max]
|
| 54 |
+
├─▶ 14_gguf-module-fusion.py → [fused deployment GGUF]
|
| 55 |
+
├─▶ 15_subagent-profile-bench.py → [trust · roles · efficiency registry]
|
| 56 |
+
└─▶ 11_perplexity-test.py → [PPL · KLD · RMS Δp · top-p · Pareto frontier]
|
| 57 |
```
|
| 58 |
|
| 59 |
Orchestrated by `00_Paretrix-pipeline.py`, which resumes from its working folder (the folder holds the state).
|
|
|
|
| 75 |
|
| 76 |
Key flags: `--from {01,02,03}` · `--tier a,b` · `--polish {far,all,held,off}` · `--full-matrix` · `--all-classics` · `--no-audit` · `--no-duel` · `--no-fold` · `--no-modules` · `--module-profile {balanced,compact}` · `--outtype {bf16,f16}` · `--cpu-only` · `--force` · `--keep-going` · `--dry-run`.
|
| 77 |
|
| 78 |
+
**llama.cpp binaries.** Every script resolves `llama-server`, `llama-quantize`, `llama-imatrix` and `llama-perplexity` in one order (`PC.find_llama_binary`; 15 and 16 apply the same): `LLAMA_<NAME>_PATH`, then `LLAMA_CPP_DIR`, then `llama-cpp/build/bin/Release` beside the scripts (a fresh build), then the root of `llama-cpp/` (a release zip, or the copy a build script leaves there), then the other build trees, then `PATH`. A build therefore takes effect as soon as it finishes, whatever binaries the root still holds.
|
| 79 |
+
|
| 80 |
### 3.2 `01_SAFETENSORS-to-BF16-GGUF.py`: conversion
|
| 81 |
|
| 82 |
Converts safetensors into a pristine BF16 GGUF with a **native split**:
|
|
|
|
| 156 |
|
| 157 |
### 3.9 `13_draft-acceptance-sweep.py`: A/B acceptance battery
|
| 158 |
|
| 159 |
+
Spawns `llama-server` with and without the module (`[model.gguf] [module.gguf]` or `<working-folder>` positionally, or via `--model` / `--module`; auto-pick selects the newest shipped rung, never a `Candidate` or `Plan`), replays deterministic prompts at temperature 0 inside a 16K context window by default (`--ctx 16384`, `--ctx-fill 16384` minus response space, calibrated to the exact token count through `/tokenize` and `/detokenize`; `--ctx-fill 0` runs short probes, `--ctx-file` supplies a custom prefix, `--cache-prompt` reuses the slot KV cache), and records acceptance, mean length, and throughput per `--n-max` into `draft-acceptance.csv`. The default follows the module: the trained block for a DSpark/DFlash module that declares `*.block_size` (the full block for an anchor-first DSpark, `*.sample_from_anchor`; block − 1 for a DFlash that denoises its masks), `2,3,4,5` for an EAGLE-3 chain, `3,7,15` otherwise; `0` reads `*.block_size` explicitly. Sweeps two KV cache salvos by default (`--kv q8_0,q5_1` on the target model paired with `--kv-draft q8_0` on the draft module, each with its own baseline). `--chat` is enabled by default (`--no-chat` for raw probes, `--thinking` for `enable_thinking=True`) and auto-detects `--tokenizer-dir` from parent folders. Custom probe sets load from `--probes-file` (`.jsonl` with optional `domain` tags for per-domain breakdown, or `.txt`) or `--probes-from-rollouts`; each round prints a `min · median · max` per-probe acceptance summary (`--per-probe` lists every probe), and `--p-min` sets `--spec-draft-p-min`. `--ngl` and `kv` are recorded, and baselines are compared only at matching offload and KV type (L20); the `spec` column carries the context fill (`|fill=N`) and `--p-min` (`|pmin=X`), so rows at different fills never compare. Each `llama-server` residency holds the shared sleep inhibitor (`PC.keep_awake`, reference-counted), and a request that fails reports the server's exit state and last lines.
|
| 160 |
|
| 161 |
### 3.10 `14_gguf-module-fusion.py`: module fusion
|
| 162 |
|
|
|
|
| 168 |
python 14_gguf-module-fusion.py out.gguf main.gguf extra.gguf [...]
|
| 169 |
```
|
| 170 |
|
| 171 |
+
### 3.11 `15_subagent-profile-bench.py`: sub-agent profile and trust bench
|
| 172 |
|
| 173 |
Judges any GGUF as the sub-agent that a larger hosted model delegates to: finding a constant in 100K tokens, mapping which function calls which, extracting a block verbatim, computing, proving, converting a format. The script loads the model through `llama-server`, asks the exercises, scores every answer by code (set arithmetic on an AST, exact keys, executed programs, compiled proofs; no judge model) and writes one registry row per configuration. The protocol lives in [section 13](#13-agent-profile-standard).
|
| 174 |
|
| 175 |
```bash
|
| 176 |
+
python 15_subagent-profile-bench.py verify # offline integrity, no model
|
| 177 |
+
python 15_subagent-profile-bench.py <model.gguf> # role profile (default)
|
| 178 |
+
python 15_subagent-profile-bench.py trust <model.gguf> # canary · defs · abstention
|
| 179 |
+
python 15_subagent-profile-bench.py <model.gguf> --categories needle,math --samples 1
|
| 180 |
+
python 15_subagent-profile-bench.py --aggregate # registry views
|
| 181 |
```
|
| 182 |
|
| 183 |
+
Key flags: `--categories` · `--samples` · `--limit` · `--long` / `--no-long` (the repository categories on the long corpus, asked only when it fits whole, and the deep needle) · `--effort` · `--budget {auto,off}` · `--reasoning-cap` · `--sampling` · `--kv` / `--kv-draft` · `--ctx-max` · `--arm` (`auto` follows the passed GGUF: `with-mtp` when given a fused `model-mtp-*` or `--mtp`, `with-draft` / `without-mtp` when given the base `model-*`; `all` runs every arm in `trust` mode) · `--mtp` / `--draft` / `--no-draft` / `--mmproj` (a draft is found beside the model, `<family>-Paretrix-<Profile>.gguf`, then in its `draft-*/` folders, those of 16) · `--n-max` (default: the `n_max` that 16 selected, read from the `selection.json` beside the draft, else 3) · `--ubatch` · `--system <file>` (replaces the system prompt for an A/B; every row carries the hash of its prompt) · `--chat-template` · `--ladder` · `--traces` · `--exe`. Reports land in `agents-profiles/<repo>/`, the registry in `agents-profiles/agent-profile.csv`, and the comparative Markdown synthesis in `agents-profiles/agent-profile.md`.
|
| 184 |
+
|
| 185 |
+
### 3.12 `16_dspark-generator.py`: DSpark draft generator
|
| 186 |
+
|
| 187 |
+
Builds a DSpark draft for a target GGUF, quantizes it with `Paretrix-modules.py` (Balanced), measures it with 13 at each `n_max` (each sweep against its own baseline, so the speedup decides; the speedups below compare drafts quantized the same way) and prints the `llama-server` flags of the fastest. One script, three modes:
|
| 188 |
+
|
| 189 |
+
| Mode | Command | Draft | Spark-X2.6, short context |
|
| 190 |
+
| :--- | :--- | :--- | :--- |
|
| 191 |
+
| convert | `16 <target.gguf> <official draft>` | The official draft's layers unchanged, with its own readout of the `--draft-vocab` most generated tokens (32,768: 99.45% of the generated tokens) instead of the target's whole vocab head, re-read on every draft pass; no training, ≈ 10 min | 4B ×2.07 (official ×1.79) · 1.7B ×1.58 (official ×1.40) |
|
| 192 |
+
| lite | `16 <target.gguf> <official draft> --lite` | The official draft pruned (4 of its layers, the subset with the best τ, FFN 1536) and trained for a night | 1.7B ×1.55 at 143 MiB (draft-32K: 259 MiB) |
|
| 193 |
+
| home | `16 <target.gguf>` | A Lite draft trained from the target's own layers: on-policy trajectories first (hours), then a night | 4B ×1.81 at 179 MiB (draft-32K: 453 MiB) |
|
| 194 |
+
|
| 195 |
+
**Products.** Convert writes `<labo>/Paretrix/draft-32K/` (the tag follows `--draft-vocab`: 16384 → `draft-16K`), lite and home `<labo>/Paretrix/draft-lite/`: `dspark-<tag>-BF16.gguf`, `dspark-<tag>-Paretrix-Balanced.gguf` with its provenance sidecar, `selection.json` (the measured `n_max` table) and `_logs/<run>/` (step logs, `summary.txt`). Lite and home keep the trained weights (`dspark.safetensors`, `dspark_config.json`); the closing cleanup removes the intermediate checkpoint of a conversion and the optimizer state of a training. `--check` rehearses every step in `<folder>-check`, so a rehearsal never touches a shipped draft.
|
| 196 |
+
|
| 197 |
+
**Official draft.** Given as its BF16 GGUF or as its HF folder (`config.json` + safetensors): a folder is converted first by the `convert_hf_to_gguf.py` of the llama.cpp sources (`--target-model-dir <labo>`, `--dspark` for a target checkpoint that carries `draft_model.*` tensors) into `<labo>/Paretrix/draft-official/`, and reused while it is newer than its safetensors. Convert serves any target whose llama.cpp graph exposes its layer inputs (Spark, Nanbeige, Qwen3, Llama…) and both dflash layouts: gated GELU layers with `fc_norm` (Spark) and q/k-norm SiLU layers (Qwen3-style drafts); the readout rows come from the target's `lm_head` when the target is untied. A draft whose graph carries what the generator does not reproduce (partial or M-RoPE, biases, a 1+N bonus-anchor block, an attention or value scale, a logit softcap, an own embedding that differs from the target's) is refused with the reason; an embedding that copies the target's is dropped, since the runtime then shares the target's. Lite and home train Spark layers and serve Spark targets.
|
| 198 |
+
|
| 199 |
+
**Data.** The readout tokens and the training come from on-policy trajectories of the target, in `<labo>/draft/` (`prompts.jsonl`, `onpolicy_v2.jsonl`, `probes_onpolicy_v2.jsonl`): generated through `llama-server` when absent (1500 for convert), or borrowed from a model with the same tokenizer (`--data-dir <labo2>/draft`).
|
| 200 |
+
|
| 201 |
+
**Engine.** The same file carries the subcommands the generator chains (`selftest`, `prompts`, `gen`, `train`, `eval`, `export`, `diag`), usable by hand with `--model-dir`, `--data-dir`, `--target-gguf`, `--out-dir` before them. `selftest` checks the training forward against a literal NumPy reference of the dflash graph (masks, Markov and confidence heads, both layouts, every block length) and that a converted official draft keeps its logits on the draft vocab. A training τ evaluation reduces its anchors per pass when the VRAM is full; a conversion writes its checkpoint first and treats τ as information.
|
| 202 |
+
|
| 203 |
+
```bash
|
| 204 |
+
python 16_dspark-generator.py <labo>/Paretrix/<target>.gguf <labo>/Paretrix/draft-official/<official>.gguf
|
| 205 |
+
python 16_dspark-generator.py <labo>/Paretrix/<target>.gguf <HF draft folder> # converted first
|
| 206 |
+
python 16_dspark-generator.py <labo>/Paretrix/<target>.gguf <official>.gguf --lite # a night
|
| 207 |
+
python 16_dspark-generator.py <labo>/Paretrix/<target>.gguf # home: from the target's layers
|
| 208 |
+
python 16_dspark-generator.py <target.gguf> <official> --dry-run # plan and pre-flight only
|
| 209 |
+
```
|
| 210 |
+
|
| 211 |
+
Key flags: `--lite` · `--draft-vocab` · `--n-max` · `--data-dir` · `--out-dir` · `--gen` / `--gen-limit` / `--gen-until HH:MM` · `--epochs` · `--layers` / `--inter` · `--official-layers` · `--kv` / `--kv-draft` · `--long` (adds a 16K measurement) · `--check` · `--dry-run` · `--from` / `--skip` · `--resume-train` · `--diag`. The drafts run on a llama.cpp build with Spark2.5 and DSpark support (XHToken's fork): `-md <draft> --spec-type draft-dspark --spec-draft-n-max <n> --spec-draft-p-min 0 -fa on -ctkd f16 -ctvd f16`.
|
| 212 |
|
| 213 |
---
|
| 214 |
|
|
|
|
| 376 |
|
| 377 |
Block-diffusion speculative drafts convert whole (tokenizer borrowed from the parent checkpoint). `Paretrix-modules.py` quantizes them imatrix-free: bridge (fc/eh_proj) ≥ Q6_K · proposal (markov_w/conf_proj) ≥ Q5_K · vocab tables K-quant · unclassified tensors at Q5_K (the F16 catch-all is never used). The trained block size lives in the module metadata (`*.block_size`); 13 reads it (`--n-max 0`), and mask lengths beyond it were never seen in training.
|
| 378 |
|
| 379 |
+
A draft without its own readout re-reads the target's whole vocab head on every draft pass (131,072 rows on Spark, 166,144 on Nanbeige). `16_dspark-generator.py` gives it its own: the rows of the generated tokens (the `d2t` table, int64, which `Paretrix-modules.py` copies intact and 16 checks after quantization) and the Markov output rows of the same tokens. On those tokens the logits are the official draft's (selftest), and the draft cycle shortens: Spark-X2.6-4B ×1.79 → ×2.07, 1.7B ×1.40 → ×1.58 (both drafts quantized Paretrix-Balanced, same sweep protocol). A non-causal draft (`*.attention.causal = false`) is a different draft at each block length; the runtime block is `n_max` long, so a trained Lite draft learns every length of `[block_min, block]`.
|
| 380 |
+
|
| 381 |
### 9.3 MMProj (vision)
|
| 382 |
|
| 383 |
CLIP vision towers quantize through a profile grid (`balanced` / `compact` / `fidelity`). Critical tensors (patch and position embeddings, norms, merger) stay pinned at F32, with a deep-boost on trailing blocks. The `llama-quantize` fallback verifies artifact-vs-plan roles; it caught a historical attn/bridge miss with a divergence of ×1.27.
|
|
|
|
| 425 |
| `PARETRIX_NO_AWAKE` | `0` / `1` | `0` | `1`: disables OS idle/sleep inhibition (`PC.keep_awake`, `13`, `15`) while `llama.cpp` tools or `llama-server` run. |
|
| 426 |
| `PARETRIX_NO_EVAL_CACHE` | `0` / `1` | `0` | Forces re-measurement in 11. |
|
| 427 |
| `IMATRIX_SOURCE_QUANT` | `<fmt>` / `bf16` | `Q8_0` | Source format for imatrix generation. |
|
| 428 |
+
| `LLAMA_CPP_DIR` / `LLAMA_<NAME>_PATH` | `<path>` | — | Custom llama.cpp binaries; without them, `llama-cpp/build/bin/Release` first, then `llama-cpp/` (§3.1). |
|
| 429 |
|
| 430 |
---
|
| 431 |
|
|
|
|
| 442 |
- **NTFS Xpress8K** compresses BF16 GGUFs and KL bases (~18%). Quantized payloads and the imatrix stay raw, since their high entropy makes decompression a tax with no gain.
|
| 443 |
- **Content-addressed eval cache** (`eval-cache.json` + `PC.fast_content_id`) makes repeated duels, sweeps and byte-identical evaluations instantaneous (10 min → milliseconds); a rerun of the ladder measures only what changed.
|
| 444 |
|
| 445 |
+
- **Speculative drafts and the KV cache**: with a draft, the target verifies `n_max + 1` tokens per cycle; on a quantized target KV that batch leaves the fast single-token kernel and converts the whole cache to f16 on every verification, a cost that grows with the context. The target KV stays f16 while it fits (Spark-X2.6-4B: 36 KiB per token, ≈ 64–70K tokens on 8 GB), q8_0 beyond, with a smaller gain (×1.51 at 64K on the 4B); the draft KV stays f16 (a 512-token window: a few MiB).
|
| 446 |
+
|
| 447 |
---
|
| 448 |
|
| 449 |
## 13. Agent Profile Standard
|
| 450 |
|
| 451 |
### 13.1 Principle
|
| 452 |
|
| 453 |
+
The bench asks questions with one verifiable answer and checks them with code. The answer keys are recomputed by independent methods at startup (`verify`), live in a `FIXTURES` block that the script cuts out of the copy of itself that the model reads, and stay hidden from the model; the offline checks of `verify` sit in `OFFLINE` blocks, cut out the same way, so the corpus never grows with them. The model reads the bench source and this document: the corpus of the document categories is the tool that tests it.
|
| 454 |
|
| 455 |
The bench carries its exercises and needs no external file. Without this document, the corpus is the bench source alone and the document questions are not asked. Up to a 128K window the model reads the bench source and this document, and the exercises turn around the bench. Above it, the long tier reads every file at once — `Paretrix.py` (with a line-number margin), `Paretrix-modules.py`, `03_BF16-GGUF-to-Paretrix.py`, the bench source and this document, about 150K tokens, whole and never trimmed — and the exercises turn around `Paretrix.py` and the bench. The bench source alone feeds the self tier, so the repository natures (line ranges, constants) reach every model whatever its window. The photograph `LaTeX-OCR.jpg` serves its own exercises, the printed formula, the handwritten line and the scene.
|
| 456 |
|
|
|
|
| 466 |
| extraction | 5 | Exact source of functions, a configuration block and prose paragraphs | text similarity |
|
| 467 |
| doc_qa | 10 | Questions answered from this document and from the bench source | fact patterns |
|
| 468 |
| needle_max | 5 / rung | The needle rounds on generated Python modules that fill the largest window the model loads, at a half and all of the room the window leaves | exact per place, per rung |
|
| 469 |
+
| repo_map | 5 | On the long corpus (`--long`), around `Paretrix.py` and the bench: callers, transitive callers, direct and route callees, and readers of a constant (a call resolves inside its own file; a function that calls through a table, `SCORERS[k](…)`, asks no callee question) | AST set |
|
| 470 |
| repo_locate | 10 | Line range of functions and constants of `Paretrix.py`, read from its line-number margin inside the long corpus | each end is worth half; on a multi-line range an end within 2 lines counts as right, a single-line constant cited 1 line off earns half credit |
|
| 471 |
| repo_extract | 5 | Exact copy of functions and configuration blocks of `Paretrix.py` and the bench | text similarity |
|
| 472 |
| repo_qa | 10 | Questions answered from the constants of `Paretrix.py`, `Paretrix-modules.py` and `03_BF16-GGUF-to-Paretrix.py` | fact patterns |
|
|
|
|
| 494 |
| self | self_locate, self_qa: the bench source alone, numbered | smallest listed window that holds it with its thinking room (96K typical) |
|
| 495 |
| vision | ocr, ocr_formula; the only residency that loads the projector | 32K (24K when memory is short) |
|
| 496 |
|
| 497 |
+
Windows come from the listed sizes 24K, 32K, 40K, 48K, 64K, 80K, 96K, 128K, 144K, 160K, 176K, 192K, 256K and above; recurrent (GDN, SSM) and sliding-window (SWA) hybrids start at the full window and step down on the post-load VRAM check. A load that exceeds the GPU steps down one listed size; one whose compute buffers or post-load VRAM floor fail loads again at `-ub 256` first (half the attention mask: prefill a little slower, decoding unchanged; `--ubatch` sets it). Answer room shrinks before the corpus does, and the standard corpus gives up this document first; the bench source always stays. When the long corpus does not fit whole in a model's window (a 128K model, for instance), the repository categories are skipped, never served an excerpt, so a `repo_*` score always describes the whole corpus; `self_locate` and `self_qa` cover the same natures for every window. The deep needle asks its five questions on generated Python modules, at a half and all of the room that the largest window leaves; the largest rung with every answer right is the capacity of the model, written to the registry. In the long corpus `Paretrix.py` carries its line numbers in a left margin (the self tier numbers the bench), so that a model cites a line without counting it; a bare call resolves to a function of its own file, so two files never share a call edge. A bare `python 15_subagent-profile-bench.py model.gguf` runs the whole compatible battery: the repository categories and the deep needle join when `Paretrix.py` sits beside the script (`--no-long` keeps them out), and every skipped exercise prints its reason.
|
| 498 |
|
| 499 |
### 13.4 Decoding and reasoning
|
| 500 |
|
| 501 |
Every model starts from the shared base sampler (`top_k=20`, `top_p=0.95`, `repeat_penalty=1.05`), and the temperature follows the category: 0.15 for the transcription and OCR categories, 0.3 elsewhere. On thinking categories, truncation knobs declared in `generation_config.json` (`top_k`, `top_p`, `min_p`) overlay the base defaults while keeping the category temperature and the bench's repeat penalty, and `--sampling` overrides any knob explicitly.
|
| 502 |
|
| 503 |
+
Reasoning effort follows the work: `low` for finding and copying, `medium` for reading, code, math and logic (`--effort high` raises every category). A template that reads `reasoning_effort` receives the level, and every thinking request (except families with custom closing tags) also receives a per-request thinking budget of 8192 or 16384 tokens (73728 at `high`; `--budget off` removes it), expanding the request ceiling inside the available window room so a reasoning trace has space to conclude before emitting the final answer.
|
| 504 |
|
| 505 |
+
Output ceilings: 2048 tokens (canary, abstention, defs), 4096 (needle, doc_qa, repo_locate, repo_qa), 8192 (extraction, repo_extract, shell), 10240 (needle_max), 12288 (relations, code, repo_map, math, logic), then 2048 and 1024 without thinking; every thinking category expands its request ceiling up to `budget + 2048` within the free room of the loaded window (and the planner sizes each window on that room, so a tokenizer that packs the corpus just under a listed size keeps the whole budget) so the full 8192 / 16384 thinking budgets apply across both standalone and document tiers. At the budget the server closes the reasoning and the model answers in the 2048 tokens left: the longest right answers measured sit below the budgets (14.7K tokens for medium, Spark-X2.6-1.7B in math), and a reasoning that loops ends there, 8K tokens sooner than at 24576. Cut at the budget in mid-search, a model may write its template's effort tag as a tool call (`<tool_call>thinking_effort…`) instead of an answer: a broken answer, an invention only when a claim stands beside it. Categories without logical reasoning (`transcription`, `ocr`, `ocr_formula`) disable thinking (`enable_thinking=False` and budget `0`), or fall back to `reasoning_effort=low` when the template keeps thinking open. The window caps them, and a truncated answer scores 0.
|
| 506 |
|
| 507 |
### 13.5 Scoring
|
| 508 |
|
| 509 |
- **Item score** runs from 0 to 1; a category scores the mean of its items. The note is D/10 = 10 × mean, shown as `9.20/10 (9.0★)`.
|
| 510 |
- **Efficiency index** η = 0.5 × (1 / (1 + t / ref) + 1 / (1 + w / (ref / 50))) combines the token brevity and the decoding throughput (t/s) of reasoning over the fully right answers of a mastered thinking category (mean ≥ 0.50 with emitted reasoning), where t is the mean number of generated tokens, w the mean duration in seconds, 50 t/s the reference sub-agent decoding speed (keeping delegated calls inside a 300 s / 5-minute orchestrator prompt-cache TTL), and ref the token reference of that category (256 for canary, needle and abstention · 384 for needle_max · 512 for defs · 1024 for extraction, doc_qa, shell, repo_locate and repo_extract · 2048 for relations and repo_qa · 4096 for code, math, logic and repo_map). A run reports the mean over the categories that have right answers alongside tokens per right answer, decoding t/s and the share of items completed within 300 s, next to D/10 and apart from it. `--aggregate` also prints the index of each category apart, so that two models compare on the categories they share.
|
| 511 |
+
- **Reading the answer**: a judge reads the answer where a sub-agent writes it and scores its content alone, the way an orchestrator receiving it would: the requested key after a lead-in (`Answer: CALLERS=main`), a value kept inside the placeholder's angle brackets (`ANSWER=<…>`), a key left empty above its list, the bare list or the `\boxed{}` result an answer closes on when it never wrote its key, islanders labelled (`A=K`) or spelled out (`knight`), list numbering, a remark after the printed output, a tuple printed around the values (`print((a, b))`), typographic quotes, a lead-in or a closing remark around a copied function, and a fraction kept with its source's parentheses. A wrong name, value, line, line break or letter keeps its full cost: the tolerance is on the form, never on the content, and `verify` checks both sides on every category.
|
| 512 |
- **Hallucination rate** is the share of absent-element questions (abstention, needle round 3) answered with an invention; `CODE=ABSENT` counts as an abstention.
|
| 513 |
+
- **Declining**: the system prompt asks for an answer in English, a short reasoning, the final answer once established, and `I don't know.` when the answer cannot be established; `ABSENT` reports a check (the files lack the element), `I don't know.` reports that the model could not tell. A declined answer scores 0 and is never an invention: the orchestrator asks elsewhere. Template markup left by a forced end of thinking (`<tool_call>`, `thinking_effort`) with no code or location beside it is a broken answer, never an invention either. Category lines and results count the declined answers.
|
| 514 |
- **Needle position** is the third of the context (1/3, 2/3 or 3/3) where each note sits, measured in tokens on the prompt the model reads; the report lists the score per third.
|
| 515 |
|
| 516 |
### 13.6 Roles
|
|
|
|
| 519 |
|
| 520 |
### 13.7 Registry and integrity
|
| 521 |
|
| 522 |
+
`agent-profile.csv` holds one row per protocol key (revision, model, arm, KV types, draft `n_max`, system prompt hash, seeds, head, effort, document nodes, template, reasoning cap, sampling); the views label a draft arm with its file and `n_max`, so two drafts of one model keep their own rows. A partial run updates only the cells it measured, and a revision change opens a new protocol. The questions on the files (functions, constants, paragraphs, callers) are drawn by a hash of their names, so an edit elsewhere in a file leaves them in place and models measured weeks apart answer the same ones; their truths are read from the files as they stand. Besides the category means, a row records the windows, the decoding speed of each tier (the arm's speed averages the tiers it ran, so rows compare tier by tier at equal windows), the hallucination rate, the efficiency index, the tokens per right answer and the needle score per third. Every completed arm and `--aggregate` write the comparative Markdown synthesis `agents-profiles/agent-profile.md` (configurations, category matrix, efficiency and speed table, per-category efficiency, gap against the reference sub-agent, and best candidate per role).
|
| 523 |
|
| 524 |
`verify` checks the bench without a model: answer keys recomputed by independent methods (programs executed, format keys), the judges' tolerance, the redacted copy free of keys, canaries and needles planted, every category counted on the real corpus (a multiple of 5 items on this host), planner scenarios and document facts. Every answer is echoed to the console as it is scored: the item line carries the verdict, and on a non-perfect item an indented second line gives the expected and received values once, so the category line closes with its summary alone; the run closes with a records table read from the registry, and the shell category executes bash and PowerShell scripts in a scratch folder.
|
README.md
CHANGED
|
@@ -13,11 +13,11 @@ tags:
|
|
| 13 |
- vision
|
| 14 |
---
|
| 15 |
|
| 16 |
-
# Paretrix Quantization Suite (v3.
|
| 17 |
|
| 18 |
[](https://github.com/ggml-org/llama.cpp)
|
| 19 |
[](#-benchmarks)
|
| 20 |
-
[ — dense SWA hybrid 3:1 · tied 131k vocab
|
| 164 |
-
*BF16 7,849 MiB · target: 6+ GB VRAM · PPL reference 14.7611 · ladder from scratch in 1h30 (matrix 33 min, 39 of 74 cells).*
|
| 165 |
|
| 166 |
| Model | MiB | PPL | ΔPPL | KLD | RMS Δp | top-p | Pareto |
|
| 167 |
| :--- | ---: | ---: | ---: | ---: | ---: | ---: | :--- |
|
|
@@ -252,7 +252,30 @@ Models run from largest to smallest by BF16 size, and each table runs from large
|
|
| 252 |
|
| 253 |
---
|
| 254 |
|
| 255 |
-
### 8. [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
*BF16 2,950 MiB · target: 2+ GB VRAM · PPL reference 12.3827.*
|
| 257 |
|
| 258 |
| Model | MiB | PPL | ΔPPL | KLD | RMS Δp | top-p | Pareto |
|
|
@@ -275,7 +298,7 @@ Models run from largest to smallest by BF16 size, and each table runs from large
|
|
| 275 |
|
| 276 |
---
|
| 277 |
|
| 278 |
-
###
|
| 279 |
*BF16 1,446 MiB · target: 2+ GB VRAM · PPL reference 29.1182.*
|
| 280 |
|
| 281 |
| Model | MiB | PPL | ΔPPL | KLD | RMS Δp | top-p | Pareto |
|
|
@@ -311,6 +334,7 @@ Families run from largest to smallest. Reading grid at the verdict regime: 🟢
|
|
| 311 |
| **TwIL-LM3-Pro** | Dense, untied | 0.0309 🟢 | 0.0552 🟢 | 0.0989 🟢 |
|
| 312 |
| **MiniCPM5-2B** | Dense, untied | 0.0551 🟢 | 0.1029 🟡 | 0.2073 🔴 |
|
| 313 |
| **LFM3-1.7B** | Conv/attention hybrid | 0.1397 🟡 | 0.2104 🔴 | 0.3574 🔴 |
|
|
|
|
| 314 |
| **ReaderLM-v2** | Dense, tied | 0.0530 🟢 | 0.0988 🟢 | 0.1816 🟡 |
|
| 315 |
| **OvisOCR3** | GDN hybrid, tied | 0.0849 🟢 | 0.1702 🟡 | 0.2947 🔴 |
|
| 316 |
|
|
@@ -318,7 +342,7 @@ Families run from largest to smallest. Reading grid at the verdict regime: 🟢
|
|
| 318 |
|
| 319 |
## Summary — strict Pareto dominations
|
| 320 |
|
| 321 |
-
**
|
| 322 |
|
| 323 |
| Family | Product | KLD | Stock twin | Stock KLD | ΔKLD | ΔMiB |
|
| 324 |
| :--- | :--- | ---: | :--- | ---: | ---: | ---: |
|
|
@@ -328,6 +352,8 @@ Families run from largest to smallest. Reading grid at the verdict regime: 🟢
|
|
| 328 |
| Spark-X2.6-4B | **Femto-21pc** | 0.3717 | IQ3_M-imx | 0.4527 | −0.0810 | −198 |
|
| 329 |
| TwIL-LM3-Pro | **Femto-21pc** | 0.0989 | IQ3_M-imx | 0.1056 | −0.0067 | −100 |
|
| 330 |
| MiniCPM5-2B | **Nano-27pc** | 0.0551 | IQ4_XS-imx | 0.0718 | −0.0167 | −8 |
|
|
|
|
|
|
|
| 331 |
| ReaderLM-v2 | **Nano-27pc** | 0.0530 | IQ4_XS-imx | 0.0580 | −0.0050 | −27 |
|
| 332 |
| OvisOCR3 | **Mini-30pc** | 0.0544 | IQ4_XS-imx | 0.0592 | −0.0048 | −34 |
|
| 333 |
| OvisOCR3 | **Nano-27pc** | 0.0849 | IQ3_M-imx | 0.1561 | −0.0712 | −28 |
|
|
@@ -343,7 +369,7 @@ Paretrix quantizes speculative modules imatrix-free (`Paretrix-modules.py`). A d
|
|
| 343 |
| Module | Role | Palette | Naming |
|
| 344 |
| :--- | :--- | :--- | :--- |
|
| 345 |
| **MTP** | Multi-token prediction fusion head (extracted by 01) | Role floors + K-quants | `mtp-Paretrix-<Profile>.gguf` |
|
| 346 |
-
| **DSpark** | Block-diffusion speculative draft (Markov + confidence heads) | Role floors + K-quants | `dspark-Paretrix-<Profile>.gguf` |
|
| 347 |
| **DFlash** | Third-party block-diffusion draft | Role floors + K-quants | `dflash-Paretrix-<Profile>.gguf` |
|
| 348 |
| **MMProj** | CLIP vision projector | Profile grid, critical tensors pinned F32 | `mmproj-Paretrix-<Profile>.gguf` |
|
| 349 |
|
|
@@ -360,6 +386,41 @@ python 14_gguf-module-fusion.py fused.gguf model-BF16.gguf mmproj-BF16.gguf
|
|
| 360 |
python 14_gguf-module-fusion.py MyModel/Paretrix mtp-Paretrix-Balanced.gguf
|
| 361 |
```
|
| 362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
---
|
| 364 |
|
| 365 |
## ⚡ Quick start
|
|
@@ -382,6 +443,10 @@ python 00_Paretrix-pipeline.py ./MyModel --all-classics
|
|
| 382 |
# Sweep every product at the verdict regime
|
| 383 |
python 11_perplexity-test.py
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
# What the suite knows about a model · its champions against their plans
|
| 386 |
python Paretrix.py show ./MyModel
|
| 387 |
python Paretrix.py verify ./MyModel
|
|
@@ -393,7 +458,7 @@ python Paretrix.py fold
|
|
| 393 |
python Paretrix.py tidy ./MyModel --publish
|
| 394 |
```
|
| 395 |
|
| 396 |
-
**Working-root convention.** A model folder holds its HF repo (safetensors + sidecars) plus a `Paretrix/` subfolder carrying every product: BF16/Q8/imatrix GGUFs, the stock line, champions, modules, and `model-paretrix.json`.
|
| 397 |
|
| 398 |
```
|
| 399 |
<model folder>/
|
|
@@ -401,6 +466,7 @@ python Paretrix.py tidy ./MyModel --publish
|
|
| 401 |
└─ Paretrix/
|
| 402 |
├─ model-BF16.gguf · model-Q8_0.gguf · imatrix.gguf · model-<Q6_K|IQ4_XS>-imx.gguf (+ Q5_K_M, IQ3_M with --all-classics)
|
| 403 |
├─ model-Paretrix-<Tier>-<XX>pc.gguf (+ .provenance.json) · mtp/mmproj/dspark products
|
|
|
|
| 404 |
├─ model-paretrix.json (matrices, plans, laws, champions: the file to share)
|
| 405 |
├─ mtp/model-mtp-Paretrix-<Tier>-<XX>pc.gguf (14 graft: the rung + its MTP head)
|
| 406 |
└─ _transient/ · _logs/ · kld-bf16-ctx<N>.dat · eval-cache.json (harness caches; tidy --publish)
|
|
|
|
| 13 |
- vision
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# Paretrix Quantization Suite (v3.1.0)
|
| 17 |
|
| 18 |
[](https://github.com/ggml-org/llama.cpp)
|
| 19 |
[](#-benchmarks)
|
| 20 |
+
[](#summary--strict-pareto-dominations)
|
| 21 |
|
| 22 |
**Paretrix** is an empirical, activation-aware quantization suite for GGUF language models and speculative decoding modules.
|
| 23 |
|
|
|
|
| 161 |
---
|
| 162 |
|
| 163 |
### 4. [XHToken/Spark-X2.6-4B](https://huggingface.co/XHToken/Spark-X2.6-4B) — dense SWA hybrid 3:1 · tied 131k vocab
|
| 164 |
+
*BF16 7,849 MiB · target: 6+ GB VRAM · PPL reference 14.7611 · ladder from scratch in 1h30 (matrix 33 min, 39 of 74 cells) · [DSpark draft](https://huggingface.co/XHToken/Spark-X2.6-4B-DSpark-GGUF), quantized as Paretrix-Balanced (×1.79) and rebuilt by 16 (`draft-32K` ×2.07 · `draft-lite` ×1.81).*
|
| 165 |
|
| 166 |
| Model | MiB | PPL | ΔPPL | KLD | RMS Δp | top-p | Pareto |
|
| 167 |
| :--- | ---: | ---: | ---: | ---: | ---: | ---: | :--- |
|
|
|
|
| 252 |
|
| 253 |
---
|
| 254 |
|
| 255 |
+
### 8. [XHToken/Spark-X2.6-1.7B](https://huggingface.co/XHToken/Spark-X2.6-1.7B) — dense SWA hybrid 3:1 · tied 131k vocab
|
| 256 |
+
*BF16 3,262 MiB · target: 2+ GB VRAM · PPL reference 36.2154 · [DSpark draft](https://huggingface.co/XHToken/Spark-X2.6-1.7B-DSpark-GGUF), quantized as Paretrix-Balanced (×1.40) and rebuilt by 16 (`draft-32K` ×1.58 · `draft-lite` ×1.55).*
|
| 257 |
+
|
| 258 |
+
| Model | MiB | PPL | ΔPPL | KLD | RMS Δp | top-p | Pareto |
|
| 259 |
+
| :--- | ---: | ---: | ---: | ---: | ---: | ---: | :--- |
|
| 260 |
+
| Q8_0 (stock) | 1736 | 36.5458 | +0.3304 | 0.0063 | 1.87% | 95.8% | ★ |
|
| 261 |
+
| **Fidelity-48pc** ⭐ | 1569 | 36.6322 | +0.4169 | 0.0170 | 2.85% | 93.4% | ★ |
|
| 262 |
+
| **Precision-42pc** | 1399 | 36.6095 | +0.3942 | 0.0247 | 3.53% | 91.5% | ★ |
|
| 263 |
+
| Q6_K-imx (stock) | 1341 | 36.0955† | −0.1199 | 0.0412 | 4.58% | 89.7% | ★ |
|
| 264 |
+
| **Quality-36pc** | 1202 | 35.2522† | −0.9632 | 0.0517 | 5.13% | 88.2% | ★ |
|
| 265 |
+
| Q5_K_M-imx (stock) | 1194 | 36.7500 | +0.5346 | 0.0840 | 6.11% | 86.0% | ★ |
|
| 266 |
+
| **Compact-33pc** | 1106 | 33.3808† | −2.8346 | 0.0984 | 6.83% | 83.8% | ★ |
|
| 267 |
+
| **Mini-30pc** | 1008 | 34.0220† | −2.1934 | 0.1352 | 7.74% | 81.4% | ★ |
|
| 268 |
+
| IQ4_XS-imx (stock) | 971 | 37.6937 | +1.4783 | 0.2728 | 11.24% | 74.9% | < **Nano-27pc** |
|
| 269 |
+
| **Nano-27pc** | 915 | 37.2969 | +1.0816 | **0.1961** | 9.38% | 77.7% | ★ |
|
| 270 |
+
| IQ3_M-imx (stock) | 848 | 53.1946 | +16.9793 | 0.5182 | 16.39% | 65.6% | < **Pico-24pc** |
|
| 271 |
+
| **Pico-24pc** | 821 | 45.7963 | +9.5810 | **0.3746** | 13.30% | 70.1% | ★ |
|
| 272 |
+
| **Femto-21pc** | 728 | 42.5738 | +6.3585 | 0.5611 | 16.23% | 64.4% | ★ |
|
| 273 |
+
|
| 274 |
+
*Nano-27pc strictly dominates IQ4_XS-imx (−0.0767 KLD, −56 MiB); Pico-24pc strictly dominates IQ3_M-imx (−0.1436 KLD, −26 MiB); Fidelity-48pc ⭐ holds 93.4% top-p at 1569 MiB, ×2.1 smaller than BF16.*
|
| 275 |
+
|
| 276 |
+
---
|
| 277 |
+
|
| 278 |
+
### 9. [jinaai/ReaderLM-v2](https://huggingface.co/jinaai/ReaderLM-v2) — dense qwen2 · tied 152k vocab · HTML/Markdown extractor
|
| 279 |
*BF16 2,950 MiB · target: 2+ GB VRAM · PPL reference 12.3827.*
|
| 280 |
|
| 281 |
| Model | MiB | PPL | ΔPPL | KLD | RMS Δp | top-p | Pareto |
|
|
|
|
| 298 |
|
| 299 |
---
|
| 300 |
|
| 301 |
+
### 10. [ATH-MaaS/OvisOCR3](https://huggingface.co/ATH-MaaS/OvisOCR3) — qwen35 GDN hybrid · tied 248k vocab · OCR
|
| 302 |
*BF16 1,446 MiB · target: 2+ GB VRAM · PPL reference 29.1182.*
|
| 303 |
|
| 304 |
| Model | MiB | PPL | ΔPPL | KLD | RMS Δp | top-p | Pareto |
|
|
|
|
| 334 |
| **TwIL-LM3-Pro** | Dense, untied | 0.0309 🟢 | 0.0552 🟢 | 0.0989 🟢 |
|
| 335 |
| **MiniCPM5-2B** | Dense, untied | 0.0551 🟢 | 0.1029 🟡 | 0.2073 🔴 |
|
| 336 |
| **LFM3-1.7B** | Conv/attention hybrid | 0.1397 🟡 | 0.2104 🔴 | 0.3574 🔴 |
|
| 337 |
+
| **Spark-X2.6-1.7B** | SWA hybrid, tied | 0.1961 🟡 | 0.3746 🔴 | 0.5611 🔴 |
|
| 338 |
| **ReaderLM-v2** | Dense, tied | 0.0530 🟢 | 0.0988 🟢 | 0.1816 🟡 |
|
| 339 |
| **OvisOCR3** | GDN hybrid, tied | 0.0849 🟢 | 0.1702 🟡 | 0.2947 🔴 |
|
| 340 |
|
|
|
|
| 342 |
|
| 343 |
## Summary — strict Pareto dominations
|
| 344 |
|
| 345 |
+
**11 products** are at most as heavy as their stock neighbour and better beyond the tie zone, at the verdict regime. Families run from largest to smallest; tiers run from largest to smallest within each family.
|
| 346 |
|
| 347 |
| Family | Product | KLD | Stock twin | Stock KLD | ΔKLD | ΔMiB |
|
| 348 |
| :--- | :--- | ---: | :--- | ---: | ---: | ---: |
|
|
|
|
| 352 |
| Spark-X2.6-4B | **Femto-21pc** | 0.3717 | IQ3_M-imx | 0.4527 | −0.0810 | −198 |
|
| 353 |
| TwIL-LM3-Pro | **Femto-21pc** | 0.0989 | IQ3_M-imx | 0.1056 | −0.0067 | −100 |
|
| 354 |
| MiniCPM5-2B | **Nano-27pc** | 0.0551 | IQ4_XS-imx | 0.0718 | −0.0167 | −8 |
|
| 355 |
+
| Spark-X2.6-1.7B | **Nano-27pc** | 0.1961 | IQ4_XS-imx | 0.2728 | −0.0767 | −56 |
|
| 356 |
+
| Spark-X2.6-1.7B | **Pico-24pc** | 0.3746 | IQ3_M-imx | 0.5182 | −0.1436 | −26 |
|
| 357 |
| ReaderLM-v2 | **Nano-27pc** | 0.0530 | IQ4_XS-imx | 0.0580 | −0.0050 | −27 |
|
| 358 |
| OvisOCR3 | **Mini-30pc** | 0.0544 | IQ4_XS-imx | 0.0592 | −0.0048 | −34 |
|
| 359 |
| OvisOCR3 | **Nano-27pc** | 0.0849 | IQ3_M-imx | 0.1561 | −0.0712 | −28 |
|
|
|
|
| 369 |
| Module | Role | Palette | Naming |
|
| 370 |
| :--- | :--- | :--- | :--- |
|
| 371 |
| **MTP** | Multi-token prediction fusion head (extracted by 01) | Role floors + K-quants | `mtp-Paretrix-<Profile>.gguf` |
|
| 372 |
+
| **DSpark** | Block-diffusion speculative draft (Markov + confidence heads) | Role floors + K-quants | `dspark-Paretrix-<Profile>.gguf` · rebuilt by 16: `draft-<tag>/dspark-<tag>-Paretrix-Balanced.gguf` |
|
| 373 |
| **DFlash** | Third-party block-diffusion draft | Role floors + K-quants | `dflash-Paretrix-<Profile>.gguf` |
|
| 374 |
| **MMProj** | CLIP vision projector | Profile grid, critical tensors pinned F32 | `mmproj-Paretrix-<Profile>.gguf` |
|
| 375 |
|
|
|
|
| 386 |
python 14_gguf-module-fusion.py MyModel/Paretrix mtp-Paretrix-Balanced.gguf
|
| 387 |
```
|
| 388 |
|
| 389 |
+
### 🧬 DSpark drafts rebuilt — `16_dspark-generator.py`
|
| 390 |
+
|
| 391 |
+
An official DSpark draft re-reads the target's whole vocab head on every draft pass. **16** gives it a readout of its own, the 32,768 tokens the target actually generates (99.45% of them), with no training and the same logits on those tokens (`draft-32K`); or prunes it and trains it for a night (`draft-lite`, `--lite`); or trains a Lite draft from the target's own layers when no official draft exists (home mode). Every draft is quantized by `Paretrix-modules.py` (Balanced), measured by 13 at each `n_max`, and shipped in its own folder with the `llama-server` flags of the fastest. The official draft can be given as its HF folder: 16 converts it first.
|
| 392 |
+
|
| 393 |
+
| Target | Draft | Module | Speedup |
|
| 394 |
+
| :--- | :--- | ---: | ---: |
|
| 395 |
+
| Spark-X2.6-4B | official draft | 415 MiB | ×1.79 |
|
| 396 |
+
| Spark-X2.6-4B | **`draft-32K`** · official layers + own readout | 453 MiB | **×2.07** |
|
| 397 |
+
| Spark-X2.6-4B | `draft-lite` · trained from the target's layers | 179 MiB | ×1.81 |
|
| 398 |
+
| Spark-X2.6-1.7B | official draft | 232 MiB | ×1.40 |
|
| 399 |
+
| Spark-X2.6-1.7B | **`draft-32K`** · official layers + own readout | 259 MiB | **×1.58** |
|
| 400 |
+
| Spark-X2.6-1.7B | `draft-lite` · official pruned and trained | 143 MiB | ×1.55 |
|
| 401 |
+
|
| 402 |
+
*Every draft quantized Paretrix-Balanced; 13 at ctx 4096, target and draft KV f16, 24 thinking probes, RTX 4060 8 GB, n_max 5 (the best for every draft); each speedup against the baseline of its own sweep.*
|
| 403 |
+
|
| 404 |
+
```bash
|
| 405 |
+
python 16_dspark-generator.py MyModel/Paretrix/model-Paretrix-Precision-42pc.gguf MyModel-DSpark # convert (≈ 10 min)
|
| 406 |
+
python 16_dspark-generator.py MyModel/Paretrix/model-Paretrix-Precision-42pc.gguf official.gguf --lite # a night
|
| 407 |
+
python 16_dspark-generator.py MyModel/Paretrix/model-Paretrix-Precision-42pc.gguf # home mode
|
| 408 |
+
```
|
| 409 |
+
|
| 410 |
+
---
|
| 411 |
+
|
| 412 |
+
## 🤖 Sub-agent profile — `15_subagent-profile-bench.py`
|
| 413 |
+
|
| 414 |
+
**15** judges a GGUF as the sub-agent a larger hosted model delegates to: finding a constant in 100K tokens, abstaining on names that exist nowhere, mapping callers, copying a block verbatim, predicting programs and shell one-liners, computing, converting formats, reading images. Every answer is scored by code (AST sets, exact keys, executed programs; no judge model), and a registry row per configuration opens roles (`scout`, `trusted`, `cartographer`, `extractor`, `documentalist`…). The arms compare the target alone, with its MTP head, or with a draft found beside it or in its `draft-*/` folders.
|
| 415 |
+
|
| 416 |
+
On Spark-X2.6-1.7B Precision-42pc (windows of 131K to 524K tokens, KV q5_1), the `draft-lite` DSpark doubles the decoding speed of the whole battery: **47.6 → 98.9 t/s** (acceptance 57.3%), with no invention on the 20 absent-element questions in either arm. On Spark-X2.6-4B Quality-36pc, `draft-32K` decodes **3.1–3.3×** faster than the target alone at every tier (25.4 → 81.7 t/s at 131K, acceptance 54.6%) and `draft-lite` 1.5–2.4×; on 8 GB both hold the 196K window that reads the whole repository corpus, `draft-32K` at `-ub 256`. A draft changes the speed, never the answers: the target verifies every token. Each size takes its own place: Spark-X2.6-1.7B Fidelity-48pc opens `scout` (the deep needle held at 247K tokens in a 524K window; every function of the 181K-token repository corpus located and copied, at 51 t/s), a scout that reports on a whole repository; Spark-X2.6-4B Quality-36pc reaches 9.61/10 over 19 categories with `trusted`, `cartographer`, `mathematician` and `transcriber`, an analyst and verifier.
|
| 417 |
+
|
| 418 |
+
```bash
|
| 419 |
+
python 15_subagent-profile-bench.py verify # offline integrity of the answer keys, no model
|
| 420 |
+
python 15_subagent-profile-bench.py MyModel/Paretrix/model-Paretrix-Precision-42pc.gguf
|
| 421 |
+
python 15_subagent-profile-bench.py --aggregate # registry: configurations, matrix, roles
|
| 422 |
+
```
|
| 423 |
+
|
| 424 |
---
|
| 425 |
|
| 426 |
## ⚡ Quick start
|
|
|
|
| 443 |
# Sweep every product at the verdict regime
|
| 444 |
python 11_perplexity-test.py
|
| 445 |
|
| 446 |
+
# A DSpark draft for the model (16), its acceptance (13), its sub-agent profile (15)
|
| 447 |
+
python 16_dspark-generator.py MyModel/Paretrix/model-Paretrix-Precision-42pc.gguf MyModel-DSpark
|
| 448 |
+
python 15_subagent-profile-bench.py MyModel/Paretrix/model-Paretrix-Precision-42pc.gguf
|
| 449 |
+
|
| 450 |
# What the suite knows about a model · its champions against their plans
|
| 451 |
python Paretrix.py show ./MyModel
|
| 452 |
python Paretrix.py verify ./MyModel
|
|
|
|
| 458 |
python Paretrix.py tidy ./MyModel --publish
|
| 459 |
```
|
| 460 |
|
| 461 |
+
**Working-root convention.** A model folder holds its HF repo (safetensors + sidecars) plus a `Paretrix/` subfolder carrying every product: BF16/Q8/imatrix GGUFs, the stock line, champions, modules, and `model-paretrix.json`. Every script finds the llama.cpp binaries in `llama-cpp/build/bin/Release` first, then at the root of `llama-cpp/` (`LLAMA_CPP_DIR` and `LLAMA_<NAME>_PATH` override both).
|
| 462 |
|
| 463 |
```
|
| 464 |
<model folder>/
|
|
|
|
| 466 |
└─ Paretrix/
|
| 467 |
├─ model-BF16.gguf · model-Q8_0.gguf · imatrix.gguf · model-<Q6_K|IQ4_XS>-imx.gguf (+ Q5_K_M, IQ3_M with --all-classics)
|
| 468 |
├─ model-Paretrix-<Tier>-<XX>pc.gguf (+ .provenance.json) · mtp/mmproj/dspark products
|
| 469 |
+
├─ draft-official/ · draft-32K/ · draft-lite/ (16: official BF16 drafts and the rebuilt DSpark drafts)
|
| 470 |
├─ model-paretrix.json (matrices, plans, laws, champions: the file to share)
|
| 471 |
├─ mtp/model-mtp-Paretrix-<Tier>-<XX>pc.gguf (14 graft: the rung + its MTP head)
|
| 472 |
└─ _transient/ · _logs/ · kld-bf16-ctx<N>.dat · eval-cache.json (harness caches; tidy --publish)
|