Repository navigation
fix(joyai): use the pipeline's model names in onload_model_names - #1725
Merged
Merged
Conversation
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).
Collaborator
|
@fusheng-ji Thank you for your suggestion. We will go ahead and merge this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two JoyAI-Image units use the model registry names in
onload_model_namesinstead of the pipeline attributes:onload_model_namesJoyAIImageUnit_PromptEmbedderjoyai_image_text_encodertext_encoderJoyAIImageUnit_EditImageEmbedderwan_video_vaevaeload_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_InputImageEmbedderalready usesvae.) 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_encoderandvae. It also makesEditImageEmbedder'soutput_paramsmatch what it returns:ref_latentsand the resizededit_image, whichPromptEmbedderreads afterwards. It previously declarednum_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
JoyAIImagePipelinewith small stand-in modules for the text encoder, VAE and DiT under VRAM management (offload to CPU, onload to CUDA). For each unit I calledload_models_to_device(unit.onload_model_names), as the unit does:mainEditImageEmbedderPromptEmbedderInputImageEmbedder(unchanged)split_pipeline_units(...), i.e. which units run at training time in split training:maindit(default)text_encoderPromptEmbeddervaeInputImageEmbedderEditImageEmbedder,PromptEmbedder,InputImageEmbedderReal weights.
JoyAI-Image-Edit, the low-VRAM setup from the example (offload_device="cpu",vram_limit), editingedit/image1.jpgfrom the example dataset with "将裙子改为粉色" at 1024×1024, 30 steps, B200:onload_devicemain"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"cpu"(as in the official example)mainSame run as the table above (left to right: input,
mainwithonload_device="cuda", this PR withonload_device="cuda",mainwithonload_device="cpu"):With this PR,
onload_device="cuda"and"cpu"also give pixel-identical images.