Repository navigation
Studio: cache Edit-mode text encoding by reference image content - #13683
Conversation
for more information, see https://pre-commit.ci
|
@codex review |
1 similar comment
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7cb84cb91e
ℹ️ 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".
| module = type(value).__module__ or "" | ||
| if not module.startswith("PIL."): | ||
| return None | ||
| digest = hashlib.sha256(value.tobytes()).hexdigest() |
There was a problem hiding this comment.
Include palette colors in image fingerprints
When a wrapped encoder receives a valid paletted (P/PA) PIL reference image, Image.tobytes() contains palette indices but not the palette or palette transparency. Two images with identical indices, size, and mode but different colors therefore produce the same cache key, so the second render reuses embeddings computed from a visually different image; hash the encoder-visible converted pixels or add palette/transparency data to the fingerprint.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable from Studio: every image that reaches encode_prompt goes through decode_b64_image, which converts to RGB (or the family's condition_image_mode, RGB/RGBA), so a palette (P/PA) image never gets fingerprinted here.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 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". |
Refs #13638 (prompt-cache half; the CUBLAS init failure on the render thread needs a GPU and is not addressed here).
Problem
In Images → Edit,
encode_promptreceives PIL reference images._plain()raisesTypeError: Imageon them, so:encode(...)runs inside theexcept TypeErrorblock, so any real encoder error (e.g. the CUBLAS one in [Bug]: TypeError: Image in diffusion_prompt_cache.py causes CUBLAS error during Image Edit (Qwen-Image-2.1) #13638) is reported as "During handling of the above exception … TypeError: Image", which sends debugging in the wrong direction.Change
_plain()keys PIL images as["PIL.Image", mode, size, sha256(pixels)]. Content-based, so an in-place edit of the same object misses, and a reloaded identical image hits. Only realPIL.*objects qualify; other duck-typed objects still bypass.cached_encode_promptand the MiniMax-H3 shim now calls the encoder after leaving the handler, so encoder errors are no longer chained onto the key error.Tests (CPU,
studio/backend/tests/test_diffusion_prompt_cache.py)New: same-image hit (also via list), miss on different pixel / size / mode, miss after in-place
putpixel, non-PIL lookalike still bypasses, bypassed encoder error has__context__ is None.test_diffusion_cond_cache.pyhas 8 failures on main in my env, unchanged by this PR.Cost
Fingerprinting is one sha256 over raw pixels: ~3.1 ms for 1184x896 RGB, ~3.3 ms for 1024x1024 (CPU, mean of 20), versus a full Qwen3-VL encode on a hit. Not measured end-to-end on GPU.