Skip to content

ImportError: cannot import name 'precompute_freqs_cis' from 'comfy.ldm.lightricks.model' #188

@changeen

Description

@changeen

ComfyUI显示导入失败,报错信息Error message occurred while importing the 'ComfyUI-TeaCache' module.

Traceback (most recent call last):
File "D:\AI\ComfyUI\ComfyUI\nodes.py", line 2227, in load_custom_node
module_spec.loader.exec_module(module)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "", line 1023, in exec_module
File "", line 488, in call_with_frames_removed
File "D:\AI\ComfyUI\ComfyUI\custom_nodes\ComfyUI-TeaCache_init
.py", line 1, in
from .nodes import NODE_CLASS_MAPPINGS as NODES_CLASS, NODE_DISPLAY_NAME_MAPPINGS as NODES_DISPLAY
File "D:\AI\ComfyUI\ComfyUI\custom_nodes\ComfyUI-TeaCache\nodes.py", line 12, in
from comfy.ldm.lightricks.model import precompute_freqs_cis
ImportError: cannot import name 'precompute_freqs_cis' from 'comfy.ldm.lightricks.model' (D:\AI\ComfyUI\ComfyUI\comfy\ldm\lightricks\model.py)

环境均为最新版本,

问了AI临时解决方案通过修改 nodes.py 中:
from comfy.ldm.lightricks.model import precompute_freqs_cis
改为
def precompute_freqs_cis(coords, dim, out_dtype):
theta = 1.0 / (10000 ** (torch.arange(0, dim, 2, device=coords.device, dtype=torch.float32) / dim))
freqs = torch.einsum('... , d -> ... d', coords.flatten(1, -2).to(torch.float32), theta)
freqs = freqs.view(*coords.shape[:-1], -1)
return torch.polar(torch.ones_like(freqs), freqs.to(out_dtype))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions