Skip to content

loom coverage: --manifest reads the shipped catalogue (engine#3156) - #3509

Merged
bong-water-water-bong merged 2 commits into
mainfrom
loom-coverage-manifest
Nov 25, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
loom-coverage-manifest

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

The coverage map's row source was registry/check_models.tsv, which its own header defines as one model per architecture a backend maps, where a model file is at hand on Strix Halo — 9 rows. What the stick ships is a different list: the payload's server_models.json, which os/v3/puppy/catalogue-manifest.py turns into hrx <id> lines for /etc/1bit/onebit-models.txt. Nothing in the tool could read that shape, so #3156's master table could never be a machine answer.

--manifest takes it. Without the flag nothing changes.

How an id becomes a row

Every verdict here is about a file — the bytes a card binds — while a catalogue id names a model, so an id is resolved to the files we pin: last path segment, trailing -gguf dropped, matched against the basenames in models/pins.json. An id that resolves to nothing is reported as unresolved rather than name-matched, because a coverage claim resting on a name match is the trap the tool exists to avoid.

What it says about table A

Run against ~/amd-oss/loom-fun/{cards,cards-staging} plus the 1bit-* cards staged from HF, with a manifest built from the checklist's GPU rows:

COVERED          qwen3-0.6b-q4_k_m.gguf                    unsloth-Qwen3-0.6B-loom (Q4_K_M) sha256 ac2d97712095
DIFFERENT-UPLOAD qwen3-1.7b-q4_k_m.gguf                    ggml-org-Qwen3-1.7B-loom binds d2387ca2dbfe
DIFFERENT-UPLOAD qwen3-4b-q4_k_m.gguf                      ggml-org-Qwen3-4B-loom binds ab27b9bfa375
COVERED          qwen3-8b-q4_k_m.gguf                      unsloth-Qwen3-8B-loom (Q4_K_M) sha256 120307ba529e
COVERED          qwen3-4b-instruct-2507-q4_k_m.gguf        unsloth-Qwen3-4B-Instruct-2507-loom sha256 3605803b982c
COVERED          qwen3.5-4b-ud-q4_k_xl.gguf                Qwen3.5-4B-GGUF-loom (UD_Q4_K_XL) sha256 b252c5610a42
COVERED          qwen3.8-27b-ud-q4_k_xl.gguf               unsloth-Qwen3.8-27B-UD-Q4_K_XL sha256 2a5f3565f39c
DIFFERENT-UPLOAD qwen3-coder-30b-a3b-instruct-q4_k_m.gguf  ggml-org-…-Coder-30B-…-loom binds f6050b4da228
COVERED          qwen2.5-coder-7b-instruct-q4_k_m.gguf     Qwen2.5-Coder-7B-Instruct-GGUF-loom sha256 509287f78cb4
COVERED          qwen2.5-coder-1.5b-instruct-q4_k_m.gguf   Qwen2.5-Coder-1.5B-Instruct-GGUF-loom sha256 cc324af070c2
COVERED          glm-4.7-flash-q4_k_m.gguf                 1bit-GLM-4.7-Flash (Q4_K_M) sha256 29837ed2c0fc
UNCOVERED        minicpm5-1b-q4_k_m.gguf                   no card names this model
UNCOVERED        zaya1-8b-q4_k_m.gguf                      no card names this model
REQUANT          gpt-oss-20b-mxfp4.gguf                    unsloth-gpt-oss-20b-loom has ['Q4_K_M'], we ship MXFP4
DIFFERENT-UPLOAD lfm3-1.7b-q4_k_m.gguf                     bartowski-LFM3-1.7B-loom binds ecc02a0720a3
loom_coverage: 8 of 8 row(s) compared on BYTES

Every DIFFERENT-UPLOAD agrees with the table's "rebind", every UNCOVERED with "none"/"private kit", so the card column is right where it was specific. Three rows move:

  • Qwen2.5-Coder-7B and -1.5B are listed as "none; config-only port in progress" / "not config-only, rerun the generator". The staged 1bit-* cards bind our pinned bytes on both (509287f7, cc324af0), so with loom coverage: our own published cards are cards (engine#3156) #3507 + loom coverage: UD (Unsloth Dynamic) quants are quants (engine#3156) #3508 those two rows are COVERED on bytes and only the gate is left.
  • Qwen3.5-4B is listed as "rebind (unsloth-Qwen3.5-4B-loom locks other bytes)". Against the 1bit-* card our pin is b252c5610a42 — COVERED. Either the table predates that card or it is looking at the corpus card only; worth a look either way.
  • gpt-oss-20b is more precise than "rebind": the card is a Q4_K_M quant where we ship MXFP4, i.e. REQUANT, not a rebind of the same quant.

Not done

This is the code half. CI still has to be handed the manifest — it is generated from the payload, which this repo does not check in — so --manifest is inert until the stick build drops (or CI checks in) onebit-models.txt. With the file, "COVERED" in #3156's table becomes a machine answer for all 23 rows instead of 9 architecture samples.

Self-test: 11 ok, 0 failed (unchanged; the manifest path adds no verdicts).

QUANTS stopped at Q\d+_K_[MSL], so every UD-* card and every UD-* row named no quant at all:
the routed, gate-passed Qwen3.8-27B row read 'REQUANT ... has (no quant named), we ship None',
and Qwen3.5-4B-UD-Q4_K_XL read UNCOVERED, for cards that bind our pinned bytes.

Three fixes, all in the matcher, none in the verdicts:
- QUANTS also matches UD[-_]?Q\d+_K_[A-Z]+ and Q\d+_K_[A-Z]+ (XL/XS/XXS suffixes).
- canon_quant() gives one spelling, so the row's UD_Q4_K_XL (from a file name) compares equal to the
  card's UD-Q4_K_XL (from its lock).
- _quant_token() drops the standalone xl/xs/xxs/ud tokens, which qualify the quant and must not
  separate a card from its row.

Self-test unchanged (11 ok, 0 failed).
The map's row source was registry/check_models.tsv, which is one model per architecture where a
file is at hand (9 rows) -- not what the stick ships. The shipped list is the payload's
server_models.json, which os/v3/puppy/catalogue-manifest.py turns into `hrx <id>` lines for
/etc/1bit/onebit-models.txt. Nothing read that shape.

--manifest takes it. Each id is resolved to the files we pin (stem or repo name, trailing -gguf
dropped), because every verdict this tool makes is about a FILE, and an id that resolves to nothing
is reported as unresolved rather than name-matched -- a coverage claim resting on a name is the trap
the tool exists to avoid. Without --manifest nothing changes.
@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 25, 2026 08:49
@bong-water-water-bong
bong-water-water-bong merged commit 6a58796 into main Nov 25, 2026
19 of 21 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the loom-coverage-manifest branch November 25, 2026 09:03
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3156 - Partially compliant

Compliant requirements:

  • The tool now reads from the shipped catalogue manifest instead of the registry
  • Each shipped model ID is resolved to the files we pin using the pinning logic
  • The tool properly handles Unsloth Dynamic quantization formats
  • The tool reports when shipped IDs resolve to no pinned files

Non-compliant requirements:

  • The tool does not yet include documentation updates for the new --manifest flag

Requires further human verification:

  • Verification that the manifest file format matches the expected structure
  • Confirmation that the resolution logic correctly maps model IDs to pinned files
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Manifest Resolution Logic

The new manifest resolution logic in rows_from_manifest function may not correctly handle all possible model ID formats or pinning scenarios. Specifically, the logic that extracts the key from model IDs by splitting on '/' and removing '.gguf' suffix might miss edge cases in how model IDs are structured in the manifest. If a model ID doesn't follow the expected pattern, it could lead to incorrect resolution or missed coverage reporting.

    key = model_id.split("/")[-1].lower()
    if key.endswith(".gguf"):
        rows.append((device, key))
        continue
    if key.endswith("-gguf"):
        key = key[: -len("-gguf")]
    hits = sorted(n for n in names if n == key + ".gguf" or n.startswith(key + "-"))
    if not hits:
        unresolved.append(model_id)
    rows.extend((device, n) for n in hits)
return rows, unresolved
Quant Format Matching

The updated QUANTS regex pattern now includes UD[-_]?Q\d+K[A-Z]+ and Q\d+K[A-Z]+ patterns, but the logic in canon_quant function may not fully account for all variations in how Unsloth Dynamic quantization tags are represented in different contexts. This could lead to mismatches between quant tags in file names and those in card locks, potentially causing coverage misclassification.

QUANTS = re.compile(r"UD[-_]?Q\d+_K_[A-Z]+|Q\d+_K_[A-Z]+|Q\d+_\d|IQ\d+_[A-Z]+|BF16|F16|MXFP4|AWQ", re.I)


def read_rows(tsv):
    """(device, model) rows of registry/check_models.tsv."""
    out = []
    for line in pathlib.Path(tsv).read_text().splitlines():
        parts = line.split("\t")
        if len(parts) >= 2:
            out.append((parts[0], parts[1]))
    return out


def read_manifest(path):
    """(device, model id) rows of the manifest `os/v3/puppy/catalogue-manifest.py` writes for the stick:
    `mode=live`, then one `hrx <id>` / `npu <id>` line per shipped catalogue entry."""
    out = []
    for line in pathlib.Path(path).expanduser().read_text().splitlines():
        line = line.strip()
        if not line or line.startswith("#") or line.split("=")[0] == "mode":
            continue
        parts = line.split(None, 1)
        if len(parts) == 2 and parts[0] in ("hrx", "npu"):
            out.append((parts[0], parts[1].strip()))
    return out


def rows_from_manifest(manifest_rows, ours):
    """(rows, unresolved): the shipped catalogue as (device, model FILE) rows.

    A catalogue id names a MODEL, and every verdict this tool makes is about a FILE (the bytes a card binds),
    so an id is resolved to the files we pin for it. The pin records basenames; an id is either a file stem
    (`Qwen3-4B-Q4_K_M`) or a repo name (`unsloth/Qwen3-4B-GGUF`), so the last path segment is the key, with a
    trailing `-gguf` dropped. An id that resolves to nothing is reported as unresolved rather than guessed at:
    a coverage claim that rests on a name match is the trap this tool exists to avoid.
    """
    names = (ours or {}).get("names") or set()
    rows, unresolved = [], []
    for device, model_id in manifest_rows:
        if device != "hrx":
            continue  # the NPU route is a different map (docs/npu.md); this tool reports HRX rows only
        key = model_id.split("/")[-1].lower()
        if key.endswith(".gguf"):
            rows.append((device, key))
            continue
        if key.endswith("-gguf"):
            key = key[: -len("-gguf")]
        hits = sorted(n for n in names if n == key + ".gguf" or n.startswith(key + "-"))
        if not hits:
            unresolved.append(model_id)
        rows.extend((device, n) for n in hits)
    return rows, unresolved


def identity(card_dir):
    """(model id, quants of the CHECKPOINT files) from a card's model.json, or (None, set()) when unreadable.

    The checkpoint is what the card serves, and it is the only thing a coverage claim may rest on. A card may also
    name files that are NOT the checkpoint -- Qwen3.6-35B-A3B ships a DFlash drafter whose files carry their own
    quantisation -- and reading `model.json` as text counted those too, which made that row read COVERED on Q8_0
    when its checkpoint is Q4_K_M (engine#3156 review). So walk the variant/service/checkpoint-file paths only.
    """
    f = card_dir / "model.json"
    try:
        doc = json.loads(f.read_text())
    except Exception:
        return None, set()
    model = doc.get("model") if isinstance(doc, dict) else None
    ident = model.get("id") if isinstance(model, dict) else None
    quants = set()
    for variant in ((doc.get("variants") or {}) if isinstance(doc, dict) else {}).values():
        for svc in (variant.get("services") or {}).values():
            for entry in (((svc.get("parameters") or {}).get("model") or {}).get("files") or []):
                quants |= {q.upper() for q in QUANTS.findall(entry.get("path", ""))}
    return ident, quants



def pin_bytes(pins_path):
    """({sha256 we ship}, {basenames we pin}) from models/pins.json, or None when it cannot be read.

    The pin is the only record of the BYTES we ship (`files.<name>.oid` is the LFS sha256), and a card binds its
    checkpoint by sha256 in `model.json.lock`. Two cards can name the same model on the same quant and bind
    different files -- `unsloth/flint`'s UD-Q4_K_XL is 25.05 GB where the card's Q4_K_M is 23.39 GB, and our own
    pin is sometimes a RE-HOST (the Flash-Next card binds the 1bit-MONSTER shards while the upstream pin is an
    older revision, and `used_for` says so in as many words). So a coverage claim that stops at the quant is an
    upper bound, and this is the arm that turns it into a fact.
    """
    try:
        doc = json.loads(pathlib.Path(pins_path).expanduser().read_text())
    except Exception:
        return None
    pins = doc.get("pins") if isinstance(doc, dict) else None
    if not isinstance(pins, dict):
        return None
    shas, names = set(), set()
    for entry in pins.values():
        for fn, meta in ((entry or {}).get("files") or {}).items():
            names.add(fn.split("/")[-1].lower())
            sha = (meta or {}).get("oid")
            if isinstance(sha, str) and len(sha) == 64:
                shas.add(sha.lower())
    return {"shas": shas, "names": names}


CHECKPOINT_KEYS = ("model", "checkpoint")


def checkpoint_shas(card_dir, lock):
    """The sha256 of the card's CHECKPOINT files (not its drafter's), from the lock, or an empty set."""
    try:
        doc = json.loads((card_dir / "model.json").read_text())
    except Exception:
        return set()
    names, shas = set(), set()
    for variant in ((doc.get("variants") or {}) if isinstance(doc, dict) else {}).values():
        for svc in ((variant or {}).get("services") or {}).values():
            params = (svc or {}).get("parameters") or {}
            for key in CHECKPOINT_KEYS:
                for f in ((params.get(key) or {}).get("files") or []):
                    n = (f or {}).get("path", "").split("/")[-1].lower()
                    if n in lock:
                        names.add(n)
    for n in names:
        shas |= lock[n]
    # engine#3156 review: the old fallback returned EVERY file the lock binds when the checkpoint file names could
    # not be read, which compares our bytes against the DRAFTER's (three files for Qwen3-Coder-30B-A3B). An
    # unreadable checkpoint is cannot-tell for the bytes arm, so return nothing and let the caller report
    # COVERED-UNPINNED rather than a fabricated DIFFERENT-UPLOAD.
    return shas


def lock_bytes(card_dir):
    """basename -> {sha256 the card binds} from model.json.lock, or None when the card has no lock."""
    try:
        doc = json.loads((card_dir / "model.json.lock").read_text())
    except Exception:
        return None
    out = {}
    for f in (doc.get("files") or []):
        origin, sha = (f or {}).get("origin"), (f or {}).get("sha256")
        if isinstance(origin, str) and isinstance(sha, str) and len(sha) == 64:
            out.setdefault(origin.split("/")[-1].lower(), set()).add(sha.lower())
    return out

NON_DISTINCTIVE = {"loom", "gguf", "merged"}
# Publisher/organisation tokens that appear in card directory names (and HF ids) but are not model identity.
VENDOR = {"ggml", "org", "bartowski", "unsloth", "lmstudio", "lmstudio-community", "model", "ai", "the",
          "someone", "acme", "liquidai", "qwen", "meta-llama", "google", "microsoft",
          # our own org's cards (`1bit-MONSTER/<model>-loom`, and the `1bit-<model>` trees the lanes build): without
          # these, same_model() rejects every card we publish ourselves and the row that matters most reads
          # UNCOVERED — GLM-4.7-Flash's published card did, with its lock binding our pinned sha256.
          "1bit", "monster"}


def _quant_token(t):
    # `xl`/`xs`/`xxs` are the K-quant size suffix of an Unsloth Dynamic tag (Q4_K_XL) and `ud` its prefix:
    # they qualify the QUANT, so they must not distinguish a card from a row (engine#3156).
    return bool(re.fullmatch(r"i?q\d+([_-][a-z0-9]+)*|f16|bf16|mxfp4|awq|xl|xs|xxs|ud", t))


def _tokens(name):
    """Distinctive tokens of a model name: family, size, and qualifiers, with quant tokens removed.

    Vendor and organisation tokens (`bartowski`, `ggml`, `org`, …) are filtered by VENDOR rather than by
    position, because a card directory may carry one or two of them (`ggml-org-Foo-loom`).
    """
    stem = re.sub(r"\.gguf$", "", name).split("/")[-1].lower()
    # single letters are quant suffixes split apart (`Q4_K_M` -> q4, k, m); they are never identity
    return [t for t in re.split(r"[^a-z0-9.]+", stem) if len(t) > 1 and not _quant_token(t)]


def same_model(row_name, card_dir, card_id):
    """True when a card is for THIS model: every row token appears, and the card adds nothing but `loom`.

    This is the trap the map has to survive: `ggml-org-Qwen2.5-VL-7B-Instruct-loom` and
    `unsloth-Qwen3-30B-A3B-Instruct-2507-loom` match their rows on family and size and are different
    models. A size-class match alone is a candidate, never a cover.
    """
    row = set(_tokens(row_name)) - NON_DISTINCTIVE
    card = set(_tokens(card_dir)) - NON_DISTINCTIVE
    if card_id:
        card |= set(_tokens(card_id)) - NON_DISTINCTIVE
    # every token of the row must be present, and nothing beyond the vendor/`loom` vocabulary may be added:
    # `Qwen2.5-VL-7B-Instruct` and `Qwen3-30B-A3B-Instruct-2507` both add a token and are different models.
    return row <= card and (card - row) <= (NON_DISTINCTIVE | VENDOR)


def canon_quant(q):
    """One spelling for a quant tag: `UD_Q4_K_XL` from a file name and `UD-Q4_K_XL` from a card must compare
    equal, and the UD (Unsloth Dynamic) prefix is part of the quant, not a model-name token."""
    return q.upper().replace("_", "-") if q else q

bong-water-water-bong pushed a commit that referenced this pull request Nov 25, 2026
…#3156)

#3510 fixed --manifest to resolve the stick's own ids, but the self-test had no arm for that path -- which is
exactly why the wrong input shape shipped in #3509: it was validated against a manifest synthesised from the
issue's row names, and against the real file it resolved 0 of 24 ids and printed an empty map that read like a
clean one.

This adds arm()'s manifest counterpart, manifest_arm, which asserts the resolved (device, model) ROWS and the
unresolved list rather than only the verdict, because "no rows" is a state a verdict-only arm cannot see. 11 arms:

- the stick's -1bit suffix is the distribution's, not the model name (hrx GLM-4.7-Flash-1bit)
- a resolved id earns a real verdict (COVERED on bytes), and can still be DIFFERENT-UPLOAD
- an id resolves on stem + quant spec, not prefix: qwen3-4b must not claim
  qwen3-4b-instruct-2507-q4_k_m.gguf
- a repo-style id ending -GGUF resolves; a bare .gguf id is a file name
- an id we pin nothing for is reported unresolved, never name-matched
- npu rows are skipped, and are not counted as unresolved either
- one id owning several pins yields one row per file (the REQUANT mechanism)
- mode=, comments, blank and junk lines are not rows

The card-writing half of arm() is factored into make_card() so both arms build the same tree; no existing arm
changes behaviour (11/11 still pass unchanged).

Control: with rows_from_manifest reverted to the #3509 resolver, the new self-test reports 17 ok / 5 failed --
the three -1bit arms resolve to nothing (rows [], unresolved ['GLM-4.7-Flash-1bit']), the instruct arm does the
same, and the prefix arm resolves BOTH files for Qwen3-4B (qwen3-4b-instruct-2507-q4_k_m.gguf and
qwen3-4b-q4_k_m.gguf), i.e. it claims the instruct model's bytes for the base model. Against the fixed resolver:
22 ok, 0 failed.

Real artifact, unchanged by this commit: --manifest on /etc/1bit/onebit-models.txt as the box generates it
(24 hrx ids) still resolves 18 of 24, with 6 reported unresolved (MiniCPM-V-4.6, Qwen3-Reranker-0.6B,
ZAYA1-8B-PM, flint-40b-a2.5b, jina-reranker-v1-tiny-en, nomic-embed-text-v2-moe) and 5 rows COVERED on bytes.

pre-pr-checks.sh --tree-only --base origin/main: 15 green, 3 skipped, 0 could not be told.
bong-water-water-bong added a commit that referenced this pull request Nov 25, 2026
…#3156) (#3511)

#3510 fixed --manifest to resolve the stick's own ids, but the self-test had no arm for that path -- which is
exactly why the wrong input shape shipped in #3509: it was validated against a manifest synthesised from the
issue's row names, and against the real file it resolved 0 of 24 ids and printed an empty map that read like a
clean one.

This adds arm()'s manifest counterpart, manifest_arm, which asserts the resolved (device, model) ROWS and the
unresolved list rather than only the verdict, because "no rows" is a state a verdict-only arm cannot see. 11 arms:

- the stick's -1bit suffix is the distribution's, not the model name (hrx GLM-4.7-Flash-1bit)
- a resolved id earns a real verdict (COVERED on bytes), and can still be DIFFERENT-UPLOAD
- an id resolves on stem + quant spec, not prefix: qwen3-4b must not claim
  qwen3-4b-instruct-2507-q4_k_m.gguf
- a repo-style id ending -GGUF resolves; a bare .gguf id is a file name
- an id we pin nothing for is reported unresolved, never name-matched
- npu rows are skipped, and are not counted as unresolved either
- one id owning several pins yields one row per file (the REQUANT mechanism)
- mode=, comments, blank and junk lines are not rows

The card-writing half of arm() is factored into make_card() so both arms build the same tree; no existing arm
changes behaviour (11/11 still pass unchanged).

Control: with rows_from_manifest reverted to the #3509 resolver, the new self-test reports 17 ok / 5 failed --
the three -1bit arms resolve to nothing (rows [], unresolved ['GLM-4.7-Flash-1bit']), the instruct arm does the
same, and the prefix arm resolves BOTH files for Qwen3-4B (qwen3-4b-instruct-2507-q4_k_m.gguf and
qwen3-4b-q4_k_m.gguf), i.e. it claims the instruct model's bytes for the base model. Against the fixed resolver:
22 ok, 0 failed.

Real artifact, unchanged by this commit: --manifest on /etc/1bit/onebit-models.txt as the box generates it
(24 hrx ids) still resolves 18 of 24, with 6 reported unresolved (MiniCPM-V-4.6, Qwen3-Reranker-0.6B,
ZAYA1-8B-PM, flint-40b-a2.5b, jina-reranker-v1-tiny-en, nomic-embed-text-v2-moe) and 5 rows COVERED on bytes.

pre-pr-checks.sh --tree-only --base origin/main: 15 green, 3 skipped, 0 could not be told.

Co-authored-by: bong-water-water-bong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant