download: replace std::regex with PEG parser and string matching#11
Open
download: replace std::regex with PEG parser and string matching#11
Conversation
Remove <regex> dependency from download.cpp by replacing three regex usages with PEG parsers (for static patterns) and simple string operations (for dynamic case-insensitive matching). https://claude.ai/code/session_01E4CtxkYe1ec7BtmhRCbVP2
Combine the separate split and tag PEG parsers in get_gguf_split_info into a single parser with ordered choice (tag+split, split-only, tag-only). Reuse tagged parsers in negate lookaheads since they don't propagate AST nodes. Add a case-insensitive flag to the PEG literal parser (default false) and use it in find_best_model instead of a string helper. Throws at GBNF generation time since icase literals are unsupported there. https://claude.ai/code/session_01E4CtxkYe1ec7BtmhRCbVP2
Split the combined 3-case parser back into two simple parsers (split and tag), each with a single negate+anchor pattern. Use a plain case-insensitive string search for find_best_model instead of building a PEG arena per tag. https://claude.ai/code/session_01E4CtxkYe1ec7BtmhRCbVP2
Uppercase both the path and the tag, then use a plain PEG literal match instead of a case-insensitive string search helper. https://claude.ai/code/session_01E4CtxkYe1ec7BtmhRCbVP2
Build a single PEG parser with all tags in a choice instead of looping and building one parser per tag. Revert the icase literal addition to peg-parser since it's no longer needed — uppercasing both sides before matching is simpler. https://claude.ai/code/session_01E4CtxkYe1ec7BtmhRCbVP2
Move gguf_split_info struct and get_gguf_split_info to the public header so it can be tested directly. Add test-download.cpp with coverage for split parsing, tag extraction, and repo tag splitting. https://claude.ai/code/session_01E4CtxkYe1ec7BtmhRCbVP2
This reverts commit a75bfde.
aldehir
pushed a commit
that referenced
this pull request
Apr 10, 2026
) * ggml: backend-agnostic tensor parallelism * support for GPT-OSS, Qwen 3 MoE * partial Vulkan fix * add support for 4/8 GPUs * unconditional peer access * re-use buffers + ggml contexts * fix output pattern * NCCL support * GGML: HIP: add RCCL support * Remove shfl and AllReduce from backend interface * move allocation workaround out of ggml-alloc.c * 2d tensor set/get support * Fix the seg fault without NCCL * Apply suggestion from JohannesGaessler * support for tensor dims % n_devs != 0 * fix view_offs scaling * arbitrary num. of GPUs/tensor split * fix compilation * better granularity estimate * Support device-specific host buffer types if all underlying backends expose the same type. This allows using pinned memory instead of pageable memory for CUDA. Fix compilation errors. * partial Qwen 3 Next support * Fix qwen3 30b (#8) * Fix crash with Qwen-30B-A3B Q4_0 Qwen-30B-A3B Q4_0 has an intermediate dimension of 768. Using a granularity of 256 forces an uneven split between GPUs, which is not supported by the current implementation. * Decide block size based on tensor quantization type * Fix crashes due to KV cache serialization (#9) KV cache serialization requires non-zero offsets on the tensor. Add support in the meta backend to set/get a tensor with a non-zero offset. * metal : fix build (#7) * static memory allocations, fix usage count * fix tensor granularity * more even memory distribution * use BF16 for allreduce * rebase fixup * better error message for unsupported architectures * Fix device mismatch during scatter of allReduce. (#11) There is a mismatch between the dst buffer device and the backend device, causing the use of sync copies * Enable the previous allreduce implementation. It is better in both perf and stability (ggml-org#12) * delay AllReduce for Moe for less I/O * build : clean-up compile warnings * backend : move most of the meta backend API to ggml-backend-impl.h * cont : hide unused public API in the implementation * llama : use llama_device + remove ggml_backend_dev_is_meta() * ggml-backend : remove unused alloc include * minor : remove regex include * ggml : introduce ggml-ext.h for staging new APIs * rebase fixup * fix tests * llama : more robust logic for determining Meta devices (ggml-org#16) * llama : more robust logic for determining Meta devices * cont : fix devs size check Co-authored-by: Johannes Gäßler <johannesg@5d6.de> * cont : fix log type Co-authored-by: Johannes Gäßler <johannesg@5d6.de> --------- Co-authored-by: Johannes Gäßler <johannesg@5d6.de> * disable roundtrip for meta backend * fix arch selection * Qwen 3.5 support * fix Gemma 4 MoE * fix OpenVino, SYCL * fix test-llama-archs for CPU-only builds * Fix Qwen 3.5 MoE * disable meta backend tests for WebGPU * tests : filter CPU-based devices from the Meta backend tests (ggml-org#17) * meta : formatting, naming, indentation (ggml-org#18) * formatting : llama-model.cpp * formatting : ggml-ext.h * formatting : ggml-backend-meta.cpp * meta : add TODO * add documentation * better error messages * fix GPT-OSS --------- Co-authored-by: Carl Philipp Klemm <carl@uvos.xyz> Co-authored-by: Gaurav Garg <gaugarg@nvidia.com> Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
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.
Remove dependency from download.cpp by replacing three regex
usages with PEG parsers (for static patterns) and simple string
operations (for dynamic case-insensitive matching).
https://claude.ai/code/session_01E4CtxkYe1ec7BtmhRCbVP2