Skip to content

fix(joyai): use the pipeline's model names in onload_model_names - #1725

Merged
Artiprocher merged 1 commit into
modelscope:mainfrom
fusheng-ji:fix/joyai-vae-onload
Oct 13, 2026
Merged

Artiprocher merged 1 commit into
modelscope:mainfrom
fusheng-ji:fix/joyai-vae-onload

Conversation

@fusheng-ji

@fusheng-ji fusheng-ji commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Two JoyAI-Image units use the model registry names in onload_model_names instead of the pipeline attributes:

unit onload_model_names pipeline attribute
JoyAIImageUnit_PromptEmbedder joyai_image_text_encoder text_encoder
JoyAIImageUnit_EditImageEmbedder wan_video_vae vae

load_models_to_device() matches these names against the pipeline's attributes, so with VRAM management enabled it offloads every model, including the one the unit is about to run. (JoyAIImageUnit_InputImageEmbedder already uses vae.) The same names are used to split the units for split training, so a trainable text encoder or VAE was not detected and their units ended up in the cached data-processing stage.

This PR uses text_encoder and vae. It also makes EditImageEmbedder's output_params match what it returns: ref_latents and the resized edit_image, which PromptEmbedder reads afterwards. It previously declared num_items / is_multi_item, which it never returns.

I checked all other pipelines in the same way, and these are the only two mismatches.

Checking

I used a real JoyAIImagePipeline with small stand-in modules for the text encoder, VAE and DiT under VRAM management (offload to CPU, onload to CUDA). For each unit I called load_models_to_device(unit.onload_model_names), as the unit does:

unit main this PR
EditImageEmbedder text_encoder on cpu, vae on cpu vae on cuda
PromptEmbedder text_encoder on cpu, vae on cpu text_encoder on cuda
InputImageEmbedder (unchanged) vae on cuda vae on cuda

split_pipeline_units(...), i.e. which units run at training time in split training:

trainable model main this PR
dit (default) none none (unchanged)
text_encoder none, so prompt embeddings are cached and the text encoder gets no gradient PromptEmbedder
vae InputImageEmbedder EditImageEmbedder, PromptEmbedder, InputImageEmbedder

Real weights. JoyAI-Image-Edit, the low-VRAM setup from the example (offload_device="cpu", vram_limit), editing edit/image1.jpg from the example dataset with "将裙子改为粉色" at 1024×1024, 30 steps, B200:

onload_device main this PR
"cuda" RuntimeError: Input type (CUDABFloat16Type) and weight type (CPUBFloat16Type) should be the same, raised in the VAE encoder: the VAE is still on CPU when the edit image is encoded works, 60.4 s, peak 33.1 GiB
"cpu" (as in the official example) works works, pixel-identical to main

Same run as the table above (left to right: input, main with onload_device="cuda", this PR with onload_device="cuda", main with onload_device="cpu"):

JoyAI-Image-Edit low-VRAM editing: main crashes with onload_device=cuda, this PR works and matches main with onload_device=cpu

With this PR, onload_device="cuda" and "cpu" also give pixel-identical images.

JoyAIImageUnit_PromptEmbedder and JoyAIImageUnit_EditImageEmbedder used
the model registry names (`joyai_image_text_encoder`, `wan_video_vae`)
in onload_model_names, but the pipeline attributes are `text_encoder` and
`vae`. With VRAM management enabled, load_models_to_device() therefore
offloaded every model, including the one the unit is about to run. The
same names are used to split the units for split training, so a
trainable text encoder or VAE was not detected and its units were cached
in the data processing stage.

Also make EditImageEmbedder's output_params match what it returns
(`ref_latents` and the resized `edit_image`, which PromptEmbedder reads).
@Artiprocher

Copy link
Copy Markdown
Collaborator

@fusheng-ji Thank you for your suggestion. We will go ahead and merge this PR.

@Artiprocher
Artiprocher merged commit 1193268 into modelscope:main Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants