Repository navigation
fix(gguf): reject malformed metadata without panicking - #2
Merged
Vasyl-Trefilov merged 1 commit intoNov 4, 2026
Merged
Vasyl-Trefilov merged 1 commit into
Vasyl-Trefilov merged 1 commit into
Conversation
Signed-off-by: bettercallcaleb <121191527+bettercallcaleb@users.noreply.github.com>
Member
|
Thanks for contribution!! you are the first ever. I am very happy, thanks again |
Vasyl-Trefilov
pushed a commit
that referenced
this pull request
Nov 8, 2026
* feat(vulkan): account Workgroup shared memory and refuse oversized pipelines Walk the committed SPIR-V, keep the Workgroup OpVariables and evaluate their OpTypeArray lengths with the pipeline's specialization map (constants 0..n-1 plus 15 = kv_q8), failing with the opcode on anything unsupported. Vk::new queries maxComputeSharedMemorySize and logs it on the device line; Vk::pipeline compares every new pipeline with it and refuses with the kernel, spec, bytes needed and limit before creating anything (the driver used to accept it and fault at dispatch, Xid 13 on Volta). STRATA_VK_SMEM_LIMIT overrides the reported limit so the refusal can be tested without a doctored shader. * feat(vulkan): preflight the model's pipelines before weights are uploaded gpu_weight_types derives the weight types a GPU load leaves for the kernels: upload_type applies Backend::upload's F16 -> F32 and Q4_0/Q5_0 -> Q8_0 rewrites (experts are copied raw), and the load_part gate (cpu_only, f32_up) is shared rather than duplicated. Vk::preflight walks the (kernel, spec) pairs each type reaches, mirroring gemm_raw's COOP split, NT and wpb, and checks them through the same accounting Vk::pipeline uses: SPIR-V and spec arithmetic only, no pipeline, model buffer or dispatch. Engine::runner runs it after the backend is opened and before GpuModel::load_split, so a refusal precedes every weight upload. The Backend trait gets a no-op default for backends without Workgroup shared memory. * feat(cli): add strata check for the Vulkan shared-memory preflight strata check --model --backend vulkan --device runs the preflight without loading the model: it lists every checked (kernel, specialization) pair, the shared-memory limit and the wall-clock cost, and exits non-zero on overflow. The GPU-free tests assert the measured sizes of the committed SPIR-V (gemmi_dp: 49152 bytes with Q2_K, 40960 with IQ3_S; the COOP gemmi: 49168) and the refusal text (kernel, spec, bytes, limit), which Vk::pipeline raises before it creates anything. The reference-model preflight test skips cleanly without the model or a Vulkan device.
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.
Problem
Opening a malformed GGUF file can panic instead of returning a parsing error. Three independent, very small synthetic files reproduce this on the original
main:general.alignment = 0div_ceilu64::MAXCur::takeu64::MAXVec::with_capacitycapacity overflowChange
Validation
mainwith all three panics; passed with this patch.cargo test --test gguf— passed (6 tests).cargo test --lib— passed.cargo test --tests— passed (all integration suites, no model/GPU required for these cases).cargo check— passed.git diff --check— passed.Tested with Rust 1.98 in an isolated container. Two files changed, one DCO-signed commit, no new dependencies.
This is a local malformed-file robustness fix; no broader security impact is claimed.