TT Latent Factory
Aspect ratio and megapixels in, ready latent out
- LATENT
- SEED
- WIDTH
- HEIGHT
- TARGET_WIDTH
- TARGET_HEIGHT
Native ComfyUI makes you compute your own latent size in pixels and remember that latents live at 1/8th the image resolution. TenserTensor's TT Latent Factory inverts the whole thing: you say "16:9, 2 megapixels, landscape" and it hands you a ready-to-sample latent, plus the width, height, and seed so you can build the rest of the graph around what it actually made. It's the node you reach for when you're tired of doing aspect-ratio arithmetic in your head.
How it works is simple and predictable. It converts your megapixels pick into a total pixel budget, splits it by the aspect_ratio (swapped for orientation = portrait), rounds the result to a 64px grid so the dims stay diffusion-friendly, and then generates torch.randn noise at the right channels and scale. The model_type pick determines the latent format: FLUX uses 16 channels at 8x compression, SDXL uses 4 channels at 8x - so the same "2 MP, 16:9" request produces a latent that's the correct shape for whichever model it's headed to. batch_size lets you roll the same noise geometry out across a batch (up to 64).
The clip_multiplier is the one input beginners tend to skip and then wonder about. It doesn't touch the latent at all - it scales the conditioning resolution that the TARGET_WIDTH/TARGET_HEIGHT outputs report. Some pipelines want the text-encoder conditioning generated at a higher resolution than the latent itself; 1x, 2x, 4x gives you that without rebuilding the latent.
Inputs that matter:
aspect_ratio- 1:1, 4:3, 3:2, 16:9, 21:9.megapixels- 0.25 up to 8 MP.orientation- landscape or portrait (swaps the ratio).model_type- FLUX or SDXL; this sets channel count and compression.seed- the noise seed; different seed, different starting noise.
Outputs: LATENT (wire to your sampler), plus SEED, WIDTH, HEIGHT, TARGET_WIDTH, and TARGET_HEIGHT as plain values you can feed into size-aware nodes.
Install is the pack standard:
cd ComfyUI/custom_nodes
git clone https://github.com/tenser-tensor/ComfyUI-TenserTensor
or search "TenserTensor" in ComfyUI Manager and restart. Only real deps are gguf and kornia.
Where people get caught:
- "The output is slightly off from my aspect ratio." Blame the 64px rounding. A 16:9 2MP request lands on the nearest 64-aligned dims, which is almost never the exact ratio. That's normal and correct - models like clean multiples, not exact floats.
- Forgetting the seed. The
SEEDoutput exists so you can log it. If you want reproducible runs, capture it; if you want variety, randomize it. The default is 0, which means everyone's default is the same - change it or wire a random source. - Wrong
model_type. Feed an SDXL-shaped latent to a FLUX sampler (or vice versa) and you'll get a channel-count error or garbage. The factory can't see your model unless you connect the graph through it - matchingmodel_typeto your loader is on you.
One caveat that applies pack-wide: this is the V1 class, deprecated as the author migrates to API V3 (the TT_LatentFactoryNode / TT_LatentFactoryByModelNode replacements, which even auto-detect the model format). Fine for existing graphs; new builds should look at the V3 versions.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 00–18446744073709550000 | — |
| aspect_ratio | COMBO | 5 options: 1:1, 4:3, 3:2, 16:9, 21:9 | |
| megapixels | COMBO | 6 options: 0.25 MP, 0.5 MP, 1 MP, 2 MP, 4 MP, 8 MP | |
| orientation | COMBO | 2 options: landscape, portrait | |
| model_type | COMBO | 2 options: FLUX, SDXL | |
| batch_size | INT | 11–64 | — |
| clip_multiplier | COMBO | 3 options: 1x, 2x, 4x |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| SEED | INT | — |
| WIDTH | INT | — |
| HEIGHT | INT | — |
| TARGET_WIDTH | INT | — |
| TARGET_HEIGHT | INT | — |