Repository navigation
Studio: score the VLM eval split on the training prompt - #18650
Conversation
…18651) ## Summary `Repo tests (CPU, studio-install)` is red on `main` (seen on #18650, and reproduced on current `main`): ``` FAILED tests/studio/install/test_install_lemonade_prebuilt.py::test_install_verifies_and_pins_fastflowlm FAILED tests/studio/install/test_install_lemonade_prebuilt.py::test_a_complete_install_is_not_downloaded_again FAILED tests/studio/install/test_install_lemonade_prebuilt.py::test_a_fastflowlm_only_pin_bump_repins_lemond FAILED tests/studio/install/test_install_lemonade_prebuilt.py::test_a_digest_mismatch_installs_nothing FAILED tests/studio/install/test_install_lemonade_prebuilt.py::test_a_cancelled_download_installs_nothing urllib.error.HTTPError: HTTP Error 404: File not found ``` ## Cause #18554 made the direct FastFlowLM install the default on every supported host (Windows and Linux x86_64, as its description says). The lemond path now only runs with `UNSLOTH_NPU_LEMONADE=1`. The installer change is intended. These tests, though, were written for the lemond path and never opted in. So `install()` now took the direct path and asked the test's local server for a FastFlowLM archive that does not exist there, which returned the 404. The tests are out of date, not the installer. ## Change All changes are in `tests/studio/install/test_install_lemonade_prebuilt.py`; the installer is unchanged. - Two fixtures pin the path each test means to cover: - `lemond_path` sets `UNSLOTH_NPU_LEMONADE=1` and asserts `direct_flm()` is False; - `direct_path` unsets it and asserts the default is the direct path. A future change of default therefore fails at the fixture instead of quietly testing one path against the other's assets. - The five existing tests use `lemond_path`, so the opt-in lemond path keeps its coverage. - The local server now also serves a real FastFlowLM archive (a tar.gz, or a zip on Windows), and the pins carry its actual digest. - Three new tests cover the default direct path, which had no installer test: - it installs the pinned FastFlowLM with no Lemonade, writes the marker, and does not download again once installed; - a digest mismatch installs nothing; - a cancelled download installs nothing. ## Testing - On `main` the file fails 5 of 6. With this change: 9 passed. - Sabotage, installer side: - dropping the reuse check in `_install_flm_direct` fails the new test with "a complete FastFlowLM install was downloaded again"; - disabling the sha256 check in `_download` fails both digest-mismatch tests (the lemond one and the direct one).
…nell ConvRot mapping (#18652) ## Summary `Backend CI / (Python 3.13, diffusion)` is red on `main` (seen on #18650, reproduced on current `main`): ``` FAILED tests/test_diffusion_family_data_freeze.py::test_family_data_resolves_identically E AssertionError: per_family E {'flux.1': {... 'convrot_default_on': True, ...}} != {'flux.1': {... 'convrot_default_on': False, ...}} ``` ## Cause #18639 deliberately gave `flux.1` a hosted ConvRot INT8 spec: `FLUX.1-schnell-INT8-ConvRot.safetensors` in `unsloth/FLUX.1-schnell-FP8`, `default_on = True`. The freeze test exists to make every such change explicit. Its docstring says a deliberate change regenerates the fixture with `UNSLOTH_FREEZE_UPDATE=1`, and the fixture diff is the review artifact. #18639 did not regenerate it, so the code change is intended and the frozen snapshot is stale. ## Change `studio/backend/tests/fixtures/diffusion_family_data_freeze.json`, regenerated with `UNSLOTH_FREEZE_UPDATE=1` and `UNSLOTH_DIFFUSION_INT8_CONVROT` unset. The diff (6 lines added, 3 removed) contains only #18639's change for `flux.1`: - `convrot_default_on`: `false` to `true`; - `convrot_filename` and `convrot_repo`: `null` to the schnell ConvRot file and repo; - `flux.1` added to the family tables: the default-on set, filename map and repo map. No exclude-token, NVFP4 or other family entry moves. Those are the sets baked into published prequant artifacts, so hosted checkpoints are unaffected. ## Testing - `tests/test_diffusion_family_data_freeze.py`: fails on `main` with the diff above, passes with this fixture. - `tests/test_diffusion_flux1_convrot_hosted.py` (#18639's own tests) still passes: 14 passed together.
…ce coverage gate (#18655) ## Summary `Repo tests (CPU, studio)` is red on `main` (seen on #18650, reproduced on current `main`): ``` FAILED tests/studio/test_appearance_coverage.py::test_every_appearance_setting_is_measured_or_allowlisted AssertionError: <html> flag 'webkit-legacy-compositor' switches on costly CSS (index.css: html.tauri.render-linux.webkit-legacy-compositor[data-glass][data-chat-wallpaper-workspace-ready] [data-slot="sidebar-co...) but no gate mode measures it: map it in ROOT_FLAGS to the mode that sets it ..., or to 'allow: <reason>' ``` ## Cause #18600 ("pinned sidebar glass haloes the logo on WebKitGTK before 2.54") adds the `webkit-legacy-compositor` class. `main.tsx` sets it only in the Linux desktop app on WebKitGTK older than 2.54, and the CSS under it works around TextureMapper blurring later layers into a `backdrop-filter`. The fix is right. The coverage gate requires every root flag that switches on costly CSS to be either measured by a gate mode or allowlisted with a reason, and this flag was not added. ## Change - `tests/studio/_appearance_coverage.py`: `webkit-legacy-compositor` is allowlisted in `ROOT_FLAGS` ("WebKitGTK before 2.54 only (TextureMapper backdrop workaround); the Chromium gate cannot run it"). That is the same treatment as its WebKitGTK siblings `data-glass-cpu` and `webkit-cpu-paint`: the browser gate runs Chromium, which can never set this class. ## Testing - `tests/studio/test_appearance_coverage.py` fails on `main` with the message above and passes with this change (5 passed).
…ort and FLM host tests (#18654) ## Summary `Repo tests (CPU, rest-2)` is red on `main` (seen on #18650, reproduced on current `main`). `tests/test_source_read_encoding.py` flags three new reads that use the platform default encoding: ``` AssertionError: 2 file reads in the test trees touch a checked-in file with the platform default encoding ...: ['tests/test_run_report.py:246: read_text()', 'tests/test_run_report.py:267: read_text()'] AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding ...: ['studio/backend/tests/test_npu_flm_host.py:286: read_text()'] ``` ## Cause - #18603 (opt-in memory and batch efficiency reports) added the two reads in `tests/test_run_report.py`. - #18554 (FastFlowLM without Lemonade) added the read in `studio/backend/tests/test_npu_flm_host.py`. All three are bare `read_text()` calls on checked-in files. On Windows they would decode with the locale code page as soon as one of those files gains a non-ASCII byte. The guard is right; the reads are what needs fixing. ## Change - `encoding = "utf-8"` on those three `read_text` calls. No behaviour change. ## Testing - `tests/test_source_read_encoding.py` lists the three offenders on `main` and passes with this change. - `tests/test_source_read_encoding.py` and `tests/test_run_report.py`: 30 passed. - `studio/backend/tests/test_npu_flm_host.py`: 21 passed.
) ## Summary `tests/test_responses_only_arrow_label_scan.py::test_masked_split_matches_the_row_by_row_scan` fails intermittently in unslothai/unsloth's `Core zoo (HF=4.57.6 + TRL<1)` job, which runs this repo's tests at `main`. Seen on unslothai/unsloth#18650: ``` tests/test_responses_only_arrow_label_scan.py:161: in test_masked_split_matches_the_row_by_row_scan assert fast_log == capsys.readouterr().out E + Unsloth: not enough free memory for dataset tokenization workers (~1GB each); tokenizing in-process. E Unsloth: Removed 1199 out of 4000 samples from train_dataset where all labels were -100 ... ``` ## Cause The test (#2324) runs `train_on_responses_only` twice, once on the Arrow fast path and once on the row-by-row path, and asserts the two printed logs are equal. `get_dataset_num_proc` sizes workers from free RAM read at call time, and `_clamp_by_memory` prints a one-shot warning when RAM is short. On a busy xdist runner, free memory dipped between the two calls, so only the second log carried the warning. Neither the code under test nor the warning is wrong. The comparison was just exposed to an environment reading that has nothing to do with what it checks. ## Change - The test sets `UNSLOTH_DATASET_NUM_PROC=0`, so both runs tokenize in-process. That override wins over the memory reading, so the worker decision and its log no longer depend on the machine. - The rest of the test is unchanged: it still compares the two outputs and logs, and still asserts the `Removed` line and that the fast path ran. ## Testing - The real file passes: 19 passed. - Reproduced the CI failure with a conftest that reports 64 GB free on the first memory read and 0.5 GB after. The test from `main` fails all three formats with the extra "not enough free memory" line, and this version passes all three.
## Summary `Repo tests (CPU, rest)` is red on `main` (seen on #18650, reproduced on current `main`): ``` FAILED tests/test_autograd_inplace_outputs.py::test_no_inplace_mutation_of_returned_fresh_tensors AssertionError: unsloth/kernels/fast_lora.py:686 LoRA_MLP: i.fill_(_SKIPPED_FILL) ``` ## Cause #18607 (skip the LoRA MLP down projection in gradient checkpoint replays) builds the skipped output as `i = X.new_empty(X.shape)`. When the test-only `_SKIPPED_FILL` sentinel is set, it then calls `i.fill_(_SKIPPED_FILL)`. `i` is returned from `LoRA_MLP.forward`. The guard exists because torch 2.11 compiles a wrong gradient for an ATen in-place op on a fresh tensor a `torch.autograd.Function` forward returns (#14712), and the block-compile path (#18641) traces this forward. The guard is right, and the skip itself is right: only the mutation needs to go. ## Change - `unsloth/kernels/fast_lora.py`: allocate the skipped output already filled, `X.new_full(X.shape, _SKIPPED_FILL)`, when the sentinel is set. Otherwise it stays `X.new_empty(X.shape)`. The values are identical (`new_empty` + `fill_` and `new_full` both give a tensor of that shape full of that value), and production never sets the sentinel. There is no in-place op left on the returned tensor. ## Testing - `tests/test_autograd_inplace_outputs.py` fails on `main` with the line above and passes with this change. - `tests/test_gc_skip_replay_mlp_down.py` and `tests/test_autograd_inplace_outputs.py` on CPU: 20 passed, 6 skipped. The skipped six need CUDA. - Not run here: those six CUDA tests, which fill the skipped output with NaN to prove nothing reads it, and `test_gc_skip_replay_mlp_down_block_compile.py` (torch >= 2.11 with CUDA). This host has no local GPU for this session, and the remote attempt failed in dependency setup before any test ran. CI's GPU jobs will exercise them.
…rming layers (#18688) ## Summary `Repo tests (CPU, rest)` fails intermittently on current `main`. It is seen on #18650 and #18532, both based on recent `main`, and both runs include #18607 and #18641: ``` FAILED tests/test_gc_skip_replay_mlp_down.py::test_only_the_post_norm_free_layer_arms E AssertionError: assert ['LlamaDecode...e_at_514_178'] == ['LlamaDecode...fast_forward'] E Left contains one more item: '__resume_at_514_178' ``` ## Cause #18607 added this test. It collects every module-level function in `unsloth.models.{llama, gemma, ...}` whose source calls `arm_mlp_output_unread(` and expects exactly `LlamaDecoderLayer_fast_forward`. When an earlier test in the same xdist worker compiles that layer and hits a graph break, Dynamo parks the continuation function (`__resume_at_<offset>_<n>`) in the compiled function's module globals. That puts it in `unsloth.models.llama`. Its code object points at `LlamaDecoderLayer_fast_forward`'s lines, so `inspect.getsource` returns the same source, and it counts as a second arming layer. The test passes alone and fails only when such a compile ran first in the worker. The product code is right; the test's view of the module namespace was not. ## Change `tests/test_gc_skip_replay_mlp_down.py`: only count a function when its code name matches the name it is bound under (`fn.__code__.co_name == fn_name`). Dynamo's resume functions are bound as `__resume_at_*` but named `torch_dynamo_resume_in_*`, so they drop out. Every function defined in the module with `def` still matches. ## Testing - `tests/test_gc_skip_replay_mlp_down.py`: 18 passed, 6 skipped (the six need CUDA). - Reproduced the CI failure with a conftest that plants a resume function exactly as Dynamo does: same code with `co_name = "torch_dynamo_resume_in_LlamaDecoderLayer_fast_forward_at_514"`, bound as `__resume_at_514_178` in `unsloth.models.llama`. The test from `main` fails with `Left contains one more item: '__resume_at_514_178'`; this version passes. - The guard still does its job: planting a real second arming function in `unsloth.models.gemma` still fails it (`Left contains one more item: 'GemmaDecoderLayer_arming'`).
A vision dataset without a question column trains on one fixed prompt, picked from row 0 of each split. Train and eval were formatted separately, so eval loss could measure a prompt the model never saw, and the seeded max_steps shuffle picked the training prompt. Pick it from 100 rows and reuse it for eval.
f68eac7 to
12a4fd9
Compare
The 100-row hint scan iterated whole rows, decoding every image: about 1 s per split on Radiology_mini (4.6 ms before the scan widened). Project to the text column first; lists and datasets without select_columns keep the row scan. [skip ci]
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03e37c70f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…ead other columns [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f2e4cbfa5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
A caption-only training split infers one prompt; passing it to the eval split as vlm_instruction overrode eval rows that carry their own question column. Pass it as vlm_fallback_instruction instead (CUDA trainer and MLX worker), which applies only when the split has no per-row question column. [skip ci]
|
@codex review |
|
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". |
Studio picks one fixed user prompt for a vision dataset with no question column, but it read only row 0 of the split being formatted. A separate eval split is formatted on its own (CUDA
trainer.py, MLXworker.py), so eval loss and best-checkpoint picks could score a prompt the model never trained on. Onunsloth/Radiology_mini, train got "Analyze this medical image and describe the key findings." and eval got "Describe this image in detail." The seededmax_stepsrow bound shuffles train first, so the seed could also change the prompt (unsloth/LaTeX_OCR: 2 of 40 seeds).Fix: score the content hints over the 100 rows the question scan already reads, return the chosen prompt from
format_and_template_dataset, and pass it to the eval split on both backends.Test:
tests/test_vlm_eval_instruction.pyfails 6 of 6 on main and passes after; alltests/test_vlm_*.pypass (97). With the same real rows, train and eval now match and LaTeX_OCR gets the LaTeX prompt on 40 of 40 seeds.Maintainer follow-up
Speed fix (
ca78090c59). The 100-row content hint scan read whole rows, and reading a row decodes its image. That made the prompt pick take about 1 s per split on Radiology_mini. The scan now reads only the text column (select_columns). Lists, and datasets withoutselect_columns, still scan full rows. A new test counts image decodes during the scan: 51 before the fix, 1 after.Time for
generate_smart_vlm_instructionon 400 real Radiology_mini rows (median of 7):Verification on real rows (400 streamed rows per split, eval formatted separately, through
UnslothTrainer.load_and_format_dataset):format_and_template_datasetwas checked. The newvlm_instructionkey is additive and read with.get. Eval splits carved out of train are created after formatting on both CUDA and MLX, so they already shared the prompt.