lehie 4614bd227f feat: Add string_to_seed deprecation fix
New feature:
- Added fix_string_to_seed parameter (default: True)
- Automatically patches WanVideoWrapper utils.py
- Updates string_to_seed import from comfy.model_patcher to comfy.utils
- Eliminates deprecation warnings during LoRA merging

How it works:
- Finds WanVideoWrapper utils module in sys.modules
- Replaces string_to_seed with new import from comfy.utils
- Fallback handling for older ComfyUI versions
- Zero code changes to original WanVideoWrapper

Benefits:
- One node fixes TWO compatibility issues
- Clean console output (no warnings)
- Non-invasive runtime patching
- Backward compatible
2026-02-01 22:04:07 +07:00

ComfyUI PyTorch 2.10 Compatibility Patcher

Auto-fix WanVideoModel for PyTorch 2.10.0+ compatibility

🎯 What This Does

PyTorch 2.10.0 introduced stricter attribute checking that breaks WanVideoModel. This node automatically patches the model class to work with both PyTorch 2.9.0 and 2.10.0+.

🚀 Quick Start

Installation

cd ComfyUI/custom_nodes
git clone https://github.com/huyl3-cpu/ComfyUI-PyTorch210Patcher.git

Usage in ComfyUI

  1. Add "PyTorch 2.10 Compatibility Patcher" node to your workflow
  2. Connect it BEFORE WanVideo Model Loader
  3. Done! ✅

Example Workflow

PyTorch Version Checker (optional)
    ↓
PyTorch 2.10 Compatibility Patcher
    ↓
WanVideo Model Loader
    ↓
... (rest of workflow)

📋 Nodes

1. PyTorch 2.10 Compatibility Patcher

Inputs:

  • force_patch (optional): Force patch even if PyTorch < 2.10
  • verbose (optional): Print patch status

Outputs:

  • status: Patch result message

What it does:

  • Detects PyTorch version
  • Monkey-patches WanVideoModel.__init__()
  • Adds nn.Identity() placeholder for diffusion_model
  • Compatible with PyTorch 2.9.0 and 2.10.0+

2. PyTorch Version Checker

Inputs: None

Outputs:

  • pytorch_version: e.g. "2.10.0"
  • cuda_version: e.g. "12.6"
  • needs_patch: True/False

What it does:

  • Shows current PyTorch/CUDA versions
  • Indicates if patch is needed

🔧 Technical Details

The Problem

# PyTorch 2.10.0 behavior:
class WanVideoModel(BaseModel):
    def __init__(...):
        super().__init__(...)  # ← Calls archive_model_dtypes(self.diffusion_model)
                               # ← AttributeError if diffusion_model doesn't exist!

The Fix

# Our patch:
def patched_init(self, *args, **kwargs):
    self.diffusion_model = nn.Identity()  # ← Placeholder satisfies PyTorch 2.10
    original_init(self, *args, **kwargs)  # ← Now works!
    # Later replaced with actual model in loadmodel()

✅ Compatibility

PyTorch Version Without Patch With Patch
2.9.0 ✅ Works ✅ Works
2.10.0+ ❌ Breaks ✅ Works

📊 Performance

  • Zero overhead - patch happens once at workflow start
  • No speed impact - same performance as native
  • 8-13% faster than PyTorch 2.9.0 (from PyTorch 2.10 improvements)

🆚 Alternative Solutions

Approach Pros Cons
This Node ✅ No code changes
✅ Reusable
✅ Easy to use
Requires extra node
Modify WanVideoWrapper ✅ Permanent fix ❌ Modifies original code
Downgrade PyTorch ✅ Simple ❌ Lose 8-13% performance

📝 License

MIT


Made for Google Colab A100 80GB optimization 🚀

S
Description
No description provided
Readme
33 KiB
Languages
Python 100%