Skip to content

docs(EmptyQwenImageLayeredLatentImage): explain the layers + 1 slot - #113

Open
christian-byrne wants to merge 2 commits into
mainfrom
docs/qwen-layered-latent-semantics
Open

docs(EmptyQwenImageLayeredLatentImage): explain the layers + 1 slot#113
christian-byrne wants to merge 2 commits into
mainfrom
docs/qwen-layered-latent-semantics

Conversation

@christian-byrne

@christian-byrne christian-byrne commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Problem

EmptyQwenImageLayeredLatentImage allocates torch.zeros([batch_size, 16, layers + 1, height // 8, width // 8]) (comfy_extras/nodes_qwen.py:109-130), and the docs never say what the + 1 is. The layers description currently reads:

The number of additional layers to add to the latent structure. This defines the depth of the latent representation.

That is not just incomplete, it points the reader the wrong way: it suggests the extra slot is structural padding, when it is an actual image the model produces. A core maintainer could not work these semantics out from the code, and nothing in core, on docs.comfy.org, or on the model card states them.

What is actually true

comfyanonymous, on the semantics of this model:

it's a model specific thing, it's because this model is an image generation model that regenerates the full image and the layers

so if you set layers to zero you get only the original image

but if you set layers to 2 you get the original image + 2 layers

the first image is exactly the same as the original and should be discarded

and all the layers when composited together should recreate the original image

So:

  1. Slot 0 is the full image, not a layer, and should be discarded when only the layers are wanted.
  2. Compositing all the layers recreates the full image. That is the reconstruction guarantee, and it is a usable correctness check.
  3. Layer order is positional and nothing carries it. The layers ride the temporal axis of the 5D latent, the same axis video models use for frames. LatentCutToBatch with dim="t" (comfy_extras/nodes_latent.py:217-256) moves that axis into the batch dimension, after which a layer's z-order is just its index in the batch. There is no z-index field and no per-layer metadata anywhere in the pipeline, so reordering or filtering the batch reorders the layers.
  4. layers has min=0, and layers=0 still yields one image.
  5. The Qwen-Image-Layered VAE decodes to 4 channels: its encoder.conv1.weight is [96, 4, 3, 3, 3], so comfy/sd.py:791 sets output_channels = 4. Decoded layers carry alpha.

Change

English source only, in comfyui_embedded_docs/docs/EmptyQwenImageLayeredLatentImage/en.md:

  • Rewrote the layers row so it states the layers + 1 output count and that 0 is valid.
  • Added a Why there is one more slot than layers section covering the five points above.
  • Left the Outputs table, the AI-generated footer and the source fingerprint untouched.

Other locales

Not touched, deliberately. .cursorrules in this repo says:

Do not automatically start translation work for other language files unless actively requested by the user

The other 11 locales (ar, es, fa, fr, ja, ko, pt-BR, ru, tr, zh, zh-TW) all carry the same wrong layers description and need the same fix. Rather than machine-translate them badly, I have filed a tracking issue: #114

Related, not fixed here

comfyanonymous also said "our qwen layered template is slightly wrong". templates/image_qwen_image_layered.json in Comfy-Org/workflow_templates runs EmptyQwenImageLayeredLatentImage with layers=2 straight into LatentCutToBatch(dim="t") -> VAEDecode -> SaveImage, so it saves 3 images and the first is a duplicate of the input. That is a separate repo and a separate fix.

The `layers` widget was documented as "the number of additional layers
to add to the latent structure. This defines the depth of the latent
representation", which does not tell the reader what the extra slot in
`[batch_size, 16, layers + 1, height // 8, width // 8]` actually is.

Qwen-Image-Layered regenerates the full image as well as the layers, so
slot 0 is the full image and is not one of the layers. It repeats content
the user already has and should be discarded when only the layers are
wanted. `layers` has min=0, and layers=0 yields that image on its own.

Also record the two semantics that are not stated anywhere else: all the
layers composited together recreate the full image, and layer order is
purely positional (the layers ride the temporal axis of the 5D latent,
LatentCutToBatch dim=t moves it into the batch dimension, and there is no
z-index field or per-layer metadata anywhere).

English source only. Per .cursorrules the other locales are hand
maintained and are not translated without an explicit request; a tracking
issue follows for the remaining 11.
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 18 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d077fb95-782b-44be-9c98-cc24c7fca4a0

📥 Commits

Reviewing files that changed from the base of the PR and between 5b80a5a and b70ed5d.

📒 Files selected for processing (1)
  • comfyui_embedded_docs/docs/EmptyQwenImageLayeredLatentImage/en.md
📝 Walkthrough

Walkthrough

The node documentation now identifies Qwen-Image-Layered, documents layers + 1 latent slots, permits zero layers, and explains slot ordering, compositing, batching, and decoded alpha channels.

Changes

Qwen-Image-Layered latent documentation

Layer / File(s) Summary
Document latent allocation and compositing
comfyui_embedded_docs/docs/EmptyQwenImageLayeredLatentImage/en.md
The documentation defines the full-image slot, layer slots, layers = 0, positional ordering, batch conversion, compositing, and decoded alpha output. A small doc update, but it layers on the facts neatly—slot by slot.

Possibly related issues

Suggested reviewers: comfyui-wiki

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/qwen-layered-latent-semantics
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch docs/qwen-layered-latent-semantics

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from comfyui-wiki August 6, 2026 22:29

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfyui_embedded_docs/docs/EmptyQwenImageLayeredLatentImage/en.md`:
- Line 3: Rewrite the documentation around the Empty Qwen Image Layered Latent
node for non-technical readers using a stack of blank painting sheets as the
central metaphor. Explain that the stack contains one sheet for the complete
image and one for each layer, sheets must stay in order, combining layer sheets
recreates the complete image, and decoded layers include transparency. Remove or
relocate unexplained terms such as latent, tensor, batch, temporal axis, VAE
Decode, z-index, metadata, LatentCutToBatch, and dim=t to technical
documentation if needed.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b2103fd2-4cdd-4ab9-9891-b6a66a267ad9

📥 Commits

Reviewing files that changed from the base of the PR and between 558020d and 5b80a5a.

📒 Files selected for processing (1)
  • comfyui_embedded_docs/docs/EmptyQwenImageLayeredLatentImage/en.md

Comment thread comfyui_embedded_docs/docs/EmptyQwenImageLayeredLatentImage/en.md Outdated
christian-byrne added a commit that referenced this pull request Aug 6, 2026
Addresses #113 (comment) review
from CodeRabbit: this repo's .cursorrules requires everyday vocabulary and a
painting or craft metaphor for a non-technical reader.

Reworked around a stack of tracing sheets. Kept every fact, including that the
first image is the complete picture and should be discarded, that the layers
composite back to it, and that order is positional with nothing recording it.
LatentCutToBatch and dim=t stay, moved into Usage suggestions, because without
them the reader cannot actually get the layers out.
@christian-byrne christian-byrne added the documentation Improvements or additions to documentation label Aug 6, 2026
christian-byrne added a commit that referenced this pull request Aug 6, 2026
Addresses #113 (comment) review
from CodeRabbit: this repo's .cursorrules requires everyday vocabulary and a
painting or craft metaphor for a non-technical reader.

Reworked around a stack of tracing sheets. Kept every fact, including that the
first image is the complete picture and should be discarded, that the layers
composite back to it, and that order is positional with nothing recording it.
LatentCutToBatch and dim=t stay, moved into Usage suggestions, because without
them the reader cannot actually get the layers out.
@christian-byrne
christian-byrne force-pushed the docs/qwen-layered-latent-semantics branch from 720e74b to 70e84e7 Compare August 6, 2026 22:37
Addresses #113 (comment) review
from CodeRabbit: this repo's .cursorrules requires everyday vocabulary and a
painting or craft metaphor for a non-technical reader.

Reworked around a stack of tracing sheets. Kept every fact, including that the
first image is the complete picture and should be discarded, that the layers
composite back to it, and that order is positional with nothing recording it.
LatentCutToBatch and dim=t stay, moved into Usage suggestions, because without
them the reader cannot actually get the layers out.
@christian-byrne
christian-byrne force-pushed the docs/qwen-layered-latent-semantics branch from 70e84e7 to b70ed5d Compare August 6, 2026 22:39
@christian-byrne

Copy link
Copy Markdown
Contributor Author

Heads up on CI: GitHub Actions is in a declared major outage right now (started 15:22 UTC, webhook triggers throttled so push and PR events are not starting workflows). This repo's last Actions run was 2026-08-04, and Comfy-Org/docs last ran at 16:09 UTC today, while the app-based checks here (Socket, CodeRabbit) report within seconds on the same commits.

Practical effect: CLA Assistant has not run, and cla-assistant is a required status check, so this PR shows BLOCKED for a reason that has nothing to do with its contents. It should clear on its own once Actions recovers. Everything that can run has passed.

@christian-byrne

Copy link
Copy Markdown
Contributor Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants