Skip to content

Fix born-broken FakeModel fixture in mlx finetune_last_n_layers test#739

Merged
danielhanchen merged 1 commit into
mainfrom
fix-mlx-finetune-test-fixture
Jun 10, 2026
Merged

Fix born-broken FakeModel fixture in mlx finetune_last_n_layers test#739
danielhanchen merged 1 commit into
mainfrom
fix-mlx-finetune-test-fixture

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

test_get_peft_model_passes_finetune_last_n_layers_through has been failing since it was introduced in #669. The trainable parameter summary at the end of get_peft_model (unsloth_zoo/mlx/loader.py, added in #634) calls model.trainable_parameters() and model.parameters(), which the synthetic FakeModel in this test never stubbed, so every run dies with AttributeError before the function returns. Verified by running the test at 049a14d in a detached worktree: it fails identically there, so this was never a regression from later commits.

It went unnoticed because CI never executes this test body: consolidated-tests-ci.yml only does pytest --collect-only for this file, and mlx-ci.yml runs just the shim smoke test on macOS.

Fix is test-only: give FakeModel the two methods returning empty trees, matching the fixture convention already used throughout test_mlx_save_lora_adapters_filter.py. With empty trees the summary computes 0 of 0 params (the existing total > 0 guard avoids division by zero) and the test reaches its num_layers assertions as intended.

No library code changes, so there is no impact on any runtime path (CUDA, ROCm, XPU, MLX) or on transformers, TRL or vLLM version compatibility.

Full suite on this branch: 1134 passed, 51 skipped, 0 failed.

test_get_peft_model_passes_finetune_last_n_layers_through has failed
since it was introduced in #669: the trainable parameter summary that
get_peft_model prints (added in #634) calls model.trainable_parameters()
and model.parameters(), which the synthetic FakeModel never stubbed.
CI never executed the test body (collect-only plus exclusion list), so
the failure stayed hidden. Give the fixture the two methods returning
empty trees, matching the fixtures in test_mlx_save_lora_adapters_filter,
so the summary computes 0 of 0 params and the num_layers assertions are
exercised as intended.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the FakeModel class in tests/test_mlx_finetune_last_n_layers.py to include mock parameters and trainable_parameters methods. This change ensures that the trainable-parameter summary at the end of get_peft_model can walk these methods without raising errors or failing assertions. There are no review comments to evaluate, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@danielhanchen danielhanchen merged commit c9506c1 into main Jun 10, 2026
15 checks passed
@danielhanchen danielhanchen deleted the fix-mlx-finetune-test-fixture branch June 10, 2026 12:44
danielhanchen added a commit that referenced this pull request Jun 11, 2026
…gate (#755)

test_mlx_finetune_last_n_layers was born broken in #669 and stayed
invisible until #739 because no CI job executed it: the version matrix
only collects, the macOS MLX job runs the shim smoke test alone, and
the zoo-specific CPU list does not include it. Add a small hard-gate
step in repo-tests-cpu running it together with
test_training_utils_use_cache (the use_cache disable/restore contract
from #715). Both files are CPU-pure and run in under a second, and the
job already installs the deps they need.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant