Commit 76d27c6
use pin_memory for ModelInput and minor refactoring (#2910)
Summary:
Pull Request resolved: #2910
# context
* this is some BE work and minor refactoring when working on pipeline optimization
* major change is to add "pin_memory" option to the test_input file for `ModelInput` generation:
```
The `pin_memory()` call for all KJT tensors are important for training benchmark, and
also valid argument for the prod training scenario: TrainModelInput should be created
on pinned memory for a fast transfer to gpu. For more on pin_memory:
https://pytorch.org/tutorials/intermediate/pinmem_nonblock.html#pin-memory
```
* minor refactoring includes
(1) default parameters for TrainPipeline benchmark so that the embedding size, batch size, etc. are resonable.
(2) fix the batch index error in trace, previously used (curr_index+1)
(3) split the `EmbeddingPipelinedForward` __call__ function into two parts.
* trace comparison: the `pin_memory()` for the ModelInput is critical for a non_blocking cpu to gpu data copy
before copy_batch_to_gpu is the same size as gpu data transfer {F1977324224}
after: copy_batch_to_gpu is hardly seen in trace {F1977324220}
Reviewed By: aporialiao
Differential Revision: D73514639
fbshipit-source-id: cdd70377212ec8db3feaadb58f1d652d044132b91 parent 7bd2afc commit 76d27c6
File tree
5 files changed
+61
-17
lines changed- torchrec/distributed
- benchmark
- test_utils
- train_pipeline
5 files changed
+61
-17
lines changedLines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
| 57 | + | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
| 870 | + | |
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| 228 | + | |
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
| |||
256 | 258 | | |
257 | 259 | | |
258 | 260 | | |
| 261 | + | |
259 | 262 | | |
260 | 263 | | |
261 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
262 | 270 | | |
263 | 271 | | |
264 | 272 | | |
| |||
279 | 287 | | |
280 | 288 | | |
281 | 289 | | |
| 290 | + | |
282 | 291 | | |
283 | 292 | | |
284 | 293 | | |
| |||
297 | 306 | | |
298 | 307 | | |
299 | 308 | | |
| 309 | + | |
300 | 310 | | |
301 | 311 | | |
302 | 312 | | |
| |||
306 | 316 | | |
307 | 317 | | |
308 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
309 | 322 | | |
310 | 323 | | |
311 | 324 | | |
| |||
404 | 417 | | |
405 | 418 | | |
406 | 419 | | |
| 420 | + | |
407 | 421 | | |
408 | 422 | | |
409 | | - | |
410 | 423 | | |
411 | 424 | | |
412 | 425 | | |
413 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
414 | 432 | | |
415 | 433 | | |
416 | 434 | | |
| |||
422 | 440 | | |
423 | 441 | | |
424 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
425 | 448 | | |
426 | 449 | | |
427 | 450 | | |
| |||
440 | 463 | | |
441 | 464 | | |
442 | 465 | | |
| 466 | + | |
443 | 467 | | |
444 | 468 | | |
445 | 469 | | |
| |||
462 | 486 | | |
463 | 487 | | |
464 | 488 | | |
| 489 | + | |
465 | 490 | | |
466 | 491 | | |
467 | 492 | | |
| |||
555 | 580 | | |
556 | 581 | | |
557 | 582 | | |
558 | | - | |
| 583 | + | |
559 | 584 | | |
560 | 585 | | |
561 | 586 | | |
562 | 587 | | |
563 | 588 | | |
564 | 589 | | |
565 | 590 | | |
| 591 | + | |
566 | 592 | | |
567 | 593 | | |
568 | 594 | | |
| |||
584 | 610 | | |
585 | 611 | | |
586 | 612 | | |
| 613 | + | |
587 | 614 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
680 | 680 | | |
681 | 681 | | |
682 | 682 | | |
683 | | - | |
| 683 | + | |
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| |||
1008 | 1008 | | |
1009 | 1009 | | |
1010 | 1010 | | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
1016 | 1018 | | |
1017 | 1019 | | |
1018 | 1020 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
| 603 | + | |
603 | 604 | | |
604 | 605 | | |
605 | 606 | | |
| |||
613 | 614 | | |
614 | 615 | | |
615 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
616 | 635 | | |
617 | 636 | | |
618 | 637 | | |
| |||
650 | 669 | | |
651 | 670 | | |
652 | 671 | | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | 672 | | |
659 | 673 | | |
660 | 674 | | |
| |||
0 commit comments