Repository navigation
MLX decision training: Clef rows and predict take images - #13127
Conversation
A decision row's `images` (PIL images, data URLs, or the bytes / path dicts of an undecoded image column) reach the MLX Clef trainer, and `FastDecisionModel.predict` takes `images` for a Clef. A row whose images cannot be read, or whose model reads none, is skipped with its reason like any row that does not fit. Laya reads text only and refuses images in `predict`. Rows without images are built as before.
Codex Review SummaryThis 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. |
With an unsloth-zoo whose Clef items take no images, a row with images failed as a row that does not fit and was skipped, so a dataset trained without its image rows, and predict raised a bare TypeError. Both now raise an ImportError naming the upgrade. Rows without images are built with the same call as before.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8992336dac
ℹ️ 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".
predict tested the raw value, so an empty serialized image column such as "[]" made a Laya refuse a text-only request. The value is normalized first, as it is for a Clef.
A nullable image column holds None or an empty {bytes, path} struct where a row has no image. Those were forwarded as images, so a text-only row was treated as one with images and skipped or refused. They are dropped.
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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 converged at What changed during review:
Not changed, with the reason in each thread:
CI at
|
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05b401f289
ℹ️ 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".
| encoded = encode(state, kept) | ||
| except (TypeError, ValueError) as exc: | ||
| encoded = encode(state, kept, _row_images(row)) | ||
| except (TypeError, ValueError, OSError) as exc: |
There was a problem hiding this comment.
Catch bombs decoded by the Clef encoder
When a training row supplies an accepted data:image/... string whose dimensions trip Pillow's decompression-bomb guard, _row_images leaves that string unopened and clef_training_item is where Pillow raises Image.DecompressionBombError. That exception is not a TypeError, ValueError, or OSError, so this handler lets one oversized URL abort the entire dataset instead of reporting and skipping its row as it does for the equivalent bytes/path dict; include this exception in the row-level handling for images decoded by the encoder.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
unsloth-zoo's _decode_images opens data URLs inside try/except Exception and raises DecisionRequestError (a ValueError), so a bomb sent as a data URL is caught here and skipped with its row; checked with a 14000x14000 PNG.
|
@codex review |
|
@codex review |
|
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". |
What this adds
Decision rows with images train MLX Clef models, and
FastDecisionModel.predicttakes images.images(PIL images, data URLs, a JSON string of them, or the{"bytes": ..., "path": ...}dicts of an undecoded image column) reach the MLX Clef trainer. Unsloth Studio's decision dataset reader already keeps the column.FastDecisionModel.predict(..., images=)accepts the same shapes for a Clef.imagesinpredict. Rows without images, Laya training and the torch path are unchanged.Depends on unslothai/unsloth-zoo#1645, which makes
clef_training_itemaccept images. With an older unsloth-zoo, rows without images are built with the same call as before.Validation
python -m pytest tests/test_decision_model_mlx.py -q # 13 passedEnd to end through
FastDecisionModelandDecisionTraineron bean leaf photos (AI-Lab-Makerere/beans, 1,034 train, 261 held out, 100 steps, batch 4, LoRA r16), held-out accuracy:A plain Qwen3.5-2B trained the same way on generated pictures saves with
save_pretrained_mergedand reloads through the serving engine reading images with the same accuracy.Risks
imagescolumn without a warning, as the torch path does.