Skip to content

fix(assets): validate conversion reuse and runtime repack parity - #298

Closed
Afloat16 wants to merge 4 commits into
Edge0-AI:mainfrom
Afloat16:fix/asset-conversion-integrity-20261117
Closed

Afloat16 wants to merge 4 commits into
Edge0-AI:mainfrom
Afloat16:fix/asset-conversion-integrity-20261117

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

What & why

The on-device converter can reuse stale outputs after its inputs change, silently skip requested numerical verification, and fail late for an already accepted source-directory spelling. Its runtime repacker also expands an entire quantized tensor at once.

This PR keeps four independent commits within the conversion pipeline:

  1. Bind cache reuse to inputs and converter identity. Compare hashes of weights, config, tokenizer and chat template, converter dependencies, NumPy version and the engine contract before reusing artifacts. An unchanged conversion still skips work; legacy manifests are revalidated. A requested --compare-against is now checked on cache hits too.
  2. Pack runtime Q4_1 tensors by row chunk. Reuse the core row bound and align only at tensor boundaries. This reduces expanded conversion workspace while retaining the same complete GGUF bytes. Packed source arrays are still loaded whole.
  3. Honor --verify all and sampled verification. Check every selected Q4_1 chunk and the interleaved BA values against the MLX-side values. Existing FP16 exemptions remain limited to the specific 32-value blocks; they cannot hide a mismatch elsewhere in the row. --verify 0 preserves the first-row sentinel, and invalid options fail before conversion.
  4. Normalize accepted source-directory spellings. When edge0_35b is used, move the completed runtime artifact to the canonical edge0-35b.gguf before the LoRA verifier consumes it. Both default and custom output directories work, including repeat cache hits.

The copied converter modifications are recorded in ORIGIN.json and the affected source headers. Historical comparisons include all 161 existing PRs and 53 non-PR issues: #171 is the separate prerouter reader, #181 is bounded GGUF metadata reading, #189 reuses source digests in make_assets, and #128 / #135 address the old hardcoded base directory. None implements these changes.

Area

  • Engine, CLI or server (edge0-infer/)
  • Model asset tools (edge0-infer/tools/assets/)
  • Chat app examples (edge0-infer/examples/)
  • Model docs (docs/)
  • Other

How was it tested?

Linux x86_64, Python 3.12.14, NumPy 2.3.5. Fixtures are valid synthetic safetensors inputs passed through the actual runtime converter and LoRA verifier, yielding 703 base tensors and 100 adapter tensors.

python3 -m pytest -q -m l1 edge0-infer/tools/assets/tests
124 passed, 6 deselected

Before each corresponding fix: cache regressions had 6 failures / 1 unchanged-input control pass; the chunk bound test failed; verification regressions had 8 failures / 4 controls passing; both underscore-directory CLI cases failed with E-BASE-MISSING. Targeted suites and the final complete asset L1 selection pass after the fixes. The verification regressions use controlled packed-output faults to show that non-first rows, later chunks, BA values and non-exempt blocks are checked.

The 3-row chunk test deliberately crosses a non-aligned boundary and leaves a final partial chunk; its complete GGUF bytes match full-tensor packing.

For a separate synthetic corpus with a 32768-row vocabulary, hidden width 256 and 703 tensors, fresh-process conversion measurements were:

Measurement Base Streaming + full verification
Python/NumPy traced peak 81,505,031 bytes 42,253,688 bytes
Process max RSS 111,760 KiB 76,440 KiB

Both produce SHA-256 6a4d65667331679e9e7d13945cc9ce6b1a643fa392f60c2f1df108ed18451162. These are small-corpus conversion memory measurements, not real-35B inference or device benchmarks; no runtime throughput claim is made. Higher asset/device test levels were not run here.

Checklist

  • ctest --preset cpu -L "L0|L1" passes locally in edge0-infer/ (engine changes)
  • Ran the higher test levels this change affects (see edge0-infer/docs/testing.md)
  • Added/updated tests for new behavior
  • Updated relevant docs / READMEs (copied-code modification provenance and verification CLI help)

@shuk777

shuk777 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the sustained contributions across serve, assets, desktop, text, and the consolidated follow-ups — several of those fixes are already on main.

We are closing the remaining open pull requests from this account. The project recently updated how pull requests are reviewed. Please open new work under the current process in CONTRIBUTING.md (agree behavior changes on an issue when required, batch related fixes in one PR, keep at most two open, fill in “How was it tested?”, use a conventional title).

Closing these does not reject the ideas in them; please resubmit under that workflow when you want to continue.

This was referenced Nov 19, 2026
@shuk777

shuk777 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Closing as noted above.

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