Skip to content

Studio Images: Compare grid (X/Y/Z plot) - #14624

Merged
danielhanchen merged 12 commits into
mainfrom
studio-images-compare-grid
Oct 22, 2026
Merged

danielhanchen merged 12 commits into
mainfrom
studio-images-compare-grid

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Refs #10695 (item 6: compare grid).

What

A Compare grid on the Images page, modelled on AUTOMATIC1111's X/Y/Z plot. It renders the same prompt across up to three axes and lays the results out as one labelled grid image.

  • Axes: X, Y, and an optional Z. Z produces one grid per value.
  • Axis types are gated on what the loaded model exposes:
    • Seed and Steps
    • CFG, unless the model is distilled to a fixed guidance
    • Sampler and Schedule type, only where the sampler picker exists
    • Shift (SD3-style) or Base / Max shift (FLUX-style), when status reports a shift control
    • LoRA weight, one axis per active LoRA row, when the load can apply LoRA
    • Prompt S/R
    • Clip skip, CFG rescale, Var. seed and Var. strength. These appear only once status reports sd_controls (Studio Images: SDXL prompt weighting, CLIP skip, CFG rescale and variation seeds #14562). Nothing here has to change when that lands.
  • Value syntax follows A1111 (scripts/xyz_grid.py, process_axis):
    • Comma or newline separated lists, with CSV quoting
    • 1-5, 10-30 (+10), 1-10 [4] (evenly spaced; truncated on integer axes)
    • Sampler values match either the id or the A1111 label
    • Seed -1 is fixed to one random seed per value, unless "Keep -1 for seeds" is on
    • Two small differences from A1111: a descending range keeps its end (5-1 is 5..1), and a decimal step may omit its sign.
  • Options:
    • Draw legend, Keep -1 for seeds, grid margin, and Swap X/Y.
    • A grid is capped at 64 cells. Past that, the panel says how many cells the axes make, and Generate grid is disabled.
  • Progress: the generation overlay reads Cell 3/9: Steps: 20, Sampler: Euler, and the panel counts finished cells.
  • Result:
    • A dialog shows each grid with a Download PNG button.
    • The PNG carries an A1111-style parameters chunk: the shared recipe plus Script: X/Y/Z plot, X Type, X Values, ....
    • Every cell is also saved to the gallery with its own recipe, so any cell can be restored or reused.

How

  • Each cell is one request through the existing generate endpoint, sent from the page's own Generate loop. handleGenerate reads the run from a ref, so a grid keeps the same behaviour as a normal Generate: Stop, live progress, the lost-response recovery, the gallery merge and the error toasts. The only edits inside the loop are:

    • the run count
    • wrapping the request body in compareRequest(...)
    • one onImages callback
  • No backend batch endpoint. A grid cell is a full denoise taking seconds, against a few ms of JSON round trip. Batching seeds or prompts through seeds / prompts would change the denoiser's batch size, which costs a compile and a graph capture per distinct size. The other axes (steps, CFG, sampler, shift) cannot share a batch anyway.

  • Cells run at batch size 1 with one shared seed (A1111 fix_seed). The prompt enhancer is off for every cell, so a per-cell rewrite cannot confound the comparison.

  • Run order: A1111 nests z, y, x, and moves costly axes to the outer loop (AxisOption.cost). On top of that, values of a costly axis run grouped by shape class:

    • CFG on vs off, i.e. whether the unconditional pass runs
    • LoRA weight 0 vs above 0
    • each Prompt S/R text

    So the denoiser changes shape at most once per class, and no cell needs a model reload. Cells are placed in the grid by index, so the run order does not affect the layout.

  • Code layout and startup bundle: the new code lives in src/features/images/compare/ (values parser, axes / plan, run object, grid layout and drawing, panel). The Images page imports it statically, and the page is already its own lazy chunk, so none of it is on the startup path. bundle:check is unchanged from main: 6,718.1 KB raw / 2,023.3 KB transfer, 97 chunks. A nested import() of the panel was measured too: rolldown split startup-shared modules out of their chunks, giving +3 startup chunks and putting the budget over by 1.2 KB transfer.

Tests

  • New tests/images-compare-grid.test.ts, 19 tests:
    • A1111 list / range / count syntax and errors
    • Capability gating, including the Studio Images: SDXL prompt weighting, CLIP skip, CFG rescale and variation seeds #14562 SD controls and the ControlNet exclusion for CFG rescale
    • The 64-cell cap and duplicate-axis checks
    • Per-cell requests: batch 1, seeds, sampler plus schedule fallback, negative prompt re-derived from CFG, Prompt S/R in both prompts, LoRA weight 0 dropping the adapter, enhancer off
    • Run order: one CFG on/off switch, Prompt S/R outermost
    • The run object and Z slices
    • Grid layout (A1111 font size and bands, legend off, Z title, shrink to the canvas limit)
    • The PNG parameters chunk read back through the existing metadata reader
    • The page wiring
  • tests/image-prompt-enhance.test.ts: its source anchor now matches the wrapped generateDiffusionImage( call.
  • npm run typecheck, npm run build, npm run bundle:check (within budget) and all tests/image*.test.ts / tests/images*.test.ts pass (379). ESLint reports nothing new in images-page.tsx, and nothing in the new files.

GPU run

Measured on a B200 shared with other jobs, so timings are indicative only. The harness drives Studio's DiffusionBackend with the exact requests the shipped planner builds, in its order, after three warm-up renders of the form's settings. It counts the deltas in torch._dynamo unique graphs and recompiles, inductor FX cache misses, and Studio's CUDA graph capture counter.

Model Grid Cells wall Recompiles New graphs CUDA graph captures
Z-Image-Turbo (UI defaults: compiled + CUDA graphs), 1024x1024 Shift 1, 3, 6 x Steps 4, 8, 12 10.4 s for 9 cells 0 0 0
tiny SDXL (compiled + CUDA graphs) Euler, Euler a, DPM++ 2M x Steps 10, 20, 30 73.5 s (70.5 s of it one compile) 0 1 1

The single SDXL compile and capture is the first DPM++ 2M cell. It is not caused by the grid. DPMSolverMultistepScheduler hands the UNet int64 timesteps, while Euler and Euler a hand it float32, so the first DPM++ render in a process traces and captures once for the new input dtype. Later DPM++ cells reuse it. A plain Generate that switches to DPM++ hits the same cost. Casting the timestep to one dtype in front of the compiled denoiser would remove it, which is left for a follow-up.

Grid from the planner's own requests (Z-Image-Turbo, Shift 1 / 3 / 6 x Steps 4 / 8 / 12, one seed), downscaled:

Z-Image-Turbo Shift x Steps grid

Not covered

  • The grid in this PR's GPU run was drawn with PIL from the planner's own layout. The in-browser canvas path, and the panel itself, were exercised by typecheck, build and the unit tests, but not by a Playwright run.
  • No real SDXL checkpoint was loaded. The sampler axis was measured on the tiny SDXL pipe.
  • "Generate anyway" after a memory refusal on a grid cell retries one normal Generate, not the rest of the grid.

Generate the same prompt across up to three axes (X, Y and an optional Z
that makes one grid per value) and compose the cells into a labelled grid.
Axes follow what the loaded model exposes: seed, steps, CFG, sampler and
schedule type where the sampler picker exists, shift or base / max shift,
LoRA weight per active row, Prompt S/R, and the SD controls when status
reports them. Values take AUTOMATIC1111's syntax (lists, 1-5, 10-30 (+10),
1-10 [4]). A grid is capped at 64 cells.

Cells go through the page's own Generate loop, one request per cell at
batch size 1 with one shared seed, so Stop, progress, the gallery merge and
error handling are unchanged and every cell is saved with its own recipe.
Costly axes run outermost and grouped by shape class (CFG on / off, LoRA
on / off, prompt text), so the denoiser changes shape at most once per
class. The grid PNG carries an A1111-style parameters chunk.
@danielhanchen danielhanchen self-assigned this Oct 22, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 22, 2026
[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T13:02:17.691631Z 9456bc2 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 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: cf0fc92237

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

delete req.sampler;
delete req.schedule_type;
if (sampler !== "default") req.sampler = sampler;
if (schedule !== "automatic" && option?.schedule_types.includes(schedule)) req.schedule_type = schedule;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject unsupported sampler and schedule combinations

When the Schedule axis selects a value unsupported by the effective sampler—for example, Karras while the form still uses Model default—this condition silently omits schedule_type, so the backend runs Automatic even though the cell and grid legend say Karras. The schedule choices are built from the union across all samplers, so this also affects unsupported combinations in a sampler-by-schedule grid and can mislabel experimental results; filter or reject incompatible pairs rather than silently changing them.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. The planner now checks each cell's sampler and schedule pair and refuses a Schedule type value the sampler does not take (for example Karras with Euler a or Model default), naming the pair, so no cell can run Automatic under a Karras label. Covered by a new test that also checks the per-cell schedule_type of a valid sampler x schedule grid.

Comment on lines +84 to +88
const bitmaps = await Promise.all(
records.map(async (r) => {
if (!r) return null;
try {
return await createImageBitmap(await fetchGalleryBlob(r.url));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid decoding every full-size grid cell concurrently

For large or high-resolution grids, this Promise.all decodes every original image in a Z slice at full resolution before any drawing begins, while the caller also composes all Z slices concurrently. A supported 64-cell grid at 2752×2752 requires roughly 1.9 GiB just for decoded RGBA pixels, excluding blobs and canvases, so grid creation can exhaust browser memory after generation succeeds despite the canvas-size cap; decode and draw cells sequentially or request resized bitmaps.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. Cells are now decoded one at a time at their drawn size and closed after drawing, and Z slices are composed one after another, so at most one decoded cell exists at a time and it is never larger than its grid slot. A test checks that decode concurrency never exceeds one and that missing or failed cells keep their placeholder.

Comment on lines +325 to +328
if (def.id === "prompt_sr") {
const search = String(values[0]);
if (!ctx.prompt.includes(search) && !ctx.negativePrompt.includes(search)) {
return { ok: false, error: `${AXIS_NAMES[a]}: Prompt S/R did not find "${search}" in the prompt or negative prompt` };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Validate Prompt S/R against the active negative prompt

When guidance is at or below the model's negative-prompt threshold, the base request omits negative_prompt, but this validation still accepts a Prompt S/R search found only in ctx.negativePrompt. With no Guidance axis raising CFG, buildCellRequest therefore has no negative text to replace and every supposedly varied cell is identical despite different labels; only count the negative prompt as a match when it can be active for at least one cell.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. A Prompt S/R term found only in the negative prompt now counts only if at least one cell's guidance (from a CFG axis or the form) actually uses the negative prompt; otherwise the grid is refused with a message saying so. Tested with and without a CFG axis that crosses the threshold.

Comment on lines +189 to +193
["Steps", firstReq?.steps ?? props.steps],
["CFG scale", firstReq?.guidance ?? props.guidance],
["Seed", firstReq?.seed],
["Size", `${props.width}x${props.height}`],
["Model", props.modelName],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the selected sampler in grid metadata

When the grid varies an unrelated setting such as Steps while the form uses a non-default sampler or schedule, this shared-recipe field list records neither setting. The downloaded PNG consequently cannot identify or restore the scheduler that produced its cells, even though firstReq contains sampler and schedule_type; include those values whenever they are not themselves represented by an axis.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. The grid's parameters chunk now records Sampler and Schedule type from the first cell's request whenever they are not themselves an axis, so the PNG names the scheduler its cells ran. Covered by a new test.

Comment on lines +195 to +197
// Weight 0 removes the adapter from the request, which is a different module set from any weight above it.
cost: 2,
shapeKey: (v) => (Number(v) === 0 ? "off" : "on"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prevent Speed Auto from compiling during LoRA comparisons

On a diffusers load with deferred Speed Auto, a zero-weight cell removes the only adapter from the request, and this shape grouping commonly runs those off cells before positive weights. Once generation_count >= 2, the backend condition in studio/backend/core/inference/diffusion.py engages compilation for that adapter-free cell; subsequent positive-weight cells are then rejected because compiled transformers do not support LoRA. Suspend deferred compilation for the compare run rather than allowing an early zero-weight cell to invalidate the remaining experiment.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in the run order rather than by suspending Speed Auto: the LoRA weight axis now runs outermost with every weighted cell before any weight-0 cell, so adapter-free cells only come at the end and a deferred compile there cannot affect a remaining LoRA cell. A new test replays the backend's deferred-compile rule over the planned order and checks no LoRA cell would reach a compiled load.

…nd grid memory

- Refuse a Schedule type the cell's sampler does not take instead of
  running Automatic under a Karras label.
- Prompt S/R counts a negative prompt match only where a cell's CFG
  engages the negative prompt.
- LoRA weight cells: every weighted cell runs before any adapter-free one,
  so Speed Auto cannot compile mid-grid and refuse the remaining LoRA cells.
- Decode and draw grid cells one at a time at their drawn size, and Z
  slices in turn, instead of every full-size cell at once.
- Name the sampler and schedule in the grid metadata when no axis varies them.
- A cell whose POST response was lost takes its record (matched by seed)
  from what the gallery gained.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member 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: 3706e9cfdb

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

Comment on lines +377 to +378
srAxes.forEach(([, search], k) => {
if (ctx.prompt.includes(search) || negative.includes(search)) srHit[k] = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Apply earlier Prompt S/R substitutions during validation

When two Prompt S/R axes are selected, this checks every search term against the original prompts rather than the per-cell text after earlier axes have run. For example, with prompt red fox, X values red, blue, and Y values red, green, the plan is accepted, but every X=blue cell removes red before Y runs, so the Y=green cells are mislabeled duplicates; the inverse case, where X introduces Y's search term, is incorrectly rejected. Validate each cell by applying the replacements in X/Y/Z order.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. Prompt S/R is now validated per cell: the earlier axes' substitutions are applied in X, Y, Z order and each axis's search term must be in that cell's text (or a negative prompt its CFG engages), as A1111 checks per image. The error names the cell. Tests cover the X-removes-Y's-term case (refused) and the X-introduces-Y's-term case (accepted, chained prompts checked).

Comment on lines +211 to +214
const infotext = gridInfotext({
prompt: context.prompt.trim(),
negativePrompt: firstReq?.negative_prompt,
fields,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve negative text used by higher-CFG cells

When a CFG axis starts at or below the negative-prompt threshold and later rises above it, the first logical request has no negative_prompt, so the PNG omits the negative text even though the higher-CFG cells were generated with it. The axis records the CFG values but not the missing text, making those cells unreproducible from the downloaded grid; include the context's negative prompt whenever any planned cell engages it rather than deriving metadata solely from firstReq.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. The negative prompt is now recorded whenever any planned cell's CFG engages it, instead of being read from the first cell's request, so a CFG axis that starts below the threshold still records the text its higher cells used. Covered by a new test.

… numbers

- Validate Prompt S/R per cell after the earlier axes' substitutions, in
  X, Y, Z order, as A1111 does per image.
- A cell whose POST response was lost keeps the seed it was sent for
  Reuse last seed.
- Record active LoRAs in the grid parameters as <lora:id:weight> tags.
- Record the negative prompt when any cell engages it, not only the first.
- Reject whitespace inside a numeric literal (1 2, 1 e2) instead of
  joining it; a space after a sign stays valid.

[skip ci]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…unded canvas, busy through composition

- Grid metadata writes Schedule type only when every cell ran it (a sampler that fell back to Automatic is not
  labelled with the form's schedule), and keeps a shared custom Shift.
- Cap the grid canvas at 32 Mpx (128 MiB RGBA) instead of the browser's 2^28 ceiling.
- Keep the compare run busy until the grid is composed, so a second run cannot compose alongside it.
- Skip the batch-offset seed overflow guard for compare runs (every cell is batch 1 on the base or axis seed).
- Disable Generate grid until image presets hydrate, as Generate does.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

One helper decides every shared field of the grid's parameters: a value is written only when no axis varies it
and every sent cell ran it. This records Flux Base/Max shift, the fitted Size the cells ran at, the implicit
Variation seed strength, and drops a Seed that differed per cell (Keep -1 for seeds). The importer reads
Base shift and Max shift back.

[skip ci]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…etry for a compare cell

- The grid's parameters carry the ControlNet every cell shares as an sd-webui-controlnet ControlNet 0 unit
  (module, model, weight, guidance range), through the same every-cell-agrees helper; the image is not embedded.
- A compare cell refused by the memory estimate no longer queues Generate anyway: that retry runs after the grid
  has ended, as a plain form generation. The toast points to Allow oversized generations instead.

[skip ci]
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
…safe canvas, empty Prompt S/R values

- A Var. strength sweep uses the form's typed Variation seed even with the form strength at 0, and gives the run's
  seed to strength 0 cells too, so every cell (and the grid recipe) shares one noise source.
- The grid layout is rechecked after each shrink: narrower cells rewrap labels onto more lines, which could push
  the canvas back over the side or pixel limit.
- Prompt S/R keeps empty replacements (red, "") as A1111 does; an empty search value is refused, and a blank
  line adds no value.
- Table tests for the variation seed cases, canvas limits after reflow, and Prompt S/R parsing.

[skip ci]
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@danielhanchen

Copy link
Copy Markdown
Member 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: 723a63561d

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

busy={busy !== null || compareRun !== null || !imagePresets.hydrated}
seedFieldEmpty={!seed.trim()}
variationSeed={sdCaps?.variation_seed ? parseVariationSeed(sdChoice.variationSeed) : null}
modelName={status?.repo_id ?? null}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the loaded checkpoint filename in grid metadata

For GGUF and single-file loads, repo_id alone does not identify the model because one repository can contain multiple checkpoint files and the existing recall path also requires status.gguf_filename. Passing only the repository here means the composed PNG's Model field loses the selected filename, so a downloaded grid cannot identify or restore the model variant that produced it even though each individual gallery cell can; carry the checkpoint filename and model kind into the grid metadata.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leaving this as is. The grid writes the same A1111 style Model field Studio already writes in each image's own parameters text (core/inference/image_gallery.py), and A1111's X/Y/Z grid infotext carries a single Model name too. The checkpoint file and model kind stay in each cell's full Studio recipe in the gallery, so adding them here would be new metadata surface only the grid has.

… run, honest ControlNet gate, report failed saves

- A Sampler axis cell whose sampler does not take the form's schedule is refused, instead of silently running
  Automatic under a sampler-only label.
- The compare context uses the request's own controlnetEngaged, so a strength-0 ControlNet keeps the CFG rescale axis.
- A grid save that fails (other than a cancelled dialog) is reported in a toast.
- Table tests for sampler x schedule plans; wiring checks for the ControlNet gate and save errors.

[skip ci]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…A ids, bounded label bands

- A compare run refuses an invalid typed Variation seed even with the form strength at 0, since a Var. strength
  axis can still engage it.
- LoRAs field entries are CSV-quoted when an id holds a comma or quote, and the importer splits them CSV-aware.
- A label band is never taller than a cell (cut with an ellipsis), so the shrink loop always reaches the canvas
  limits; a layout that still does not fit is refused before drawing.
- Table rows for 5000-word labels and LoRA ids with commas and quotes; a check for the seed validation.

[skip ci]
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 22, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9456bc2891

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

@danielhanchen
danielhanchen merged commit fcc7660 into main Oct 22, 2026
@danielhanchen
danielhanchen deleted the studio-images-compare-grid branch October 22, 2026 21:16
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 7, 2026
…rs (server-rendered X/Y grid, no UI change) (unslothai#15169)

Part of unslothai#10695.

**This is the API version of a feature the Images page already has.** In
the app, Images > Create > **Compare grid** (unslothai#14624) already varies two
settings and lays the results out as a grid; this PR adds no button and
changes nothing in the UI. What it adds is the same grid for anything
that is not the browser: `POST /api/inference/images/generate` takes an
optional `xy` spec and the server renders the cells and composes the
labelled grid. Leave `xy` out and the request runs exactly as on main;
the response only gains two empty fields, `grid: null` and, on each
gallery record, `xy_grid: null`.

Why it is worth having next to Compare: Compare renders in the browser,
so scripts and other API clients can't use it, and its grid PNG is
download-only. Here the grid and every cell land in the gallery with
their own recipes.

**Changes in this PR**
- `xy` is optional: up to two axes, each a field and a list of values.
Axis fields are an allowlist: seed, steps, guidance, sampler,
schedule_type, shift, base_shift, max_shift, strength, clip_skip,
cfg_rescale, variation_seed, variation_strength, a LoRA weight by index,
and Prompt S/R. 64-cell cap, same as Compare.
- Every cell is validated as a full generate request before anything
renders (a bad value is a 400 naming the cell), rendered on one shared
seed unless seed is an axis, and saved to the gallery as a normal image
with its own recipe.
- One extra labelled grid PNG (A1111 layout) is saved to the gallery and
returned as `grid`, on top of the cells, not instead of them.
- A frontend test keeps the TS field list, the Compare axes and the
server allowlist in sync.
- A Stop pressed while the grid is between two cells (a cell saving, the
next not started yet) ends the grid with the usual cancelled 409; the
cells already rendered stay in the gallery. `POST
/images/generate/cancel` reports `cancelled: true` for it.
- The grid record keeps its real pixel size in `width` / `height` and
adds `xy_grid.cell_width` / `cell_height`; reusing the grid's settings
on the Images page restores the cell size instead of the grid's.
- Robustness from review: a LoRA sent without a weight keeps its default
1.0; a variation-strength sweep shares one variation seed; cells keeping
any active adapter render before adapter-free ones (a deferred Speed
Auto compile then cannot refuse a later LoRA cell); a Stop also reaches
a cell still queued for the engine and one landing after the last cell;
the canvas, label bands included, stays under the 32 MP budget and each
cell is held at its share of it while later cells render; layered models
(one call, several layers) are refused with a 400 up front.

**Test matrix**
| where | what ran | result |
|---|---|---|
| Colab T4 high-RAM, Linux, `3879b43` | Z-Image-Turbo Q4_K_M, steps
4/8/12 x guidance 0/1.5/3, seed 42, 768px, over the API | 200 in 303.8
s, 9 cells plus a 2880x2441 labelled grid, all in the gallery |
| Colab L4, Linux, main `5a04ef7` | same request | 200, `xy` ignored,
one image (byte-identical to the steps 8 / guidance 0 cell) |
| Apple M5 Mac, `3879b43` | `test_diffusion_xy.py`, frontend parity
test, typecheck | pass |

**Screenshots**
The existing in-app way, unchanged by this PR: the Compare grid switch
at the bottom of the Create panel.

<img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/25152ed429947ea2ac9fd8927fcc60c785a9ace1/studio-images-xy-grid/after-compare-panel.png"
width="700">

The API request and the grid it returned:

<img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/25152ed429947ea2ac9fd8927fcc60c785a9ace1/studio-images-xy-grid/after-xy-request.png"
width="700">

That grid saved to the gallery, with the 9 cells beside it as normal
images:

<img
src="https://raw.githubusercontent.com/LeoBorcherding/unsloth/25152ed429947ea2ac9fd8927fcc60c785a9ace1/studio-images-xy-grid/after-gallery-grid.png"
width="700">

**Not tested**
- Sampler as an axis on a real GPU: Z-Image-Turbo offers no sampler
choices on this base.
- The Compare grid's own PNG still isn't saved to the gallery; out of
scope here.

_Branch merged with main at `b6fc821`; tests and typecheck rerun after
the merge. The `test_diffusion_routes.py` failures (6,
`cancel_generate() ... expected_account`) fail identically on main
`b6fc821`._



**Restore these settings on a grid image (before / after)**
A grid image seeded into the gallery as /images/generate saves it
(2880x2441 grid of 768x768 cells), then Recipe > Restore these settings.
Before, the size controls take a size scaled from the grid; after, the
cell size.

<img
src="https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/15169/pr15169_pair_00-9dea84ff5570.png"
width="700">

---------

Co-authored-by: Daniel Han <[email protected]>
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.

1 participant