Z2 — memory discipline + high-res: flash-attn mask fix, tiled VAE decode (+ upstream candle PRs) #199
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of the text-to-image epic #197. Unlocks ≥1536² and shrinks the working set; both fixes were proven by hand on beast during the 2026-07-29 bench.
Context
Two upstream candle defects cap resolution today (bench findings #2 and #3 in #197):
z_image:ZImageTransformer2DModel::forwardalways wraps attention masks inSome(...), andattention_cudafalls back to naive attention whenever a mask is present. At batch-1 the mask is all-ones. PassingNoneunlocked the full 9-step denoise at 1536² and 2048² on a 5090 (steps: 2.0s / 4.4s).Scope
Option<&Tensor>through properly) so the flash path engages at batch-1. Correct general fix: skip the mask when every element is valid, keep the fallback for real padding.enable_vae_tilingsemantics), bounding decode transients regardless of resolution. Trigger above a latent-size threshold; full-frame below it.[patch]on the candle fork) until merged. Given mistral.rs-era upstream-responsiveness history, plan for the vendored state to persist; keep the patch surface minimal.Acceptance
Depends on
Z1 (#198).
Landed in two parts: neuron-side tiled VAE decode via PR #206 (64-latent tiles, 16-latent seam overlap, weighted-accumulation blending — seam-free at 1024²/1536²/2048², verified visually), and the candle-side mask elision via PR #209 (pin to
grenade/candlebranchz-image-mask-elision; upstream PR huggingface/candle#3798 — drop the pin when it lands).Live results on beast (5090, flash-attn build): 1536² = 21.2 units (denoise 7.2 s, decode 5.3 s), 2048² = 37.7 units (denoise 15.1 s, decode 8.4 s) — both OOM'd pre-fix. One additional finding fixed on the #204 branch: mixed-resolution request sequences fragment the cudarc pool until a generation that would fit a clean slate OOMs; the worker now trims the pool after every image job.
Resolution policy note: flash-attn ships on the blackwell flavour only (#95's staged rollout), so ≥1536² is a beast-tier capability today; ada/ampere serve ≤1024². Extending flash-attn to ada is #95's call, not this issue's.