pytorch - 💡(How to fix) Fix [DTensor] Backward failure in index selection [4 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#179136Fetched 2026-04-08 02:33:05
View on GitHub
Comments
4
Participants
2
Timeline
62
Reactions
0
Author
Participants
Timeline (top)
mentioned ×20subscribed ×20labeled ×10unlabeled ×7

Error Message

DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:0'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),)) DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:1'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),)) [rank0]: Traceback (most recent call last): [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path [rank0]: result = self.sharding_propagator.propagate_op_sharding(op_info.schema) [rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in call [rank0]: return self.cache(*args, **kwargs) [rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached [rank0]: op_strategy = op_strategy_func(strategy_schema) [rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put [rank0]: raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}") [rank0]: AssertionError: Expected TupleStrategy, got <class 'list'>

[rank0]: The above exception was the direct cause of the following exception:

[rank0]: Traceback (most recent call last): [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 25, in <module> [rank0]: main() [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 21, in main [rank0]: y.sum().backward() [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/_tensor.py", line 631, in backward [rank0]: torch.autograd.backward( [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/init.py", line 381, in backward [rank0]: _engine_run_backward( [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward [rank0]: return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass [rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank0]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 251, in _propagate_op_sharding_dispatch_slow_path [rank0]: raise RuntimeError( [rank0]: RuntimeError: Expected TupleStrategy, got <class 'list'>

[rank0]: Sharding propagation failed for aten.index_put.default(Spec(f321, 8), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f321, 3), True) on DeviceMesh((model=2), 'cuda', stride=(1,))) [rank1]: Traceback (most recent call last): [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path [rank1]: result = self.sharding_propagator.propagate_op_sharding(op_info.schema) [rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in call [rank1]: return self.cache(*args, **kwargs) [rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached [rank1]: op_strategy = op_strategy_func(strategy_schema) [rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put [rank1]: raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}") [rank1]: AssertionError: Expected TupleStrategy, got <class 'list'>

[rank1]: The above exception was the direct cause of the following exception:

[rank1]: Traceback (most recent call last): [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 25, in <module> [rank1]: main() [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 21, in main [rank1]: y.sum().backward() [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/_tensor.py", line 631, in backward [rank1]: torch.autograd.backward( [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/init.py", line 381, in backward [rank1]: _engine_run_backward( [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward [rank1]: return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass [rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank1]: File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 251, in _propagate_op_sharding_dispatch_slow_path [rank1]: raise RuntimeError( [rank1]: RuntimeError: Expected TupleStrategy, got <class 'list'>

[rank1]: Sharding propagation failed for aten.index_put.default(Spec(f321, 8), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f321, 3), True) on DeviceMesh((model=2), 'cuda', stride=(1,))) W0402 18:06:14.571000 18061 torch/distributed/elastic/multiprocessing/api.py:1012] Sending process 18145 closing signal SIGTERM E0402 18:06:14.635000 18061 torch/distributed/elastic/multiprocessing/api.py:986] failed (exitcode: 1) local_rank: 1 (pid: 18146) of binary: /inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/python3 Traceback (most recent call last): File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/torchrun", line 10, in <module> sys.exit(main()) ^^^^^^ File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 362, in wrapper return f(*args, **kwargs) ^^^^^^^^^^^^^^^^^^ File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 990, in main run(args) File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 981, in run elastic_launch( File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 170, in call return launch_agent(self._config, self._entrypoint, list(args)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 317, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

exp/tests/dtensor_index_backward.py FAILED

Failures: [1]: time : 2026-04-02_18:06:14 host : xyge-1--7aca0d3562fc-4nedeaiite rank : 0 (local_rank: 0) exitcode : 1 (pid: 18145) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

Root Cause (first observed failure): [0]: time : 2026-04-02_18:06:14 host : xyge-1--7aca0d3562fc-4nedeaiite rank : 1 (local_rank: 1) exitcode : 1 (pid: 18146) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

Root Cause

[rank1]: Sharding propagation failed for aten.index_put.default(Spec(f321, 8), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f321, 3), True) on DeviceMesh((model=2), 'cuda', stride=(1,))) W0402 18:06:14.571000 18061 torch/distributed/elastic/multiprocessing/api.py:1012] Sending process 18145 closing signal SIGTERM E0402 18:06:14.635000 18061 torch/distributed/elastic/multiprocessing/api.py:986] failed (exitcode: 1) local_rank: 1 (pid: 18146) of binary: /inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/python3 Traceback (most recent call last): File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/torchrun", line 10, in <module> sys.exit(main()) ^^^^^^ File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 362, in wrapper return f(*args, **kwargs) ^^^^^^^^^^^^^^^^^^ File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 990, in main run(args) File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 981, in run elastic_launch( File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 170, in call return launch_agent(self._config, self._entrypoint, list(args)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 317, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

exp/tests/dtensor_index_backward.py FAILED

Failures: [1]: time : 2026-04-02_18:06:14 host : xyge-1--7aca0d3562fc-4nedeaiite rank : 0 (local_rank: 0) exitcode : 1 (pid: 18145) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

Root Cause (first observed failure): [0]: time : 2026-04-02_18:06:14 host : xyge-1--7aca0d3562fc-4nedeaiite rank : 1 (local_rank: 1) exitcode : 1 (pid: 18146) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

Fix Action

Fix / Workaround

DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:0'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),))
DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:1'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),))
[rank0]: Traceback (most recent call last):
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path
[rank0]:     result = self.sharding_propagator.propagate_op_sharding(op_info.schema)
[rank0]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in __call__
[rank0]:     return self.cache(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached
[rank0]:     op_strategy = op_strategy_func(strategy_schema)
[rank0]:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put
[rank0]:     raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}")
[rank0]: AssertionError: Expected TupleStrategy, got <class 'list'>

[rank0]: Traceback (most recent call last):
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 25, in <module>
[rank0]:     main()
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 21, in main
[rank0]:     y.sum().backward()
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/_tensor.py", line 631, in backward
[rank0]:     torch.autograd.backward(
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/__init__.py", line 381, in backward
[rank0]:     _engine_run_backward(
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward
[rank0]:     return Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 251, in _propagate_op_sharding_dispatch_slow_path
[rank0]:     raise RuntimeError(
[rank0]: RuntimeError: Expected TupleStrategy, got <class 'list'>

[rank0]: Sharding propagation failed for aten.index_put.default(Spec(f32[1, 8](R)), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f32[1, 3](R)), True) on DeviceMesh((model=2), 'cuda', stride=(1,)))
[rank1]: Traceback (most recent call last):
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path
[rank1]:     result = self.sharding_propagator.propagate_op_sharding(op_info.schema)
[rank1]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in __call__
[rank1]:     return self.cache(*args, **kwargs)
[rank1]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached
[rank1]:     op_strategy = op_strategy_func(strategy_schema)
[rank1]:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put
[rank1]:     raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}")
[rank1]: AssertionError: Expected TupleStrategy, got <class 'list'>

Code Example

torch.cuda.set_device(int(os.environ["LOCAL_RANK"]))
mesh = init_device_mesh("cuda", (2,), mesh_dim_names=("model",))

x = DTensor.from_local(torch.arange(8, device="cuda", dtype=torch.float32).unsqueeze(0), device_mesh=mesh, placements=(Replicate(),)).requires_grad_(True)

indices = DTensor.from_local(torch.tensor([1, 3, 5], device="cuda", dtype=torch.long), device_mesh=mesh, placements=(Replicate(),))

y = x[:, indices] # DTensor([[1., 3., 5.]])

y.sum().backward()

---

DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:0'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),))
DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:1'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),))
[rank0]: Traceback (most recent call last):
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path
[rank0]:     result = self.sharding_propagator.propagate_op_sharding(op_info.schema)
[rank0]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in __call__
[rank0]:     return self.cache(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached
[rank0]:     op_strategy = op_strategy_func(strategy_schema)
[rank0]:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put
[rank0]:     raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}")
[rank0]: AssertionError: Expected TupleStrategy, got <class 'list'>

[rank0]: The above exception was the direct cause of the following exception:

[rank0]: Traceback (most recent call last):
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 25, in <module>
[rank0]:     main()
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 21, in main
[rank0]:     y.sum().backward()
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/_tensor.py", line 631, in backward
[rank0]:     torch.autograd.backward(
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/__init__.py", line 381, in backward
[rank0]:     _engine_run_backward(
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward
[rank0]:     return Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 251, in _propagate_op_sharding_dispatch_slow_path
[rank0]:     raise RuntimeError(
[rank0]: RuntimeError: Expected TupleStrategy, got <class 'list'>

[rank0]: Sharding propagation failed for aten.index_put.default(Spec(f32[1, 8](R)), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f32[1, 3](R)), True) on DeviceMesh((model=2), 'cuda', stride=(1,)))
[rank1]: Traceback (most recent call last):
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path
[rank1]:     result = self.sharding_propagator.propagate_op_sharding(op_info.schema)
[rank1]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in __call__
[rank1]:     return self.cache(*args, **kwargs)
[rank1]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached
[rank1]:     op_strategy = op_strategy_func(strategy_schema)
[rank1]:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put
[rank1]:     raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}")
[rank1]: AssertionError: Expected TupleStrategy, got <class 'list'>

[rank1]: The above exception was the direct cause of the following exception:

[rank1]: Traceback (most recent call last):
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 25, in <module>
[rank1]:     main()
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 21, in main
[rank1]:     y.sum().backward()
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/_tensor.py", line 631, in backward
[rank1]:     torch.autograd.backward(
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/__init__.py", line 381, in backward
[rank1]:     _engine_run_backward(
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward
[rank1]:     return Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
[rank1]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 251, in _propagate_op_sharding_dispatch_slow_path
[rank1]:     raise RuntimeError(
[rank1]: RuntimeError: Expected TupleStrategy, got <class 'list'>

[rank1]: Sharding propagation failed for aten.index_put.default(Spec(f32[1, 8](R)), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f32[1, 3](R)), True) on DeviceMesh((model=2), 'cuda', stride=(1,)))
W0402 18:06:14.571000 18061 torch/distributed/elastic/multiprocessing/api.py:1012] Sending process 18145 closing signal SIGTERM
E0402 18:06:14.635000 18061 torch/distributed/elastic/multiprocessing/api.py:986] failed (exitcode: 1) local_rank: 1 (pid: 18146) of binary: /inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/python3
Traceback (most recent call last):
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/torchrun", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 362, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 990, in main
    run(args)
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 981, in run
    elastic_launch(
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 170, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 317, in launch_agent
    raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError: 
============================================================
exp/tests/dtensor_index_backward.py FAILED
------------------------------------------------------------
Failures:
[1]:
  time      : 2026-04-02_18:06:14
  host      : xyge-1--7aca0d3562fc-4nedeaiite
  rank      : 0 (local_rank: 0)
  exitcode  : 1 (pid: 18145)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
  time      : 2026-04-02_18:06:14
  host      : xyge-1--7aca0d3562fc-4nedeaiite
  rank      : 1 (local_rank: 1)
  exitcode  : 1 (pid: 18146)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

---

PyTorch version: 2.11.0+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.26.4
Libc version: glibc-2.35

Python version: 3.12.11 (main, Jun  4 2025, 17:36:43) [Clang 20.1.4 ] (64-bit runtime)
Python platform: Linux-5.15.0-119-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: 
GPU models and configuration: 
GPU 0: NVIDIA H100 80GB HBM3
GPU 1: NVIDIA H100 80GB HBM3

Nvidia driver version: 570.124.06
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        46 bits physical, 57 bits virtual
Byte Order:                           Little Endian
CPU(s):                               192
On-line CPU(s) list:                  0-191
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) Platinum 8468
CPU family:                           6
Model:                                143
Thread(s) per core:                   2
Core(s) per socket:                   48
Socket(s):                            2
Stepping:                             8
CPU max MHz:                          3800.0000
CPU min MHz:                          800.0000
BogoMIPS:                             4200.00
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            4.5 MiB (96 instances)
L1i cache:                            3 MiB (96 instances)
L2 cache:                             192 MiB (96 instances)
L3 cache:                             210 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-47,96-143
NUMA node1 CPU(s):                    48-95,144-191
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Retpolines; IBPB conditional; IBRS_FW; STIBP conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI Retpoline
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] Could not collect
[conda] libopenvino-pytorch-frontend            2025.0.0         h5888daf_3             conda-forge
[conda] numpy                                   2.3.3            pypi_0                 pypi
[conda] nvidia-cublas-cu12                      12.8.4.1         pypi_0                 pypi
[conda] nvidia-cuda-cupti-cu12                  12.8.90          pypi_0                 pypi
[conda] nvidia-cuda-nvrtc-cu12                  12.8.93          pypi_0                 pypi
[conda] nvidia-cuda-runtime-cu12                12.8.90          pypi_0                 pypi
[conda] nvidia-cudnn-cu12                       9.10.2.21        pypi_0                 pypi
[conda] nvidia-cufft-cu12                       11.3.3.83        pypi_0                 pypi
[conda] nvidia-curand-cu12                      10.3.9.90        pypi_0                 pypi
[conda] nvidia-cusolver-cu12                    11.7.3.90        pypi_0                 pypi
[conda] nvidia-cusparse-cu12                    12.5.8.93        pypi_0                 pypi
[conda] nvidia-cusparselt-cu12                  0.7.1            pypi_0                 pypi
[conda] nvidia-nccl-cu12                        2.27.5           pypi_0                 pypi
[conda] nvidia-nvjitlink-cu12                   12.8.93          pypi_0                 pypi
[conda] nvidia-nvtx-cu12                        12.8.90          pypi_0                 pypi
[conda] tbb                                     2022.3.0         h8d10470_1             conda-forge
[conda] torch                                   2.9.0            pypi_0                 pypi
[conda] triton                                  3.5.0            pypi_0                 pypi
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

I've just encountered a problem in running backward on selecting indices from DTensor, when the index is a mixture of slice and dim indices. Here's an MRE:

torch.cuda.set_device(int(os.environ["LOCAL_RANK"]))
mesh = init_device_mesh("cuda", (2,), mesh_dim_names=("model",))

x = DTensor.from_local(torch.arange(8, device="cuda", dtype=torch.float32).unsqueeze(0), device_mesh=mesh, placements=(Replicate(),)).requires_grad_(True)

indices = DTensor.from_local(torch.tensor([1, 3, 5], device="cuda", dtype=torch.long), device_mesh=mesh, placements=(Replicate(),))

y = x[:, indices] # DTensor([[1., 3., 5.]])

y.sum().backward()

It throws the following error:

DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:0'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),))
DTensor(local_tensor=tensor([[1., 3., 5.]], device='cuda:1'), device_mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),))
[rank0]: Traceback (most recent call last):
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path
[rank0]:     result = self.sharding_propagator.propagate_op_sharding(op_info.schema)
[rank0]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in __call__
[rank0]:     return self.cache(*args, **kwargs)
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached
[rank0]:     op_strategy = op_strategy_func(strategy_schema)
[rank0]:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put
[rank0]:     raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}")
[rank0]: AssertionError: Expected TupleStrategy, got <class 'list'>

[rank0]: The above exception was the direct cause of the following exception:

[rank0]: Traceback (most recent call last):
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 25, in <module>
[rank0]:     main()
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 21, in main
[rank0]:     y.sum().backward()
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/_tensor.py", line 631, in backward
[rank0]:     torch.autograd.backward(
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/__init__.py", line 381, in backward
[rank0]:     _engine_run_backward(
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward
[rank0]:     return Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
[rank0]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 251, in _propagate_op_sharding_dispatch_slow_path
[rank0]:     raise RuntimeError(
[rank0]: RuntimeError: Expected TupleStrategy, got <class 'list'>

[rank0]: Sharding propagation failed for aten.index_put.default(Spec(f32[1, 8](R)), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f32[1, 3](R)), True) on DeviceMesh((model=2), 'cuda', stride=(1,)))
[rank1]: Traceback (most recent call last):
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 226, in _propagate_op_sharding_dispatch_slow_path
[rank1]:     result = self.sharding_propagator.propagate_op_sharding(op_info.schema)
[rank1]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 129, in __call__
[rank1]:     return self.cache(*args, **kwargs)
[rank1]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_sharding_prop.py", line 576, in propagate_op_sharding_non_cached
[rank1]:     op_strategy = op_strategy_func(strategy_schema)
[rank1]:                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_ops/_tensor_ops.py", line 996, in prop_index_put
[rank1]:     raise AssertionError(f"Expected TupleStrategy, got {type(indices_spec)}")
[rank1]: AssertionError: Expected TupleStrategy, got <class 'list'>

[rank1]: The above exception was the direct cause of the following exception:

[rank1]: Traceback (most recent call last):
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 25, in <module>
[rank1]:     main()
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/exp/tests/dtensor_index_backward.py", line 21, in main
[rank1]:     y.sum().backward()
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/_tensor.py", line 631, in backward
[rank1]:     torch.autograd.backward(
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/__init__.py", line 381, in backward
[rank1]:     _engine_run_backward(
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/autograd/graph.py", line 869, in _engine_run_backward
[rank1]:     return Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
[rank1]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank1]:   File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/tensor/_dispatch.py", line 251, in _propagate_op_sharding_dispatch_slow_path
[rank1]:     raise RuntimeError(
[rank1]: RuntimeError: Expected TupleStrategy, got <class 'list'>

[rank1]: Sharding propagation failed for aten.index_put.default(Spec(f32[1, 8](R)), [None, DTensorSpec(mesh=DeviceMesh((model=2), 'cuda', stride=(1,)), placements=(Replicate(),), tensor_meta=TensorMeta(shape=torch.Size([3]), stride=(1,), dtype=torch.int64), shard_order=(), use_strided_shard_as_shard_order=False)], Spec(f32[1, 3](R)), True) on DeviceMesh((model=2), 'cuda', stride=(1,)))
W0402 18:06:14.571000 18061 torch/distributed/elastic/multiprocessing/api.py:1012] Sending process 18145 closing signal SIGTERM
E0402 18:06:14.635000 18061 torch/distributed/elastic/multiprocessing/api.py:986] failed (exitcode: 1) local_rank: 1 (pid: 18146) of binary: /inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/python3
Traceback (most recent call last):
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/bin/torchrun", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 362, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 990, in main
    run(args)
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/run.py", line 981, in run
    elastic_launch(
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 170, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/inspire/hdd/global_user/hezhengfu-240208120186/xy_projects/Language-Model-SAEs/.venv/lib/python3.12/site-packages/torch/distributed/launcher/api.py", line 317, in launch_agent
    raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError: 
============================================================
exp/tests/dtensor_index_backward.py FAILED
------------------------------------------------------------
Failures:
[1]:
  time      : 2026-04-02_18:06:14
  host      : xyge-1--7aca0d3562fc-4nedeaiite
  rank      : 0 (local_rank: 0)
  exitcode  : 1 (pid: 18145)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
  time      : 2026-04-02_18:06:14
  host      : xyge-1--7aca0d3562fc-4nedeaiite
  rank      : 1 (local_rank: 1)
  exitcode  : 1 (pid: 18146)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

It works correctly when the indexing changes simpler to x[0, indices] or x[:, 1]. Is there any workaround over this?

Versions

It seems the script cannot detect uv environments. I'm using torch==2.11.0.

PyTorch version: 2.11.0+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.26.4
Libc version: glibc-2.35

Python version: 3.12.11 (main, Jun  4 2025, 17:36:43) [Clang 20.1.4 ] (64-bit runtime)
Python platform: Linux-5.15.0-119-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: 
GPU models and configuration: 
GPU 0: NVIDIA H100 80GB HBM3
GPU 1: NVIDIA H100 80GB HBM3

Nvidia driver version: 570.124.06
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        46 bits physical, 57 bits virtual
Byte Order:                           Little Endian
CPU(s):                               192
On-line CPU(s) list:                  0-191
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) Platinum 8468
CPU family:                           6
Model:                                143
Thread(s) per core:                   2
Core(s) per socket:                   48
Socket(s):                            2
Stepping:                             8
CPU max MHz:                          3800.0000
CPU min MHz:                          800.0000
BogoMIPS:                             4200.00
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            4.5 MiB (96 instances)
L1i cache:                            3 MiB (96 instances)
L2 cache:                             192 MiB (96 instances)
L3 cache:                             210 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-47,96-143
NUMA node1 CPU(s):                    48-95,144-191
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Retpolines; IBPB conditional; IBRS_FW; STIBP conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI Retpoline
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] Could not collect
[conda] libopenvino-pytorch-frontend            2025.0.0         h5888daf_3             conda-forge
[conda] numpy                                   2.3.3            pypi_0                 pypi
[conda] nvidia-cublas-cu12                      12.8.4.1         pypi_0                 pypi
[conda] nvidia-cuda-cupti-cu12                  12.8.90          pypi_0                 pypi
[conda] nvidia-cuda-nvrtc-cu12                  12.8.93          pypi_0                 pypi
[conda] nvidia-cuda-runtime-cu12                12.8.90          pypi_0                 pypi
[conda] nvidia-cudnn-cu12                       9.10.2.21        pypi_0                 pypi
[conda] nvidia-cufft-cu12                       11.3.3.83        pypi_0                 pypi
[conda] nvidia-curand-cu12                      10.3.9.90        pypi_0                 pypi
[conda] nvidia-cusolver-cu12                    11.7.3.90        pypi_0                 pypi
[conda] nvidia-cusparse-cu12                    12.5.8.93        pypi_0                 pypi
[conda] nvidia-cusparselt-cu12                  0.7.1            pypi_0                 pypi
[conda] nvidia-nccl-cu12                        2.27.5           pypi_0                 pypi
[conda] nvidia-nvjitlink-cu12                   12.8.93          pypi_0                 pypi
[conda] nvidia-nvtx-cu12                        12.8.90          pypi_0                 pypi
[conda] tbb                                     2022.3.0         h8d10470_1             conda-forge
[conda] torch                                   2.9.0            pypi_0                 pypi
[conda] triton                                  3.5.0            pypi_0                 pypi

cc @ezyang @gchanan @kadeng @msaroufim @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta @dcci @aditvenk @xmfan @tianyu-l @XilunWu @SherlockNoMad @ppwwyyxx

extent analysis

TL;DR

The issue is likely due to the indexing operation x[:, indices] not being supported for DTensors with a mixture of slice and dim indices, and a workaround may involve modifying the indexing operation or the DTensor creation.

Guidance

  • The error message indicates that the prop_index_put function expects a TupleStrategy but receives a list instead, suggesting that the indexing operation is not compatible with the DTensor's sharding strategy.
  • To mitigate this issue, try modifying the indexing operation to use a simpler indexing scheme, such as x[0, indices] or x[:, 1], which are reported to work correctly.
  • Alternatively, investigate the DTensor creation process and consider modifying the placements or device_mesh arguments to ensure that the resulting DTensor has a compatible sharding strategy for the desired indexing operation.
  • Verify that the workaround resolves the issue by running the modified code and checking for any error messages or incorrect results.

Example

No code example is provided, as the issue is likely related to the specific DTensor creation and indexing operation, and a minimal reproducible example would require more information about the desired use case.

Notes

  • The issue may be specific to the PyTorch version (2.11.0) or the CUDA version (13.0) being used, and upgrading or downgrading these versions may resolve the issue.
  • The error message suggests that the prop_index_put function is not designed to handle the specific indexing operation being used, and modifying this function or creating a custom indexing operation may be necessary to resolve the issue.

Recommendation

Apply a workaround, such as modifying the indexing operation or the DTensor creation process, to resolve the issue. The exact workaround will depend on the specific use case and requirements.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING