Skip to content

hw-gate: unshallow the pair's llama.cpp checkout, so a labelled PR's KLD rows can place their golden (Fixes #2713) - #2717

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-1051/2713-hwgate-unshallow
Nov 16, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-1051/2713-hwgate-unshallow

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2713.

What

The hw-gate job checks the pair out with --depth 1 and never deepens it, so each KLD verdict cannot place its
golden's recorded_at commit against the tested pin: the clone holds neither that object nor the ancestry between
them. judge returns exit 2 (INCOMPLETE) — correctly, engine#2643/#2676 — the row is SKIP with infra=1, the gate's
overall exit is 2 and the final status step fails the job. So a labelled PR read red on any pin while every
functional row passed (engine#2692: 840 s in the gate, ops 3604/3604, fa-decode-q8 6/6, kat x6, needle x5,
placement x6 greens, kld SKIP x5).

One step changes: unshallow third_party/llama.cpp before the gate runs, guarded on --is-shallow-repository so a
runner that already holds the history is a no-op instead of a --unshallow on a complete repository error.
hrx-system is not read by the KLD rows and stays shallow.

Measured (CPU only, no device, the same clone the runner makes)

Depth-1 clone of the fork at the tested pin dd9f270f6, then the manifest's own provenance():

$ git clone --depth 1 --branch 1bit/hrx-vulkan-patched … llama.cpp && git fetch --depth 1 origin dd9f270f6
golden llama.cpp 4a58da9b087d, tested dd9f270f6c1d: cannot place (4a58da9b087d is not in …/pair-shallow)
judge exit class: 2 (INCOMPLETE)                                      <- the red check, reproduced

.git 41 MB. Then git fetch --unshallow: 27 s, .git 407 MB (+366 MB), and the same three goldens that the
issue lists from a full-history worktree:

golden llama.cpp 4a58da9b087d, tested dd9f270f6c1d: golden is 234 commits behind the tested tree
golden llama.cpp 6b9fcacb7fbd, tested dd9f270f6c1d: golden is 16 commits behind the tested tree
golden llama.cpp 148e7f329ff9, tested dd9f270f6c1d: golden is 7 commits behind the tested tree

Both arms of the guard, run verbatim against the two clones:

shallow clone  -> is-shallow-repository=true  -> fetch --unshallow -> shallow now: false   (rc 0)
complete clone -> is-shallow-repository=false -> nothing          -> shallow now: false   (rc 0)

Why not the other option

"Treat a gate exit 2 whose only blocking rows are infra=1 as neutral" would make a genuinely absent input read as
a pass — the failure mode engine#2522 exists to prevent. The rows are right; the clone was wrong.

Cost

27 s and 366 MB per gate run on top of a job that is 20–30 minutes and spends most of it waiting for the GPU token
and the build; and it is paid only when the pair is not already deep (guarded).

The repo's own checks on this tree

moving_ref_check      --check  rc 0  (every inline build input pinned, 4 deliberate reads marked)
ci_targets_check      --check  rc 0  (9 targets whose test never reaches ctest under ci.yml, baseline 9)
tests_referenced_check --check rc 0  (102 scripts referenced)
conflict_marker_check --check  rc 0  (0 markers)
doc_section_loss_check --base origin/main --head HEAD  rc 0  (all 672 sections present)
bash -n scripts/hw-gate.sh                            rc 0

The workflow file itself is parsed after the edit (the step's run: still contains the submodule sync + update +
the guarded fetch + git submodule status), so the change is a step body, not a new job or a restructured file.

No behaviour change outside the gate: no test, no build step, no packaging.

…KLD rows can place their golden

The KLD verdict places each golden's recorded_at commit against the tested pin, and the gate's
pair checkout is --depth 1, so the clone held neither that object nor the ancestry between them:
every KLD row came back cannot-place -> judge exit 2 -> SKIP with infra=1 -> the gate INCOMPLETE
and the job red. engine#2692 was 840 s in the gate with ops 3604/3604, kat/needle/placement green
and kld SKIP x5, i.e. the rows were honest and the check was red on any pin.

Unshallow third_party/llama.cpp before the gate step, guarded on --is-shallow-repository so a
runner that already holds the history is a no-op instead of a --unshallow-on-a-complete-repository
error. hrx-system is not read by the KLD rows and stays shallow.

Measured on the fork (the same clone the runner makes): depth-1 .git 41 MB; fetch --unshallow 27 s,
407 MB; then the three golden bases place as 234, 16 and 7 commits behind the tested pin, and the
manifest's provenance returns those relations instead of cannot-place (engine#2643's exit-2 class).

