nemo_automodel.components.models.qwen_image_edit.adapter
nemo_automodel.components.models.qwen_image_edit.adapter
Flow-matching adapter for cached Qwen-Image-Edit-2511 conditioning.
Module Contents
Classes
API
Bases: ModelAdapter
Adapt cached image-edit batches to the upstream Diffusers transformer.
Qwen-Image-Edit concatenates the packed noisy target tokens followed by the packed context-image tokens. The transformer predicts every image token, but flow matching supervises only the leading target-token span.
Pack 2-by-2 latent patches in the upstream Diffusers layout.
Parameters:
Tensor of shape [batch, channels, latent_height, latent_width]. Both spatial dimensions must be even.
Returns: torch.Tensor
Tensor of shape [batch, packed_tokens, 4 * channels], where
Restore packed predictions to a channels-first latent grid.
Parameters:
Tensor of shape [batch, packed_tokens, 4 * channels] in the upstream Diffusers 2-by-2 patch layout.
Output latent height. It must be even.
Output latent width. It must be even.
Returns: torch.Tensor
Tensor of shape [batch, channels, height, width]. The returned
Validate the ordered cached context-latent sequence.
Parameters:
Ordered list of tensors, each with shape [batch, channels, context_height, context_width].
Required leading size for every context tensor.
Required latent channel count for every context tensor.
Returns: list[torch.Tensor]
The validated list of context tensors in its original order. The
Compute unreduced flow-matching velocity MSE in float32.
Parameters:
Predicted target velocity tensor of shape [batch, channels, target_height, target_width].
Reference noise - clean_latent velocity tensor with the
same shape as model_pred.
Returns: torch.Tensor
Per-element float32 squared-error tensor with the same shape as
Run the upstream transformer and return only target predictions.
Parameters:
Upstream Diffusers Qwen image transformer. Its packed output has shape [batch, total_image_tokens, 4 * channels].
Mapping returned by prepare_inputs. Tensor-bearing fields
have the layouts documented by that method.
Returns: torch.Tensor
Target velocity prediction tensor of shape [batch, channels,
Build Qwen edit conditioning from a cached flow-matching batch.
Parameters:
Flow context whose noisy_latents tensor has shape
[batch, channels, target_height, target_width]. Its batch must
contain context_latents as an ordered list of tensors with
shape [batch, channels, context_height, context_width],
text_embeddings with shape [batch, text_tokens, hidden],
and text_attention_mask with shape [batch, text_tokens].
Returns: dict[str, Any]
Mapping containing hidden_states with shape [batch, total_image_tokens,