Repository navigation
Fix image inputs in Clef training and prediction - #13471
Conversation
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. |
|
I checked The existing @pytest.mark.parametrize("natural, expected", [(16, False), (17, True)])
def test_clef_image_truncation_keeps_media(monkeypatch, natural, expected):
from unsloth.models import clef
tokenizer, processor = object(), object()
images = [object(), object(), object()]
original = images.copy()
def encode(tok, record, max_length, processor=None):
assert tok is tokenizer
assert record["images"] is images
assert record["images"] == original
assert processor is expected_processor
assert max_length == 17
return types.SimpleNamespace(input_ids=[0] * min(natural, max_length))
expected_processor = processor
monkeypatch.setattr(clef, "encode_record", encode)
encoded = types.SimpleNamespace(input_ids=[0] * 16)
assert decision._clef_truncated(
tokenizer, "synthetic frames", {}, encoded, 16,
images=images, processor=processor,
) is expected
assert images == originalMy executed probe AST-extracted the real helper and mocked only |
Share MLX's row image reader so bare images, data URLs and undecoded image-column structs load the same on both paths. Training items no longer hold pixel tensors (24 MiB per 1024x1024 image); the collator makes them again per batch, as the MLX path does.
|
@codex review |
1 similar comment
|
@codex review |
|
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". |
…reads them POST /v1/systemone validated images and then refused outright when the configured model was a saved connection, and _connection_decide had no images parameter to pass on. A multimodal System One server reached through a custom connection could only be asked text questions, even though unslothai#13126 and unslothai#13471 gave the native Clef path images. Images are forwarded now, but never on a guess: Studio cannot see what a remote System One server accepts, so the owner declares it per connection (input_modalities: ["text", "image"], stored for the configured connection only, with a switch in Settings > API) and an undeclared connection keeps refusing images with a message naming the setting. Declared or not, _validate_images runs first, so a malformed, oversized, over-pixel or non-PNG/JPEG image is refused before any provider is called, and remote URLs are still never fetched. A provider that cannot read what it was sent fails through _upstream_error as itself, with no silent text-only retry. laya_runtime.input_modalities answers for a connection too, so GET /api/settings/systemone, /v1/models and the try dialog agree with what gets forwarded. Try a decision gains an image example, "Read a screenshot", offered only when the configured model reads images. Its PNG sits in its own module behind import(), so the startup bundle never carries it.
…reads them POST /v1/systemone validated images and then refused outright when the configured model was a saved connection, and _connection_decide had no images parameter to pass on. A multimodal System One server reached through a custom connection could only be asked text questions, even though unslothai#13126 and unslothai#13471 gave the native Clef path images. Images are forwarded now, but never on a guess: Studio cannot see what a remote System One server accepts, so the owner declares it per connection (input_modalities: ["text", "image"], stored for the configured connection only, with a switch in Settings > API) and an undeclared connection keeps refusing images with a message naming the setting. Declared or not, _validate_images runs first, so a malformed, oversized, over-pixel or non-PNG/JPEG image is refused before any provider is called, and remote URLs are still never fetched. A provider that cannot read what it was sent fails through _upstream_error as itself, with no silent text-only retry. laya_runtime.input_modalities answers for a connection too, so GET /api/settings/systemone, /v1/models and the try dialog agree with what gets forwarded. Try a decision gains an image example, "Read a screenshot", offered only when the configured model reads images. Its PNG sits in its own module behind import(), so the startup bundle never carries it.
Clef training rows currently lose their
imagesfield, and prediction bypasses the vision tower. Preserve ordered images through encoding, question permutation and batching, forward the resulting tensors through the multimodal backbone, and acceptimages=inFastDecisionModel.predict().Reuses Clef's existing media encoder/collator. Image rows without a processor are rejected in the dataset report. Text-only requests retain the language-only path, and LoRA keeps the existing frozen vision tower policy.
Validation:
8b2e5fd17c09fd49bc2880b805d5323ec7ff4ff3), A100 80GB, BF16 without quantization: original 8/32 versus patched 32/32 on a fixed balanced synthetic set covering colours, counts, digits and ordered frames. The vendored Cloudflare encoder/wrapper/head, sharing the same loaded backbone, also scores 32/32; maximum probability difference is 0.000512. Public prediction agrees on all 32 cases; reversing the frames gives the correct opposite direction in 8/8 cases. The tested source hash matches this commit.The pretrained evaluation is a small synthetic correctness check, not a general accuracy benchmark or an independent backbone-loader comparison. No Studio UI or serving API changes are included.
Fixes #13461