Repository navigation
Conversation
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. More of your lovely PRs please. 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". |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
## Summary The whole-tree "Duplicate definitions" step in Lint CI fails on main: ``` duplicate definitions (1): unsloth/kernels/dequant_cache.py:740: _ is defined twice (def at line 721, def here) ``` Every PR's source lint job inherits this (for example the staging runs for #17742 and #18108, both on current main). ## Cause #18285 registers fake (meta) kernels for its two custom ops with the idiom the torch.library docs use: ```python @torch.library.register_fake("unsloth::nf4_cached_matmul", lib = _LIB) def _(X, W, ...): ... @torch.library.register_fake("unsloth::nf4_cached_addmm_", lib = _LIB) def _(out, X, W, ...): ... ``` That code is correct. The decorator keeps a reference to each function, and the name `_` is never read back, so neither copy is dead. `lint_duplicate_definitions.py` exists to catch a second copy that silently replaces the first, which is not what happens here. The lint is too broad for this case. ## Fix In `scripts/lint_duplicate_definitions.py`, a `def _` that has at least one decorator binds nothing. This covers `register_fake`, `singledispatch`'s `@f.register def _`, and similar registration hooks. The exemption is deliberately narrow: - An undecorated `def _` defined twice is still a finding. - Any other decorated name defined twice is still a finding. Two self-test cases pin both sides. The docstring's list of carve-outs documents it. ## Verification - `--self-test`: 65 cases pass. With the exemption removed, the new decorated `_` case fails (`self-test FAILED (1 case(s))`). - Whole tree (`unsloth unsloth_cli studio scripts tests cli.py unsloth-cli.py`): `clean: 6105 file(s) checked`. On main the only finding was the one above, so the exemption hides nothing else. - `tests/test_lint_duplicate_definitions.py`: 12 passed. ruff is clean.
## Summary Six tests in `tests/saving/test_save_method_lora_routing.py` fail on main in every Core job (HF default, 4.57.6 and latest): ``` NameError: name '_release_nf4_dequant_cache' is not defined FAILED test_unsloth_save_model_guards_a_respelled_merged_4bit[merged-4bit] (and 2 more params) FAILED test_the_adapter_save_forwards_a_real_safe_serialization FAILED test_an_adapter_push_survives_a_transformers_that_dropped_the_keywords FAILED test_an_adapter_push_still_passes_every_keyword_a_transformers_4_accepts ``` Seen on the staging runs for #17742 and #18256, both on current main. ## Cause #18285 has `unsloth_save_model` call `_release_nf4_dequant_cache()` first, so a merge gets back the memory the training-time NF4 dequant cache held. That is correct. The helper is deliberately module-level, because `unsloth_save_model` forwards its own `locals()`. This test does not import `unsloth/save.py`. It execs the named functions into a namespace that `_load()` builds, pre-stubbing the helpers every save path calls (`_unmerge_flags_on_error`, `lora_relative_to_original_base`, and so on). The new helper was not in that namespace. ## Fix Add `_release_nf4_dequant_cache` as a no-op default in `_load()`, next to the other always-called save helpers. None of these fixtures has a dequant cache to free. ## Verification `tests/saving/` without the model-loading `test_unsloth_save.py`: | Tree | Result | |---|---| | main | 7 failed (the 6 above plus `test_torchao_remote_code_consent.py::test_compressed_and_gguf_lora_paths_drop_auto_map_trust`) | | this branch | 1 failed (the same torchao test) | The torchao test fails identically on both sides on this host and does not fail in CI, so it is unrelated. `test_save_method_lora_routing.py` passes 80 out of 80. ruff is clean.
…ckward harnesses (#18368) ## Summary Sixteen tests in the CPU "rest" shard fail on main since #18285, in two groups: ``` tests/test_for_inference_resets_inference_runs.py (6) KeyError: "'__name__' not in globals" tests/test_return_logits_survives_for_training.py (8) KeyError: "'__name__' not in globals" tests/test_fp8_down_proj_bf16_backward.py (2) RuntimeError: 0 active drivers ([]). There should only be one. ``` Seen on the staging run for #17742, which does not touch these files. ## Cause #18285 keeps dequantized NF4 LoRA base weights in a cache. Both new call paths are correct; the CPU harnesses could not follow them. 1. `FastBaseModel.for_inference` (`unsloth/models/vision.py`) now clears that cache with an inline `from ..kernels.dequant_cache import clear_dequant_cache`. `_fast_base_model()` in `test_return_logits_survives_for_training.py` lifts `for_inference` / `for_training` out of the source and execs them in a namespace with no package. A relative import there raises `KeyError: '__name__' not in globals`. The harness already stubbed whole helpers for this reason, but this import sits in the lifted method itself. 2. The LoRA backward now dequantizes through `dequant_cache.dequantize`. That function reads `fast_dequantize` from `kernels.utils` when called. The fp8 fixture only patched `fast_lora.fast_dequantize`, so the real Triton path ran on a CPU runner. For an fp8 quant state, `dequantize` falls straight through to `fast_dequantize`, so production behaviour is unchanged. ## Fix Test-only: - `_fast_base_model()` rewrites each relative `from ..x import a` in the lifted bodies to `a = _relative_import("x", "a")`, resolved from an explicit stub table. The table starts with `clear_dequant_cache` as a no-op. Guarded imports the fakes never reach still need no stub. One that a fake does reach without a stub fails with `stub the relative import ('kernels.dequant_cache', 'clear_dequant_cache') lifted from unsloth/models`, so the next inline import says what to add instead of surfacing as a `KeyError`. - The fp8 fixture patches `fast_dequantize` in `kernels.utils` as well as in `fast_lora`. ## Verification | Tree | Result (the three files) | |---|---| | main | 16 failed, 5 passed | | this branch | 21 passed | | this branch, stub table emptied (sabotage) | 14 failed, each naming the missing stub | | this branch, `kernels.utils` patch removed (sabotage) | 2 failed, `0 active drivers` | ruff is clean. The 17th failure in that shard, `test_grpo_autocast_disabled.py::test_reading_it_tolerates_an_older_trainer`, has a different cause (#18335) and is handled separately.
…ast (#18369) ## Summary `tests/test_grpo_autocast_disabled.py::test_reading_it_tolerates_an_older_trainer` fails on main since #18335: ``` AssertionError: getattr(self, "_autocast_enabled", False) ``` Seen in the CPU "rest" shard on the staging run for #17742. ## Cause The test requires every `getattr(self, "_autocast_enabled", ...)` in `rl_replacements.py` to default to `True`. On a trainer built before the autocast latch existed, that keeps the scoring forwards autocasting as they always did. #18335 added `_unsloth_grpo_packing_leaks`, a one-off probe that checks whether packed documents can see each other. It reads `getattr(self, "_autocast_enabled", False)`, and `False` is the right default there. The probe runs from `_unsloth_grpo_refuse_boundary_blind_packing` on the loss path as well, where the latch may not have run yet (for example under vLLM). Unlatched, `True` would autocast in the `bfloat16` fallback dtype. As `_unsloth_grpo_autocast` itself notes, reading the precision as bfloat16 raises on a T4 or V100. Running the probe in the model's own dtype is the safe choice, and once the latch exists the probe follows it. So the code is correct and the test rule was broader than its intent. ## Fix Test-only: - `test_reading_it_tolerates_an_older_trainer` scans `rl_replacements.py` with the probe's function body removed. It now also asserts that it found scoring call sites, so it cannot pass on an empty match. - A new `test_an_unlatched_probe_runs_without_autocast` pins the probe's `False` default, so neither side of the rule can drift silently. ## Verification | Change to `rl_replacements.py` | Result | |---|---| | none (main) | 18 passed (before: 1 failed) | | a scoring site switched to `False` | `test_reading_it_tolerates_an_older_trainer` fails | | the probe switched to `True` | `test_an_unlatched_probe_runs_without_autocast` fails | ruff is clean.
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
## Summary `tests/studio/test_model_picker_contracts.py::test_the_chat_picker_marks_ollama_targets_unloadable_by_the_api` fails on main: ``` AssertionError: assert 'return !isLora && !ids.some(isOllamaLinkPath);' in '...' ``` Seen in "Repo tests (CPU, studio)" on the staging run for #17742, which is on current main. ## Cause #18253 lists and loads Ollama MLX-format tags. Their checkpoint directories sit under the same `ollama_links` tree, but the resolver does index them. So `apiAutoSwitchMayLoad` and the override backfill (`migrate-model-overrides.ts`) now exclude only a materialized `.gguf` link, `isMaterializedOllamaLink`, instead of every `isOllamaLinkPath`. That change is intended and covered by `model-identity.test.ts`. The contract test still pinned the old line. ## Fix Test-only: - Pin the new predicate in `apiAutoSwitchMayLoad` and in the backfill. - Also pin `isMaterializedOllamaLink`'s definition (`isOllamaLinkPath(modelId) && !isOllamaMlxModelId(modelId)`). A materialized `.gguf` link stays unloadable, which is what this test exists to guard. ## Verification | `features/hub/lib/model-identity.ts` | Result | |---|---| | main | 205 passed (before: 1 failed) | | `isMaterializedOllamaLink` reduced back to every link (sabotage) | this test fails | ruff is clean.
…18373) ## Summary `studio/backend/tests/test_view_image_tool.py::test_invalid_large_and_pixel_bomb_files` fails on main when it runs after the other tests in its file: ``` assert 'megapixel limit' in 'Opened image.\n__MCP_IMAGES__:[...]' ``` Seen in "(Python 3.13, rest)" on the staging run for #17742, which is on current main. Run alone, it passes. ## Cause #18256 memoizes the normalized PNG data URL per payload, so a replayed screenshot is not re-decoded on every message. Only images that passed the size checks are stored. `MAX_IMAGE_PIXELS` is a constant in production, so a memo hit is always within budget. That code is correct. The test lowers `mcp_images.MAX_IMAGE_PIXELS` at runtime, for the same `image.png` that earlier tests in the file had already viewed. The memo returned the earlier result without reaching the pixel check. ## Fix Test-only: give the budget check an empty memo (`_PNG_MEMO` and `_png_memo_chars`, restored by monkeypatch), so it exercises the check rather than the cache. ## Verification | Tree | `test_view_image_tool.py` in file order | |---|---| | main | 1 failed, 30 passed | | this branch | 31 passed | The test also passes on its own on this branch. ruff is clean.
|
Codex Review: Didn't find any major issues. 👍 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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
## Problem `Repo tests (CPU, rest-2)` fails on `main` since #18625 and on every PR based on it (for example #17742, #18032, #18610, #18740): ``` test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding[3] AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding, so they break on Windows as soon as that file gains a non-ASCII byte. Pass encoding = "utf-8" ... 'tests/test_tp_vocab_parallel_gloo.py:307: open()' ``` ## Cause #18625 added a source check to `tests/test_tp_vocab_parallel_gloo.py` that reads `unsloth/models/llama.py` with a bare `open(...)`. On Windows that uses the locale code page, so it would raise `UnicodeDecodeError` once `llama.py` carries a non-ASCII byte. The guard is right; the new read is missing its encoding. ## Fix Pass `encoding = "utf-8"` to that `open()`. One line, test-only. ## Verification - On `main`: `tests/test_source_read_encoding.py -k checked_in_file_reads` fails (`[3]`, naming this line). - With this change: 16 passed, and `tests/test_tp_vocab_parallel_gloo.py` passes (11 passed).
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
Studio now shows how much memory a GGUF model needs on each GPU when you split it manually. Refs #11475.
The old estimate combined both GPUs. In this simulated example, the new warning shows that 17.84 GiB would land on a 16 GiB card.
At a panel width of 410 px, moving the per-GPU rows into a disclosure reduces the expanded panel from 505 px to 393 px. The GPU row shows the shortfall even with the details closed. Both sides below use the same simulated split.
Tested on one RTX 3090. Estimated weight memory was within 1 MiB of llama.cpp’s reported model buffer for both full and partial offload.
Earlier UI and hardware validation
Before / after (Run settings, manual layer split across two GPUs)
Merge base
00fb6a3c5vs head98a1e0500, both built withinstall.sh --local. The model is a Qwen3-14B-shaped Q8_0 GGUF (real tensor table, 14.62 GiB of weights), 40,960 context, GPU Layers 41, split 34 / 7. The host has no GPU, so both Studios were given the same fixed two-GPU CUDA inventory (16 GiB RTX 4060 Ti, 24 GiB RTX 3090) for/api/system; the estimate route and the frontend are unmodified. After also shows "GPU 0 needs more than its total VRAM." below the details.Per-GPU figures were checked against llama.cpp on a real 2x T4 (b12347, CUDA): 48 of 48 device rows matched the reported model and KV/recurrent buffers to 0.01 MiB, covering Qwen3 (tied and untied output) and Qwen3.5 hybrid, explicit ratios and the default free-memory split.
Real two-GPU host (Kaggle, 2x Tesla T4)
Same settings as above, on a real inventory:
/api/systemreported backendcudawith two Tesla T4s (15 GiB each,vram_free_bytes15633219584) and the panel warned "GPU 0 needs more than its total VRAM." This run also showed thatpcie.link.gen.currentreads Gen1 on an idle T4, so the picker now reportspcie.link.gen.max/pcie.link.width.maxinstead.