Skip to content

hyperloom custom workload: name the gate reference in every compared result - #955

Merged
bong-water-water-bong merged 14 commits into
mainfrom
1bit/hyperloom-gate-reference
Nov 4, 2026
Merged

bong-water-water-bong merged 14 commits into
mainfrom
1bit/hyperloom-gate-reference

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Root cause

quality_gate in the result JSON carries the candidate's own numbers (kld_mean, kld_max_mean,
texts_identical, texts_differing, kld_ok) and nothing about the reference those numbers are relative to.
The two references the gate uses live in HL_STATE (~/lb/hl-gate/<model-stem>), outside the checkout:

  • kld-base.kld — 1,013,178,324 B of base logits on this box (31 Oct 13:31);
  • texts.json — the baseline's three greedy replies;
  • ref.json — the baseline model fingerprint + the levers the baseline ran with.

That directory is per box, and kld() re-records the base whenever it is missing (recording = not base.is_file()),
so a KLD mean is only interpretable against these bytes — yet neither the base hash nor ref.json's fingerprint and
levers reach the report. The pair-of-record artifacts show the gap:

$ python3 -c "import json; print(sorted(json.load(open('arm_pair2_c20-A.json'))['quality_gate']))"
['kld_max_mean', 'kld_mean', 'kld_ok', 'kld_recorded', 'passed', 'reason', 'texts_differing', 'texts_identical']

Fix

gate_reference(ref, base_kld, texts_path) — one helper, reusing the existing sha256_head() the build and device
fields already use — is written to quality_gate.reference at the comparison site only, i.e. exactly when a comparison
happened. The reference-establishing half returns before it, so no result claims to have been compared against a
reference that did not exist yet. Live on this box, against the real gate state:

$ python3 -c "... print(json.dumps(m.gate_reference(ref, s/'kld-base.kld', s/'texts.json'), indent=1))"
{
 "model": "0bc73cb2357258a977f33f910a7d2b02c3c3ac7db98e4dcac6b58a8618b43827",
 "levers": {},
 "base_kld_sha256": "591c18a1b2ff504e7edc364147a324826c173d58508c335f0e4e8dbd8c91ffc8",
 "texts_sha256": "ec910c1b1caf60a319db7d249b605744e7730933b1a6ed49ad331d86f4c4981b"
}

Before/after

main  : quality_gate keys = kld_max_mean, kld_mean, kld_ok, kld_recorded, passed, reason,
                            texts_differing, texts_identical            <- no reference at all
branch: + reference = {model, levers, base_kld_sha256, texts_sha256}

Device-free: no GPU, no NPU, no load. The new unit check writes a stub base and texts file, asserts both hashes against
hashlib.sha256 of the bytes, and asserts that a changed base of the same name is a different reference (which is the
whole point).

Verification

python3 tests/hyperloom_benchmark_test.py -> hyperloom_benchmark_test: OK    (rc=0)
python3 tools/copyright.py --check        -> rc=0
diff vs origin/main: 3 files, +36/-2

No score changes: nothing here touches a measurement, a lever or a threshold — kld_max_mean, kld_ok, passed and
reason are byte-identical to before.

closes #954

…result

`quality_gate` recorded the candidate's own verdict (kld_mean, texts_identical)
and nothing about what that verdict was relative to: `HL_STATE` is per-box, and
kld() re-records kld-base.kld whenever it is missing, so the same KLD mean can
read PASS against a different reference with an identical-looking report.

gate_reference() puts the reference identity in the artifact: the baseline's
model fingerprint and levers (from ref.json) plus the SHA-256 of kld-base.kld
and texts.json. Written only where a comparison actually happened, so the
reference-establishing half does not claim to have been compared with anything.

closes #954
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

@pi-prs #955 ready for review at b49ba42

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at b49ba42f4.

Ran it: python3 tests/hyperloom_benchmark_test.py → hyperloom_benchmark_test: OK, exit 0, and py_compile on benchmark.py clean. The new arm is real and discriminating rather than descriptive — it mutates the base file (b"logits " * 1000 → * 999) and asserts the recorded base_kld_sha256 changes, which is the property the PR is about.

The placement is the right one too: gate_reference() is only called on the compared path (after the finish(True, "reference_established") return), so an establishing run does not record a reference against itself. Naming model + levers + both file hashes is what makes a KLD verdict re-checkable across sessions, and the README sentence explains why the directory alone was not enough.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit baa7c8a)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

954 - Partially compliant

Compliant requirements:

  • Every compared result now names the reference it was compared against
  • The reference includes model fingerprint, levers, and SHA-256 hashes of base logits and texts
  • The quality gate result JSON now carries information about the reference used for comparison

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Reference Naming

The gate_reference function correctly creates a reference object with model, levers, and SHA-256 hashes of base KLD and texts. However, the implementation assumes that base_kld and texts_path are always valid paths, which could lead to runtime errors if these paths do not exist or are not accessible. This could be mitigated by adding error handling or validation checks.

def gate_reference(ref, base_kld, texts_path):
    """What a gate verdict is relative to.

    A KLD mean is a distance to *these* base logits, and `HL_STATE` is per-box and regenerated when
    the base is missing, so the same number reads `PASS` against a different reference. The result
    JSON carried the half's own verdict (`kld_mean`, `texts_identical`) and nothing about the
    reference, so a report from one session could not be compared with — or re-checked against —
    another's.
    """
    return {"model": ref.get("model"), "levers": ref.get("levers"),
            "base_kld_sha256": sha256_head(base_kld), "texts_sha256": sha256_head(texts_path)}

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit d58cbd5

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 2e37a3e

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 348378f

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit feb4b9c

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit ea9f50d

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 8fd2a18

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 978807e

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 06e7f17

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 46ba12c

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit d0a567f

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit baa7c8a

@bong-water-water-bong
bong-water-water-bong merged commit 485f998 into main Nov 4, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/hyperloom-gate-reference branch November 4, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant