Skip to content

Support Comfy 0.3.69+ and Add Lumina2 (ZImage Turbo) Compatibility #69

Open
EnragedAntelope wants to merge 8 commits into
ChenDarYen:mainfrom
EnragedAntelope:main
Open

Support Comfy 0.3.69+ and Add Lumina2 (ZImage Turbo) Compatibility #69
EnragedAntelope wants to merge 8 commits into
ChenDarYen:mainfrom
EnragedAntelope:main

Conversation

@EnragedAntelope
Copy link
Copy Markdown

No description provided.

claude and others added 8 commits November 21, 2025 23:31
- Update imports to use comfy.ldm.flux.layers instead of comfy.ldm.chroma.layers
  for DoubleStreamBlock and SingleStreamBlock (they are now set to None in chroma.layers)
- Pass latent_shapes parameter through executor.execute in NAGCFGGuider.sample()
  to match base CFGGuider implementation in latest ComfyUI

Fixes:
- TypeError: NoneType takes no arguments (import issue)
- TypeError: NAGCFGGuider.inner_sample() got an unexpected keyword argument 'latent_shapes'
…ck-016HZBLZssSEyCn5ne5dT9k9

Fix ComfyUI 0.3.69+ compatibility issues
Add None check for guidance parameter before calling .detach() to prevent
AttributeError: 'NoneType' object has no attribute 'detach' when queue
is interrupted.

When guidance is None, use zeros_like(distill_timestep) as fallback,
matching the pattern used in other model implementations (flux, hunyuan_video).
1. Fix TypeError: Chroma.forward_orig() got multiple values for argument 'attn_mask'
   - Remove incorrect txt_ids_negative parameter from else block
   - The else block calls base Chroma.forward_orig which doesn't accept txt_ids_negative
   - Previous fix in e751545 was based on misunderstanding of the code flow

2. Add defensive checks for IndexError during queue interruption
   - Check img_ids is not None and has correct dimensions before concatenation
   - Handle edge case where origin_bsz <= 0
   - Prevents "Dimension out of range" error when img_ids has unexpected shape
   - Follows same pattern as flux/model.py

This properly handles queue interruption scenarios while maintaining compatibility
with base Chroma class in non-NAG mode.
**Root cause:** When a queue with NAG active is interrupted, the restoration
of self.forward_orig and block.forward methods never executes, leaving them
in the NAG state. When a new queue starts without NAG active, the else block
calls self.forward_orig which is still the NAG version, causing parameter
misalignment and IndexError.

**Fixes applied to all models:**

1. **Chroma** (chroma/model.py):
   - Wrap NAG setup in try/finally to ensure restoration even on interruption
   - In else block, call Chroma.forward_orig directly instead of self.forward_orig
   - Add defensive checks for img_ids dimensions

2. **Flux** (flux/model.py):
   - Same try/finally protection
   - Call Flux.forward_orig directly in else block

3. **HunyuanVideo** (hunyuan_video/model.py):
   - Same try/finally protection
   - Call HunyuanVideo.forward_orig directly in else block

4. **Wan** (wan/model.py - both NAGWanModel and NAGVaceWanModel):
   - Wrap forward_orig call in try/finally
   - Initialize forward_orig_ and cross_attns_forward before if block
   - Restore in finally block only if NAG was active

This ensures that even if queue is interrupted mid-processing, all modified
methods are restored to their original state, preventing parameter misalignment
errors in subsequent queue runs.
…ck-016HZBLZssSEyCn5ne5dT9k9

Claude/fix comfyui node pack 016 hzbl zss s ey cn5ne5d t9k9
This adds NAG (Normalized Attention Guidance) support for Lumina 2 and
Z-Image Turbo models which use the NextDiT architecture.

- Add lumina/model.py with NAGNextDiT wrapper and NAGNextDiTSwitch
- Add lumina/layers.py with utility function for attention-level NAG
- Register NextDiT model type in samplers.py

The implementation applies NAG at the output level by running the model
with both positive and negative conditions, then extrapolating between
the outputs using the NAG guidance formula.
…-QMcu0

Add NAG support for Lumina/NextDiT models (Z-Image Turbo)
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