Skip to content

fix(assets): validate GGUF metadata encodings against native reader - #262

Closed
Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:fix/gguf-metadata-types
Closed

Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:fix/gguf-metadata-types

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

What & why

The Python asset checker can report passed for GGUF files that the native loader rejects. general.alignment is accepted as an INT32/UINT64/INT64 whenever its value is 32, although the native GGUF reader requires UINT32. An empty metadata array can also carry an unknown element type: no elements are read, so validation never reaches the unsupported-type check. The writer can produce the incorrectly typed alignment itself.

Validate the encoded alignment type when reading and writing, and validate the array element type before reading its items. All supported empty-array types still round-trip. The change concerns GGUF metadata; it does not change catalog parsing or tensor payloads.

Area

  • Model asset tools (edge0-infer/tools/assets/)

How was it tested?

Base f6bfa5546bcf89919f86946ec669bcc7f4cd526d; Linux, Python 3.12.14, GCC 14.2, CPU preset.

  • Before the fix: 8 new regression failures, 12 passing compatibility controls. Five failures use complete small asset fixtures with updated catalog hashes: the checker incorrectly reports success for three wrong alignment types and two unknown empty-array types. Three writer cases incorrectly create malformed alignment metadata.
  • After the fix: uv run --project tools/assets --offline --no-sync pytest -q -p no:cacheprovider -m l1 tools/assets/tests — 121 passed, 6 deselected.
  • A small probe linked against this checkout's actual libggml-base.a calls gguf_init_from_file on the five malformed fixture files. It rejects all five, reporting the wrong alignment type or unknown array type, and accepts a valid UINT32-alignment/empty-string-array control. This confirms the native/Python mismatch with actual encoded files.
  • CPU build passed. ctest --preset cpu -L "L0|L1" --output-on-failure -j 4: 97 passed, 3 Vulkan tests skipped, 4 existing failures. The same base failures are moe_test_app_generation (std::tmpfile unavailable here), moe_test_platform_memory (Linux expectation), and extreme-float serialization in moe_test_ordered_json / moe_test_template_tools.
  • git diff --check passed. No real checkpoint, GPU, or numerical inference validation was run; this change rejects malformed metadata before tensor execution.

Checklist

  • Added complete-asset rejection tests and supported-type compatibility controls.
  • Ran all asset L1 tests and compared rejection with the native GGUF reader.
  • Full L0/L1 is green (four base failures described above).

@Afloat16

Copy link
Copy Markdown
Contributor Author

Superseded by #290, the consolidated asset-checking PR requested in #289. The original change and regression coverage are preserved, and the original commit remains in the consolidated branch's history.

@Afloat16 Afloat16 closed this Nov 17, 2026
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.

1 participant