Files
olivv-cs-ComfyUI-FunPack/__init__.py
T
digital-garbageandClaude Fable 5 3dd2d33f1d model: experimental NVFP4 on-the-fly patching for LTX-AV on Blackwell
FunPackNVFP4ModelLoader quantizes an existing bf16/fp16 checkpoint to NVFP4
at load time as a pure state-dict transform: selected 2D Linears are
re-serialized in ComfyUI core's quantized-checkpoint format (packed fp4
weights + fp8-e4m3 block scales + fp32 tensor scale + per-layer comfy_quant
metadata) and handed to the stock loading path. Core's MixedPrecisionOps
then does everything: real FP4 tensor-core GEMMs on sm_100+ (sm_120 incl.),
dynamic activation scales (no calibration pass), per-layer LoRA fallback,
and dequant emulation on older GPUs. No custom forward, no monkeypatching.

Zone-aware precision map for the joint AV transformer: default scope
quantizes only video-branch Linears (attn1/attn2/ff) of the middle blocks;
the audio branch, the audio<->video cross-modal bridges, the first/last N
blocks, and all non-matmul weights stay full precision. Scopes widen to
+cross-modal, all blocks, and all 2D layers for experimentation.

Tests drive the REAL comfy.quant_ops/comfy.ops via comfy_kitchen's eager
backend on CPU: scope selection, serialized-format contract, prefix
handling, refusal of pre-quantized checkpoints, and a load+forward
roundtrip through MixedPrecisionOps on both the NVFP4 and emulation paths.

The Movie Editor Models modal picks the node up automatically as a
Unet/Diffusion Model candidate (object_info-driven).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 06:16:08 +03:00

139 lines
5.6 KiB
Python

# ComfyUI-FunPack/__init__.py
if __package__:
from .conditioning import (
FunPackAdvisorLLM,
FunPackConditioningAdjust,
FunPackLorebookEnhancer,
FunPackPromptCombiner,
FunPackPromptEnhancer,
FunPackSaveRefinementLatent,
FunPackStoryWriter,
FunPackStudio,
FunPackVideoRefinerV2,
)
from .image_processing import (
FunPackClipVisionOutputCombine,
FunPackContinueVideo,
FunPackStoryMemKeyframeExtractor,
FunPackStoryMemLastFrameExtractor,
FunPackVideoStitch,
)
from .model_management import FunPackApplyLoraWeights, FunPackLoraLoader
from .nvfp4_patch import FunPackNVFP4ModelLoader
from .samplers import FunPackHybridEuler2SSampler, FunPackDistilledFlowSampler, FunPackLTXAVSceneChainSampler
from .templates import FunPackRefinementKeyLoader
try:
from . import batch_training # noqa: F401 registers /funpack/batch/* routes
except Exception as _e:
print(f"[FunPack] batch_training routes unavailable: {_e}")
try:
from .movie_editor import server as _movie_editor_server # noqa: F401 registers /funpack/movie/* routes
except Exception as _e:
print(f"[FunPack] Movie Editor routes unavailable: {_e}")
else:
# Standalone tests may not have the full ComfyUI/CUDA runtime loaded.
from conditioning import (
FunPackAdvisorLLM,
FunPackConditioningAdjust,
FunPackLorebookEnhancer,
FunPackPromptCombiner,
FunPackPromptEnhancer,
FunPackSaveRefinementLatent,
FunPackStoryWriter,
FunPackStudio,
FunPackVideoRefinerV2,
)
try:
from image_processing import (
FunPackClipVisionOutputCombine,
FunPackContinueVideo,
FunPackStoryMemKeyframeExtractor,
FunPackStoryMemLastFrameExtractor,
FunPackVideoStitch,
)
except Exception:
FunPackClipVisionOutputCombine = None
FunPackContinueVideo = None
FunPackStoryMemKeyframeExtractor = None
FunPackStoryMemLastFrameExtractor = None
FunPackVideoStitch = None
try:
from model_management import FunPackApplyLoraWeights, FunPackLoraLoader
except Exception:
FunPackApplyLoraWeights = None
FunPackLoraLoader = None
try:
from nvfp4_patch import FunPackNVFP4ModelLoader
except Exception:
FunPackNVFP4ModelLoader = None
try:
from samplers import FunPackHybridEuler2SSampler, FunPackDistilledFlowSampler, FunPackLTXAVSceneChainSampler
except Exception:
FunPackHybridEuler2SSampler = None
FunPackDistilledFlowSampler = None
FunPackLTXAVSceneChainSampler = None
try:
from templates import FunPackRefinementKeyLoader
except Exception:
FunPackRefinementKeyLoader = None
WEB_DIRECTORY = "./web"
NODE_CLASS_MAPPINGS = {
"FunPackAdvisorLLM": FunPackAdvisorLLM,
"FunPackConditioningAdjust": FunPackConditioningAdjust,
"FunPackStudio": FunPackStudio,
"FunPackPromptCombiner": FunPackPromptCombiner,
"FunPackStoryMemKeyframeExtractor": FunPackStoryMemKeyframeExtractor,
"FunPackStoryMemLastFrameExtractor": FunPackStoryMemLastFrameExtractor,
"FunPackPromptEnhancer": FunPackPromptEnhancer,
"FunPackStoryWriter": FunPackStoryWriter,
"FunPackVideoStitch": FunPackVideoStitch,
"FunPackClipVisionOutputCombine": FunPackClipVisionOutputCombine,
"FunPackContinueVideo": FunPackContinueVideo,
"FunPackLorebookEnhancer": FunPackLorebookEnhancer,
"FunPackVideoRefinerV2": FunPackVideoRefinerV2,
"FunPackSaveRefinementLatent": FunPackSaveRefinementLatent,
"FunPackHybridEuler2SSampler": FunPackHybridEuler2SSampler,
"FunPackDistilledFlowSampler": FunPackDistilledFlowSampler,
"FunPackLTXAVSceneChainSampler": FunPackLTXAVSceneChainSampler,
"FunPackApplyLoraWeights": FunPackApplyLoraWeights,
"FunPackLoraLoader": FunPackLoraLoader,
"FunPackNVFP4ModelLoader": FunPackNVFP4ModelLoader,
"FunPackRefinementKeyLoader": FunPackRefinementKeyLoader,
}
NODE_CLASS_MAPPINGS = {name: cls for name, cls in NODE_CLASS_MAPPINGS.items() if cls is not None}
NODE_DISPLAY_NAME_MAPPINGS = {
"FunPackAdvisorLLM": "FunPack Advisor LLM",
"FunPackConditioningAdjust": "FunPack Conditioning Adjust",
"FunPackStudio": "FunPack Studio",
"FunPackPromptCombiner": "FunPack Prompt Combiner",
"FunPackStoryMemKeyframeExtractor": "FunPack StoryMem Keyframe Extractor",
"FunPackStoryMemLastFrameExtractor": "FunPack StoryMem Last Frame Extractor",
"FunPackPromptEnhancer": "FunPack Prompt Enhancer (Standalone)",
"FunPackStoryWriter": "FunPack Story Writer",
"FunPackVideoStitch": "FunPack Video Stitch",
"FunPackClipVisionOutputCombine": "FunPack CLIP Vision Output Combine",
"FunPackContinueVideo": "FunPack Continue Video",
"FunPackLorebookEnhancer": "FunPack Lorebook Enhancer",
"FunPackVideoRefinerV2": "FunPack Video Refiner V2",
"FunPackSaveRefinementLatent": "FunPack Save Refinement Latent",
"FunPackHybridEuler2SSampler": "FunPack Hybrid Euler 2S Sampler",
"FunPackDistilledFlowSampler": "FunPack Distilled Flow Sampler",
"FunPackLTXAVSceneChainSampler": "FunPack LTXAV Scene Chain Sampler",
"FunPackApplyLoraWeights": "FunPack Apply LoRA Weights",
"FunPackLoraLoader": "FunPack LoRA Loader",
"FunPackNVFP4ModelLoader": "FunPack NVFP4 Model Loader (Experimental)",
"FunPackRefinementKeyLoader": "FunPack Refinement Key Loader",
}
__all__ = [
"NODE_CLASS_MAPPINGS",
"NODE_DISPLAY_NAME_MAPPINGS",
"WEB_DIRECTORY",
]