Repository navigation
GGUF LoRA export: read quantization_method case insensitively - #19113
Merged
danielhanchen merged 4 commits intoNov 24, 2026
Merged
Conversation
save_pretrained_gguf and push_to_hub_gguf with save_method="lora" matched quantization_method against the LoRA outtypes as written, so "Q8_0" or "BF16" fell back to f16 with a "does not support" warning. The merged GGUF path already lowercases quant names. Move the duplicated selection into _lora_gguf_outtype, lowercase string input there, and add a test that lifts the helper with ast.
Member
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
added a commit
that referenced
this pull request
Nov 24, 2026
## Problem `studio/backend/tests/test_log_bounds.py` fails on main in the backend `(Python 3.13, g-l)` shard. It also shows on staging runs, for example for #19113: ``` TestFamiliesAreBounded::test_every_python_written_family_prunes these log families are written but never pruned: sglang (sglang-*.log) TestFamiliesAreBounded::test_a_new_family_cannot_be_added_unnoticed new log families: sglang ``` ## Cause #19166 (per-attempt logs for managed SGLang) added the `sglang` family, and its logs are pruned: `ManagedEngineLog.open` calls `prune_log_dir(directory, f"{engine}-*.log", protect = path)` after opening each attempt's file. The guard could not see that, for two reasons: - it only reads `run.py`, `log_retention.py`, `llama_cpp.py` and `lemonade_server.py`; - it looks for the literal glob `sglang-*.log`, which an f-string never contains. The reviewed list also did not name the new family. So this is a guard gap, not unbounded logs. ## Fix - `managed_engine_log.py`: prune with the `pattern` it already reads from `MANAGED_ENGINE_LOG_FAMILIES`. It is the same value, but now the family table is the one place the glob is defined. - `test_log_bounds.py`: - managed engine families are proved by running the code. `test_a_managed_engine_log_prunes_its_family_on_open` is parametrised over `MANAGED_ENGINE_LOG_FAMILIES`. It fills a temp studio home with `DEFAULT_KEEP + 5` old logs and opens a new one, then checks: - exactly `DEFAULT_KEEP` remain; - the new handle is kept; - the oldest is gone. - the source scan skips these families instead of grepping for their glob; - `sglang` joins the reviewed list. A future managed engine still fails `test_a_new_family_cannot_be_added_unnoticed` until someone adds it there, and the behavioral test covers it automatically. ## Verification - `test_log_bounds.py` and `test_managed_engine_logs.py`: 17 passed. On main, 2 fail. - Sabotage: - replacing the `prune_log_dir` call with `pass` fails `test_a_managed_engine_log_prunes_its_family_on_open[sglang]`; - adding a `vllm` entry to `MANAGED_ENGINE_LOG_FAMILIES` fails `test_a_new_family_cannot_be_added_unnoticed`.
danielhanchen
added a commit
that referenced
this pull request
Nov 24, 2026
## Problem On runners with 16 GB of RAM, 35 llama.cpp placement tests fail across `(Python 3.13, g-l)` and `(Python 3.13, m-r)`. The staging runs for #19113, #19181 and #19244 all show them, for example: ``` test_llama_cpp_placement.py::test_the_moe_cache_stays_off[ram_cannot_pin_experts-] assert _load_mode(cmd) == "none" (None == 'none') Load mode: keeping mmap; pinning the host-side weights plus the 9.0 GB llama-server grows into would hold more than 50% of the 15.3 GB of RAM, which the OS cannot page out. ``` They pass on larger runners and locally, so this only shows up on some runners. ## Cause #19231 (price llama-server host RAM growth before pinning a spilled load) is correct. A pinned launch (`--load-mode none`) now also checks that the pinned host-side weights plus llama-server's growth stay under a safe share of total RAM. That total comes from `_host_memory_capacity_mib()`, which reads the real `MemTotal` and the cgroup limit. The placement tests fake the GPUs and, where they care, the available RAM. They never pin the total, so each launch decided against whatever machine ran it. Reproduced locally by stubbing `_total_system_memory_mib` to 15667 MiB: 35 failed, 770 passed in the three files below. ## Fix - `test_llama_cpp_placement.py` gets an autouse fixture, `_pinned_host_ram`. It pins `LlamaCppBackend._total_system_memory_mib` to 256 GiB and `_cgroup_memory_limit_mib` to `None`, so every launch sees the same host on any runner. - `test_lookup_table_fit.py` and `test_prompt_cache_sized_to_context.py` launch through that file's helpers, so they import the fixture. - Tests that are about host RAM still set their own total in the test body, which overrides the fixture. ## Verification - The three files on this branch: 805 passed. - With the host forced to 15.3 GB (a plugin stubbing `_total_system_memory_mib`): 805 passed on this branch, and 35 failed on main. - All 34 test files that import `test_llama_cpp_placement`: 2365 passed and 24 skipped. - One test failed: `test_cached_gguf_routes.py::test_pipeline_class_guard_passes_every_shipped_family`. - It fails identically on main, because this host has diffusers 0.41.0.dev0 and the test needs 0.42.0. It is unrelated to this change.
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.
save_pretrained_gguf(save_method = "lora")andpush_to_hub_gguf(save_method = "lora")comparequantization_methodagainst the LoRA outtypes (f32,f16,bf16,q8_0,auto) as written. Soquantization_method = "Q8_0"or"BF16"logs "LoRA GGUF export does not support quantization_method='Q8_0'; using outtype 'f16'" and writes an f16 adapter instead of the q8_0 or bf16 one that was asked for.The merged GGUF path in the same functions lowercases each quant name before using it, so
"Q8_0"works there. Only the LoRA branch is case sensitive.Changes:
_lora_gguf_outtype, next to_LORA_GGUF_OUTTYPESinunsloth/save.py.Noneand"fast_quantized"still give f16 with no warning, and an unsupported name such asq4_k_mstill falls back to f16 with the warning.Testing:
tests/test_lora_gguf_outtype.pylifts the helper out ofsave.pywithast, the same waytests/test_gguf_model_basename.pydoes, so it runs without the GPU stack. It covers upper case names, a one item list or tuple, the valid lower case names, the f16 default and the warning fallback.mainthe file fails (the helper does not exist there). Running the old inline logic onmaingivesQ8_0 -> f16andBF16 -> f16, both with the warning.ruff checkis clean on the changed files.Follow-up commit
save_pretrained_ggml/push_to_hub_ggml(outtype="Q8_0")go straight to the LoRA GGUF writer, which still raisedValueError: ... (got 'Q8_0'). The writer now lowercasesouttypetoo, so every LoRA GGUF entry point accepts any case. Verified on a Colab L4 with a tiny Qwen3 LoRA: before,"Q8_0"/"BF16"produced an f16 file andsave_pretrained_ggml(outtype="Q8_0")raised; after, they write-lora-q8_0.gguf(Q8_0 tensors) and-lora-bf16.gguf(BF16 tensors). Lowercase inputs are unchanged.