Implementation:Deepseek ai Janus Noise Initialization
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Image_Generation, Diffusion_Models |
| Last Updated | 2026-02-10 09:30 GMT |
Overview
Pattern for sampling Gaussian noise in the SDXL VAE latent space as the starting point for rectified flow ODE solving.
Description
This user-defined pattern initializes the latent noise tensor and computes the Euler step size for the ODE loop. The latent space matches the SDXL VAE's configuration: 4 channels at 48×48 spatial resolution.
Usage
Implement this pattern after CFG input preparation and before the ODE denoising loop.
Code Reference
Source Location
- Repository: Janus
- File: demo/app_janusflow.py
- Lines: L86-89
Pattern Implementation
# Initialize Gaussian noise in SDXL VAE latent space
# 4 channels, 48x48 spatial (for 384px images, 8x downscale)
z = torch.randn((parallel_size, 4, 48, 48), dtype=torch.bfloat16).cuda()
# Euler ODE step size
num_inference_steps = 30
dt = 1.0 / num_inference_steps
dt = torch.zeros_like(z).cuda().to(torch.bfloat16) + dt
Import
import torch
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| parallel_size | int | Yes | Number of images to generate |
| num_inference_steps | int | No | ODE steps (default 30) |
Outputs
| Name | Type | Description |
|---|---|---|
| z | torch.Tensor [parallel_size, 4, 48, 48] | Gaussian noise in VAE latent space (bfloat16, CUDA) |
| dt | torch.Tensor [parallel_size, 4, 48, 48] | Euler step size broadcast to latent shape |
Usage Examples
Standard Initialization
parallel_size = 5
num_inference_steps = 30
z = torch.randn((parallel_size, 4, 48, 48), dtype=torch.bfloat16).cuda()
dt = 1.0 / num_inference_steps
dt = torch.zeros_like(z).cuda().to(torch.bfloat16) + dt
# z: initial noise, shape [5, 4, 48, 48]
# dt: step size, shape [5, 4, 48, 48] (broadcast-compatible scalar)
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment