Repository navigation
fix: let the model library scan read large checkpoint metadata - #967
Merged
Merged
Conversation
Large-vocabulary checkpoints ship a shard index above the scan's 4 MiB JSON cap — GLM-5.3-Flash's 43-shard index is 11.5 MiB — so inspect() stopped with 'checkpoint metadata is too large to inspect safely' and the scan marked a perfectly loadable checkpoint incomplete. The bundled native engine reads these files fine; the limit only guards the bounded read loop, so raise it to 64 MiB per file and 256 MiB for a checkpoint's scan-wide metadata budget.
…gression tests The tokenizer is checked through safeFile(), not the JSON cap, so the old comment wrongly blamed it; name the shard index as the file the cap gates. Cover the >4 MiB shard index scanning and resolving, the oversized tokenizer passing unchanged, the new per-file cap still rejecting, malformed JSON still rejecting, and the scan-wide budget staying bounded with a visible truncation.
heitke
force-pushed
the
fix/library-metadata-scan-limits
branch
from
October 16, 2026 22:28
295928d to
1b32d2b
Compare
This was referenced Oct 17, 2026
Open
Owner
|
Thank you, @heitke, for the larger-metadata fix and regression fixtures. We merged your work for 1.1.0 in 4a2d760. The scanner accepts a valid 5 MiB index, refuses a 65 MiB index before reading and still rejects corrupt metadata. Our scan-budget fixture also checks two indexes that fit separately but exceed the shared budget together. Native model admission and shard validation remain in place. Posted by Ash's AI Assistant Synthena |
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…files up to 64 MiB, within a 256 MiB budget for the scan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The local model library scan rejects large-vocabulary checkpoints because their shard index exceeds the scan's 4 MiB per-file JSON cap (
JSON_LIMITinapp/electron/agent/engine/library.ts). The bundled native engine reads these files without complaint — the cap only guards the scan's bounded read loop — so this change raisesJSON_LIMITto 64 MiB per file and the scan-wide metadata budget to 256 MiB. With that, a 43-shard GLM-5.3-Flash checkpoint (~170 GiB, 11.5 MiBmodel.safetensors.index.json) scanscomplete/compatible/loadableinstead of failing withThe checkpoint metadata is too large to inspect safely.tokenizer.jsonis checked throughsafeFile(), not the JSON cap, so an oversized tokenizer already passed; the regression tests pin that behavior.metadataBytesis a scan-wide budget shared by every checkpoint in one scan, not a per-checkpoint allocation.JSON_LIMITalso caps safetensors header sizes, so raising it widens that bound too.A large checkpoint on an exFAT volume hits two independent causes — the over-cap shard index and the AppleDouble companions (#970) — and needs both changes; neither PR alone fixes that case.
Receipt
1.0.0-beta.6, native engine1.0.12(build.zig.zon), commit1b32d2b7(this PR, based on46a08c18); macOS 26.6.2, Apple M3 Ultra (Apple Silicon, Metal), Node 22.14.0, npm 10.9.8. Checkpoint: a localglm-5.3-flash-mlx-4bit-mtpcheckpoint (43 shards, ~170 GiB) on an external drive; its Hugging Face repository and revision are unrecorded, and the receipt's verification of it is the author-reported manual run on the earlier commit, not re-run for this commit.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: not applicable — filesystem model-library inspection only; inference and prompt-processing code are unchanged.tools/bench_openai.py: not applicable — filesystem model-library inspection only; inference and prompt-processing code are unchanged.tools/prefill_cold.py: not applicable — filesystem model-library inspection only; inference and prompt-processing code are unchanged.app/with the repo's pinned Node 22.14.0 and npm 10.9.8:assertcalls respectively, 0 failures, 0 skips),npm run typecheckclean,git diff --checkclean, and the repo's private-leak and test-coverage gates pass; the fullnpm testsuite was not run locally end to end — in this environment two unrelated suites (session-search-index,mobile-security-dependencies) fail for missing local modules, the same failures as on the unmodified base commit. GitHub CI: 548/548 test files passed (thedesktopcheck).Regression evidence (synthetic, through the public
ModelLibraryAPI —scan,addFolder,resolve):The checkpoint metadata is too large to inspect safely.; after, it scanscomplete/compatible/loadable, resolves, and reports the rightweightsBytes/memoryFloorBytes. The same new test fails against the pre-change implementation.tokenizer.jsonalone scansloadableboth before and after — confirming the tokenizer was never gated by this cap.stat, not 64 MiB of writes), and malformed JSON in an index is still rejected.limits, the scan stops at a visible bound:truncated: trueand a safety-limit warning.