Skip to content

npu-pack: external-data import of a non-default weight layout has no test that the key is written #1840

Closed

Description

@bong-water-water-bong

Found auditing the merges that went in over an unanswered CHANGES (~/briefs/MERGED-OVER-CHANGES-2026-11-10.md, row #1793).

What is missing

The merged fix is right — import_external now writes q4nx_weight_layout exactly as the .fconst path does, so a container built for the _b8 family no longer asks
for the untagged ELFs and reports "missing full ELF" for files that are on disk. The CHANGES at the merged head e3361b8 agreed with the fix and asked for the arm that
would have caught it
, noting "the fixture already exists".

That arm is still absent on main:

grep -c q4nx_weight_layout tests/npu_pack_import_test.cpp   ->   0

So the regression this fixed — a report printing declares q4nx_weight_layout "b8" while the writer omitted the key — can return silently, because nothing asserts that
an import_external container built with a non-default layout actually carries the key.

The fix

Two lines in the existing test: build the fixture container with --weight-layout b8 (or the equivalent in-process options), read back the container header, and assert
the key is present and equals b8; plus the negative — a default-layout import must not carry it, since the key is written only for a non-default layout and every
earlier container depends on that.

Context

Not a revert candidate and not urgent on its own; it is the last step of a fix that already works, and leaving it out means the next change to the writer has nothing to
fail against.

Activity

  1. bong-water-water-bong commented on Nov 10, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claimed by the pkg lane (test-coverage work; I did the registration sweep tonight — #1824 — and this is the same class: a fix whose arm was asked for and not delivered).

    Reading it as: assert the positive (an import_external container built with --weight-layout b8 carries q4nx_weight_layout == "b8") and the negative (a default-layout import must not carry it, since every earlier container depends on the key being absent). Will report back with the head; if the fixture needs a real pack or a device I will say so rather than shipping an arm I could not run.

  2. bong-water-water-bong commented on Nov 10, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Surface map from reading main, so the next person starts where I did rather than re-deriving it:

    • import_external is defined in npu/pack_import.cpp:3241 and is not declared in any header — the only in-tree caller is the CLI dispatch at :3418. So the arm cannot call it from tests/npu_pack_import_test.cpp directly; it has to go through the npu-pack import --weight-layout b8 path (the test already takes a pack and golden dir as argv[1..2]), or the function has to be exported for the test the way read_dims_exported/weight_layout_refusal are.
    • The option itself is Options::weight_layout (npu/pack_import.h:227-239), documented there: empty means the default row-major family and the key is left out entirely — as every container the importer wrote before the option existed; b8 is the only layout a bare flag can express. That comment is the negative arm's justification, in the code, already.
    • The existing test's test_weight_layout() (:2797) only exercises weight_layout_refusal() — the validator — which is why grep -c q4nx_weight_layout tests/npu_pack_import_test.cpp is 0. test_weight_layout is exactly where the two assertions belong, beside the refusal checks.

    Holding on the last step, with the reason: this needs a compile plus a run, and / is at 163G, under this lane's 175G worktree gate (it has oscillated 128-220G all night as the pack lanes sweep). I will not ship a test edit I could not compile. Picking this up the moment df clears the gate — the plan above is the whole change, so it is a short job then.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions