I got this issue
Based on the logs from latest:149-153, here is what went wrong, the
root cause, and the fix.
──────
1. What Went Wrong
During media generation with the LTX-2 distilled pipeline and Gemma
3 text encoder on Apple Silicon (M3 Max), the MMGP offloading
engine attempted to transfer model weights into GPU memory via
_PinnedStager.to_gpu.
The operation crashed with an unhandled exception:
File ".../app/mmgp/pinned.py", line 55, in register
error = torch.cuda.cudart().cudaHostRegister(self.pointer,
self.size, self.flags)
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute
'cudaHostRegister'
──────
2. Root Cause
- Hardware & Platform:
• The application is running on macOS Apple Silicon (MPS) using
unified memory (CPU RAM and GPU VRAM share the same physical
address space).
• PyTorch on macOS is built without CUDA support (USE_CUDA=OFF),
meaning the CUDA Runtime library (libcudart) does not exist and
torch.cuda.cudart() evaluates to None.
- Recent MMGP Upstream Changes:
• Commit 2dca0c44 introduced pinned.py:1-61 to lock host
staging buffers via Registration.register by calling torch.
cuda.cudart().cudaHostRegister(...) and cudaHostUnregister(...).
- Missing Patch in MPS Compatibility Layer:
• device_patch.py:105-157 redirects most CUDA methods to MPS
and stubs _lazy_init() to a no-op.
• However, it did not stub torch.cuda.cudart(). When MMGP
called torch.cuda.cudart().cudaHostRegister(), cudart()
returned None, triggering the AttributeError.
──────
3. Next Fix
Add a mock CUDA runtime stub directly in device_patch.py:154-157
inside apply_mps_patch:
Code Change in device_patch.py:154-157:
# Stub cudart for MMGP host memory registration on Apple
Silicon Unified Memory
class _CudaRt:
class cudaError:
success = 0
@staticmethod
def cudaHostRegister(pointer, size, flags):
return 0
@staticmethod
def cudaHostUnregister(pointer):
return 0
@staticmethod
def cudaGetErrorString(error):
return "cudaSuccess"
_cuda_rt_instance = _CudaRt()
_cuda.cudart = lambda: _cuda_rt_instance
Also ensure stream synchronization stubs (_dummy_stream and
_PatchedStream in device_patch.py:38-43) include:
wait_event=lambda *a, **kw: None,
record_event=lambda *a, **kw: None,
Once applied, restart the WanGP service in Pinokio to reload the
patched runtime.
I got this issue
Based on the logs from latest:149-153, here is what went wrong, the
root cause, and the fix.
──────
1. What Went Wrong
During media generation with the LTX-2 distilled pipeline and Gemma
3 text encoder on Apple Silicon (M3 Max), the MMGP offloading
engine attempted to transfer model weights into GPU memory via
_PinnedStager.to_gpu.
The operation crashed with an unhandled exception:
File ".../app/mmgp/pinned.py", line 55, in register
error = torch.cuda.cudart().cudaHostRegister(self.pointer,
self.size, self.flags)
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute
'cudaHostRegister'
──────
2. Root Cause
• The application is running on macOS Apple Silicon (MPS) using
unified memory (CPU RAM and GPU VRAM share the same physical
address space).
• PyTorch on macOS is built without CUDA support (USE_CUDA=OFF),
meaning the CUDA Runtime library (libcudart) does not exist and
torch.cuda.cudart() evaluates to None.
• Commit 2dca0c44 introduced pinned.py:1-61 to lock host
staging buffers via Registration.register by calling torch.
cuda.cudart().cudaHostRegister(...) and cudaHostUnregister(...).
• device_patch.py:105-157 redirects most CUDA methods to MPS
and stubs _lazy_init() to a no-op.
• However, it did not stub torch.cuda.cudart(). When MMGP
called torch.cuda.cudart().cudaHostRegister(), cudart()
returned None, triggering the AttributeError.
──────
3. Next Fix
Add a mock CUDA runtime stub directly in device_patch.py:154-157
inside apply_mps_patch:
Code Change in device_patch.py:154-157:
Also ensure stream synchronization stubs (_dummy_stream and
_PatchedStream in device_patch.py:38-43) include:
Once applied, restart the WanGP service in Pinokio to reload the
patched runtime.