Fixes #2713
@bong-water-water-bong
bong-water-water-bong marked this pull request as ready for review November 16, 2026 17:08

@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 at a4732ff: READY

Reproduced the whole claim on the real fork, from a clean shallow clone to a placed golden. The premise, the fix, and the guard all check out.

The premise, on a fresh --depth 1 clone of 1bit/hrx-vulkan-patched

$ git clone --depth 1 --branch 1bit/hrx-vulkan-patched https://github.com/1bit-MONSTER/llama.cpp forkchk
$ git rev-parse --is-shallow-repository   -> true
$ du -sh .git                             -> 41M
$ git cat-file -e <recorded_at>^{commit}   for the three distinct llama.cpp bases in tests/golden/hw-gate/manifest.json
4a58da9b0: MISSING      6b9fcacb7: MISSING      148e7f329: MISSING

i.e. every KLD row's recorded_at is unplaceable exactly as the body says, and the 41 MB depth-1 .git matches your measurement.

After the fix's own command

$ git fetch --unshallow        -> rc 0, 31 s
$ du -sh .git                  -> 407M
$ git rev-parse --is-shallow-repository -> false
4a58da9b0: present, 236 commits behind HEAD
6b9fcacb7: present,  18 commits behind HEAD
148e7f329: present,   9 commits behind HEAD

All three place, which is what turns the rows from SKIP infra=1 into judged rows. The behind-counts are 2 higher than the 234/16/7 in the body because my clone's tip is 2 commits past the engine pin (dd9f270f6 → 7c41f572b #411 → bb71f1be0 #408), and the difference is the same for all three — so both sets of numbers are right for their own tree. Disk is 407 MB, not 366 MB: 366 is the download, 407 is what the .git grows to (worth being precise in the comment, since the comment is what a runner-cost argument will be checked against).

The guard

Hermetic, on a scratch repo shallow-cloned over file://:

shallow before: true
shallow after : false        (fetch --unshallow ran)
--- second run
shallow before: false
shallow after : false        rc 0, no "--unshallow on a complete repository" error

--is-shallow-repository is the right test rather than a .git size or a shallow file check: my own worktree's module is 371 MB and reports shallow (it was re-shallowed after an earlier unshallow), so a size-based guard would either skip when it must not or run when it need not.

One thing to know rather than fix

The step is under set -euo pipefail, so a network failure during the unshallow fails the job instead of leaving the KLD rows to report INCOMPLETE. That is the better failure (it names the network, not the goldens) — just worth a half-sentence in the comment so the next person reading a red hw-gate knows which of the two it is.

hrx-system staying shallow is right: it is not what the KLD rows place, and it would double the fetch.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2717

A --depth 1 clone that is never deepened is a check that cannot see history — and the failure is silent in the worst way: git log -S returns nothing, so the tool concludes "nothing replaced this line" and reports a loss that may not exist, or (with the fallback) a clean scan that may. Either way the evidence was never there.

