Leakage Composes: Wang-Tile Diagnostics for Region Masking in Diffusion Models

Text-to-image diffusion models are generators that build a picture by repeatedly denoising random noise. They often let one object's description bleed into another: you ask for "a blue apple and a green vase" and get a green apple. The standard fix is spatial attention masking. You block, inside the network's attention layers, the image positions of one region from reading the text or the image content assigned to another region. Masking has a well-known cost. Walling regions off completely breaks lighting, shadows and seams. Every method that tries to keep some cross-region contact for coherence then has to tune by hand when and where that contact is allowed.

This note argues that the right unit of analysis is not the mask applied at one layer but the mask composed across all layers and all denoising steps. Information that may cross one region boundary per layer can cross many boundaries after dozens of layers and steps, because the composition acts like a transitive closure of the region-adjacency relation. That is the same mechanism that tiling reductions in logic identify as the point where "local" constraints become global. We propose a diagnostic benchmark built from Wang tiles, a controlled method that bounds how many boundaries information can cross, and an analysis that predicts leakage from the composed mask before any image is generated. Wang tiles are square tiles whose edges carry colors that must match their neighbors'. The benchmark scores both seam coherence and interior purity exactly, at the pixel level.

Core Claim

Two tiling ideas carry over to attention masking. In tiling reductions, a logic becomes undecidable when local successor steps can be chained arbitrarily far, through transitive closure or role composition, and paths are forced to reconverge into a grid. Augmenting Concept Languages by Transitive Closure of Roles shows this when functional roles meet transitive closure. Decidability of SHIQ with Complex Role Inclusion Axioms shows it for cyclic role compositions, and restores decidability by forcing the compositions to be acyclic. We do not claim any decidability result for neural networks. We borrow two structural facts:

  1. Chaining local permissions produces global reach.
  2. On a grid, horizontal-then-vertical and vertical-then-horizontal paths reach the same cell, so a diagonal neighbor is reached by multiple routes.

Applied to attention, the claim is as follows. Write $A_{l,t}$ for the binary region-adjacency matrix permitted by the mask at layer $l$ and denoising step $t$, where entry $(i,j)=1$ means region $i$ may read region $j$. The set of regions that can influence region $i$ by the end of sampling is the nonzero pattern of

$$R = \prod_{t}\prod_{l}\,(I + A_{l,t}),$$

where $I$ keeps each region's own content. Define the leakage radius $\rho$ as the largest grid distance between two regions linked in $R$.

We predict three things. Measured attribute leakage tracks $\rho$ and the number of routes in $R$, not the per-layer mask. Methods that look different, such as soft boosting, layer-selective masking and early-timestep-only modulation, mainly differ in the $\rho$ they induce. Finally, a mask designed so that $\rho = 1$, meaning only immediate neighbors share information and only through a thin band along their shared edge, should give the best trade-off between seam coherence and interior purity.

Research Program

The benchmark (WangBench). A $k \times k$ canvas, with $k$ from 2 to 6, is split into cells. Each cell's prompt specifies two things. The first is an interior attribute: a color or texture drawn from the T2I-CompBench vocabularies (T2I-CompBench). The second is four edge colors, drawn from a Wang tile set so that adjacent edges match. The model must render each interior faithfully and make each shared edge a continuous band of the specified color.

Because both targets are colors at known pixel locations, scoring needs no detector:

  • Edge agreement rate: how often each shared seam matches its specified color.
  • Interior purity: how well each cell interior keeps its own attribute.
  • Leakage profile: how much of a cell's interior attribute appears in other cells, as a function of grid distance and of the number of shortest grid paths. This is the commutation test: diagonal neighbors have two routes.

We also include deliberately unsatisfiable layouts, where two adjacent prompts demand different colors on their shared edge. These show whether a method silently lets one region overwrite the other or produces a visible conflict. That behavior matters for real overlapping layouts. Both Localized Text-to-Image Generation for Free via Cross Attention Control and Boundary Attention Constrained Zero-Shot Layout-To-Image Generation report that their methods degrade in such cases.

The analysis. For each existing method we write down its effective $A_{l,t}$:

For each, we compute $R$ and $\rho$ and check them against the measured leakage profile. For soft masks we replace the binary $A$ with measured attention mass between regions and use attention rollout, so the prediction becomes a graded matrix rather than a reachability pattern. The hypothesis is falsified if leakage is uncorrelated with the composed quantity once the per-layer mask strength is controlled for.

The method (hop-bounded boundary masks). Each region gets a thin band of tokens along each shared edge. Interior tokens never attend across regions. Band tokens may attend to the facing band of the neighbor, but only within a single designated block of layers and a single window of denoising steps. Interior tokens may read their own region's band tokens only after that window closes.

The construction makes the composed reach provably one boundary. Content crosses an edge once, lands in a band, and cannot be forwarded through the far side of the receiving region. Mirroring the fix in the SHIQ paper, which kept role compositions but made them acyclic, we keep cross-region contact for coherence but cut the cycles that let it compound. Unlike LayoutDiffusion, which uses a regular patch grid only as an input encoding, our grid structure constrains information flow inside the network. Unlike MAC's soft overlap penalty, we bound multi-hop reach structurally rather than penalizing overlap after the fact.

Baselines

The naive reference point is the unmodified base model given the concatenated prompt. On the established benchmarks, the Cross Attention Control paper (CAC) reports this kind of base at 49.91% attribute-binding success on CC-500 and 0.094 object precision on COCO.

The first masking baseline is CAC itself. It is a training-free, cross-attention-only method and the cleanest example of masking that leaves self-attention global. Its reported 67.27% on CC-500 is the binding figure to beat on that benchmark.

DenseDiffusion is the strongest training-free method that also modulates self-attention. It reports 34.99 IoU on its 250-sample COCO subset, against 23.76 for SD-Pww.

Seg2Any's layer-selective masking is the strongest competitor on the coherence-versus-isolation question specifically, because it already keeps some cross-region contact on purpose. No reported result was found on Lacuna for Seg2Any on any benchmark in this file.

MAC represents optimization-based separation. It reports 50.39% spatial accuracy on HRS-Bench, against 10.80% for Stable Diffusion 1.5, and a counting F1 of 91.72% on DrawBench.

No reported result was found on Lacuna for any method on WangBench, since the benchmark is new.

Fairness. All methods run on the same base models: Stable Diffusion 1.5, for comparability with CAC, DenseDiffusion and MAC, and a diffusion transformer such as FLUX.1 for the Seg2Any-style comparison. They use the same seeds, samplers and step counts. Each method gets an equal hyperparameter search of about 30 configurations on a held-out WangBench split, covering its boost factors, layer ranges or time windows. Our band width and window position get the same budget.

Ablations. Two ablations isolate the key ingredient, which is the bound on composed reach rather than the band itself:

  • The same boundary bands with the window left open across all layers and steps, giving the same per-layer mask but a large $\rho$.
  • Full isolation with $\rho = 0$.

What counts as beating the baselines. Our method beats them if it Pareto-dominates the tuned baselines on WangBench edge agreement and interior purity. It must also stay within noise of DenseDiffusion and CAC on CC-500 and T2I-CompBench B-VQA, with FID not worse on COCO-stuff layouts.

Why not just…?

Why not just use Seg2Any's layer-selective masking? This is the most serious threat. Restricting isolation to middle layers may already keep $\rho$ small enough in practice. Our analysis treats it as one point in the space of composed masks, not as a rival theory. If it matches our method's frontier on WangBench, the contribution narrows to explaining why it works and predicting good layer ranges for new architectures without per-model search. We will report that outcome honestly.

Why not just generate each region in full isolation and blend the seams afterward? Full isolation ($\rho = 0$) plus harmonization or inpainting at seams should give near-perfect interior purity. Its weakness is coherence that must be decided jointly, such as a shared light direction or a shadow crossing a boundary. Seg2Any reports that severing self-attention destroys exactly these effects. WangBench measures edge agreement directly, and we add a variant where the edge color must come from a single global light source. Blending would have to invent consistency there, rather than generate it.

Why not just tune DenseDiffusion's boost factor and time window? Tuning a soft mask strength can trade leakage for coherence. Our prediction, however, is that leakage depends on how many layer-step pairs allow contact, so tuning the strength alone traces a worse curve than bounding the hops. The equal-budget tuning sweep and the "window open everywhere" ablation test this directly. If tuned DenseDiffusion reaches our frontier, the hop-bound claim fails.

Why not just evaluate on COCO and T2I-CompBench? Their detector- and question-answering-based metrics merge omission, leakage and seam quality into one score. They also cannot tell a distance-one leak from a distance-three leak. We keep these benchmarks for external validity, but the composition hypothesis can only be tested where leakage is measurable as a function of grid distance and path count.

Proposed Experiments

Experiment 1: does composed reach predict leakage? For every baseline and ablation on WangBench, we regress the leakage at each grid distance on the composed reach matrix $R$ and on the per-layer mask strength alone. Composition must explain significantly more of the variance than per-layer strength.

Experiment 2: commutation. Predicted leakage to diagonal neighbors, which have two shortest routes, should exceed leakage to straight neighbors two steps away, which have one route. The gap should vanish under our $\rho = 1$ mask.

Experiment 3: the trade-off frontier. We compare the edge-agreement versus interior-purity frontier of our method against the tuned baselines. We also report CC-500 binding, T2I-CompBench B-VQA, HRS-Bench spatial accuracy and COCO-stuff FID to show the method does not trade benchmark performance for diagnostic gains.

Experiment 4: unsatisfiable layouts. We count how often each method produces a visible seam conflict rather than one region silently overwriting the other. This is a controlled stand-in for the overlapping-box failure that CAC and MAC report.

If Experiment 1 fails, the central claim is wrong and the benchmark remains as the contribution. If Experiments 1 and 2 succeed but Seg2Any matches the frontier in Experiment 3, the contribution is the explanation and a predictive rule for choosing which layers and steps to mask, rather than a new method.