Commit 13c1d03
committed
fix: wrap positions as DTensor in RoPE and warn on missing position_buffer
When TP uses use_local_output=False (DeepSeek V3, Qwen3, GPT-OSS),
freqs_cis becomes a DTensor(Replicate) but positions remains a plain
tensor. torch.gather requires both operands to be the same type, causing
a runtime error. Fix by wrapping positions via DTensor.from_local() at
the apply_rotary_emb public API boundary.
Also add a logger.warning when loading a checkpoint that is missing the
position_buffer key in the dataset state dict, to help users debug
incorrect RoPE positions when resuming from older checkpoints.1 parent 4e6888b commit 13c1d03
2 files changed
+41
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
161 | 169 | | |
162 | 170 | | |
163 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
292 | 322 | | |
293 | 323 | | |
294 | 324 | | |
| |||
304 | 334 | | |
305 | 335 | | |
306 | 336 | | |
| 337 | + | |
307 | 338 | | |
308 | 339 | | |
309 | 340 | | |
| |||
324 | 355 | | |
325 | 356 | | |
326 | 357 | | |
| 358 | + | |
327 | 359 | | |
328 | 360 | | |
329 | 361 | | |
| |||
345 | 377 | | |
346 | 378 | | |
347 | 379 | | |
| 380 | + | |
348 | 381 | | |
349 | 382 | | |
350 | 383 | | |
| |||
0 commit comments