Skip to content

perf(assets): read numeric GGUF metadata in bounded blocks - #181

Closed
Afloat16 wants to merge 2 commits into
Edge0-AI:mainfrom
Afloat16:afloat/20261111-next-batched-gguf-arrays
Closed

Afloat16 wants to merge 2 commits into
Edge0-AI:mainfrom
Afloat16:afloat/20261111-next-batched-gguf-arrays

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Numeric GGUF arrays performed one Python read/dispatch per scalar, making vocabulary-sized score/type tables expensive.

Decode numeric arrays in blocks of at most 8192 elements (64 KiB), preserving scalar types, little-endian decoding, empty arrays and truncation errors. String arrays retain their path.

Reference: https://github.com/ggml-org/ggml/blob/cd6d2b75f5d3e4b2f3fe8e8fbc6c8b84ac80e74a/docs/gguf.md

Area

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

Main-branch update

The branch now includes main at f6bfa5546bcf89919f86946ec669bcc7f4cd526d via merge commit 1873b169e204d90321e316e378a2924ac60b03e6. The Q4_1 finite-value checks and regressions from #172 are preserved unchanged. The net diff remains limited to format_gguf.py and test_gguf_lite.py.

How was it tested?

Validation of exact head 1873b169e204d90321e316e378a2924ac60b03e6:

python -m pytest -q -s tools/assets/tests/test_gguf_lite.py

21 passed with Python 3.12.14 and NumPy 2.4.4. The 25000-element uint32 case reports 13 reader calls and a maximum read of 32768 bytes. The existing tests cover all 11 scalar formats, block boundaries, empty/truncated arrays, tensor round-trips and quantization.

The normal CPU configure and build also succeeded on Linux with GCC 14.2.0, CMake 3.31.10 and Ninja 1.13.2. With the repository-locked Python asset dependencies (NumPy 2.5.4), the affected moe_test_asset_tools_l1 target passed: 113 pytest cases passed, 6 deselected.

cmake --preset cpu
cmake --build --preset cpu --parallel 2
ctest --preset cpu -L "L0|L1" --parallel 2

The full local L0/L1 selection was 97 passed, 4 failed, 3 Vulkan tests skipped out of 104; all 15 L0 tests passed. The four L1 failures were:

  • moe_test_app_generation: std::tmpfile() failed in this environment, where /tmp is unavailable.
  • moe_test_platform_memory: the non-Apple/Windows test expects RSS to be unavailable, but the Linux implementation returns RSS data.
  • moe_test_ordered_json and moe_test_template_tools: the JSON probe serializes the largest finite binary64 value as 2e+308 instead of 1.7976931348623157e+308.

The native source, tests, third-party code and CMake configuration involved in these failures are byte-for-byte identical to main at f6bfa554; they are outside this PR's two-file change. A separate baseline build was not run. The full-local-pass checkbox therefore remains unchecked.

Separately, the upstream macOS CPU workflow on this head passed its L0/L1 selection: 101 passed, 3 Vulkan tests skipped out of 104. Its two selected L2 strata tests also passed. git diff --check passes, and verification did not modify tracked files.

Checklist

  • Full ctest --preset cpu -L "L0|L1" passes locally
  • Added/updated focused regressions and ran the affected target
  • No public interface/configuration change requiring additional documentation

@shuk777

shuk777 commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this. It now conflicts with main after #172 landed in the same files (format_gguf.py / test_gguf_lite.py), so we can't merge it as-is.

Please rebase onto current main, resolve the conflicts, and we can take another look.

@Afloat16

Copy link
Copy Markdown
Contributor Author

@shuk777 The branch is now updated with current main (f6bfa554) in merge commit 1873b169e204d90321e316e378a2924ac60b03e6, and GitHub reports no conflicts. I checked that pack_q4_1 and the regressions from #172 are preserved unchanged; the net diff remains the bounded metadata reads and their tests.

Validation on this exact head:

  • Focused GGUF suite: 21 passed.
  • Repository-locked asset-tools target: 113 passed, 6 deselected.
  • Upstream macOS CPU CI: 101 L0/L1 tests passed, 3 Vulkan tests skipped; the two selected L2 strata tests also passed.

The local Linux CPU build succeeded. Its full L0/L1 run was 97 passed, 4 failed, 3 skipped. The four failures concern temporary-file creation, the Linux RSS expectation, and JSON serialization (two targets); the involved native source, tests and build configuration are unchanged from main. I recorded those details in the description and left the full-local-pass checkbox unchecked.

Could you take another look and, if this resolves the review, approve and merge?

@shuk777

shuk777 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Closing as part of clearing this pre-hygiene queue; see #298 (comment) for the note on the updated review process. Thank you again.

@shuk777 shuk777 closed this Nov 19, 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.

2 participants