A user reports [code] He added debug prints in ComfyUI-FeatherOps\kernel\hip\utils.py…
- User
A user reports
code - Assistant
Inspecting the HIP extension loader and the corresponding
torch.utils.cpp_extensioncode path to trace wheresourcespicks up aNone. - Assistant
The repo’s loader passes a plain string path to
load(), so theNoneis not originating inComfyUI-FeatherOps. I’m tracing the PyTorch HIP/Windows branch next, especially thehipifyrewrite that mutatessourcesbefore Ninja generation. - Assistant
I’ve narrowed it to a PyTorch-side Windows ROCm bug: the JIT HIP path normalizes a source path to
/for membership checks, but stores the same extra file inall_fileswith\, so hipify marks it ignored and returnshipified_path=None. I’m checking whether upstream already fixed that exact spot. - Assistant
I can reproduce the bad state directly from the hipify code without needing a HIP-capable local torch. I’m checking that next so the explanation isn’t just theoretical.
- Assistant
Cause
source_fileis notNoneinComfyUI-FeatherOps. TheNoneis introduced later inside PyTorch’s Windows ROCm JIT extension path. - User
I've checked out C:\pytorch\ to the latest main branch. Does this issue still exist there? If so, make a minimal patch there to fix this issue.
- Assistant
Checking the current
C:\pytorchsources for the same ROCm/Windows JIT hipify path, then I’ll patch the smallest safe fix if it’s still present. - Assistant
The same buggy code is still present on
main. I’m patching the JIT HIP path to match the existing safersetup()path, then I’ll run a targeted repro against the source tree. - Assistant
Applying a one-line guard in
cpp_extension.pyand adding a mocked regression test that exercises the JIT HIP path without requiring ROCm hardware or compilation. - Assistant
Verifying the source-tree patch with a direct mocked call into the edited
cpp_extension.py, plus a syntax check on both edited files. - Assistant
The verification script picked up the source checkout as
torchbecause it ran insideC:\pytorch. Re-running the same mocked check from outside the repo so it uses the installed torch runtime with the edited source file. - Assistant
Yes. The same bug is still present on
main.I patched it in
C:\pytorch:-
torch/utils/cpp_extension.py- In
_jit_compile(), the ROCm JIT hipify path now falls back to the original source whenhipify_result[s_abs].hipified_pathisNone. - This matches the already-safe logic in the
setup()path.
- In
-
test/test_utils.py- Added a regression test that mocks the HIP JIT flow and verifies
_write_ninja_file_and_build_library()receives the original source path, notNone.
- Added a regression test that mocks the HIP JIT flow and verifies
Why this fix:
hipifycan returnhipified_path=Nonefor ignored files.- The JIT path was inserting that
Noneintosources. - Later
_write_ninja_file_to_build_library()called and crashed.
-
- User
After this patch, does it correctly compiles the kernel in
hip_kernel.cuon AMD GPU on Windows? - Assistant
Not guaranteed end-to-end, but it now does the correct thing for this failure.
What the patch changes:
- Before: PyTorch turned
sourcesinto[None]and crashed before invoking the compiler. - After: PyTorch keeps the original
hip_kernel.cupath and passes that to the JIT build.
Why that is correct for
hip_kernel.cu:hip_kernel.cuis already HIP-native code.- It includes
hip/hip_fp16.handhip/hip_runtime.h, not CUDA headers. - So if
hipifyreturnshipified_path=None, falling back to the original source is the right behavior.
What I can say confidently:
- The
NoneTypecrash is fixed. - The build now proceeds to the real HIP compile step instead of dying in Python.
- Before: PyTorch turned