Skip to content

fix: replace invalid kornia pad import with F.pad in pyramid_blending - #556

Open
Jhonny Rosa (lordekeen) wants to merge 1 commit into
Lightricks:masterfrom
lordekeen:dev
Open

Jhonny Rosa (lordekeen) wants to merge 1 commit into
Lightricks:masterfrom
lordekeen:dev

Conversation

@lordekeen

Copy link
Copy Markdown

Description

This PR fixes a critical ImportError that prevents the custom node from loading correctly in ComfyUI, caused by an invalid import of pad from the kornia library.

The Bug

When ComfyUI attempts to load the custom node, the following exception is thrown:

ImportError: cannot import name 'pad' from 'kornia.geometry.transform.pyramid'

kornia.geometry.transform.pyramid does not expose a pad function. Internally, Kornia relies on PyTorch's torch.nn.functional.pad.

The Fix

  1. Removed invalid import: Removed pad from the kornia.geometry.transform.pyramid import block in pyramid_blending.py.
  2. Updated padding logic: Replaced the erroneous pad(...) calls in _pad_for_laplacian and _gaussian_pyramid with F.pad(..., mode="reflect") (using PyTorch's functional API which was already imported as F).
  3. Added Unit Tests: Added a new test suite at tests/test_pyramid_blending.py that fully verifies:
    • Successful module imports.
    • Correct spatial padding dimensions in _pad_for_laplacian.
    • Correct output levels in _gaussian_pyramid.
    • Successful execution of the overall _pyramid_blend operation.

Testing Instructions

  1. Run the new test suite via pytest:
    pytest custom_nodes/ComfyUI-LTXVideo/tests/test_pyramid_blending.py --import-mode=importlib
  2. Start ComfyUI and verify that LTXVLaplacianPyramidBlend initializes successfully without throwing an ImportError.

@EKI-INDRADI

EKI INDRADI (EKI-INDRADI) commented Sep 19, 2026 •

Copy link
Copy Markdown

thanks work for me

replace pad to F.pad

ubuntu 24.04 LTS
2 gpu RTX 5060 TI

depedency :
Python 3.12
pip install torch==2.11.0 torchvision==0.26.0 torchaudio==2.11.0 --index-url https://download.pytorch.org/whl/cu130
pip install xformers --no-deps
pip install ninja packaging wheel
pip install sageattention-2.2.0-cp312-cp312-linux_x86_64.whl
pip install flash_attn-2.8.3.post1-cp312-cp312-linux_x86_64.whl

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.

3 participants