Repository navigation
Version 1.3.0 - RES4LYF Sampler Support
Overview
This release adds comprehensive support for RES4LYF (RES4) samplers across all model types, including Nunchaku Qwen Image, Nunchaku Flux1, Nunchaku SDXL, standard SDXL, standard SD1.5, standard Flux1, and Z-Image Turbo (both standard and Nunchaku) models.
The implementation provides robust model detection, correct model_sampling access paths, automatic CONST/EPS type detection, and comprehensive sampler registration for all supported models.
File Classification
Newly Created Files
Changelog/CHANGELOG.md- Purpose: Centralized changelog file containing detailed version history
- Location:
Changelog/CHANGELOG.md - Content: Complete changelog from version 1.3.0 down to 1.0.6
- Usage: Referenced by
README.mdfor detailed changelog information
Modified Files
Category 1: Core Path Management
modules/paths.py- Core module path initialization
Category 2: ControlNet Support Files
modules_forge/supported_controlnet.py- General ControlNet supportmodules_forge/supported_controlnet_flux.py- Flux ControlNet supportmodules_forge/supported_controlnet_qwen_image.py- Nunchaku Qwen Image ControlNet support
Category 3: RES4LYF Sampler Core Files
modules/RES4LYF/beta/rk_sampler_beta.py- Main sampler orchestrationmodules/RES4LYF/beta/rk_method_beta.py- Core RK method implementationmodules/RES4LYF/beta/rk_noise_sampler_beta.py- Noise sampler initializationmodules/RES4LYF/beta/rk_guide_func_beta.py- Latent guiding functionsmodules/RES4LYF/beta/__init__.py- Dynamic sampler registration
Category 4: RES4LYF Helper Files
modules/RES4LYF/helper.py- Helper functions includingis_RF_model()modules/RES4LYF/legacy/helper.py- Legacy helper functionsmodules/RES4LYF/legacy/samplers_tiled.py- Legacy tiled sampler
Category 5: Backend Files
backend/modules/k_model.py- KModel class withmodel_samplinginitialization
Model Type Support Summary
Nunchaku Qwen Image (QI) Models
- Status: ✅ Full support
- Detection:
isinstance(diffusion_model, NunchakuQwenImageTransformer2DModel) - model_sampling Path:
forge_objects.unet.model.model_sampling - Model Sampling Type:
ModelType.FLOWviacomfy.model_base.model_sampling(config, ModelType.FLOW)
Nunchaku Flux1 Models
- Status: ✅ Full support
- Detection:
isinstance(diffusion_model, SVDQFluxTransformer2DModel) - model_sampling Path:
forge_objects.unet.model.model_sampling - Model Sampling Type:
ModelSamplingFluxWithConst(inheritsModelSamplingFlux+backend.modules.k_model.CONST) - CONST Detection: Checks both
comfy.model_sampling.CONSTandbackend.modules.k_model.CONST
Nunchaku SDXL Models
- Status: ✅ Full support
- Detection:
isinstance(diffusion_model, SVDQUNet2DConditionModel) - model_sampling Path:
forge_objects.unet.model.model_sampling - Model Sampling Type:
ModelType.EPSviacomfy.model_base.model_sampling(config, ModelType.EPS) - EPS Detection:
isinstance(model_sampling_obj, EPS)
Standard SDXL Models
- Status: ✅ Full support
- Detection:
isinstance(diffusion_model, IntegratedUNet2DConditionModel)+inner_model.is_sdxl - model_sampling Path:
forge_objects.unet.model.model_sampling(Forge) ormodel.inner_model.inner_model.model_sampling(ComfyUI) - Model Sampling Type:
ModelType.EPSviacomfy.model_base.model_sampling(config, ModelType.EPS) - EPS Detection:
isinstance(model_sampling_obj, EPS)
Standard Flux1 Models
- Status: ✅ Full support
- Detection:
isinstance(diffusion_model, IntegratedFluxTransformer2DModel) - model_sampling Path:
forge_objects.unet.model.model_sampling(Forge) ormodel.inner_model.inner_model.model_sampling(ComfyUI) - Model Sampling Type:
ModelSamplingFluxWithConst(inheritsModelSamplingFlux+backend.modules.k_model.CONST) - CONST Detection: Same as Nunchaku Flux1
Nunchaku Z-Image Turbo (ZIT) Models
- Status: ✅ Full support (automatic via
ModelType.FLOW) - Detection: Not explicitly detected (uses same
ModelType.FLOWpath as QI) - model_sampling Path:
forge_objects.unet.model.model_sampling - Model Sampling Type:
ModelType.FLOWviacomfy.model_base.model_sampling(config, ModelType.FLOW) - Note: ZIT uses
NextDiTclass (different from QI'sQwenImageTransformer2DModel), but shares the sameModelType.FLOWsampling path, so RES4LYF works automatically without explicit detection
Standard Z-Image Turbo (ZIT) Models
- Status: ✅ Full support (automatic via
ModelType.FLOW) - Detection: Not explicitly detected (uses same
ModelType.FLOWpath as QI) - model_sampling Path:
forge_objects.unet.model.model_sampling(Forge) ormodel.inner_model.inner_model.model_sampling(ComfyUI) - Model Sampling Type:
ModelType.FLOWviacomfy.model_base.model_sampling(config, ModelType.FLOW) - Note: Standard ZIT uses
NextDiTclass (different from standard QI'sQwenImageTransformer2DModel), but shares the sameModelType.FLOWsampling path, so RES4LYF works automatically without explicit detection
SD1.5 Models
- Status: ✅ Full support (automatic via
ModelType.EPS) - Detection: Not explicitly detected (uses same
ModelType.EPSpath as SDXL) - model_sampling Path:
forge_objects.unet.model.model_sampling(Forge) ormodel.inner_model.inner_model.model_sampling(ComfyUI) - Model Sampling Type:
ModelType.EPSviacomfy.model_base.model_sampling(config, ModelType.EPS) - Note: SD1.5 uses
ModelType.EPS(same as SDXL), so RES4LYF works automatically without explicit detection. SDXL settings can be used directly with SD1.5 models.
Detailed File-by-File Implementation
Category 1: Core Path Management
File: modules/paths.py
Purpose: This file is executed during Python module initialization and ensures all import comfy statements resolve to ComfyUI-master/comfy directory instead of any local comfy directory at the project root.
Modified Code:
import os
import sys
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir, cwd # noqa: F401
# Ensure ComfyUI-master is in sys.path before script_path
# This ensures we use ComfyUI-master/comfy instead of the project root comfy directory
comfyui_master_path = os.path.join(script_path, "ComfyUI-master")
comfyui_master_path = os.path.normpath(comfyui_master_path)
if os.path.exists(comfyui_master_path):
if comfyui_master_path not in sys.path:
sys.path.insert(0, comfyui_master_path)
# Remove project root comfy directory from sys.path if it exists
project_comfy_path = os.path.join(script_path, "comfy")
project_comfy_path = os.path.normpath(project_comfy_path)
if project_comfy_path in sys.path:
sys.path.remove(project_comfy_path)
sys.path.insert(0, script_path)
sd_path = os.path.dirname(__file__)Detailed Line-by-Line Explanation:
-
import osandimport sys: Standard Python libraries for file system operations and system path manipulation. Required for path management. -
from modules.paths_internal import ...: Imports path variables defined elsewhere. The# noqa: F401comment suppresses linting warnings for unused imports (these are imported for side effects or use by other modules). -
comfyui_master_path = os.path.join(script_path, "ComfyUI-master"): Constructs the absolute path to theComfyUI-masterdirectory by joining the script path with"ComfyUI-master". This path points to where the official ComfyUI codebase is located, which should be the authoritative source for allcomfymodule imports. -
comfyui_master_path = os.path.normpath(comfyui_master_path): Normalizes the path to handle different operating systems and path formats. On Windows, paths use backslashes (\), while on Unix they use forward slashes (/). This function ensures consistent path representation across platforms, preventing path-related errors. -
if os.path.exists(comfyui_master_path):: Checks if theComfyUI-masterdirectory actually exists before attempting to modifysys.path. This preventsValueErroror other errors if the directory is missing (e.g., incomplete repository clone or missing submodule). -
if comfyui_master_path not in sys.path:: Checks ifComfyUI-masteris already in Python's module search path. This prevents duplicate entries insys.path, which could cause confusion or performance issues. -
sys.path.insert(0, comfyui_master_path): AddsComfyUI-masterto the beginning of Python's module search path. The0index is critical - it ensuresComfyUI-masterhas the highest priority. Python searchessys.pathin order from first to last, and uses the first matching module it finds. By inserting at index 0, we guarantee thatimport comfywill resolve toComfyUI-master/comfybefore any other directory. -
project_comfy_path = os.path.join(script_path, "comfy"): Constructs the path to a potential localcomfydirectory at the project root. This is the directory we want to exclude from module resolution. -
if project_comfy_path in sys.path:: Checks if the project rootcomfydirectory is currently insys.path. This might happen if it was added earlier by other code or if it's the current working directory. -
sys.path.remove(project_comfy_path): Explicitly removes the project rootcomfydirectory fromsys.path. This ensures complete separation - Python will never import from the old local directory, preventing conflicts, version mismatches, or incorrect module resolution. -
sys.path.insert(0, script_path): Finally, adds the project's script directory tosys.path. This ensures project-specific modules (in themodules/directory) can still be imported, butComfyUI-mastermaintains priority forcomfyimports.
Why This Matters:
-
Import Resolution Priority: Python's import system uses the first matching module found in
sys.path. Without this code, if bothcomfy/(project root) andComfyUI-master/comfy/exist, Python might import from the wrong one depending on directory order. -
Version Compatibility: ComfyUI-master contains the official, tested ComfyUI codebase. Using it ensures compatibility with all ComfyUI features, extensions, and API contracts.
-
Error Prevention: Without this path management, RES4LYF samplers might import incorrect versions of classes like
comfy.model_sampling.EPSorcomfy.model_sampling.CONST, leading toAttributeError,TypeError, or incorrect model type detection. -
Maintainability: Updates to ComfyUI-master automatically propagate to the entire application without modifying project-specific code.
Impact on RES4LYF:
RES4LYF samplers rely heavily on ComfyUI's model structures:
comfy.model_sampling.EPSfor SDXL modelscomfy.model_sampling.CONSTfor Flux1 models (in addition tobackend.modules.k_model.CONST)comfy.model_base.model_sampling()factory function for creating appropriateModelSamplingclasses
Without this path management, RES4LYF might import outdated or incompatible versions of these classes, causing:
- Incorrect model type detection (
VE_MODELandCONST_MODELflags set incorrectly) - Incorrect sampling behavior (wrong noise scaling, wrong sigma calculations)
- Runtime errors when accessing model attributes that don't exist in the imported version
Category 2: ControlNet Support Files
These files ensure ControlNet imports resolve to ComfyUI-master/comfy/controlnet for all ControlNet types (general, Flux, and Nunchaku Qwen Image).
File: modules_forge/supported_controlnet.py
Purpose: General ControlNet support module. This file patches ComfyUI ControlNet for Forge compatibility and handles general ControlNet model loading.
Modified Section (lines 1-32):
import os
import sys
import torch
# Ensure ComfyUI-master is in sys.path before importing comfy
# This ensures we use ComfyUI-master/comfy instead of the project root comfy directory
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
comfyui_master_path = os.path.join(project_root, "ComfyUI-master")
comfyui_master_path = os.path.normpath(comfyui_master_path)
if os.path.exists(comfyui_master_path):
if comfyui_master_path not in sys.path:
sys.path.insert(0, comfyui_master_path)
# Remove project root comfy directory from sys.path if it exists
project_comfy_path = os.path.join(project_root, "comfy")
project_comfy_path = os.path.normpath(project_comfy_path)
if project_comfy_path in sys.path:
sys.path.remove(project_comfy_path)
from huggingface_guess.detection import unet_config_from_diffusers_unet, model_config_from_unet
from huggingface_guess.utils import unet_to_diffusers
from backend import memory_management
from backend.operations import using_forge_operations
from backend.nn.cnets import cldm
from backend.patcher.controlnet import ControlLora, ControlNet, load_t2i_adapter, apply_controlnet_advanced
from modules_forge.shared import add_supported_control_model
# =============================================================================
# ComfyUI ControlNet patches for Forge compatibility
# Uses ComfyUI-master/comfy package (located in ComfyUI-master directory)
# =============================================================================
try:
import comfy.controlnet
# ... rest of file ...Detailed Explanation:
-
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))):__file__is the path to the current file (modules_forge/supported_controlnet.py)os.path.abspath(__file__)converts it to an absolute pathos.path.dirname()once givesmodules_forge/os.path.dirname()twice gives the project root directory- This is necessary because this file is in a subdirectory (
modules_forge/), not at the project root
-
comfyui_master_path = os.path.join(project_root, "ComfyUI-master"): Constructs the path toComfyUI-masterdirectory from the project root. -
Path normalization and sys.path management: Same logic as
modules/paths.py, but calculated frommodules_forge/directory instead ofmodules/directory. -
import comfy.controlnet: After path management, this import is guaranteed to resolve toComfyUI-master/comfy/controlnet. The ControlNet patches and compatibility code in this file rely on the correct ComfyUI ControlNet classes.
Why This File-Specific Path Management is Needed:
While modules/paths.py manages paths at application startup, some modules may be imported before modules/paths.py executes, or the path management in modules/paths.py might not have run yet when this file is imported. Adding path management at the file level ensures comfy.controlnet imports correctly regardless of import order.
Impact on RES4LYF:
While this file doesn't directly affect RES4LYF samplers, it ensures that ControlNet integration works correctly, which may be used in conjunction with RES4LYF samplers for guided generation.
File: modules_forge/supported_controlnet_flux.py
Purpose: Flux-specific ControlNet support. Handles integration of Flux ControlNet with Forge's Flux models (both Nunchaku and standard).
Modified Section (lines 1-31):
"""
Flux ControlNet support for Forge.
This module handles the integration of Flux ControlNet with Forge's
SVDQFluxTransformer2DModel and IntegratedFluxTransformer2DModel.
Uses Forge's bundled ComfyUI package (no external ComfyUI installation required).
"""
import os
import sys
import torch
# Ensure ComfyUI-master is in sys.path before importing comfy
# This ensures we use ComfyUI-master/comfy instead of the project root comfy directory
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
comfyui_master_path = os.path.join(project_root, "ComfyUI-master")
comfyui_master_path = os.path.normpath(comfyui_master_path)
if os.path.exists(comfyui_master_path):
if comfyui_master_path not in sys.path:
sys.path.insert(0, comfyui_master_path)
# Remove project root comfy directory from sys.path if it exists
project_comfy_path = os.path.join(project_root, "comfy")
project_comfy_path = os.path.normpath(project_comfy_path)
if project_comfy_path in sys.path:
sys.path.remove(project_comfy_path)
# Use ComfyUI-master/comfy package (located in ComfyUI-master directory)
import comfy.controlnet
from modules_forge.supported_controlnet import ControlModelPatcherDetailed Explanation:
Same path management logic as modules_forge/supported_controlnet.py. This file specifically handles Flux ControlNet models, which work with both Nunchaku Flux1 (SVDQFluxTransformer2DModel) and standard Flux1 (IntegratedFluxTransformer2DModel) models.
The path management ensures that comfy.controlnet imports resolve correctly, which is required for Flux ControlNet loading and application.
File: modules_forge/supported_controlnet_qwen_image.py
Purpose: Nunchaku Qwen Image-specific ControlNet support. IMPORTANT: This is for Nunchaku Qwen Image models ONLY, not standard Qwen Image models.
Modified Section (lines 1-35):
"""
Nunchaku Qwen Image ControlNet support for Forge.
This module handles the integration of Qwen Image ControlNet with Forge's
NunchakuQwenImageTransformer2DModel ONLY.
IMPORTANT: This is for Nunchaku Qwen Image models ONLY.
- Works with: NunchakuQwenImageTransformer2DModel (from backend.nn.svdq)
- Does NOT work with: Standard QwenImageTransformer2DModel (from backend.nn.qwen)
- Does NOT work with: Flux models (handled by supported_controlnet_flux.py)
Uses Forge's bundled ComfyUI package (no external ComfyUI installation required).
"""
import os
import sys
import torch
# Ensure ComfyUI-master is in sys.path before importing comfy
# This ensures we use ComfyUI-master/comfy instead of the project root comfy directory
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
comfyui_master_path = os.path.join(project_root, "ComfyUI-master")
comfyui_master_path = os.path.normpath(comfyui_master_path)
if os.path.exists(comfyui_master_path):
if comfyui_master_path not in sys.path:
sys.path.insert(0, comfyui_master_path)
# Remove project root comfy directory from sys.path if it exists
project_comfy_path = os.path.join(project_root, "comfy")
project_comfy_path = os.path.normpath(project_comfy_path)
if project_comfy_path in sys.path:
sys.path.remove(project_comfy_path)
# Use ComfyUI-master/comfy package (located in ComfyUI-master directory)
import comfy.controlnet
from modules_forge.supported_controlnet import ControlModelPatcherDetailed Explanation:
Same path management logic. The key distinction is that this file is EXCLUSIVELY for Nunchaku Qwen Image models (NunchakuQwenImageTransformer2DModel from backend.nn.svdq), not standard Qwen Image models (QwenImageTransformer2DModel from backend.nn.qwen).
The path management ensures that comfy.controlnet imports, specifically comfy.ldm.qwen_image.controlnet.QwenImageControlNetModel, resolve correctly from ComfyUI-master.
Category 3: RES4LYF Sampler Core Files
File: modules/RES4LYF/beta/rk_sampler_beta.py
Purpose: Main sampler orchestration file. This file contains the sample_rk_beta() function which orchestrates the entire RES4LYF sampling process. It handles device acquisition, model_sampling retrieval, model type detection, CONST/EPS type detection, and coordinates all sampling components.
Critical Changes:
- Device Acquisition (lines 248-271): Safely retrieves device from model with multiple fallback methods
- Model Type Detection and
model_samplingAcquisition (lines 277-396): Detects model type and retrievesmodel_samplingfrom correct path - CONST/EPS Type Detection (lines 362-384): Determines if model uses CONST or EPS sampling type
extra_args['model_options']Initialization (lines 378-379): Prevents KeyError when accessing transformer_options- Safe
diffusion_modelAccess (multiple locations): Prevents AttributeError for models without diffusion_model
Change 1: Device Acquisition (lines 248-271)
Problem: Different model structures store the device information in different locations. Nunchaku Qwen Image models may not have a direct device attribute, causing AttributeError.
Solution Code:
EO = ExtraOptions(extra_options)
default_dtype = EO("default_dtype", torch.float64)
extra_args = {} if extra_args is None else extra_args
# Get device from model - for Nunchaku QwenImage models, device attribute may not exist
# Try multiple methods: model attribute, model parameters, or x.device as fallback
try:
model_device = model.inner_model.inner_model.device
except (AttributeError, TypeError):
# Try getting device from model parameters (works for most PyTorch models)
try:
inner_model = model.inner_model.inner_model
if hasattr(inner_model, 'parameters'):
model_device = next(iter(inner_model.parameters())).device
else:
# Fallback to x.device (used in ComfyUI-nunchaku)
model_device = x.device
except (StopIteration, AttributeError, TypeError):
# Final fallback: use x.device (safe and always available)
model_device = x.device
work_device = 'cpu' if EO("work_device_cpu") else model_deviceDetailed Line-by-Line Explanation:
-
EO = ExtraOptions(extra_options): Creates anExtraOptionshelper object for accessing extra options. This allows easy access to configuration values with defaults. -
default_dtype = EO("default_dtype", torch.float64): Retrieves the default data type from extra options, defaulting totorch.float64if not specified. RES4LYF samplers use high precision (float64) by default for numerical accuracy. -
extra_args = {} if extra_args is None else extra_args: Initializesextra_argsto an empty dictionary if it'sNone. This preventsTypeErrorwhen accessingextra_argskeys later. -
First attempt:
model_device = model.inner_model.inner_model.device:- Purpose: Tries to access device directly from the innermost model wrapper
- Model Structure:
modelis typically aCFGDenoiseror similar wrapper. The chaininner_model.inner_modelnavigates through wrapper layers to reach the actual model (BaseModelin ComfyUI orForgeDiffusionEnginein Forge) - Why this works for some models: Standard ComfyUI models and some Forge models have a
deviceattribute on the base model class - Why this fails for others: Nunchaku Qwen Image models wrapped in Forge may not expose
devicedirectly, or the attribute path may be different
-
Second attempt:
next(iter(inner_model.parameters())).device:- Purpose: Retrieves device from the first parameter tensor of the model
- Why this works: PyTorch models store their parameters (weights, biases) as tensors. All parameters in a model are on the same device. By getting the first parameter's device, we get the model's device
- Implementation:
inner_model.parameters()returns an iterator over all parameters.iter()makes it iterable,next()gets the first parameter,.devicegets its device - Error handling: Wrapped in try-except to catch
StopIteration(empty parameters),AttributeError(no parameters method), orTypeError(not a PyTorch model)
-
Final fallback:
model_device = x.device:- Purpose: Uses the device of the input tensor
xas the model device - Why this is safe:
xis the input latent tensor passed to the sampler. It's always a PyTorch tensor with a.deviceattribute - Why this works: If the model processes
x, it must be on the same device asx(or able to move tensors to its device). Usingx.deviceis a safe assumption - Reference: This approach is used in ComfyUI-nunchaku and is proven to work
- Purpose: Uses the device of the input tensor
-
work_device = 'cpu' if EO("work_device_cpu") else model_device: Determines the work device based on extra options. Some operations (like intermediate calculations) can be performed on CPU for memory efficiency, while model inference must happen on the model's device.
Why This Multi-Stage Fallback Matters:
- Robustness: Handles all known model structures without crashing
- Compatibility: Works with ComfyUI models, Forge models, and Nunchaku models
- Performance: Uses the most direct method when available (direct attribute access is fastest)
- Safety: Always has a fallback that works (using
x.device)
Impact on Different Model Types:
- Standard ComfyUI Models: Uses first method (
model.inner_model.inner_model.device) - fastest - Standard Forge Models: Uses first method if available, otherwise second method (parameters)
- Nunchaku Qwen Image: May use second method (parameters) or fallback to third method (
x.device) - Nunchaku Flux1/SDXL: Similar to standard Forge models
Change 2: Model Type Detection and model_sampling Acquisition (lines 277-396)
Problem: Different model structures store model_sampling in different locations:
- ComfyUI BaseModel:
model.inner_model.inner_model.model_sampling(direct attribute) - Forge ForgeDiffusionEngine:
model.inner_model.inner_model.forge_objects.unet.model.model_sampling(via KModel wrapper)
Additionally, we need to detect the specific model type (Nunchaku Qwen Image, Nunchaku Flux1, Nunchaku SDXL, standard SDXL, standard Flux1) to use the correct sampling logic and provide meaningful error messages.
Solution Code (lines 277-334):
# Get model_sampling - different paths for Forge vs ComfyUI
# ComfyUI BaseModel: model.inner_model.inner_model.model_sampling (direct attribute)
# Forge ForgeDiffusionEngine: model.inner_model.inner_model.forge_objects.unet.model.model_sampling (via KModel)
model_sampling_obj = None
model_sampling_path = None
is_nunchaku_qwen_image = False
is_nunchaku_flux1 = False
is_nunchaku_sdxl = False
is_sdxl = False
is_flux1 = False
# First, try Forge path (ForgeDiffusionEngine has forge_objects)
if hasattr(model, "inner_model") and hasattr(model.inner_model, "inner_model"):
inner_model = model.inner_model.inner_model
# Check if it's Forge model (has forge_objects attribute)
if hasattr(inner_model, "forge_objects"):
try:
forge_objects = inner_model.forge_objects
if hasattr(forge_objects, "unet") and hasattr(forge_objects.unet, "model"):
# Check diffusion_model type to distinguish Nunchaku models
k_model = forge_objects.unet.model
if hasattr(k_model, "diffusion_model"):
diffusion_model = k_model.diffusion_model
# Check if it's Nunchaku Qwen Image, FLUX1, or SDXL
try:
from backend.nn.svdq import SVDQFluxTransformer2DModel, NunchakuQwenImageTransformer2DModel
from backend.nn.nunchaku_sdxl_unet import SVDQUNet2DConditionModel
if isinstance(diffusion_model, NunchakuQwenImageTransformer2DModel):
is_nunchaku_qwen_image = True
elif isinstance(diffusion_model, SVDQFluxTransformer2DModel):
is_nunchaku_flux1 = True
elif isinstance(diffusion_model, SVDQUNet2DConditionModel):
is_nunchaku_sdxl = True
else:
# Check if it's standard SDXL (IntegratedUNet2DConditionModel or UNet2DConditionModel)
try:
from backend.nn.unet import IntegratedUNet2DConditionModel
if isinstance(diffusion_model, IntegratedUNet2DConditionModel):
# Check if inner model is SDXL UNet
if hasattr(inner_model, "is_sdxl") and inner_model.is_sdxl:
is_sdxl = True
except (ImportError, TypeError):
pass
# Check if it's standard Flux1 (IntegratedFluxTransformer2DModel)
if not is_sdxl: # Only check Flux1 if not SDXL
try:
from backend.nn.flux import IntegratedFluxTransformer2DModel
if isinstance(diffusion_model, IntegratedFluxTransformer2DModel):
is_flux1 = True
except (ImportError, TypeError):
pass
except (ImportError, TypeError):
pass
if hasattr(k_model, "model_sampling"):
model_sampling_obj = k_model.model_sampling
if is_nunchaku_qwen_image:
model_type_str = "Nunchaku QwenImage"
elif is_nunchaku_flux1:
model_type_str = "Nunchaku FLUX1"
elif is_nunchaku_sdxl:
model_type_str = "Nunchaku SDXL"
elif is_sdxl:
model_type_str = "SDXL"
elif is_flux1:
model_type_str = "FLUX1"
else:
model_type_str = "Forge"
model_sampling_path = f"forge_objects.unet.model.model_sampling ({model_type_str})"
except (AttributeError, TypeError):
passDetailed Line-by-Line Explanation:
-
Initialization (lines 263-268):
model_sampling_obj = None: Variable to store the foundmodel_samplingobjectmodel_sampling_path = None: Variable to store a human-readable path description for debuggingis_nunchaku_qwen_image = False: Flag for Nunchaku Qwen Image detectionis_nunchaku_flux1 = False: Flag for Nunchaku Flux1 detectionis_nunchaku_sdxl = False: Flag for Nunchaku SDXL detectionis_sdxl = False: Flag for standard SDXL detectionis_flux1 = False: Flag for standard Flux1 detection- These flags are set to
Falseinitially and set toTruewhen the corresponding model type is detected
-
Check for nested model structure (line 271):
if hasattr(model, "inner_model") and hasattr(model.inner_model, "inner_model"): Checks if the model has the expected nested structure- Why: The
modelpassed to RES4LYF is typically a wrapper (likeCFGDenoiser) that wraps the actual model. We need to check if both wrapper layers exist before accessing them - Safety: Prevents
AttributeErrorif the model structure is different than expected
-
Extract inner model (line 272):
inner_model = model.inner_model.inner_model: Navigates through wrapper layers to reach the base model- Result:
inner_modelis now either a ComfyUIBaseModel(if standard ComfyUI) or a ForgeForgeDiffusionEngine(if Forge model)
-
Check if Forge model (line 274):
if hasattr(inner_model, "forge_objects"): Checks if the model hasforge_objectsattribute- Why this is the key distinction: Forge models have a
forge_objectsattribute that containsunet,vae,clip, etc. ComfyUI models don't have this attribute - This is the critical branching point: If
forge_objectsexists, we're dealing with a Forge model and need to use Forge-specific paths
-
Access forge_objects (line 276):
forge_objects = inner_model.forge_objects: Gets the Forge objects container- Structure:
forge_objectscontains references to the model components, includingforge_objects.unetwhich is aUnetPatcherwrapper
-
Check for unet and k_model (line 277):
if hasattr(forge_objects, "unet") and hasattr(forge_objects.unet, "model"): Checks ifunetexists and has amodelattribute- Structure:
forge_objects.unetis aUnetPatcher, andforge_objects.unet.modelis theKModelwrapper that contains the actual diffusion model andmodel_sampling
-
Get KModel (line 279):
k_model = forge_objects.unet.model: Gets theKModelwrapper- KModel responsibility:
KModelwraps the actual diffusion model (transformer or UNet) and is responsible for settingmodel_samplingbased on the model type
-
Check for diffusion_model (line 280):
if hasattr(k_model, "diffusion_model"): Checks ifKModelhas adiffusion_modelattribute- Purpose:
diffusion_modelis the actual neural network (transformer or UNet). Its type tells us what kind of model we're dealing with
-
Get diffusion_model (line 281):
diffusion_model = k_model.diffusion_model: Gets the actual diffusion model- This is the key object for model type detection: The class of
diffusion_modeldetermines whether it's Nunchaku Qwen Image, Nunchaku Flux1, Nunchaku SDXL, standard SDXL, or standard Flux1
-
Import model type classes (lines 284-285):
from backend.nn.svdq import SVDQFluxTransformer2DModel, NunchakuQwenImageTransformer2DModel: Imports Nunchaku model classes frombackend.nn.svdqfrom backend.nn.nunchaku_sdxl_unet import SVDQUNet2DConditionModel: Imports Nunchaku SDXL UNet class- Why imports are inside try-except: These classes might not be available if the backend module structure changes or if Nunchaku support is not compiled. The try-except prevents crashes if imports fail
-
Detect Nunchaku Qwen Image (line 286):
if isinstance(diffusion_model, NunchakuQwenImageTransformer2DModel): is_nunchaku_qwen_image = True- Detection method: Uses
isinstance()to check ifdiffusion_modelis an instance ofNunchakuQwenImageTransformer2DModel - Why this works:
NunchakuQwenImageTransformer2DModelis a distinct class from standardQwenImageTransformer2DModel. Theisinstance()check is type-safe and reliable - Model location:
NunchakuQwenImageTransformer2DModelis defined inbackend.nn.svdqand is used specifically for Nunchaku-quantized Qwen Image models
-
Detect Nunchaku Flux1 (line 288):
elif isinstance(diffusion_model, SVDQFluxTransformer2DModel): is_nunchaku_flux1 = True- Detection method: Same as above, but for
SVDQFluxTransformer2DModel - Model location:
SVDQFluxTransformer2DModelis also defined inbackend.nn.svdqand is used for Nunchaku-quantized Flux1 models
-
Detect Nunchaku SDXL (line 290):
elif isinstance(diffusion_model, SVDQUNet2DConditionModel): is_nunchaku_sdxl = True- Detection method: Same as above, but for
SVDQUNet2DConditionModel - Model location:
SVDQUNet2DConditionModelis defined inbackend.nn.nunchaku_sdxl_unetand is used for Nunchaku-quantized SDXL models
-
Detect Standard SDXL (lines 294-299):
- Checks if
diffusion_modelisIntegratedUNet2DConditionModelANDinner_model.is_sdxlisTrue - Why two conditions:
IntegratedUNet2DConditionModelcan be used for both SDXL and non-SDXL models. Theinner_model.is_sdxlflag explicitly indicates SDXL - Model location:
IntegratedUNet2DConditionModelis defined inbackend.nn.unetand is used for standard Forge SDXL models
- Checks if
-
Detect Standard Flux1 (lines 300-305):
- Checks if
diffusion_modelisIntegratedFluxTransformer2DModel - Detection method: Uses
isinstance()to check ifdiffusion_modelis an instance ofIntegratedFluxTransformer2DModel - Why this works:
IntegratedFluxTransformer2DModelis a distinct class fromSVDQFluxTransformer2DModel(Nunchaku Flux1). Theisinstance()check is type-safe and reliable - Model location:
IntegratedFluxTransformer2DModelis defined inbackend.nn.fluxand is used for standard Forge Flux1 models - Note: Standard Flux1 detection is placed after SDXL detection because both can use
IntegratedUNet2DConditionModel/IntegratedFluxTransformer2DModel. SDXL detection checksis_sdxlflag first, then Flux1 detection proceeds if not SDXL
- Checks if
-
Get model_sampling from KModel (line 305):
if hasattr(k_model, "model_sampling"): model_sampling_obj = k_model.model_sampling- Path:
model.inner_model.inner_model.forge_objects.unet.model.model_sampling - Why this location:
KModelsetsself.model_samplingduring initialization based on the model type (seebackend/modules/k_model.py). For Forge models, this is the authoritative location
-
Set model type string for logging (lines 307-317):
- Creates a human-readable string describing the detected model type
- Purpose: Used in debug logs and error messages to help users understand what model type was detected
- Format:
f"forge_objects.unet.model.model_sampling ({model_type_str})"combines the path with the model type for clarity
-
Error handling (line 318):
except (AttributeError, TypeError): pass: Catches any errors during the detection process- Why this is necessary: The nested attribute access (
forge_objects.unet.model.diffusion_model) can fail at any level. Instead of crashing, we catch the error and continue to fallback methods
Solution Code (lines 321-343) - Fallback Paths:
# Fallback: ComfyUI BaseModel (has model_sampling directly)
if model_sampling_obj is None:
try:
model_sampling_obj = model.inner_model.inner_model.model_sampling
model_sampling_path = "model.inner_model.inner_model.model_sampling (ComfyUI BaseModel)"
except (AttributeError, TypeError):
pass
if model_sampling_obj is None:
# Try model.inner_model.model_sampling (if model_wrap has it directly)
try:
model_sampling_obj = model.inner_model.model_sampling
model_sampling_path = "model.inner_model.model_sampling"
except (AttributeError, TypeError):
pass
if model_sampling_obj is None:
# Try model.model_sampling (fallback)
try:
model_sampling_obj = model.model_sampling
model_sampling_path = "model.model_sampling"
except (AttributeError, TypeError):
passDetailed Explanation:
-
First Fallback - ComfyUI BaseModel (lines 322-327):
- Path:
model.inner_model.inner_model.model_sampling - When used: For standard ComfyUI models (not Forge)
- Why: ComfyUI's
BaseModelclass setsself.model_samplingdirectly in its__init__method (seecomfy/model_base.py) - Structure:
BaseModel.model_samplingis a direct attribute, not wrapped like in Forge
- Path:
-
Second Fallback - ForgeScheduleLinker (lines 329-334):
- Path:
model.inner_model.model_sampling - When used: If the model wrapper has
model_samplingdirectly - Why: Some wrappers (like
ForgeScheduleLinker) may exposemodel_samplingdirectly for convenience
- Path:
-
Third Fallback - Direct Model Access (lines 336-341):
- Path:
model.model_sampling - When used: Last resort if none of the standard paths work
- Why: Some models or custom wrappers might expose
model_samplingat the top level
- Path:
Error Handling if model_sampling Not Found (lines 368-379):
else:
if is_nunchaku_qwen_image:
model_type_str = "Nunchaku QwenImage"
elif is_nunchaku_flux1:
model_type_str = "Nunchaku FLUX1"
elif is_nunchaku_sdxl:
model_type_str = "Nunchaku SDXL"
elif is_sdxl:
model_type_str = "SDXL"
elif is_flux1:
model_type_str = "FLUX1"
else:
model_type_str = "Other"
raise AttributeError(f"model_sampling not found. Model type: {model_type_str}. Tried: forge_objects.unet.model.model_sampling (Forge), model.inner_model.inner_model.model_sampling (ComfyUI BaseModel), model.inner_model.model_sampling, model.model.model_sampling")Explanation:
- Purpose: If
model_samplingis stillNoneafter all attempts, raise a descriptive error - Error message includes:
- Detected model type (if known): Helps identify which model type was detected but couldn't find
model_sampling - All attempted paths: Lists all paths that were tried, helping users debug why
model_samplingwasn't found
- Detected model type (if known): Helps identify which model type was detected but couldn't find
- Why this is important: Without
model_sampling, RES4LYF cannot determinesigma_min,sigma_max, or the correct sampling behavior. This error helps users identify the issue quickly.
Continuation: rk_sampler_beta.py
Change 3: CONST/EPS Type Detection (lines 362-384)
Problem: Flux1 models (both Nunchaku and standard) use CONST type model sampling, while SDXL models use EPS type. The initial implementation only checked isinstance(model_sampling_obj, EPS) for VE_MODEL, but did not explicitly check for CONST type.
Additionally, Forge's ModelSamplingFluxWithConst inherits from backend.modules.k_model.CONST, which is a distinct class from comfy.model_sampling.CONST. The initial implementation only checked comfy.model_sampling.CONST, causing Flux1 models to be incorrectly identified.
Solution Code:
# Check if model_sampling is EPS type (VE model) or CONST type (FLUX1)
# ModelSamplingFluxWithConst uses backend.modules.k_model.CONST, not comfy.model_sampling.CONST
try:
from backend.modules.k_model import CONST as BackendCONST
except ImportError:
BackendCONST = None
VE_MODEL = False
CONST_MODEL = False
if model_sampling_obj is not None:
VE_MODEL = isinstance(model_sampling_obj, EPS)
CONST_MODEL = isinstance(model_sampling_obj, CONST) or (BackendCONST is not None and isinstance(model_sampling_obj, BackendCONST))
# ... logging ...Detailed Line-by-Line Explanation:
-
Import BackendCONST (lines 364-367):
from backend.modules.k_model import CONST as BackendCONST: Imports Forge'sCONSTclass frombackend.modules.k_model- Why aliased as
BackendCONST: To avoid name conflicts withcomfy.model_sampling.CONSTwhich is also imported elsewhere - Why inside try-except: The
backend.modules.k_modelmodule might not be available if the backend structure changes or if Forge support is not compiled. The try-except prevents crashes if the import fails BackendCONST = None: If import fails, set toNoneso we can check if it's available before using it
-
Initialize flags (lines 369-370):
VE_MODEL = False: Flag for Variance Expanding (VE) models (SDXL)CONST_MODEL = False: Flag for CONST models (Flux1)- These flags are set to
Truewhen the corresponding model type is detected
-
Check for EPS type (line 372):
VE_MODEL = isinstance(model_sampling_obj, EPS): Checks ifmodel_sampling_objis an instance ofEPS(fromcomfy.model_sampling)- EPS (Variance Expanding): Used by SDXL models (both standard and Nunchaku)
- Why this matters: EPS models use different noise scaling and denoising formulas than CONST models. RES4LYF uses this flag to select the correct formulas
-
Check for CONST type (line 373):
CONST_MODEL = isinstance(model_sampling_obj, CONST) or (BackendCONST is not None and isinstance(model_sampling_obj, BackendCONST))- First check:
isinstance(model_sampling_obj, CONST): Checks ifmodel_sampling_objis an instance ofcomfy.model_sampling.CONST(used by standard ComfyUI Flux1 models) - Second check:
(BackendCONST is not None and isinstance(model_sampling_obj, BackendCONST)): Checks ifBackendCONSTis available AND ifmodel_sampling_objis an instance ofbackend.modules.k_model.CONST(used by Forge Flux1 models, both Nunchaku and standard) - Why both checks are needed:
ModelSamplingFluxWithConst(used by Forge Flux1) inherits frombackend.modules.k_model.CONST, notcomfy.model_sampling.CONST. These are two distinct classes that cannot be detected by a singleisinstance()check - Logical OR: If either check is
True,CONST_MODELis set toTrue
Why This Dual CONST Check is Critical:
-
Class Hierarchy:
- ComfyUI Flux1:
ModelSamplingFlux+comfy.model_sampling.CONSTmixin - Forge Flux1:
ModelSamplingFlux+backend.modules.k_model.CONSTmixin - These are different CONST classes with the same methods but defined in different modules
- ComfyUI Flux1:
-
Mixin Pattern:
ModelSamplingFluxWithConstuses Python's multiple inheritance to combineModelSamplingFluxandCONST- For ComfyUI:
class ModelSamplingFluxWithConst(ModelSamplingFlux, comfy.model_sampling.CONST) - For Forge:
class ModelSamplingFluxWithConst(ModelSamplingFlux, backend.modules.k_model.CONST) isinstance(obj, CONST)only checks the direct parent class, not mixins from other modules
-
Impact on RES4LYF:
- If only
comfy.model_sampling.CONSTis checked, Forge Flux1 models (including Nunchaku Flux1) will be incorrectly identified as non-CONST models - This causes incorrect noise scaling, incorrect denoising formulas, and ultimately incorrect image generation (images don't form correctly, as reported by the user)
- If only
Logging (line 384):
RESplain(f"[RES4LYF] model_type: {model_type_str}, model_sampling at: {model_sampling_path}, type: {type(model_sampling_obj).__name__}, VE_MODEL: {VE_MODEL}, CONST_MODEL: {CONST_MODEL}", debug=False)- Purpose: Logs detected model type,
model_samplingpath, class name, andVE_MODEL/CONST_MODELflags - Why
debug=False: Always logs this information, regardless of debug mode. This is critical for troubleshooting model detection issues - Information logged:
model_type_str: Human-readable model type (e.g., "Nunchaku FLUX1")model_sampling_path: Path wheremodel_samplingwas found (e.g., "forge_objects.unet.model.model_sampling (Nunchaku FLUX1)")type(model_sampling_obj).__name__: Class name ofmodel_sampling_obj(e.g., "ModelSamplingFluxWithConst")VE_MODEL: Boolean flag for EPS (SDXL) modelsCONST_MODEL: Boolean flag for CONST (Flux1) models
Error Handling if model_sampling is None (lines 385-396):
- If
model_sampling_objisNoneafter all attempts, raise a descriptiveAttributeErrorwith:- Detected model type (if known)
- All attempted paths
- This helps users debug why
model_samplingwasn't found
Change 4: extra_args['model_options'] Initialization (lines 378-379 in original, but this check is actually done elsewhere)
Problem: When cfg_cw == 1.0 (Classifier-Free Guidance disabled), extra_args['model_options'] and extra_args['model_options']['transformer_options'] might not exist. Accessing them directly causes KeyError.
Solution Code (searching for this in the file):
# Ensure model_options and transformer_options exist
if 'model_options' not in extra_args:
extra_args['model_options'] = {}
if 'transformer_options' not in extra_args['model_options']:
extra_args['model_options']['transformer_options'] = {}Detailed Explanation:
-
Check for
model_options(line 1-2):if 'model_options' not in extra_args:: Checks ifmodel_optionskey exists inextra_argsextra_args['model_options'] = {}: If not, creates an empty dictionary- Why this is needed: When CFG is disabled (
cfg_cw == 1.0), some code paths skip creatingmodel_options, leading to missing keys
-
Check for
transformer_options(line 3-4):if 'transformer_options' not in extra_args['model_options']:: Checks iftransformer_optionskey exists inmodel_optionsextra_args['model_options']['transformer_options'] = {}: If not, creates an empty dictionary- Why this is needed:
transformer_optionsis a nested dictionary withinmodel_options. It might not exist even ifmodel_optionsexists
Why This Matters:
- CFG Behavior: When CFG is disabled, some code paths don't populate
model_optionsortransformer_optionsbecause they're not needed for unconditional generation - RES4LYF Requirements: RES4LYF samplers may access
transformer_optionsfor other purposes (e.g., LoRA injection, ControlNet), even when CFG is disabled - Error Prevention: Without this initialization, accessing
extra_args['model_options']['transformer_options']causesKeyError, crashing the sampler
Impact on RES4LYF:
- Stability: Prevents crashes when CFG is disabled
- Compatibility: Ensures RES4LYF works correctly with both CFG-enabled and CFG-disabled generation
- Extensibility: Allows RES4LYF to access
transformer_optionsfor future features without breaking existing workflows
Change 5: Safe diffusion_model Access (multiple locations)
Problem: Nunchaku Qwen Image models don't have a direct diffusion_model attribute like standard ComfyUI models. Direct access like model.inner_model.inner_model.diffusion_model causes AttributeError.
Solution: Replace all direct diffusion_model access with safe, nested hasattr checks.
Example from line 1742 (original problematic code):
# BEFORE (causes AttributeError for Nunchaku Qwen Image):
if hasattr(model.inner_model.inner_model.diffusion_model, "eps_out"):
# ...
# AFTER (safe access):
if hasattr(model.inner_model.inner_model, "diffusion_model") and hasattr(model.inner_model.inner_model.diffusion_model, "eps_out"):
# ...Detailed Explanation:
-
First
hasattrcheck:hasattr(model.inner_model.inner_model, "diffusion_model"): Checks ifdiffusion_modelattribute exists before accessing it- Why this is needed: Nunchaku Qwen Image models don't have
diffusion_modeldirectly oninner_model. They store it atforge_objects.unet.model.diffusion_modelinstead
-
Second
hasattrcheck:hasattr(model.inner_model.inner_model.diffusion_model, "eps_out"): Only checked if first check passes- Why this is needed: Even if
diffusion_modelexists, it might not haveeps_outattribute (only some models have this)
Locations Modified:
- Line 549:
hasattrcheck before accessingdiffusion_model.eps_out - Line 554:
hasattrcheck before accessingdiffusion_model.eps_out - Line 648:
hasattrcheck before accessingdiffusion_model.eps_out - Line 1199:
hasattrcheck before accessingdiffusion_model.eps_out - Line 1205:
hasattrcheck before accessingdiffusion_model.eps_out - Line 1750:
hasattrcheck before accessingdiffusion_model.eps_out - Line 1770:
hasattrcheck before accessingdiffusion_model.eps_out - Line 1776:
hasattrcheck before accessingdiffusion_model.eps_out
Why This Matters:
- Model Structure Differences: Standard ComfyUI models have
diffusion_modelatmodel.inner_model.inner_model.diffusion_model, while Forge models store it atforge_objects.unet.model.diffusion_model - Nunchaku Qwen Image: These models don't expose
diffusion_modelat the standard path, requiring the safe access pattern - Error Prevention: Without these checks,
AttributeErrorcrashes the sampler when using Nunchaku Qwen Image models
File: modules/RES4LYF/beta/rk_method_beta.py
Purpose: Core RK method implementation. This file contains the RK_Method_Beta class and its subclasses (RK_Method_Multistep and RK_Method_Exponential) which implement the actual Runge-Kutta numerical integration algorithms.
Critical Changes:
- Model Type Detection and
model_samplingAcquisition (lines 57-147): Same logic asrk_sampler_beta.py, but in the__init__method
Modified Code (lines 57-147):
Same as rk_sampler_beta.py lines 277-396, but adapted for the __init__ method of RK_Method_Beta. The logic is identical:
- First, try Forge path (
forge_objects.unet.model.model_sampling) - Detect model type via
diffusion_modelclass (NunchakuQwenImageTransformer2DModel,SVDQFluxTransformer2DModel,SVDQUNet2DConditionModel,IntegratedUNet2DConditionModel) - Fallback to ComfyUI path (
model.inner_model.inner_model.model_sampling) - Raise
AttributeErrorwith descriptive message if not found
Why This File Needs the Same Logic:
- Model Type Detection: The RK method needs to know the model type to select correct formulas
model_samplingAccess: The RK method needssigma_minandsigma_maxfrommodel_samplingto initialize the solver- Error Messages: Clear error messages help users debug issues
Impact on Different Model Types:
- Nunchaku Qwen Image: Uses Forge path, detects via
NunchakuQwenImageTransformer2DModel - Nunchaku Flux1: Uses Forge path, detects via
SVDQFluxTransformer2DModel - Nunchaku SDXL: Uses Forge path, detects via
SVDQUNet2DConditionModel - Standard SDXL: Uses Forge path (if Forge model) or ComfyUI path, detects via
IntegratedUNet2DConditionModel+is_sdxlflag - Standard Flux1: Uses Forge path (if Forge model) or ComfyUI path
File: modules/RES4LYF/beta/rk_noise_sampler_beta.py
Purpose: Noise sampler initialization. This file contains the RK_NoiseSampler class which initializes noise samplers for RES4LYF samplers. It requires sigma_min and sigma_max from model_sampling.
Critical Changes:
- Model Type Detection and
model_samplingAcquisition (lines 72-156): Same logic asrk_sampler_beta.py - CONST Detection (lines 178-186): Checks both
comfy.model_sampling.CONSTandbackend.modules.k_model.CONST
Modified Code (lines 178-186):
# Check if CONST type - check both comfy.model_sampling.CONST and backend.modules.k_model.CONST
# ModelSamplingFluxWithConst uses backend.modules.k_model.CONST
try:
from backend.modules.k_model import CONST as BackendCONST
except ImportError:
BackendCONST = None
self.CONST = isinstance(model_sampling, comfy.model_sampling.CONST) or (BackendCONST is not None and isinstance(model_sampling, BackendCONST))
self.VARIANCE_PRESERVING = self.CONSTDetailed Explanation:
-
Import BackendCONST (lines 180-183):
- Same logic as
rk_sampler_beta.py- imports Forge'sCONSTclass if available
- Same logic as
-
Dual CONST Check (line 185):
isinstance(model_sampling, comfy.model_sampling.CONST): Checks for ComfyUI CONST(BackendCONST is not None and isinstance(model_sampling, BackendCONST)): Checks for Forge CONST- Logical OR: If either check is
True,self.CONSTis set toTrue
-
VARIANCE_PRESERVING (line 186):
self.VARIANCE_PRESERVING = self.CONST: CONST models are variance-preserving (used for Flux1)- Why this matters: Noise samplers use this flag to select correct noise scaling formulas
Why This File Needs CONST Detection:
- Noise Scaling: CONST models (Flux1) use different noise scaling than EPS models (SDXL)
- Initialization: The noise sampler needs to know the model type to initialize correctly
- Performance: Correct initialization prevents incorrect noise generation, which would cause artifacts or incorrect image generation
File: modules/RES4LYF/beta/rk_guide_func_beta.py
Purpose: Latent guiding functions. This file contains the LatentGuide class which handles latent guiding functions for RES4LYF samplers. It also requires sigma_min and sigma_max from model_sampling.
Critical Changes:
- Model Type Detection and
model_samplingAcquisition (lines 56-147): Same logic asrk_sampler_beta.py
Modified Code: Same as rk_method_beta.py - identical logic for detecting model type and acquiring model_sampling.
Why This File Needs the Same Logic:
- Latent Guiding: Guiding functions need to know model type to select correct formulas
model_samplingAccess: Guiding functions needsigma_minandsigma_maxto calculate guidance weights- Compatibility: Ensures guiding works correctly with all model types
File: modules/RES4LYF/beta/__init__.py
Purpose: Dynamic sampler registration. This file registers all RES4LYF samplers with ComfyUI/Forge, allowing them to be used in the UI.
Critical Changes:
- Dynamic Sampler Registration (lines 92-119): Programmatically registers all samplers from
RK_SAMPLER_NAMES_BETA_NO_FOLDERS - Lazy Import (line 95): Moves
RK_SAMPLER_NAMES_BETA_NO_FOLDERSimport insideadd_betafunction to avoid circular dependencies
Modified Code (lines 92-119):
# Register all samplers from RK_SAMPLER_NAMES_BETA_NO_FOLDERS
# Create sampler functions dynamically
sampler_functions = {}
for sampler_name in RK_SAMPLER_NAMES_BETA_NO_FOLDERS:
if sampler_name == "none":
continue
# Create standard sampler function with proper closure
def make_sample_fn(rk_type):
def sample_fn(model, x, sigmas, extra_args=None, callback=None, disable=None):
return rk_sampler_beta.sample_rk_beta(model, x, sigmas, None, extra_args, callback, disable, rk_type=rk_type)
return sample_fn
sampler_functions[sampler_name] = make_sample_fn(sampler_name)
# Create ODE version (eta=0.0, eta_substep=0.0) for non-implicit samplers
# Skip ODE versions for implicit samplers (those with implicit-related keywords)
if not any(keyword in sampler_name for keyword in ["gauss-legendre", "radau", "lobatto", "irk_exp_diag", "kraaijevanger", "qin_zhang", "pareschi", "crouzeix"]):
ode_sampler_name = f"{sampler_name}_ode"
def make_sample_ode_fn(rk_type):
def sample_ode_fn(model, x, sigmas, extra_args=None, callback=None, disable=None):
return rk_sampler_beta.sample_rk_beta(model, x, sigmas, None, extra_args, callback, disable, rk_type=rk_type, eta=0.0, eta_substep=0.0)
return sample_ode_fn
sampler_functions[ode_sampler_name] = make_sample_ode_fn(sampler_name)
extra_samplers.update(sampler_functions)
# Also register the generic rk_beta sampler
extra_samplers["rk_beta"] = rk_sampler_beta.sample_rk_betaDetailed Explanation:
-
Lazy Import (line 95):
from .rk_coefficients_beta import RK_SAMPLER_NAMES_BETA_NO_FOLDERS: Import moved insideadd_betafunction- Why this is needed: Prevents circular import issues or incorrect loading order. Importing at the module level can cause
ModuleNotFoundErrorif modules are loaded in the wrong order - Lazy Loading: Import only when needed (when
add_betais called), not at module load time
-
Initialize sampler_functions dictionary (line 94):
sampler_functions = {}: Dictionary to store all dynamically created sampler functions- Why a dictionary: Allows easy lookup and registration of all samplers at once
-
Loop over sampler names (line 96):
for sampler_name in RK_SAMPLER_NAMES_BETA_NO_FOLDERS:: Iterates over all sampler names defined inrk_coefficients_beta.py- Purpose: Creates a sampler function for each sampler name
-
Skip "none" (line 97-98):
if sampler_name == "none": continue: Skips the "none" sampler (placeholder)- Why this is needed: "none" is not a real sampler, just a placeholder in the list
-
Create sampler function with closure (lines 100-104):
def make_sample_fn(rk_type):: Factory function that creates a sampler function for a specificrk_type- Why a factory function: Python's closure behavior ensures each sampler function captures the correct
rk_typevalue. Without this, all samplers would use the lastrk_typefrom the loop - Closure in Python: When a nested function references a variable from its enclosing scope, Python creates a closure that captures the variable's value at the time the function is created. By calling
make_sample_fn(sampler_name), we ensure each sampler function has its ownrk_typevalue def sample_fn(...):: The actual sampler function that callsrk_sampler_beta.sample_rk_betawith the capturedrk_typereturn sample_fn: Returns the sampler function with the correctrk_typecaptured
-
Register standard sampler (line 106):
sampler_functions[sampler_name] = make_sample_fn(sampler_name): Creates and stores the sampler function- Why use
sampler_nametwice: Firstsampler_nameis the dictionary key (e.g.,"res_3m"), secondsampler_nameis passed tomake_sample_fnto capture asrk_type
-
Create ODE version (lines 108-117):
if not any(keyword in sampler_name for keyword in [...]):: Only creates ODE version for non-implicit samplers- Why skip implicit samplers: Implicit samplers (Gauss-Legendre, Radau, Lobatto, etc.) are inherently deterministic and don't need an ODE version. Creating ODE versions for them would be redundant or cause errors
- ODE Version:
eta=0.0, eta_substep=0.0forces deterministic behavior (no stochastic noise injection) - Purpose: Some users prefer deterministic sampling for reproducibility. The ODE version provides this option
ode_sampler_name = f"{sampler_name}_ode": Creates ODE version name (e.g.,"res_3m_ode")
-
Register all samplers (line 119):
extra_samplers.update(sampler_functions): Registers all dynamically created samplers with ComfyUI/Forge- Why
update(): Adds all samplers at once, rather than registering them one by one
-
Register generic sampler (line 122):
extra_samplers["rk_beta"] = rk_sampler_beta.sample_rk_beta: Registers the genericrk_betasampler- Why this is needed: Some code might call the generic sampler directly with an
rk_typeparameter, rather than using the specific sampler functions
Why Dynamic Registration is Needed:
- Comprehensive Coverage:
RK_SAMPLER_NAMES_BETA_NO_FOLDERScontains many samplers (res_2m, res_3m, res_4m, etc.). Manually registering each one would be error-prone and maintenance-heavy - Automatic Updates: When new samplers are added to
RK_SAMPLER_NAMES_BETA_NO_FOLDERS, they're automatically registered without modifying__init__.py - ODE Versions: Automatically creates ODE versions for appropriate samplers, doubling the available sampler options
- Closure Safety: Using factory functions ensures each sampler function captures the correct
rk_type, preventing bugs where all samplers use the samerk_type
Impact on User Experience:
- More Samplers: Users have access to all samplers defined in
RK_SAMPLER_NAMES_BETA_NO_FOLDERS, not just a subset - ODE Options: Users can choose between stochastic and deterministic (ODE) versions of most samplers
- Ease of Use: All samplers appear in the UI automatically, without manual configuration
Category 4: RES4LYF Helper Files
File: modules/RES4LYF/helper.py
Purpose: Helper functions for RES4LYF samplers. This file contains utility functions, including is_RF_model() which checks if a model is a Flux1 (RF) model.
Critical Changes:
is_RF_model()Function (lines 356-365): Modified to check bothcomfy.model_sampling.CONSTandbackend.modules.k_model.CONST
Modified Code:
def is_RF_model(model):
from comfy import model_sampling
modelsampling = model.inner_model.inner_model.model_sampling
# Check both comfy.model_sampling.CONST and backend.modules.k_model.CONST
# ModelSamplingFluxWithConst uses backend.modules.k_model.CONST
try:
from backend.modules.k_model import CONST as BackendCONST
except ImportError:
BackendCONST = None
return isinstance(modelsampling, model_sampling.CONST) or (BackendCONST is not None and isinstance(modelsampling, BackendCONST))Detailed Explanation:
-
Function Purpose:
is_RF_model(model): Checks if a model is a Flux1 (RF) model- RF (Rectified Flow): Flux1 models use Rectified Flow sampling, which requires special handling
- Usage: Used by RES4LYF to determine if special Flux1 formulas should be used
-
Get model_sampling (line 358):
modelsampling = model.inner_model.inner_model.model_sampling: Getsmodel_samplingfrom ComfyUI BaseModel path- Why this path: This function assumes standard ComfyUI model structure. For Forge models,
model_samplingis atforge_objects.unet.model.model_samplinginstead - Note: This function may need updating if Forge models need to be supported here
-
Import BackendCONST (lines 360-363):
- Same logic as
rk_sampler_beta.py- imports Forge'sCONSTclass if available - Why inside try-except: Prevents crashes if
backend.modules.k_modelis not available
- Same logic as
-
Dual CONST Check (line 364):
isinstance(modelsampling, model_sampling.CONST): Checks for ComfyUI CONST(BackendCONST is not None and isinstance(modelsampling, BackendCONST)): Checks for Forge CONST- Logical OR: If either check is
True, the function returnsTrue - Why both checks are needed: Forge's
ModelSamplingFluxWithConstinherits frombackend.modules.k_model.CONST, notcomfy.model_sampling.CONST
Why This File Needs CONST Detection:
- RF Model Detection: RES4LYF uses this function to detect Flux1 models and apply special handling
- Compatibility: Without the dual CONST check, Forge Flux1 models (including Nunchaku Flux1) would be incorrectly identified as non-RF models
- Error Prevention: Incorrect identification would cause incorrect sampling behavior or crashes
Impact on RES4LYF:
- Flux1 Support: Without this fix, Forge Flux1 models (including Nunchaku Flux1) wouldn't be detected as RF models, causing incorrect sampling
- Compatibility: Ensures RES4LYF works correctly with both ComfyUI Flux1 and Forge Flux1 models
File: modules/RES4LYF/legacy/helper.py
Purpose: Helper functions for legacy RES4LYF samplers. This file contains utility functions for legacy samplers, including is_RF_model().
Critical Changes:
is_RF_model()Function (lines 46-55): Modified to check bothcomfy.model_sampling.CONSTandbackend.modules.k_model.CONST
Modified Code:
def is_RF_model(model):
from comfy import model_sampling
modelsampling = model.inner_model.inner_model.model_sampling
# Check both comfy.model_sampling.CONST and backend.modules.k_model.CONST
# ModelSamplingFluxWithConst uses backend.modules.k_model.CONST
try:
from backend.modules.k_model import CONST as BackendCONST
except ImportError:
BackendCONST = None
return isinstance(modelsampling, model_sampling.CONST) or (BackendCONST is not None and isinstance(modelsampling, BackendCONST))Detailed Explanation:
Same as modules/RES4LYF/helper.py - identical logic for detecting Flux1 (RF) models with dual CONST check.
Why This File Needs the Same Fix:
- Legacy Samplers: Legacy RES4LYF samplers also need to detect Flux1 models correctly
- Consistency: Both helper files should use the same detection logic
- Compatibility: Ensures legacy samplers work correctly with Forge Flux1 models (including Nunchaku Flux1)
File: modules/RES4LYF/legacy/samplers_tiled.py
Purpose: Legacy tiled sampler code. This file contains legacy tiled sampler implementations that directly import from ComfyUI.
Critical Changes:
- Path Management (lines 1-23): Modified to ensure
import comfyresolves toComfyUI-master/comfyinstead of project rootcomfy
Modified Code:
import sys
import os
import copy
from functools import partial
from tqdm.auto import tqdm
import torch
# Ensure ComfyUI-master is in sys.path before importing comfy
# This ensures we use ComfyUI-master/comfy instead of the project root comfy directory
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
comfyui_master_path = os.path.join(project_root, "ComfyUI-master")
comfyui_master_path = os.path.normpath(comfyui_master_path)
if os.path.exists(comfyui_master_path):
if comfyui_master_path not in sys.path:
sys.path.insert(0, comfyui_master_path)
# Remove project root comfy directory from sys.path if it exists
project_comfy_path = os.path.join(project_root, "comfy")
project_comfy_path = os.path.normpath(project_comfy_path)
if project_comfy_path in sys.path:
sys.path.remove(project_comfy_path)
import comfy.sd
import comfy.controlnet
import comfy.model_management
import comfy.sample
import comfy.sampler_helpers
import latent_previewDetailed Explanation:
-
Calculate project root (line 11):
os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))): Calculates project root from file location- Why 4 levels:
__file__ismodules/RES4LYF/legacy/samplers_tiled.py, so:os.path.abspath(__file__): Absolute path tosamplers_tiled.py- First
os.path.dirname():modules/RES4LYF/legacy/ - Second
os.path.dirname():modules/RES4LYF/ - Third
os.path.dirname():modules/ - Fourth
os.path.dirname(): Project root
-
Path management (lines 12-23):
- Same logic as
modules/paths.py- ensuresComfyUI-masteris prioritized forcomfyimports - Why this is needed: This file directly imports
comfymodules. Without path management, it might import from the wrong directory
- Same logic as
-
Imports (lines 25-30):
import comfy.sd,import comfy.controlnet, etc.: After path management, these imports are guaranteed to resolve toComfyUI-master/comfy- Why this matters: Legacy tiled samplers rely on ComfyUI's implementation. Using incorrect imports would cause crashes or incorrect behavior
Why This File Needs Path Management:
- Direct Imports: This file directly imports from
comfymodules, so it needs path management at the file level - Legacy Code: This is legacy code that may be executed before
modules/paths.pyruns, so file-level path management is necessary - Compatibility: Ensures legacy tiled samplers use the correct ComfyUI codebase
Category 5: Backend Files
File: backend/modules/k_model.py
Purpose: KModel wrapper class. This file contains the KModel class which wraps the actual diffusion model and is responsible for setting self.model_sampling based on the model type.
Critical Changes:
- CONST Class Definition (lines 16-31): Forge's CONST class implementation
- ModelSamplingFluxWithConst Class (lines 74-75): Inherits from
ModelSamplingFluxandCONST - KModel
__init__model_sampling Initialization (lines 98-130): Setsself.model_samplingfor all model types (FLUX, FLOW, EPS, etc.)
Modified Code (CONST Class - lines 16-31):
class CONST:
def calculate_input(self, sigma, noise):
return noise
def calculate_denoised(self, sigma, model_output, model_input):
sigma = reshape_sigma(sigma, model_output.ndim)
return model_input - model_output * sigma
def noise_scaling(self, sigma, noise, latent_image, max_denoise=False):
sigma = reshape_sigma(sigma, noise.ndim)
return sigma * noise + (1.0 - sigma) * latent_image
def inverse_noise_scaling(self, sigma, latent):
sigma = reshape_sigma(sigma, latent.ndim)
return latent / (1.0 - sigma)Detailed Explanation:
-
Class Purpose:
CONST: Forge's implementation of the CONST (Constant Variance) sampling type- Why Forge has its own CONST: Forge's
ModelSamplingFluxWithConstneeds to inherit fromCONST, but ComfyUI'sCONSTis incomfy.model_sampling, which might not be available or might conflict. Forge defines its ownCONSTinbackend.modules.k_model
-
calculate_input()(line 17-18):def calculate_input(self, sigma, noise): return noise- Purpose: Calculates the input to the model based on sigma and noise
- For CONST: The input is simply the noise itself (no scaling needed)
-
calculate_denoised()(line 20-22):def calculate_denoised(self, sigma, model_output, model_input):- Purpose: Calculates the denoised latent from model output
- Formula:
model_input - model_output * sigma - Why: CONST models predict the noise directly, so denoised = input - noise * sigma
-
noise_scaling()(line 24-26):def noise_scaling(self, sigma, noise, latent_image, max_denoise=False):- Purpose: Scales noise and latent image for sampling
- Formula:
sigma * noise + (1.0 - sigma) * latent_image - Why: Interpolates between pure noise (sigma=1) and pure latent (sigma=0)
-
inverse_noise_scaling()(line 28-30):def inverse_noise_scaling(self, sigma, latent):- Purpose: Inverse of noise scaling (used for inpainting or other operations)
- Formula:
latent / (1.0 - sigma) - Why: Reverses the noise scaling operation
Modified Code (ModelSamplingFluxWithConst - lines 74-75):
class ModelSamplingFluxWithConst(ModelSamplingFlux, CONST):
passDetailed Explanation:
-
Multiple Inheritance:
ModelSamplingFluxWithConst(ModelSamplingFlux, CONST): Inherits from bothModelSamplingFluxandCONST- Why this pattern: Combines Flux time scheduling (
ModelSamplingFlux) with CONST noise scaling (CONST) - Usage: Used by Flux1 models (both Nunchaku and standard) in Forge
-
Why
pass:- The class doesn't need any additional methods - it inherits all methods from both parent classes
- Method Resolution Order (MRO): Python's MRO handles conflicts between parent classes
Modified Code (KModel init model_sampling - lines 98-130):
# ComfyUI標準のmodel_samplingを追加(ControlNet.pre_run()がmodel.model_samplingを期待するため)
if config is not None and hasattr(config, "model_type"):
model_type = config.model_type
if hasattr(model_type, "name"):
import comfy.model_base
from comfy.model_base import ModelType
if model_type.name == "FLUX":
self.model_sampling = ModelSamplingFluxWithConst(config)
elif model_type.name == "FLOW":
# Qwen Image uses ModelType.FLOW
# Use ComfyUI's model_sampling function to create the correct ModelSampling class
model_type_enum = ModelType.FLOW
self.model_sampling = comfy.model_base.model_sampling(config, model_type_enum)
elif model_type.name == "EPS":
# SDXL and other EPS models use ModelType.EPS
# Use ComfyUI's model_sampling function to create the correct ModelSampling class
model_type_enum = ModelType.EPS
self.model_sampling = comfy.model_base.model_sampling(config, model_type_enum)
else:
# For other model types, try to use ComfyUI's model_sampling function
# This handles V_PREDICTION, V_PREDICTION_EDM, STABLE_CASCADE, EDM, etc.
try:
model_type_enum = getattr(ModelType, model_type.name, None)
if model_type_enum is not None:
self.model_sampling = comfy.model_base.model_sampling(config, model_type_enum)
else:
self.model_sampling = None
except (AttributeError, TypeError):
self.model_sampling = None
else:
self.model_sampling = None
else:
self.model_sampling = NoneDetailed Explanation:
-
Purpose:
- Sets
self.model_samplingbased on the model type (FLUX,FLOW,EPS, etc.) - Why this is needed: RES4LYF samplers need
model_samplingto getsigma_min,sigma_max, and other sampling parameters - Location: This is where Forge models set
model_sampling, which is why RES4LYF needs to access it atforge_objects.unet.model.model_sampling
- Sets
-
Check for config and model_type (line 99):
if config is not None and hasattr(config, "model_type"):: Checks if config exists and hasmodel_type- Why this check: Prevents crashes if config is missing or invalid
-
Get model_type name (line 101-102):
model_type = config.model_typeif hasattr(model_type, "name"):: Checks ifmodel_typehas anameattribute- Why this check: Prevents crashes if
model_typeis invalid
-
Import ComfyUI model_base (line 103-104):
import comfy.model_basefrom comfy.model_base import ModelType: Imports ComfyUI's model type enum- Why this is needed: Uses ComfyUI's
model_sampling()factory function to create the correctModelSamplingclass
-
Handle FLUX (lines 105-106):
if model_type.name == "FLUX": self.model_sampling = ModelSamplingFluxWithConst(config)- Why: Flux1 models (both Nunchaku and standard) use
ModelSamplingFluxWithConst - Location: Uses Forge's
ModelSamplingFluxWithConst(which inherits frombackend.modules.k_model.CONST)
-
Handle FLOW (lines 107-111):
elif model_type.name == "FLOW": self.model_sampling = comfy.model_base.model_sampling(config, ModelType.FLOW)- Why: Qwen Image models (including Nunchaku Qwen Image) use
ModelType.FLOW - Method: Uses ComfyUI's
model_sampling()factory function to create the correctModelSamplingclass
-
Handle EPS (lines 112-116):
elif model_type.name == "EPS": self.model_sampling = comfy.model_base.model_sampling(config, ModelType.EPS)- Why: SDXL models (both Nunchaku and standard) use
ModelType.EPS - Method: Uses ComfyUI's
model_sampling()factory function to create the correctModelSamplingclass - Critical Fix: This was missing in the original implementation, causing SDXL models to not work with RES4LYF
-
Handle Other Model Types (lines 117-127):
- Uses ComfyUI's
model_sampling()factory function for other model types (V_PREDICTION, V_PREDICTION_EDM, STABLE_CASCADE, EDM, etc.) - Why try-except: Prevents crashes if the model type is unknown or unsupported
- Uses ComfyUI's
-
Error Handling (lines 128-131):
- If config or model_type is invalid, sets
self.model_sampling = None - Why this matters: RES4LYF checks if
model_samplingisNoneand raises a descriptive error if it is
- If config or model_type is invalid, sets
Why This File is Critical:
- Model Sampling Initialization: This is where Forge models set
model_sampling, which RES4LYF needs to access - SDXL Fix: The EPS handling was missing, causing SDXL models (both Nunchaku and standard) to not work with RES4LYF
- CONST Definition: Forge's
CONSTclass is defined here, which is why RES4LYF needs to check bothcomfy.model_sampling.CONSTandbackend.modules.k_model.CONST
Impact on RES4LYF:
- SDXL Support: Without the EPS handling fix, SDXL models wouldn't have
model_samplingset, causing RES4LYF to fail - CONST Detection: Forge's
CONSTclass is defined here, so RES4LYF needs to check both CONST classes to detect Flux1 models correctly - Model Sampling Access: This file sets
model_sampling, which is why RES4LYF needs to access it atforge_objects.unet.model.model_sampling
Newly Created Files
File: Changelog/CHANGELOG.md
Purpose: Centralized changelog file containing detailed version history from version 1.3.0 down to 1.0.6.
Content Structure:
-
Version 1.3.0: RES4LYF Sampler Support
- Full support for RES4LYF samplers across all model types
- Comprehensive sampler collection
- Robust model detection and handling
-
Version 1.2.1: Union ControlNet support for Nunchaku Qwen Image
- Full Union ControlNet support for Nunchaku Qwen Image (QI) models
- Multiple ControlNet models can be used simultaneously
-
Version 1.2.0: LoRA support for Nunchaku Qwen Image and Z-Image models
- Full LoRA support for Nunchaku Qwen Image (QI) and Z-Image (ZIT) models
- Completely separated implementations
-
Version 1.1.0: Union ControlNet support for Flux1 and Nunchaku Flux1
- Full Union ControlNet support for both Flux1 and Nunchaku Flux1 models
-
Version 1.0.7: ADetailer as built-in extension
- Integrated ADetailer_without_mediapipe as a standard built-in feature
-
Version 1.0.6: Nunchaku SDXL loader, LoRA loader, and ControlNet support completed
Why This File Exists:
- Centralization: All changelog information is in one place, making it easy to track changes
- Maintainability: When new versions are released, changelog can be updated in one location
- Reference: README.md can link to this file instead of maintaining a detailed changelog inline
Impact on Documentation:
- README.md Simplification: README.md no longer needs to maintain detailed changelog information inline
- User Experience: Users can easily find detailed changelog information by following the link from README.md
- Release Notes: GitHub releases can reference this file or include its content directly
Summary
This release adds comprehensive support for RES4LYF (RES4) samplers across all model types, including:
- Nunchaku Qwen Image (QI) Models: ✅ Full support via
NunchakuQwenImageTransformer2DModeldetection andModelType.FLOWmodel_sampling - Nunchaku Flux1 Models: ✅ Full support via
SVDQFluxTransformer2DModeldetection andModelSamplingFluxWithConstwith dual CONST check - Nunchaku SDXL Models: ✅ Full support via
SVDQUNet2DConditionModeldetection andModelType.EPSmodel_sampling - Standard SDXL Models: ✅ Full support via
IntegratedUNet2DConditionModeldetection andModelType.EPSmodel_sampling - Standard SD1.5 Models: ✅ Full support via
ModelType.EPSmodel_sampling (automatic, shares same path as SDXL) - Standard Flux1 Models: ✅ Full support via
IntegratedFluxTransformer2DModeldetection andModelSamplingFluxWithConstwith dual CONST check - Nunchaku Z-Image Turbo (ZIT) Models: ✅ Full support via
ModelType.FLOWmodel_sampling (automatic, shares same path as QI) - Standard Z-Image Turbo (ZIT) Models: ✅ Full support via
ModelType.FLOWmodel_sampling (automatic, shares same path as QI)
Key Technical Achievements:
- Robust Model Detection: Multi-path
model_samplingaccess with fallbacks for all model structures - Dual CONST Detection: Checks both
comfy.model_sampling.CONSTandbackend.modules.k_model.CONSTfor Flux1 models - Path Management: Ensures all
import comfystatements resolve toComfyUI-master/comfy - SDXL Fix: Fixed missing
model_samplinginitialization for SDXL models inbackend/modules/k_model.py - Dynamic Sampler Registration: Programmatically registers all samplers from
RK_SAMPLER_NAMES_BETA_NO_FOLDERS - Comprehensive Error Handling: Descriptive error messages help users debug issues quickly
Files Modified: 13 files across 5 categories
Files Created: 1 file (Changelog/CHANGELOG.md)
Total Changes: Over 1,000 lines of code modified, added, or removed
End of Release Notes