mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[GH-ISSUE #114] na3d custom-op registration uses PEP-585 annotations, breaking import on torch < 2.7 #35
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-kitchen#35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @j2gg0s on GitHub (Aug 13, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-kitchen/issues/114
Summary
Since v0.2.28,
import comfy_kitchenfails outright on torch 2.6:The error is raised at package-import time, so the entire package becomes unimportable — not just the
na3dop. Any downstream project on torch 2.6 breaks when it picks up a newer comfy-kitchen. That includes ComfyUI itself: itsrequirements.txtpinscomfy-kitchen==0.2.31but leavestorchunpinned, so whether it works depends entirely on which torch happens to be installed.Root cause
comfy_kitchen/backends/eager/na.py(added in #95) registers the custom op with PEP-585 builtin-generic annotations:torch.library.infer_schemaonly learned to accept builtin generics in torch 2.7.0:derived_seq_types()intorch/_library/infer_schema.pygainedGenericAlias(list, (typ,))andGenericAlias(collections.abc.Sequence, (typ,))there (pytorch/pytorch#146594). On 2.6 it accepts onlytyping.List[int]/typing.Sequence[int].Worth noting
scale: float | Noneis not part of the problem —float | Nonecompares and hashes equal totyping.Optional[float], so the dict lookup resolves fine even on 2.6. Only the twolist[...]parameters fail.Repro
torch 2.6.0+cu124, Python 3.10.12, Linux:
Import chain:
comfy_kitchen/__init__.py:3→backends/cuda/__init__.py:161→backends/eager/__init__.py:71→backends/eager/na.py:164.Suggested fix
Two annotations, no behavior change, restores torch 2.6 compatibility at zero cost:
Alternatively, if torch >= 2.7 is intended as a real floor, it would help a lot to declare it —
pyproject.tomlcurrently hasdependencies = []with no mention of torch, so pip installs the package happily and the incompatibility only surfaces at runtime, with an error message that doesn't point at the version mismatch. Happy to send a PR for either direction.Environment
@coderabbitai[bot] commented on GitHub (Aug 13, 2026):
🔗 Related PRs
Comfy-Org/comfy-kitchen#105 - Document the actual PyTorch minimum (>=2.7.0) [open]
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!