Commit 491596e
authored
[qwen3.5] fix DTensor TP vision position caches (#3899)
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* #3895
* __->__ #3899
Main TP was failing with `FLA_TILELANG=0 MODULE=qwen3_5
CONFIG=qwen35_debugmodel NGPU=2 ./run_train.sh
--parallelism.tensor_parallel_degree 2
--parallelism.data_parallel_shard_degree 1 --debug.seed 42
--debug.deterministic --training.steps 1`
```
[rank0]:[rank0]: File "/data/users/pianpwk/full_spmd_types_torchtitan/tt4_spmd_types/torchtitan/torchtitan/models/qwen3_5/vision_encoder.py", line 91, in _compute_learned_pos_embeds
[rank0]:[rank0]: pos_hw = F.interpolate(
[rank0]:[rank0]: ^^^^^^^^^^^^^^
[rank0]:[rank0]: File "/data/users/pianpwk/full_spmd_types_torchtitan/pytorch/torch/nn/functional.py", line 5273, in interpolate
[rank0]:[rank0]: )._upsample_linear_vec(input, output_size, align_corners, scale_factors)
[rank0]:[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:[rank0]: File "/data/users/pianpwk/full_spmd_types_torchtitan/pytorch/torch/_decomp/decompositions.py", line 4507, in _upsample_linear_vec
[rank0]:[rank0]: return _upsample_linear(input, osize, align_corners, scales)
[rank0]:[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:[rank0]: File "/data/users/pianpwk/full_spmd_types_torchtitan/pytorch/torch/_decomp/decompositions.py", line 91, in inner
[rank0]:[rank0]: r = f(*tree_map(increase_prec, args), **tree_map(increase_prec, kwargs))
[rank0]:[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:[rank0]: File "/data/users/pianpwk/full_spmd_types_torchtitan/pytorch/torch/_decomp/decompositions.py", line 4627, in _upsample_linear
[rank0]:[rank0]: v = aten._unsafe_index(input, idx)
[rank0]:[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:[rank0]: File "/data/users/pianpwk/full_spmd_types_torchtitan/pytorch/torch/_ops.py", line 1350, in __call__
[rank0]:[rank0]: return self._op(*args, **kwargs)
[rank0]:[rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:[rank0]: RuntimeError: aten._unsafe_index.Tensor got mixed torch.Tensor and DTensor, need to convert all torch.Tensor to DTensor before calling distributed operators!
```
- DTensor decomposition goes to unsafe_index which creates local plain
tensors - fixes by local-mapping interpolate
- upcoming spmd_types PR would parallelize inv_freq, get ahead of this
by also wrapping positions as DTensors - previously that portion was
done in plain tensor1 parent 6ad8c3d commit 491596e
2 files changed
Lines changed: 43 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
97 | 108 | | |
98 | 109 | | |
99 | 110 | | |
| |||
251 | 262 | | |
252 | 263 | | |
253 | 264 | | |
254 | | - | |
| 265 | + | |
| 266 | + | |
255 | 267 | | |
256 | 268 | | |
257 | 269 | | |
| |||
485 | 497 | | |
486 | 498 | | |
487 | 499 | | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
495 | 519 | | |
496 | 520 | | |
497 | 521 | | |
| |||
0 commit comments