Repository navigation
Commit 7f40b1b
committed
Fix FSDP SDMA output allocation and stream ordering
Standalone outputs could be allocator subblocks even though IPC imports use
the allocation base. Share private-pool allocation between standalone outputs
and pool arenas, and preserve old views when standalone storage grows.
A local consumer event cannot protect remote readers. Add a standalone SDMA
readiness exchange before data writes, including the first write. Order writes
across backend instances and pools on the same process group with a weakly held
completion event, and reuse that event for asynchronous Work completion.
Cover standalone allocation growth, pooled and standalone output reuse, and
cross-backend ordering. Document the ownership, readiness, and ordering rules.
Test Plan:
Using the isolated runtime verified byte-for-byte against the reviewed sources,
with unchanged PyTorch and MORI binaries, from /tmp inside sdma-test1:
```bash
HIP_VISIBLE_DEVICES= PYTHONPATH=/home/yangwu/.codex/fsdp-mori-code-review-20260920/runtime /opt/conda/envs/py_3.10/bin/python -m pytest -q /root/wuyl/mori-jeff/tests/python/ccl/test_torch_fsdp.py
HIP_VISIBLE_DEVICES= PYTHONPATH=/home/yangwu/.codex/fsdp-mori-code-review-20260920/runtime /opt/conda/envs/py_3.10/bin/python /root/wuyl/pytorch-jeff-input-hook/test/distributed/_composable/fsdp/test_fully_shard_comm.py TestAllGatherLayouts TestParamContiguousEligibility -v
/opt/conda/envs/py_3.10/bin/python /home/yangwu/.codex/fsdp-mori-code-review-20260920/stage.py /home/yangwu/.codex/fsdp-mori-code-review-20260920/gpu-suite-ordered.json
```
45 MORI CPU tests, 51 matching PyTorch CPU tests, and all 3 GPU suite entries
passed. GPU coverage includes stream reuse, two- and four-rank training, exact
losses, gradients, and optimizer parameters, FP32/BF16, sync/async completion,
integer reshard, and fallback. The GPU suites completed in 82.49 seconds.
From the MORI repository root:
```bash
/opt/conda/envs/py_3.10/bin/python -m ruff check python/mori/ccl/torch_fsdp.py tests/python/ccl/test_torch_fsdp.py tests/python/ccl/test_torch_fsdp_pool.py tests/python/ccl/test_torch_fsdp_streams.py
git diff --check
```
Both checks passed. No new performance benchmark was run; standalone readiness
adds a collective and small control buffer, and private allocator segment
rounding can increase reserved memory.
Authored with assistance from OpenAI Codex.1 parent 3798f26 commit 7f40b1b
5 files changed
Lines changed: 183 additions & 27 deletions
File tree
- docs
- python/mori/ccl
- tests/python/ccl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
84 | 94 | | |
85 | 95 | | |
86 | 96 | | |
| |||
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
96 | 113 | | |
97 | 114 | | |
98 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
91 | | - | |
92 | | - | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
| |||
203 | 201 | | |
204 | 202 | | |
205 | 203 | | |
206 | | - | |
| 204 | + | |
207 | 205 | | |
208 | 206 | | |
| 207 | + | |
209 | 208 | | |
210 | 209 | | |
211 | 210 | | |
| |||
241 | 240 | | |
242 | 241 | | |
243 | 242 | | |
244 | | - | |
| 243 | + | |
245 | 244 | | |
246 | 245 | | |
247 | 246 | | |
248 | | - | |
| 247 | + | |
249 | 248 | | |
250 | 249 | | |
251 | 250 | | |
| |||
382 | 381 | | |
383 | 382 | | |
384 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
385 | 387 | | |
386 | 388 | | |
387 | 389 | | |
| |||
407 | 409 | | |
408 | 410 | | |
409 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
410 | 415 | | |
411 | 416 | | |
412 | 417 | | |
| |||
431 | 436 | | |
432 | 437 | | |
433 | 438 | | |
434 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
435 | 442 | | |
436 | 443 | | |
437 | 444 | | |
| |||
466 | 473 | | |
467 | 474 | | |
468 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
469 | 482 | | |
470 | | - | |
471 | 483 | | |
472 | 484 | | |
473 | | - | |
| 485 | + | |
474 | 486 | | |
475 | 487 | | |
476 | 488 | | |
| |||
482 | 494 | | |
483 | 495 | | |
484 | 496 | | |
485 | | - | |
| 497 | + | |
486 | 498 | | |
| 499 | + | |
| 500 | + | |
487 | 501 | | |
488 | 502 | | |
489 | | - | |
490 | 503 | | |
491 | 504 | | |
| 505 | + | |
| 506 | + | |
492 | 507 | | |
493 | 508 | | |
494 | 509 | | |
| |||
512 | 527 | | |
513 | 528 | | |
514 | 529 | | |
515 | | - | |
| 530 | + | |
516 | 531 | | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
517 | 535 | | |
518 | | - | |
| 536 | + | |
519 | 537 | | |
520 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
521 | 549 | | |
522 | 550 | | |
523 | 551 | | |
| |||
653 | 681 | | |
654 | 682 | | |
655 | 683 | | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
656 | 696 | | |
657 | 697 | | |
658 | 698 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
231 | 234 | | |
232 | 235 | | |
233 | 236 | | |
| |||
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
243 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
244 | 249 | | |
245 | 250 | | |
246 | 251 | | |
247 | 252 | | |
248 | 253 | | |
249 | 254 | | |
250 | | - | |
251 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| |||
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
262 | 290 | | |
263 | 291 | | |
264 | 292 | | |
| |||
268 | 296 | | |
269 | 297 | | |
270 | 298 | | |
| 299 | + | |
271 | 300 | | |
272 | 301 | | |
273 | 302 | | |
| |||
285 | 314 | | |
286 | 315 | | |
287 | 316 | | |
| 317 | + | |
288 | 318 | | |
289 | 319 | | |
290 | 320 | | |
| |||
309 | 339 | | |
310 | 340 | | |
311 | 341 | | |
| 342 | + | |
312 | 343 | | |
313 | 344 | | |
314 | 345 | | |
| |||
340 | 371 | | |
341 | 372 | | |
342 | 373 | | |
| 374 | + | |
343 | 375 | | |
344 | 376 | | |
345 | 377 | | |
| |||
370 | 402 | | |
371 | 403 | | |
372 | 404 | | |
| 405 | + | |
373 | 406 | | |
374 | 407 | | |
375 | 408 | | |
| |||
402 | 435 | | |
403 | 436 | | |
404 | 437 | | |
| 438 | + | |
405 | 439 | | |
406 | 440 | | |
407 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | | - | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
140 | 144 | | |
141 | | - | |
| 145 | + | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| |||
164 | 169 | | |
165 | 170 | | |
166 | 171 | | |
167 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
168 | 177 | | |
169 | 178 | | |
170 | 179 | | |
| |||
296 | 305 | | |
297 | 306 | | |
298 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
299 | 314 | | |
300 | 315 | | |
301 | 316 | | |
| |||
0 commit comments