Repository navigation
Studio: surface an MLX completion-masking miss as a warning, not a status line - #8133
Conversation
apply_completion_masking reports a double miss at level "warning" and returns
applied=False, leaving the run training on full sequences. The MLX worker passed
`notify = lambda level, message: _send("status", ...)`, which drops the level, and
assigned the result to `_masking_applied`, which discards it. So a run that was
asked for response-only training and did not get it finished looking like an
ordinary success.
The CUDA path already does both halves: it routes by level and drops
train_on_responses_enabled so the run reports what it actually did. The MLX worker
also already emits real warning events elsewhere -- the eval-split fallback uses
exactly this channel -- so masking was the one path still flattening them.
Verified end to end on an M2 (SmolLM-135M-Instruct-4bit, chatml dataset,
train_on_completions on), forcing a double miss with an older unsloth_zoo whose
dataset_utils has no get_chat_template_parts:
before: WARNING_EVENTS [] <- both notices arrived as transient statuses
after : WARNING_EVENTS [auto-detection failed..., could not be applied...]
The run still completes in both cases, which is correct: a masking miss should be
visible, not fatal.
Note this is a robustness fix rather than a live bug. On a correctly pinned
unsloth_zoo (>=2026.8.3) auto-detection succeeds for the mlx-community models I
tried, so a double miss needs a template the detector cannot parse AND absent from
MODEL_TO_TEMPLATE_MAPPER.
The routing is a module-level helper so it can be tested without a training run.
Both new tests fail without this change (the helper does not exist).
tests/test_mlx_training_worker_config.py is 17 passed.
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Resolves the conflict in the MLX completion-masking call. Keeps main's dataset_template argument from unslothai#8103 alongside the level-preserving notifier, so Alpaca-rendered datasets still get explicit markers.
apply_completion_masking also reports at level "warning" when auto-detection raises and the template table then succeeds. Routing on level meant that run, which got the masking it asked for, was left with a permanent warning in the UI. Send from the caller instead, where masking_applied is already in hand, so only a real miss is sticky. That also drops the duplicate log line, since the parent pump already logs every warning event it receives. Tests now pin the call site rather than the helper in isolation: a revert to the old flattening lambda, or a dropped dataset_template, passed the previous tests. Also stubs utils.hf_dataset_options so the module can be run on its own.
|
Good catch on this one, the flattening was real and the warning channel is the right home for it. I pushed two commits to the branch.
except Exception as e:
notify(
"warning",
f"Auto-detection of instruction/response markers failed ({e}); "
f"falling back to the template table",
)That one is recoverable, and the template table right below it can still return Since if not masking_applied:
_send(
"warning",
message = (
f"'Train on completions' could not be applied for {model_name}: no "
f"instruction/response markers were found. Training will run on full "
f"sequences (prompts included)."
),
)Only a real miss is sticky, One correction on the comment that was there. The CUDA path does not actually report anything either. On the tests. Both of the originals passed against a call site reverted to the old flattening lambda, and against one with Also added a Verified: 18927 passed on Two things I left alone. CUDA's |
_run_mlx_training only runs on Apple Silicon, so the guarded masking block is lifted out with ast and executed directly against the real apply_completion_masking and the real template tables. That gives Linux CI actual behavioural coverage of the branch this PR changes. Covers the three skip conditions, both applied paths (auto-detected, and recovered by the template table after detection raises), the double miss, and odd model names in the interpolated message. Mutation checked: routing the miss back to a status event, dropping dataset_template, routing warnings in notify, and ignoring masking_applied each fail at least one test.
|
Ran this through a proper simulation pass before signing off. Summary first: the issue is real, the fix holds, and nothing else can be affected. One more commit, Before and afterBefore, After, the miss goes out as Real issue, narrow blast radius. It needs both halves of the double miss, so it is a robustness fix rather than something users hit daily, which is what you said in the description. SimulationRather than reimplement the call site, the harness lifts the guarded masking block out of
That is the issue reproduced and the fix demonstrated, in the same file, without a Mac. Coverage: the three skip conditions, preset markers on the tokenizer, preset markers behind mlx-lm's Pipeline: events pushed through a real Nothing else can break
Old installs are fine. Browsers do not come into it, there is no frontend diff. The string lands in the existing callout in Python matrix in isolated The new commitThe tests were shape-only, so they could not catch a behavioural regression. Full suite under One thing the simulation surfaced that is worth a separate look: a marker mismatch, where |
Follow-up from testing the studio training paths on Apple Silicon. One commit, two files.
apply_completion_maskingreports a double miss at level"warning"and returnsapplied=False, leaving the run training on full sequences. The MLX worker discarded both signals:The lambda drops
level, so a warning becomes a status line that scrolls past._masking_appliedis discarded outright. A run that asked for response-only training and did not get it finishes looking like an ordinary success.Why this is the odd one out
The CUDA path already does both halves — it routes by level, and drops
train_on_responses_enabledso the run reports what it actually did:And the MLX worker already emits real
warningevents elsewhere; the eval-split fallback a few hundred lines above uses exactly this channel:Masking was the one path still flattening them.
Verified end to end
M2 MacBook Air,
mlx-community/SmolLM-135M-Instruct-4bit, a chatml dataset,train_on_completionson. A double miss was forced with an olderunsloth_zoowhosedataset_utilshas noget_chat_template_parts, so auto-detection fails and the model is absent fromMODEL_TO_TEMPLATE_MAPPER:The run still completes in both cases, which is the intended behaviour — a masking miss should be visible, not fatal.
Scope, honestly
This is a robustness and parity fix rather than a live bug. On a correctly pinned
unsloth_zoo(>=2026.8.3) auto-detection succeeded for every mlx-community model I tried, so reaching a double miss needs a template the detector cannot parse and one absent from the 630-entryMODEL_TO_TEMPLATE_MAPPER. I am not claiming users are hitting this today; the point is that when it does happen the training objective changes silently.I deliberately did not change what the run metadata records. Both backends store the requested
train_on_completions, and changing one would introduce a new inconsistency rather than remove one.Tests
The routing is a module-level helper so it can be tested without a training run. Both new tests fail without this change — the helper does not exist, so the module attribute lookup raises.
ruff checkclean.For anyone re-running the suites:
test_training_streaming.py(8 failures) andtest_training_raw_support.py(1) fail identically on unmodifiedmain— I baselined them before and after this change, same counts both ways.