You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ModuleNotFoundError: No module named 'torch._C._distributed_c10d'; 'torch._C' is not a package
This is due to import torch.distributed.tensor failing but being called by the transformers package even if if torch.distributed.is_available() returns false. A fix has been merged but is not yet included in a stable release of that package: huggingface/transformers@a5fac1c.
The workarounds are either
For Python < 3.13, install the last working version of transformers:
pip install transformers==4.41.2
For any Python version, install the latest source which includes a fix:
Then trying to import torch.distributed.tensor fails:
(3.13.venv) λ python
Python 3.13.5 (tags/v3.13.5:6cb20a2, Jun 11 2025, 16:15:46) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license"for more information.
>>> import torch.distributed.tensor
Traceback (most recent call last):
File "<python-input-0>", line 1, in<module>
import torch.distributed.tensor
File "D:\scratch\therock\3.13.venv\Lib\site-packages\torch\distributed\tensor\__init__.py", line 4, in<module>
import torch.distributed.tensor._ops # force import all built-in dtensor ops
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\scratch\therock\3.13.venv\Lib\site-packages\torch\distributed\tensor\_ops\__init__.py", line 2, in<module>
from ._conv_ops import *# noqa: F403
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\scratch\therock\3.13.venv\Lib\site-packages\torch\distributed\tensor\_ops\_conv_ops.py", line 5, in<module>
from torch.distributed.tensor._dtensor_spec import DTensorSpec, TensorMeta
File "D:\scratch\therock\3.13.venv\Lib\site-packages\torch\distributed\tensor\_dtensor_spec.py", line 6, in<module>
from torch.distributed.tensor.placement_types import (
...<4 lines>...
)
File "D:\scratch\therock\3.13.venv\Lib\site-packages\torch\distributed\tensor\placement_types.py", line 8, in<module>
import torch.distributed._functional_collectives as funcol
File "D:\scratch\therock\3.13.venv\Lib\site-packages\torch\distributed\_functional_collectives.py", line 9, in<module>
import torch.distributed.distributed_c10d as c10d
File "D:\scratch\therock\3.13.venv\Lib\site-packages\torch\distributed\distributed_c10d.py", line 23, in<module>
from torch._C._distributed_c10d import (
...<22 lines>...
)
ModuleNotFoundError: No module named 'torch._C._distributed_c10d';'torch._C' is not a package
I would not expect distributed APIs to work until we somehow enable GLOO (the collective communications library used by PyTorch: https://github.com/pytorch/gloo) on Windows:
Important
SUMMARY:
If you see
This is due to
import torch.distributed.tensorfailing but being called by thetransformerspackage even ifif torch.distributed.is_available()returns false. A fix has been merged but is not yet included in a stable release of that package: huggingface/transformers@a5fac1c.The workarounds are either
transformers:Forking from #910 (comment).
Setup:
Then trying to
import torch.distributed.tensorfails:Users report that https://github.com/comfyanonymous/ComfyUI triggers this code path on launch.
Copying one of my comments from #1179:
Taking that a step further, maybe we can help this degrade gracefully instead of failing?