Three asks:

  1. state which way an un-deepened clone fails — if hw-gate runs the merged-tail check, an unshallow failure must be UNVERIFIABLE, not LOST and not clean. hw-gate CI: the KLD rows cannot place their golden in the runner's shallow clone, so a labelled PR is red on any pin #2713's own finding is that the shallow clone produced a wrong answer; the fix should make the absence of history an explicit state rather than a fact about the code;
  2. --depth 1 may be needed for speed — say whether the fix deepens unconditionally or to a bounded depth (--depth 200, or --shallow-since). On a busy repo an unconditional unshallow turns a 2-second checkout into a minutes-long one, and a gate that is slow gets disabled;
  3. the docs line should say the gate needs history — one sentence, because the next person to "optimise" this workflow will see --depth 1 as free and put it back (the same re-introduction risk as ci: pin the build container and the pip line, and shrink the moving-ref baseline to nothing #2709's pinned refs).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Answering the three asks at a4732ffb (head unchanged, nothing new pushed).

1. Which way an un-deepened clone fails — and it is not merged_tail_check. The gate does not run that check
(that one lives in ci.yml's own checkout, which this PR does not touch). In scripts/hw-gate.sh the only git reads
are rev-parse/ls-tree (lines 437, 856); the single consumer of pair history in the gate is
tools/hw_gate_manifest.py → judge → provenance(), and it already fails explicitly: an unplaceable base is
cannot place (…), judge returns exit 2, hw-gate.sh turns that into a SKIP row with infra=1, never a
FAIL row and never a silent pass — that is engine#2643/#2676, already merged, and it is why #2713 read as INCOMPLETE
rather than as a wrong KLD number. So the "absence of history is an explicit state" property the ask wants is already
in the tool; what was missing is that the gate's own clone could never satisfy it. This PR removes the cause instead of
re-labelling the symptom, and it deliberately does not take the other option in the issue (treat infra=1 SKIP as
neutral), because a genuinely absent input would then read as a pass — the #2522 failure mode.

2. Unconditional, and here is the measured price. The pair checkout is submodule update --init --depth 1, and the
step then runs, guarded on --is-shallow-repository:

if [ "$(git -C third_party/llama.cpp rev-parse --is-shallow-repository)" = true ]; then
  git -C third_party/llama.cpp fetch --unshallow
fi

Measured on the same fork the runner clones: depth-1 .git 41 MB → 27 s and 407 MB (+366 MB), after which the
three golden bases place as 234 / 16 / 7 commits behind the tested pin. That is ~2 % of a 20–30 minute gate job that
spends most of its wall time waiting for the token and the build. hrx-system stays shallow — no KLD row reads it.

I did not use a bounded depth on purpose: the pin moves and the goldens age (the qwen3-0.6b base is 234 commits back
today; the #2502 re-record moved another). A --depth 200 would work today and then silently stop placing a base
again — the exact class of defect this PR exists to remove, and silent is the part that hurts. The guard also means
the cost is paid only when the checkout really is shallow (a runner with a cached full pair does nothing, and does not
hit --unshallow on a complete repository); both arms of that guard were run against real clones and are in the body.

3. The docs line, and it names the re-introduction risk. docs/hw-gate.md, in the KLD section right after the
cannot place / exit-2 paragraph:

The hw-gate workflow therefore unshallows that one submodule before the gate runs (engine#2713). A person running
the gate by hand can fetch the history and re-run; a labelled PR's gate cannot, and with the pair checked out at
--depth 1 every KLD row was INCOMPLETE, so that check read red on any pin (engine#2692: 840 s in the gate, ops
3604/3604, kat/needle/placement green, kld SKIP x5). The fetch is guarded on --is-shallow-repository, so a
runner that already holds the history does nothing, and it is measured at 27 s and 366 MB on the gate box's own
clone (41 MB depth-1 .git against 407 MB unshallowed).

That is the sentence a future "let us make the checkout faster" edit will land next to, together with the number that
says what it would cost. doc_section_loss_check --base origin/main --head HEAD returns rc 0 on this head (672/672
sections present), so the paragraph is an addition, not a rewrite.

@bong-water-water-bong
bong-water-water-bong merged commit 6fa314f into main Nov 16, 2026
10 of 12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-1051/2713-hwgate-unshallow branch November 16, 2026 17:45
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two things from the review of the duplicate (#2724, now redundant) that are worth having attached to the work that actually merged — one is a follow-up and one is a sentence the file does not carry.

1. --no-tags is a real (small) saving, and it is not on main

main (0b0561a82) has:

git -C third_party/llama.cpp fetch --unshallow

The duplicate measured the same fetch with tags excluded — 31 s / 406 MB against 27 s / 366 MB from a 37/41 MB depth-1 .git — and nothing in the gate reads a tag. So fetch --unshallow --no-tags origin is a one-word change that saves ~4 s and ~40 MB per cold runner, in the step that runs before the gate takes its GPU ticket.

Not worth its own PR on a saturated build queue (this repo is at eight open PRs), so: whoever next touches hw-gate.yml for any reason should fold it in. If nobody does, it costs 4 s a run and nothing else.

2. The failure shape when the unshallow itself fails

GitHub's default shell for a run: block is bash -e {0}, so if the fetch fails — network, a flush that cannot complete, a runner that cannot reach the fork — the step aborts at the fetch, before the gate runs and before INCOMPLETE can be reported. That is the correct shape: a fetch failure is infrastructure, and dressing it as a provenance verdict would send the next reader into manifest.json looking for a commit that is perfectly fine.

One sentence beside the guard would make that legible, because the two reds look similar from the outside:

  • gate exits 2 INCOMPLETE ⇒ the ancestry could not be placed (this PR's bug, and #2676's state);
  • step aborts at the fetch ⇒ the history could not be fetched.

What this PR got exactly right, for the record

The guard is the part that needed a measurement, and the comment has it: "--unshallow fails on a complete repository". Unguarded, a green gate becomes red on every run after the first — and a self-inflicted red is how a label stops being read, which is a bigger loss than the redundancy that #2724 represented.

Placing the fetch before the GPU ticket is the other decision worth keeping: 27–31 s of history is not spent holding a device, and on a queue that has been 5–10 deep all evening that is the difference between a slot being useful and a slot being spent on git.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The fix is now exercised end to end, on the tree that failed — and it turns the check green. No gate run had taken this path since the merge (the only hw-gate run after 17:45 was my own dispatch, which died at actions/checkout on a short SHA), so I ran it:

gh workflow run hw-gate.yml -R 1bit-MONSTER/engine --ref main \
  -f ref=pull/2692/head -f phases=build,kld      # the workflow file from main (this fix), the tree from #2692

Run 43930808387, 18:42:15–18:55:54Z, success, ## HRX hardware gate: PASS. The same five rows, on the same tree 965e910, before this fix (run 43901875203) and after:

before:  kld qwen3-0.6b       SKIP  -s  ... [golden llama.cpp 4a58da9b087d, tested dd9f270f6c1d: cannot place (4a58da9b087d is not in …)]
         kld zaya1-8b         SKIP  -s  … cannot place …
         kld qwen3.8-27b      SKIP  -s  … cannot place (the history between them is not in this clone; shallow=true …)
         kld qwen3.6-35b-a3b  SKIP  -s  … cannot place …
         kld qwen3-4b-iq4xs   SKIP  -s  … cannot place …
after:   kld qwen3-0.6b       PASS  -s  mean KLD 0.000003, p99 0.00004, same top 99.95%  [golden … 4a58da9b087d, tested …: golden is 234 commits behind the tested tree]
         kld zaya1-8b         PASS  -s  mean KLD 0.008280, p99 0.16076, same top 97.79%  [golden is 234 commits behind]
         kld qwen3.8-27b      PASS  -s  mean KLD 0.000001, p99 0.00004, same top 100.00% [golden is 7 commits behind]
         kld qwen3.6-35b-a3b  PASS  -s  mean KLD -0.000000, p99 0.00003, same top 100.00% [golden is 16 commits behind]
         kld qwen3-4b-iq4xs   PASS  -s  mean KLD 0.000001, p99 0.00005, same top 99.90%  [golden is 234 commits behind]

Same numbers, same limits, and the only thing that changed between the two runs is whether the ancestry was there to place the golden.

The step itself, measured on the runner rather than inferred: actions-runner-engine/_work/engine/engine/.git/modules/third_party/llama.cpp was 212 MB, is-shallow-repository=true, 1 commit before this run and is 603 MB, false, 10,936 commits after, with 4a58da9b087d present — so the guard fired once and the "Check out the HRX pair" step read as success; a later run on the same workspace skips the fetch. hrx-system stayed at --depth 1 as intended.

Two things this does not say: phases=build,kld is not the full gate (ops/kat/needle/placement were not re-run — #2692's own run had them all green), and the GPU was quiet enough at 18:42–18:55Z (MemAvailable 44–73 GiB) for the KLD models, which is why this ran now and not an hour ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hw-gate CI: the KLD rows cannot place their golden in the runner's shallow clone, so a labelled PR is red on any pin

1 participant