Skip to content

Studio: say when an attached image is over the 20 MB limit - #14538

Merged
Lyxot merged 5 commits into
unslothai:mainfrom
NilayYadav:oversized-image-attach-toast
Oct 22, 2026
Merged

Lyxot merged 5 commits into
unslothai:mainfrom
NilayYadav:oversized-image-attach-toast

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Picking or dropping an image larger than 20 MB in the chat composer did nothing. No chip appeared and no message explained why, so the file just seemed to vanish. The Compare composer skipped such an image silently too. Every other refusal in the same place (a PDF that is too large, a model that cannot see images, the MCP image limits) already shows a toast.

Both composers now show a toast naming the file and the 20 MB limit, the same way the other attachment checks report a refusal. Images under the limit attach as before.

Screenshots

A 27 MB PNG picked with a vision model loaded, in a normal chat and in Compare.

Before (main) After (this PR)

danielhanchen added a commit that referenced this pull request Oct 21, 2026
…arness (#14545)

Repo tests (CPU, rest) is red on main since #14516: 7 cases in
`tests/test_optimized_precision_conflicts.py` fail with

```
unsloth/models/loader.py:1811: in from_pretrained
    _fp8_dequantize_config = _fp8_dequantize_quantization_config(model_config)
E   NameError: name '_fp8_dequantize_quantization_config' is not defined
```

The product is fine: `loader.py` imports the helper from
`.loader_utils`. The test rebuilds `FastLanguageModel.from_pretrained`
from source inside a hand-written namespace of stubs, and #14516 added a
call that namespace did not have. Seen on #14538's run (job
119354809171).

## Change

Instead of adding one more stub, the fixture now also loads the real
definitions of the `.loader_utils` functions that `loader.py` imports
and `from_pretrained` references, for any name it does not already stub.
They are compiled with postponed annotations so signatures such as
`Union[...]` do not need their typing imports. Existing stubs win, so
every current fixture behaves as before; the next helper a PR adds to
that import list is picked up without touching this test.

For these fixtures the real `_fp8_dequantize_quantization_config` sees a
config with no `quantization_config` and returns None, which is exactly
what a non-fp8 checkpoint does.

## Testing

- CPU torch 2.10, transformers 5.17: main 7 failed / 12 passed; this
branch 19 passed.
- Sabotage: making the real `_fp8_dequantize_quantization_config` raise
fails the same 7 cases with that error, so they run the real helper
rather than a stub.
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T07:08:06.606107Z 6afbdbe Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: c1b1a47c10

ℹ️ 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".

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a51fd51e85

ℹ️ 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".

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: a51fd51e85

ℹ️ 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".

Lyxot added 2 commits October 22, 2026 15:04
# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
… image in Compare

One helper now owns the 20 MB limit and its message for both composers. Compare toasts each oversized image rather than only the first, reports a model that cannot take images before the size, and lets a paste of only an oversized image reach that toast instead of the generic paste error.
@Lyxot

Lyxot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Pushed a review pass on top of your branch (merged current main to clear the conflict, then 6afbdbe):

  • One helper, getChatImageSizeError in image-normalize.ts, now owns the 20 MB limit and the message for both composers (was three constants and two copies of the string).
  • Compare toasts every oversized image, not only the first one in a batch, matching the single-chat composer.
  • Compare reports "Load a model before adding images" before the size, the same order as the single-chat adapter.
  • Compare paste of only an oversized image now gets the named toast instead of the generic "Could not paste files".
  • Dropped the bundle-budget bump: after merging main the startup bundle is within budget without it.
  • Test now checks the helper at the 20 MB boundary plus both composers, including the paste pre-check.

Checked in a built Unsloth Studio: drop, paste and the file picker in both the single chat and Compare.

@Lyxot

Lyxot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 6afbdbebb6

ℹ️ 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".

@Lyxot Lyxot removed the conflicts# label Oct 22, 2026
@Lyxot

Lyxot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Done on 6afbdbe:

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Verified in a built Unsloth Studio; Codex converged and CI passed on a staging copy.

@Lyxot
Lyxot merged commit 3ba06aa into unslothai:main Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants