---
title: 'MPW-VAE: Watermarking in Latent Diffusion Models'
url: https://www.emergentmind.com/topics/multiplexing-watermark-vae-mpw-vae
type: topic
---

# MPW-VAE: Watermarking in Latent Diffusion Models

Searching arXiv for the cited paper and closely related watermarking methods mentioned in the provided data.
The **Multiplexing Watermark VAE (MPW-VAE)** is the watermarking component of StableGuard, a diffusion-native framework for latent diffusion models that integrates an **imperceptible holistic binary watermark** into the image generation process while using the same watermark patterns as cues for **tamper localization** [2509.17993]. In StableGuard, MPW-VAE replaces or wraps the standard VAE decoder at the second stage of the latent diffusion pipeline, after denoising has produced a clean latent \(z_0\). Its defining property is **multiplexing**: from a shared latent code \(z\), it can generate both a watermark-free reconstruction and a watermarked image, thereby coupling copyright protection with self-supervised forensic training in a single end-to-end design.

## 1. Position in the StableGuard framework

In a standard latent diffusion model such as Stable Diffusion, the pipeline first denoises sampled noise into a clean latent \(z_0\) through the diffusion UNet and then decodes \(z_0\) into an image \(X\) through the VAE decoder. StableGuard inserts MPW-VAE at this second stage. The original decoder \(\mathcal{D}_\nu\) is kept and **frozen**, while a watermark adapter is inserted after each decoder block to form the MPW-VAE decoder \(\mathcal{D}_\phi\) [2509.17993].

This arrangement allows the adapters to be toggled on or off. From the same latent \(z\), the system can therefore produce a **watermark-free reconstruction**
\[
\hat{X} = \mathcal{D}_\nu(z)
\]
and a **watermarked image**
\[
Y = \mathcal{D}_\phi(z).
\]
These paired outputs are central to the design. StableGuard uses the pairs \((\hat{X}, Y)\), together with random fusion masks, to synthesize tampered images \(\hat{Y}\) and corresponding ground-truth tamper masks \(M\) for training the **Mixture-of-Experts Guided Forensic Network (MoE-GFN)**. Within this overall system, MPW-VAE is both the **embedding module**, which ties watermarking to the latent diffusion model’s generative process, and the **multiplexing source** that makes self-supervised forensic learning possible.

A common misconception would be to treat MPW-VAE as a conventional post hoc watermarking module attached after generation. The StableGuard formulation explicitly differs from that pattern: the watermark is integrated into the decoder path of the latent diffusion model rather than appended as a separate image-space encoder [2509.17993].

## 2. Architectural formulation and watermark injection

StableGuard does not retrain the base VAE. The encoder \(\mathcal{E}_\mu\) and decoder \(\mathcal{D}_\nu\) are frozen, while MPW-VAE augments the decoder using **latent residual-based adapters** inserted after each decoder block [2509.17993]. In the standard VAE setting, the encoder is \(q_\phi(z \mid x)\), the decoder is \(p_\theta(x \mid z)\), and the classical objective is
\[
\mathcal{L}_{\text{VAE}}(x;\phi,\theta) = \mathbb{E}_{q_\phi(z \mid x)}[-\log p_\theta(x \mid z)] + \mathrm{KL}\big(q_\phi(z \mid x)\,\|\,p(z)\big),
\]
with \(p(z) = \mathcal{N}(0, I)\).

MPW-VAE preserves this pretrained backbone and injects the watermark through intermediate decoder features. Let the feature map at decoder block \(k\) be \(f^{(k)} \in \mathbb{R}^{B \times C_k \times H_k \times W_k}\), and let the watermark be a binary bit vector
\[
W \in \{0,1\}^L.
\]
The adapter \(A^{(k)}\) first encodes \(W\) through two fully connected layers,
\[
e^{(k)} = \mathrm{FC}_2^{(k)}\big(\mathrm{FC}_1^{(k)}(W)\big) \in \mathbb{R}^{C_k \cdot H_k \cdot W_k},
\]
reshapes the result to match the feature map,
\[
E^{(k)} = \mathrm{Reshape}\big(e^{(k)}, (B, C_k, H_k, W_k)\big),
\]
concatenates it with the original block features, and applies two convolutional blocks followed by a residual addition:
\[
F^{(k)}_{\text{concat}} = \mathrm{Concat}\big(f^{(k)}, E^{(k)}\big),
\]
\[
\Delta f^{(k)} = \mathrm{Conv}_2^{(k)}\big(\mathrm{Conv}_1^{(k)}(F^{(k)}_{\text{concat}})\big),
\]
\[
f^{(k)}_{\text{wm}} = f^{(k)} + \Delta f^{(k)}.
\]

The resulting watermark-conditioned decoder is
\[
Y = \mathcal{D}_\phi(z, W) = \mathrm{DecoderBlocksWithAdapters}(z, W),
\]
whereas disabling the adapters recovers the vanilla decoder
\[
\hat{X} = \mathcal{D}_\nu(z) = \mathrm{DecoderBlocksWithoutAdapters}(z).
\]

The paper characterizes this residual design as minimally perturbing the original decoder features while keeping **image fidelity high** and encoding watermark patterns that are subtle but traceable [2509.17993]. It also states that the adapters are hierarchical, operating at different spatial scales after each decoder block, which is used to enhance watermark robustness.

## 3. Multiplexing, paired outputs, and synthetic tampering data

In StableGuard, “multiplexing” means that a **single latent code** \(z\) can be transformed into two consistent outputs with different forensic properties: a watermark-free reconstruction \(\hat{X}\) and a watermarked version \(Y\) [2509.17993]. For each input image \(X\), the process is
\[
z = \mathcal{E}_\mu(X), \quad \hat{X} = \mathcal{D}_\nu(z), \quad Y = \mathcal{D}_\phi(z, W).
\]
This yields the triplet \((X, \hat{X}, Y)\), where \(X\) is the original real image, \(\hat{X}\) is the reconstruction by the vanilla VAE, and \(Y\) is the watermarked reconstruction.

StableGuard then synthesizes tampered examples by splicing watermarked and watermark-free regions. Let \(M \in \{0,1\}^{H \times W}\) be a random binary mask or a semantic mask from SAM. The fused image \(\hat{Y}\) is defined as
\[
\begin{cases}
\hat{Y} = (1 - M) \odot Y + M \odot X, & p \leq 0.5, \\
\hat{Y} = (1 - M) \odot Y + M \odot \hat{X}, & p > 0.5.
\end{cases}
\]
Here, \(Y\) carries watermark everywhere, whereas \(X\) or \(\hat{X}\) supplies watermark-free source regions. Pixels with \(M_{ij}=1\) are therefore “tampered” relative to the watermarked baseline, and the ground-truth tamper mask is exactly \(M\).

Mask generation uses two strategies. With 50% probability, StableGuard uses random binary masks composed of pure noise patterns. With 50% probability, it uses semantic masks from SAM segmentations, with masks kept **non-paired** across images to maximize shape diversity. The dataset construction is further used with different editing backbones—SD, SDXL, Kandinsky, ControlNet, and LaMa—in the AIGC tampering dataset [2509.17993].

This design produces a **rich, tampering-agnostic dataset** in which MoE-GFN is exposed to object-level and region-level splicing, to both “human-like” edits using original \(X\) and AI-generated content using \(\hat{X}\), and to precise labels for tampered regions and watermark integrity without manual annotation. A plausible implication is that the term “multiplexing” refers not merely to dual decoding, but to the generation of matched supervision signals for both attribution and localization.

## 4. Watermark representation, objectives, and self-supervised optimization

StableGuard uses a **binary bit watermark**
\[
W \in \{0,1\}^L,
\]
with reported bit lengths
\[
L \in \{32, 48, 64, 128, 256\}.
\]
The watermark is embedded **inside the VAE decoder** through adapters; it is **not** added directly to the latent \(z\) and **not** added directly to image pixels [2509.17993]. The decoder may be written as
\[
Y = \mathcal{D}_\phi(z, W) = \mathcal{D}_{\nu}(z;\,\mathrm{Adapters}(W)).
\]
The data describe the induced perturbation as **holistically spread** over the image rather than taking the form of a local logo or visible mark.

Training is governed by the overall StableGuard objective. The **similarity loss** preserves fidelity between the watermarked image \(Y\) and the clean reconstruction \(\hat{X}\):
\[
\mathcal{L}_{\text{sim}} = \|\hat{X} - Y\|_1 + \mathrm{PS}(\hat{X}, Y),
\]
where \(\mathrm{PS}(\cdot,\cdot)\) is a perceptual similarity term described as LPIPS-style feature distance. The **watermark loss** supervises extraction of the bit vector from images, including tampered ones:
\[
\mathcal{L}_{\text{wm}} = -\frac{1}{L} \sum_{l=1}^{L} \Big[ W_l \log(\hat{W}_l) + (1 - W_l)\log(1 - \hat{W}_l) \Big].
\]
The **tampering loss** is
\[
\mathcal{L}_{\text{tamper}} = \lambda_0 \mathcal{L}_{\text{wbce}} + (1 - \lambda_0)\mathcal{L}_{\text{dice}},
\]
with
\[
\mathcal{L}_{\text{wbce}} = -\frac{1}{N} \sum_{i,j} \Big[ \lambda_1 M_{i,j}\log(\sigma(\hat{M}_{i,j})) + \lambda_2(1-M_{i,j})\log(1-\sigma(\hat{M}_{i,j})) \Big],
\]
\[
\mathcal{L}_{\text{dice}} = 1 - \frac{2\sum_{i,j} M_{i,j}\cdot \sigma(\hat{M}_{i,j})}{\sum_{i,j} M_{i,j}^2 + \sum_{i,j} (\sigma(\hat{M}_{i,j}))^2}.
\]
The total loss is
\[
\mathcal{L}_{\text{total}} = \mathcal{L}_{\text{sim}} + \mathcal{L}_{\text{wm}} + \mathcal{L}_{\text{tamper}}.
\]

The training loop is explicitly self-supervised. Given a real image \(X\), StableGuard encodes it into \(z\), decodes \(\hat{X}\) and \(Y\), samples a mask \(M\), constructs \(\hat{Y}\), feeds \(\hat{Y}\) to MoE-GFN, computes \(\mathcal{L}_{\text{total}}\), and updates the adapter parameters of MPW-VAE and the forensic network parameters while keeping the base VAE encoder and decoder frozen [2509.17993]. Supervision comes automatically from the known bit vector \(W\) and the constructed mask \(M\); no manual tamper annotation is required.

## 5. Interaction with MoE-GFN

MoE-GFN receives three types of images generated by MPW-VAE: pure watermarked images \(Y\), tampered versions \(\hat{Y}\) built from \(Y\) and \(X/\hat{X}\), and watermarked reconstructions used for robustness evaluation. For each \(\hat{Y}\), it predicts both the watermark bits and the tamper mask:
\[
\hat{W} = \text{watermark prediction}, \qquad \hat{M} = \text{tamper mask prediction}.
\]

Its internal **MoFE block** contains three experts [2509.17993]. The **Watermark Extraction Expert** is a global transformer that captures global correlations of watermark patterns across the image:
\[
x_{\text{wm}} = \mathrm{FFN}\big(\mathrm{MHSA}(\mathrm{Proj}(x_{\text{flat}}))\big) + x_{\text{flat}}.
\]
The **Tampering Localization Expert** is a sub-patch transformer. It partitions the feature map into patches of size \(n \times n\), with \(n=8\) in the implementation details, and is described as being sensitive to local inconsistencies indicative of tampering:
\[
x_{\text{tamp}} = \mathrm{FFN}\big(\mathrm{MHSA}(\mathrm{Proj}(x_{\text{sub}}))\big) + x_{\text{sub}}.
\]
The **Boundary Enhancement Expert** is a frequency-domain transformer:
\[
x_{\text{FFT}} = \mathrm{Reshape}(\mathrm{FFT}(x), (B, HW, C)),
\]
\[
x_{\text{bound}} = \mathrm{iFFT}\Big(\mathrm{FFN}\big(\mathrm{MHSA}(\mathrm{Proj}(x_{\text{FFT}}))\big) + x_{\text{FFT}}\Big),
\]
and is intended to highlight high-frequency edges where manipulations occur.

The outputs of the three experts are merged through a **Dynamic Soft Router** with router weights
\[
R = \mathrm{Softmax}(f(x)) \in \mathbb{R}^{B \times 3 \times 1 \times 1},
\]
where \(f(\cdot)\) is a small MLP, producing a unified forensic feature
\[
x_{\text{unified}} = \sum_{n=1}^{3} R_n \odot \mathrm{Expert}_n(x).
\]

The interaction between MPW-VAE and MoE-GFN is not unidirectional. StableGuard describes a reciprocal relation in which MPW-VAE improves forensic accuracy by supplying paired, consistent watermarked and clean samples together with rich tampering variants, while MoE-GFN guides watermark embedding through backpropagation so that the embedded patterns become more useful for detection and localization [2509.17993]. Ablation in Tab. 12 is reported to show that training MPW-VAE and MoE-GFN separately, without joint optimization, yields poorer localization than joint training.

## 6. Empirical characteristics, implementation, and relation to prior methods

The reported empirical profile of MPW-VAE is defined by three simultaneous targets: **image fidelity**, **watermark robustness**, and **tamper localization** [2509.17993]. On COCO and T2I datasets, MPW-VAE is reported to achieve PSNR of approximately \(40\)–\(41\) dB, SSIM of approximately \(0.97\), LPIPS of approximately \(0.06\)–\(0.07\), and FID of approximately \(19.4\)–\(20.1\). The same section states that bit accuracy on clean images reaches up to **99.98%**, and that compared to methods such as WAM, OmniGuard, WaDiff, and Stable Signature, MPW-VAE improves perceptual quality and FID while achieving near-perfect bit accuracy of about **99.9%**.

Under noise, JPEG, Poisson, and many real-world degradations, the combination of MPW-VAE and MoE-GFN is reported to maintain bit accuracy above **99.6%** in most noise and compression conditions, while F1 scores for tampering localization remain above **0.9** in many settings. Under varying tampering ratios, the paper reports bit accuracy of approximately **99.96–99.98%** at 10–50% tampered area, and approximately **89.6%** even at 90% tampering, outperforming post hoc methods. On the AIGC tampering dataset, the reported localization performance across SD-Inpainting, SD-XL, Kandinsky, ControlNet, and LaMa is \( \mathrm{F1} \approx 0.979\)–\(0.981\), \( \mathrm{AUC} \approx 0.991\)–\(0.993\), and \( \mathrm{IoU} \approx 0.960\)–\(0.963\). On traditional datasets including CASIA, NIST, Columbia, Coverage, and IMD2020, StableGuard is reported often to exceed EditGuard, OmniGuard, and WAM, with \( \mathrm{F1} \approx 0.93\)–\(0.99\) and \( \mathrm{IoU} \approx 0.90\)–\(0.99\).

The reported trade-offs are correspondingly explicit. Increasing the bit length from \(32\) to \(256\) slightly lowers PSNR and SSIM and increases LPIPS, while image quality remains high at approximately \(40\) dB PSNR. Stronger watermark embedding can marginally improve robustness but must be balanced with \(\mathcal{L}_{\text{sim}}\) to avoid artifacts. Joint optimization is described as crucial, because decoupling MPW-VAE from MoE-GFN reduces localization performance significantly. This suggests that MPW-VAE should be understood not simply as a watermark encoder, but as a component whose utility depends on co-adaptation with the forensic model.

Implementation details situate MPW-VAE within **Stable Diffusion 2.1**. The architecture uses the original VAE encoder \(\mathcal{E}_\mu\) and decoder \(\mathcal{D}_\nu\), inserts watermark adapters composed of two FC layers, two conv layers, and a residual connection after each decoder block, and trains with Adam at learning rate \(1 \times 10^{-4}\) for 10 epochs with batch size 16 on \(2\times\) RTX 4090D. The reported loss weights are \(\lambda_0 = 0.2\), \(\lambda_1 = 2\), and \(\lambda_2 = 0.5\). In text-to-image generation, after denoising latent \(z_0\) with the UNet, decoding through \(\mathcal{D}_\phi\) yields watermarked images, while the original decoder remains available for comparison and clean reconstruction.

The complexity overhead is described as small. Tab. 21 reports vanilla VAE latency of approximately **12.69 ms** and MPW-VAE latency of approximately **14.99 ms**; VRAM rises from **1682 MB** to **2034 MB** for the decoder, while MoE-GFN uses approximately **428 MB**. The paper therefore characterizes the added overhead as negligible relative to the base VAE.

Relative to prior watermarking approaches, StableGuard distinguishes MPW-VAE from two families. First, **post hoc image-space methods** such as HiDDeN, SepMark, WAM, EditGuard, and OmniGuard attach an external encoder and decoder after generation, incur extra runtime and potential degradation, are decoupled from the diffusion process, and are often optimized separately from forensics. Second, **diffusion-native latent watermarking** methods such as Stable Signature, WOUAF, and WaDiff modify noise, UNet weights, or latent routing, but are described as focusing on source attribution or simple watermark detection rather than fine-grained tamper localization or self-supervised forensic training [2509.17993].

Within that comparison, MPW-VAE is defined by three features: a **decoder-side latent residual adapter** that directly modulates decoder features conditioned on a bit vector; a **multiplexing design** in which a single latent \(z\) yields both watermarked and watermark-free outputs; and **joint optimization with MoE-GFN**, through which embedding and forensics are trained together in a single end-to-end system. In the formulation of StableGuard, this shifts watermarking from **post hoc, isolated watermarking** to **embedded, multiplexed, forensic-aware watermarking** inside the latent diffusion pipeline.

Source: https://www.emergentmind.com/topics/multiplexing-watermark-vae-mpw-vae