forked from pytorch/pytorch.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtroubleshooting.html
1547 lines (1297 loc) · 105 KB
/
troubleshooting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PyTorch 2.0 Troubleshooting — PyTorch master documentation</title>
<link rel="canonical" href="https://pytorch.org/docs/stable/compile/troubleshooting.html"/>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!-- <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> -->
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" type="text/css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" type="text/css" />
<link rel="stylesheet" href="../_static/katex-math.css" type="text/css" />
<link rel="stylesheet" href="../_static/sphinx-dropdown.css" type="text/css" />
<link rel="stylesheet" href="../_static/panels-bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/jit.css" type="text/css" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Frequently Asked Questions" href="faq.html" />
<link rel="prev" title="torch.compile" href="generated/torch.compile.html" />
<!--
Search engines should not index the master version of documentation.
Stable documentation are built without release == 'master'.
-->
<meta name="robots" content="noindex">
<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-117752657-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-117752657-2');
</script>
<!-- End Google Analytics -->
<script src="../_static/js/modernizr.min.js"></script>
<!-- Preload the theme fonts -->
<link rel="preload" href="../_static/fonts/FreightSans/freight-sans-book.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="../_static/fonts/FreightSans/freight-sans-medium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="../_static/fonts/IBMPlexMono/IBMPlexMono-Medium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="../_static/fonts/FreightSans/freight-sans-bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="../_static/fonts/FreightSans/freight-sans-medium-italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="../_static/fonts/IBMPlexMono/IBMPlexMono-SemiBold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<!-- Preload the katex fonts -->
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size1-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size4-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size2-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size3-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.2/css/all.css" integrity="sha384-vSIIfh2YWi9wW0r9iZe7RJPrKwp6bG+s9QZMoITbCckVJqGCCRhc+ccxNcdpHuYu" crossorigin="anonymous">
</head>
<div class="container-fluid header-holder tutorials-header" id="header-holder">
<div class="container">
<div class="header-container">
<a class="header-logo" href="https://pytorch.org/" aria-label="PyTorch"></a>
<div class="main-menu">
<ul>
<li>
<a href="https://pytorch.org/get-started">Get Started</a>
</li>
<li>
<a href="https://pytorch.org/ecosystem">Ecosystem</a>
</li>
<li>
<a href="https://pytorch.org/mobile">Mobile</a>
</li>
<li>
<a href="https://pytorch.org/blog/">Blog</a>
</li>
<li>
<a href="https://pytorch.org/tutorials">Tutorials</a>
</li>
<li class="active docs-active">
<div id="resourcesDropdownButton" data-toggle="resources-dropdown" class="resources-dropdown">
<a class="resource-option with-down-orange-arrow">
Docs
</a>
<div class="resources-dropdown-menu">
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/docs/stable/index.html">
<span class="dropdown-title">PyTorch</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/audio/stable/index.html">
<span class="dropdown-title">torchaudio</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/text/stable/index.html">
<span class="dropdown-title">torchtext</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/vision/stable/index.html">
<span class="dropdown-title">torchvision</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/torcharrow">
<span class="dropdown-title">torcharrow</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/data">
<span class="dropdown-title">TorchData</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/torchrec">
<span class="dropdown-title">TorchRec</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/serve/">
<span class="dropdown-title">TorchServe</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/torchx/">
<span class="dropdown-title">TorchX</span>
<p></p>
</a>
<a class="doc-dropdown-option nav-dropdown-item" href="https://pytorch.org/xla">
<span class="dropdown-title">PyTorch on XLA Devices</span>
<p></p>
</a>
</div>
</li>
<li>
<div id="resourcesDropdownButton" data-toggle="resources-dropdown" class="resources-dropdown">
<a class="resource-option with-down-arrow">
Resources
</a>
<div class="resources-dropdown-menu">
<a class="nav-dropdown-item" href="https://pytorch.org/features">
<span class="dropdown-title">About</span>
<p>Learn about PyTorch’s features and capabilities</p>
</a>
<a class="nav-dropdown-item" href="https://pytorch.org/foundation">
<span class="dropdown-title">PyTorch Foundation</span>
<p>Learn about the PyTorch foundation</p>
</a>
<a class="nav-dropdown-item" href="https://pytorch.org/#community-module">
<span class="dropdown-title">Community</span>
<p>Join the PyTorch developer community to contribute, learn, and get your questions answered.</p>
</a>
<a class="nav-dropdown-item" href="https://pytorch.org/community-stories">
<span class="dropdown-title">Community Stories</span>
<p>Learn how our community solves real, everyday machine learning problems with PyTorch.</p>
</a>
<a class="nav-dropdown-item" href="https://pytorch.org/resources">
<span class="dropdown-title">Developer Resources</span>
<p>Find resources and get questions answered</p>
</a>
<a class="nav-dropdown-item" href="https://pytorch.org/events">
<span class="dropdown-title">Events</span>
<p>Find events, webinars, and podcasts</p>
</a>
<a class="nav-dropdown-item" href="https://discuss.pytorch.org/" target="_blank">
<span class="dropdown-title">Forums</span>
<p>A place to discuss PyTorch code, issues, install, research</p>
</a>
<a class="nav-dropdown-item" href="https://pytorch.org/hub">
<span class="dropdown-title">Models (Beta)</span>
<p>Discover, publish, and reuse pre-trained models</p>
</a>
</div>
</div>
</li>
<li>
<a href="https://github.com/pytorch/pytorch">GitHub</a>
</li>
</ul>
</div>
<a class="main-menu-open-button" href="#" data-behavior="open-mobile-menu"></a>
</div>
</div>
</div>
<body class="pytorch-body">
<div class="table-of-contents-link-wrapper">
<span>Table of Contents</span>
<a href="#" class="toggle-table-of-contents" data-behavior="toggle-table-of-contents"></a>
</div>
<nav data-toggle="wy-nav-shift" class="pytorch-left-menu" id="pytorch-left-menu">
<div class="pytorch-side-scroll">
<div class="pytorch-menu pytorch-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<div class="pytorch-left-menu-search">
<div class="version">
<a href='https://pytorch.org/docs/versions.html'>master (2.1.0a0+gitbe0b12e ) ▼</a>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search Docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div>
<a style="color:#F05732" href="https://pytorch.org/docs/stable/compile/troubleshooting.html">
You are viewing unstable developer preview docs.
Click here to view docs for latest stable release.
</a>
</div>
<p class="caption" role="heading"><span class="caption-text">Community</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../community/build_ci_governance.html">PyTorch Governance | Build + CI</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/contribution_guide.html">PyTorch Contribution Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/design.html">PyTorch Design Philosophy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/governance.html">PyTorch Governance | Mechanics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/persons_of_interest.html">PyTorch Governance | Maintainers</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Developer Notes</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../notes/amp_examples.html">CUDA Automatic Mixed Precision examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/autograd.html">Autograd mechanics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/broadcasting.html">Broadcasting semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/cpu_threading_torchscript_inference.html">CPU threading and TorchScript inference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/cuda.html">CUDA semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/ddp.html">Distributed Data Parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/extending.html">Extending PyTorch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/extending.func.html">Extending torch.func with autograd.Function</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/gradcheck.html">Gradcheck mechanics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/hip.html">HIP (ROCm) semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/large_scale_deployments.html">Features for large-scale deployments</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/modules.html">Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/mps.html">MPS backend</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/multiprocessing.html">Multiprocessing best practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/numerical_accuracy.html">Numerical accuracy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/randomness.html">Reproducibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/serialization.html">Serialization semantics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../notes/windows.html">Windows FAQ</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">torch.compile</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">torch.compile</a></li>
<li class="toctree-l1"><a class="reference internal" href="get-started.html">Getting Started</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">PyTorch 2.0 Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="technical-overview.html">Technical Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="guards-overview.html">Guards Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="custom-backends.html">Custom Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="deep-dive.html">TorchDynamo Deeper Dive</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ir.html">IRs</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Language Bindings</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../cpp_index.html">C++</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/javadoc/">Javadoc</a></li>
<li class="toctree-l1"><a class="reference internal" href="../deploy.html">torch::deploy</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Python API</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../torch.html">torch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nn.html">torch.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nn.functional.html">torch.nn.functional</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tensors.html">torch.Tensor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tensor_attributes.html">Tensor Attributes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tensor_view.html">Tensor Views</a></li>
<li class="toctree-l1"><a class="reference internal" href="../amp.html">torch.amp</a></li>
<li class="toctree-l1"><a class="reference internal" href="../autograd.html">torch.autograd</a></li>
<li class="toctree-l1"><a class="reference internal" href="../library.html">torch.library</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cuda.html">torch.cuda</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mps.html">torch.mps</a></li>
<li class="toctree-l1"><a class="reference internal" href="../backends.html">torch.backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed.html">torch.distributed</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed.algorithms.join.html">torch.distributed.algorithms.join</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed.elastic.html">torch.distributed.elastic</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fsdp.html">torch.distributed.fsdp</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed.optim.html">torch.distributed.optim</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed.tensor.parallel.html">torch.distributed.tensor.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributed.checkpoint.html">torch.distributed.checkpoint</a></li>
<li class="toctree-l1"><a class="reference internal" href="../distributions.html">torch.distributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../_dynamo.html">torch._dynamo</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fft.html">torch.fft</a></li>
<li class="toctree-l1"><a class="reference internal" href="../func.html">torch.func</a></li>
<li class="toctree-l1"><a class="reference internal" href="../futures.html">torch.futures</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fx.html">torch.fx</a></li>
<li class="toctree-l1"><a class="reference internal" href="../hub.html">torch.hub</a></li>
<li class="toctree-l1"><a class="reference internal" href="../jit.html">torch.jit</a></li>
<li class="toctree-l1"><a class="reference internal" href="../linalg.html">torch.linalg</a></li>
<li class="toctree-l1"><a class="reference internal" href="../monitor.html">torch.monitor</a></li>
<li class="toctree-l1"><a class="reference internal" href="../signal.html">torch.signal</a></li>
<li class="toctree-l1"><a class="reference internal" href="../special.html">torch.special</a></li>
<li class="toctree-l1"><a class="reference internal" href="../torch.overrides.html">torch.overrides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../package.html">torch.package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../profiler.html">torch.profiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nn.init.html">torch.nn.init</a></li>
<li class="toctree-l1"><a class="reference internal" href="../onnx.html">torch.onnx</a></li>
<li class="toctree-l1"><a class="reference internal" href="../onnx_diagnostics.html">torch.onnx diagnostics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../optim.html">torch.optim</a></li>
<li class="toctree-l1"><a class="reference internal" href="../complex_numbers.html">Complex Numbers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ddp_comm_hooks.html">DDP Communication Hooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../pipeline.html">Pipeline Parallelism</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quantization.html">Quantization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../rpc.html">Distributed RPC Framework</a></li>
<li class="toctree-l1"><a class="reference internal" href="../random.html">torch.random</a></li>
<li class="toctree-l1"><a class="reference internal" href="../masked.html">torch.masked</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nested.html">torch.nested</a></li>
<li class="toctree-l1"><a class="reference internal" href="../sparse.html">torch.sparse</a></li>
<li class="toctree-l1"><a class="reference internal" href="../storage.html">torch.Storage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../testing.html">torch.testing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../benchmark_utils.html">torch.utils.benchmark</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bottleneck.html">torch.utils.bottleneck</a></li>
<li class="toctree-l1"><a class="reference internal" href="../checkpoint.html">torch.utils.checkpoint</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp_extension.html">torch.utils.cpp_extension</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data.html">torch.utils.data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../jit_utils.html">torch.utils.jit</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dlpack.html">torch.utils.dlpack</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mobile_optimizer.html">torch.utils.mobile_optimizer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo.html">torch.utils.model_zoo</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tensorboard.html">torch.utils.tensorboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="../type_info.html">Type Info</a></li>
<li class="toctree-l1"><a class="reference internal" href="../named_tensor.html">Named Tensors</a></li>
<li class="toctree-l1"><a class="reference internal" href="../name_inference.html">Named Tensors operator coverage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../config_mod.html">torch.__config__</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Libraries</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/audio/stable">torchaudio</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/data">TorchData</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/torchrec">TorchRec</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/serve">TorchServe</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/text/stable">torchtext</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/vision/stable">torchvision</a></li>
<li class="toctree-l1"><a class="reference external" href="https://pytorch.org/xla/">PyTorch on XLA Devices</a></li>
</ul>
</div>
</div>
</nav>
<div class="pytorch-container">
<div class="pytorch-page-level-bar" id="pytorch-page-level-bar">
<div class="pytorch-breadcrumbs-wrapper">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="pytorch-breadcrumbs">
<li>
<a href="../index.html">
Docs
</a> >
</li>
<li><a href="index.html">torch.compile</a> ></li>
<li>PyTorch 2.0 Troubleshooting</li>
<li class="pytorch-breadcrumbs-aside">
<a href="../_sources/compile/troubleshooting.rst.txt" rel="nofollow"><img src="../_static/images/view-page-source-icon.svg"></a>
</li>
</ul>
</div>
</div>
<div class="pytorch-shortcuts-wrapper" id="pytorch-shortcuts-wrapper">
Shortcuts
</div>
</div>
<section data-toggle="wy-nav-shift" id="pytorch-content-wrap" class="pytorch-content-wrap">
<div class="pytorch-content-left">
<div class="rst-content">
<div role="main" class="main-content" itemscope="itemscope" itemtype="http://schema.org/Article">
<article itemprop="articleBody" id="pytorch-article" class="pytorch-article">
<section id="pytorch-2-0-troubleshooting">
<h1>PyTorch 2.0 Troubleshooting<a class="headerlink" href="#pytorch-2-0-troubleshooting" title="Permalink to this heading">¶</a></h1>
<p><strong>Author</strong>: <a class="reference external" href="https://github.com/mlazos">Michael Lazos</a></p>
<p><cite>torch.compile</cite> is still in active development, and many of the reasons for
graph breaks and excessive recompilation will be fixed with upcoming
support for <a class="reference external" href="https://docs.google.com/document/d/1QJB-GOnbv-9PygGlOMXwiO9K6vVNm8sNg_olixJ9koc/edit?usp=sharing">tracing dynamic tensor
shapes</a>,
more careful choices for guards and better tuned heuristics.</p>
<p>In the meantime, you may need to diagnose a particular issue and
determine if it is easy to work around with a change to your model, or
file an issue for support.</p>
<p>Also, we are actively developing debug tools, profilers, and improving our
errors/warnings. Please give us feedback if you have an issue with this
infra, or an idea for an improvement. Below is a table of the available
tools and their typical usage. For additional help see
<a class="reference external" href="#diagnosing-runtime-errors">Diagnosing Runtime Errors</a>.</p>
<table class="docutils align-default" id="id1">
<caption><span class="caption-text">Title</span><a class="headerlink" href="#id1" title="Permalink to this table">¶</a></caption>
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Tool</p></th>
<th class="head"><p>Purpose</p></th>
<th class="head"><p>Usage</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Info logging</p></td>
<td><p>View summarized steps of compilation</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.log_level</span> <span class="pre">=</span> <span class="pre">logging.INFO</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Debug logging</p></td>
<td><p>View detailed steps of compilation (print every instruction traced)</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.log_level</span> <span class="pre">=</span> <span class="pre">logging.DEBUG</span></code> and
<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.verbose</span> <span class="pre">=</span> <span class="pre">True</span></code></p></td>
</tr>
<tr class="row-even"><td><p>Minifier for any backend</p></td>
<td><p>Find smallest subgraph which reproduces errors for any backend</p></td>
<td><p>set environment variable <code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_REPRO_AFTER="dynamo"</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Minifier for <code class="docutils literal notranslate"><span class="pre">TorchInductor</span></code></p></td>
<td><p>If the error is known to occur after <cite>AOTAutograd`</cite> find
smallest subgraph which reproduces errors during TorchInductor lowering</p></td>
<td><p>set environment variable <code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_REPRO_AFTER="aot"</span></code></p></td>
</tr>
<tr class="row-even"><td><p>Dynamo accuracy minifier</p></td>
<td><p>Finds the smallest subgraph which reproduces an accuracy issue
between an eager model model and optimized model, when you
suspect the problem is in AOTAutograd</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_REPRO_AFTER="dynamo"</span> <span class="pre">TORCHDYNAMO_REPRO_LEVEL=4</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Inductor accuracy minifier</p></td>
<td><p>Finds the smallest subgraph which reproduces an accuracy issue
between an eager model model and optimized model, when you
suspect the problem is in the backend (e.g., inductor).
If this doesn’t work, try the Dynamo accuracy minifier
instead.</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_REPRO_AFTER="aot"</span> <span class="pre">TORCHDYNAMO_REPRO_LEVEL=4</span></code></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">torch._dynamo.explain</span></code></p></td>
<td><p>Find graph breaks and display reasoning for them</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">torch._dynamo.explain(fn,</span> <span class="pre">*inputs)</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Record/Replay</p></td>
<td><p>Record and replay frames which to reproduce errors during graph capture</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.replay_record_enabled</span> <span class="pre">=</span> <span class="pre">True</span></code></p></td>
</tr>
<tr class="row-even"><td><p>TorchDynamo function name filtering</p></td>
<td><p>Only compile functions with the given name to reduce noise when
debugging an issue</p></td>
<td><p>set environment variable <code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_DEBUG_FUNCTION=<name></span></code></p></td>
</tr>
<tr class="row-odd"><td><p>TorchInductor Debug logging</p></td>
<td><p>Print general TorchInductor debug info and generated Triton/C++ code</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">torch._inductor.config.debug</span> <span class="pre">=</span> <span class="pre">True</span></code></p></td>
</tr>
<tr class="row-even"><td><p>TorchInductor Tracing</p></td>
<td><p>Show time taken in each TorchInductor stage + output code and graph
visualization</p></td>
<td><p>set the environment variable TORCH_COMPILE_DEBUG=1 or
<code class="docutils literal notranslate"><span class="pre">torch._inductor.config.trace.enabled</span> <span class="pre">=</span> <span class="pre">True</span></code></p></td>
</tr>
</tbody>
</table>
<section id="diagnosing-runtime-errors">
<h2>Diagnosing Runtime Errors<a class="headerlink" href="#diagnosing-runtime-errors" title="Permalink to this heading">¶</a></h2>
<p>Below is the TorchDynamo compiler stack.</p>
<p>At a high level, the TorchDynamo stack consists of a graph capture from
Python code (TorchDynamo) and a backend compiler. In this example, the
backend compiler consists of backward graph tracing (AOTAutograd) and
graph lowering (TorchInductor)*. Errors can occur in any component of
the stack and will provide full stack traces.</p>
<p>You may use info logging
(<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.log_level</span> <span class="pre">=</span> <span class="pre">logging.INFO</span></code>) and look for
<code class="docutils literal notranslate"><span class="pre">Step</span> <span class="pre">#:</span> <span class="pre">...</span></code> outputs in order to determine in which component the
error has occurred. Logs are made at the beginning and end of each step,
so the step that an error should correspond to is the most recent logged
step whose end has not yet been logged. The steps correspond to the
following parts of the stack (according to the image above):</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Step</p></th>
<th class="head"><p>Component</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>1</p></td>
<td><p>TorchDynamo</p></td>
</tr>
<tr class="row-odd"><td><p>2</p></td>
<td><p>Compiler Backend</p></td>
</tr>
<tr class="row-even"><td><p>3</p></td>
<td><p>TorchInductor</p></td>
</tr>
</tbody>
</table>
<p>The beginning and end of AOTAutograd is currently not logged, but we
plan to add it soon.</p>
<p>If info logging is insufficient, then there are also some backend
options which can enable you to determine which component is causing the
error if you’re unable to understand the error message that is
generated. These are the following:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"eager"</span></code>: only runs torchdynamo forward graph capture and then
runs the captured graph with PyTorch. This provides an indication as
to whether TorchDynamo is raising the error.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"aot_eager"</span></code>: runs torchdynamo to capture a forward graph, and
then AOTAutograd to trace the backward graph without any additional
backend compiler steps. PyTorch eager will then be used to run the
forward and backward graphs. This is useful to narrow down the issue
to AOTAutograd.</p></li>
</ul>
<p>The general procedure to narrow down an issue is the following:</p>
<ol class="arabic simple">
<li><p>Run your program with the <code class="docutils literal notranslate"><span class="pre">"eager"</span></code> backend. If the error no longer
occurs, the issue is in the backend compiler that is being used (if
using TorchInductor, proceed to step 2. If not, see <a class="reference external" href="#minifying-backend-compiler-errors">this
section</a>). If the error still
occurs with the <code class="docutils literal notranslate"><span class="pre">"eager"</span></code> backend, it is an <a class="reference external" href="#torchdynamo-errors">error while running
torchdynamo</a>.</p></li>
<li><p>This step is only necessary if <code class="docutils literal notranslate"><span class="pre">TorchInductor</span></code> is used as the backend
compiler. Run the model with the <code class="docutils literal notranslate"><span class="pre">"aot_eager"</span></code> backend. If this
backend raises an error then the error is occurring during
AOTAutograd tracing. If the error no longer occurs with this backend,
then <a class="reference external" href="#minifying-torchinductor-errors">the error is in
TorchInductor*</a>.</p></li>
</ol>
<p>Each of these cases are analyzed in the following sections.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The TorchInductor backend consists of
both AOTAutograd tracing and the TorchInductor compiler itself. We will
disambiguate by referring to <code class="docutils literal notranslate"><span class="pre">TorchInductor</span></code> as the backend, and
TorchInductor lowering as the phase which lowers the graph traced by
AOTAutograd.</p>
</div>
<section id="torchdynamo-errors">
<h3>Torchdynamo Errors<a class="headerlink" href="#torchdynamo-errors" title="Permalink to this heading">¶</a></h3>
<p>If the error that is generated occurs with the <code class="docutils literal notranslate"><span class="pre">"eager"</span></code> backend, then
TorchDynamo is the most likely source of the error. Here is a sample code
which will generate an error.</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">import</span> <span class="nn">torch._dynamo</span> <span class="k">as</span> <span class="nn">dynamo</span>
<span class="k">def</span> <span class="nf">test_assertion_error</span><span class="p">():</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
<span class="n">z</span> <span class="o">=</span> <span class="p">{</span><span class="n">y</span><span class="p">:</span> <span class="mi">5</span><span class="p">}</span>
<span class="k">return</span> <span class="n">z</span>
<span class="n">compiled_test_assertion_error</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">test_assertion_error</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="s2">"eager"</span><span class="p">)</span>
<span class="n">compiled_test_assertion_error</span><span class="p">()</span>
</pre></div>
</div>
<p>Which will generate the following error:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">torch</span><span class="o">.</span><span class="n">_dynamo</span><span class="o">.</span><span class="n">convert_frame</span><span class="p">:</span> <span class="p">[</span><span class="n">ERROR</span><span class="p">]</span> <span class="n">WON</span><span class="s1">'T CONVERT test_assertion_error /scratch/mlazos/torchdynamo/../test/errors.py line 26</span>
<span class="n">due</span> <span class="n">to</span><span class="p">:</span>
<span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
<span class="n">File</span> <span class="s2">"/scratch/mlazos/torchdynamo/torchdynamo/symbolic_convert.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">837</span><span class="p">,</span> <span class="ow">in</span> <span class="n">BUILD_MAP</span>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">ConstantVariable</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span>
<span class="ne">AssertionError</span>
<span class="kn">from</span> <span class="nn">user</span> <span class="n">code</span><span class="p">:</span>
<span class="n">File</span> <span class="s2">"/scratch/mlazos/torchdynamo/../test/errors.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">34</span><span class="p">,</span> <span class="ow">in</span> <span class="n">test_assertion_error</span>
<span class="n">z</span> <span class="o">=</span> <span class="p">{</span><span class="n">y</span><span class="p">:</span> <span class="mi">5</span><span class="p">}</span>
<span class="n">Set</span> <span class="n">torch</span><span class="o">.</span><span class="n">_dynamo</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">verbose</span><span class="o">=</span><span class="kc">True</span> <span class="k">for</span> <span class="n">more</span> <span class="n">information</span>
<span class="o">==========</span>
</pre></div>
</div>
<p>As the message suggests you can set
<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.verbose=True</span></code> to get a full stack trace to both
the error in TorchDynamo and the user code. In addition to this flag,
you can also set the <code class="docutils literal notranslate"><span class="pre">log_level</span></code> of torchdynamo through
<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.log_level</span></code>. The available levels are the
following:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">logging.DEBUG</span></code>: Print every instruction that is
encountered in addition to all below log levels.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">logging.INFO</span></code>:
Print each function that is compiled (original and modified bytecode)
and the graph that is captured in addition to all below log levels.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">logging.WARNING</span></code> (default): Print graph breaks in addition to all
below log levels.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">logging.ERROR</span></code>: Print errors only.</p></li>
</ul>
<p>If a model is sufficiently large, the logs can become overwhelming. If
an error occurs deep within a model’s Python code, it can be useful to
execute only the frame in which the error occurs to enable easier
debugging. There are two tools available to enable this:</p>
<ul class="simple">
<li><p>Setting the environment variable <code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_DEBUG_FUNCTION</span></code> to the desired function name will only run torchdynamo on functions with that name.</p></li>
<li><p>Enabling the record/replay tool (set <code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.replay_record_enabled</span> <span class="pre">=</span> <span class="pre">True</span></code>) which dumps an execution record when an error is encountered. This record can then be replayed to run only the frame where an error occurred.</p></li>
</ul>
</section>
<section id="torchinductor-errors">
<h3>TorchInductor Errors<a class="headerlink" href="#torchinductor-errors" title="Permalink to this heading">¶</a></h3>
<p>If the error does not occur with the <code class="docutils literal notranslate"><span class="pre">"eager"</span></code> backend, then the
backend compiler is the source of the error (<a class="reference external" href="https://gist.github.com/mlazos/2f13681e3cc6c43b3911f336327032de%5D">example
error</a>).
There are <a class="reference external" href="https://github.com/pytorch/torchdynamo/blob/0b8aaf340dad4777a080ef24bf09623f1aa6f3dd/README.md#existing-backends">different
choices</a>
for backend compilers for TorchDynamo, with TorchInductor or nvfuser
fitting the needs of most users. This section focuses on TorchInductor
as the motivating example, but some tools will be usable with other
backend compilers.</p>
<p>Below is the portion of the stack which we are focusing on:</p>
<p>With TorchInductor as the chosen backend, AOTAutograd is used to
generate the backward graph from the forward graph captured by
torchdynamo. It is important to note that errors can occur during this
tracing and also while TorchInductor lowers the forward and backward
graphs to GPU code or C++. A model can often consist of hundreds or
thousands of FX nodes, so narrowing the exact nodes where this problem
occurred can be very difficult. Fortunately, there are tools available to
automatically minify these input graphs to the nodes which are causing
the issue. The first step is to determine whether the error occurs
during tracing of the backward graph with AOTAutograd or during
TorchInductor lowering. As mentioned above in step 2, the
<code class="docutils literal notranslate"><span class="pre">"aot_eager"</span></code> backend can be used to run only AOTAutograd in isolation
without lowering. If the error still occurs with this backend, this
indicates that the error is occurring during AOTAutograd tracing.</p>
<p>Here is an example:</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">import</span> <span class="nn">torch._dynamo</span> <span class="k">as</span> <span class="nn">dynamo</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Sequential</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Linear</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">)])</span>
<span class="k">def</span> <span class="nf">test_backend_error</span><span class="p">():</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
<span class="n">z</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ops</span><span class="o">.</span><span class="n">aten</span><span class="o">.</span><span class="n">_foobar</span><span class="p">(</span><span class="n">z</span><span class="p">)</span> <span class="c1"># dummy function which errors</span>
<span class="k">return</span> <span class="n">model</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="n">compiled_test_backend_error</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">test_backend_error</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="s2">"inductor"</span><span class="p">)</span>
<span class="n">compiled_test_backend_error</span><span class="p">()</span>
</pre></div>
</div>
<p>Running this should give you this error with a longer stack trace below
it:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
<span class="n">File</span> <span class="s2">"/scratch/mlazos/torchdynamo/torchinductor/graph.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">246</span><span class="p">,</span> <span class="ow">in</span> <span class="n">call_function</span>
<span class="k">return</span> <span class="n">lowerings</span><span class="p">[</span><span class="n">target</span><span class="p">](</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="n">File</span> <span class="s2">"/scratch/mlazos/torchdynamo/torchinductor/lowering.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">185</span><span class="p">,</span> <span class="ow">in</span> <span class="n">wrapped</span>
<span class="k">return</span> <span class="n">decomp_fn</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="n">File</span> <span class="s2">"/scratch/mlazos/torchdynamo/torchinductor/lowering.py"</span><span class="p">,</span> <span class="n">line</span> <span class="mi">810</span><span class="p">,</span> <span class="ow">in</span> <span class="n">_foobar</span>
<span class="k">assert</span> <span class="kc">False</span>
<span class="ne">AssertionError</span>
<span class="o">...</span>
</pre></div>
</div>
<p><a class="reference external" href="https://gist.github.com/mlazos/d6947854aa56d686800259a164c62100">error with full stack
trace</a></p>
<p>If you then change <code class="docutils literal notranslate"><span class="pre">torch.compile(backend="inductor")</span></code> to
<code class="docutils literal notranslate"><span class="pre">torch.compile(backend="aot_eager")</span></code>, it will run without error, because
<a class="reference external" href="https://github.com/pytorch/torchdynamo/blob/d09e50fbee388d466b5252a63045643166006f77/torchinductor/lowering.py#:~:text=%23%20This%20shouldn%27t%20be,assert%20False">the
issue</a>
is in the TorchInductor lowering process, not in AOTAutograd.</p>
</section>
<section id="minifying-torchinductor-errors">
<h3>Minifying TorchInductor Errors<a class="headerlink" href="#minifying-torchinductor-errors" title="Permalink to this heading">¶</a></h3>
<p>From here, let’s run the minifier to get a minimal repro. Setting the
environment variable <code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_REPRO_AFTER=“aot”</span></code> (or setting
<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.repro_after="aot"</span></code> directly) will generate a
Python program which reduces the graph produced by AOTAutograd to the
smallest subgraph which reproduces the error. (See below for an example
where we minify the graph produced by torchdynamo) Running the program
with this environment variable should show nearly <a class="reference external" href="https://gist.github.com/mlazos/0458ab828aa403c779fe73c012aa5982">identical
output</a>,
with an additional line indicating where <code class="docutils literal notranslate"><span class="pre">minifier_launcher.py</span></code> has
been written to. The output directory is configurable by setting
<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.base_dir</span></code> to a valid directory name. The final
step is to run the minifier and check that it runs successfully. A
successful run looks like
<a class="reference external" href="https://gist.github.com/mlazos/e6ea41ccce68a7b1b8a7a09acb1b206a">this</a>.
If the minifier runs successfully, it generates runnable python code
which reproduces the exact error. For our example this is the following
code:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">from</span> <span class="nn">torch</span> <span class="kn">import</span> <span class="n">tensor</span><span class="p">,</span> <span class="n">device</span>
<span class="kn">import</span> <span class="nn">torch.fx</span> <span class="k">as</span> <span class="nn">fx</span>
<span class="kn">from</span> <span class="nn">torch._dynamo.testing</span> <span class="kn">import</span> <span class="n">rand_strided</span>
<span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">inf</span>
<span class="kn">from</span> <span class="nn">torch.fx.experimental.proxy_tensor</span> <span class="kn">import</span> <span class="n">make_fx</span>
<span class="c1"># torch version: 1.13.0a0+gitfddfc44</span>
<span class="c1"># torch cuda version: 11.6</span>
<span class="c1"># torch git version: fddfc4488afb207971c54ad4bf58130fdc8a4dc5</span>
<span class="c1"># CUDA Info:</span>
<span class="c1"># nvcc: NVIDIA (R) Cuda compiler driver</span>
<span class="c1"># Copyright (c) 2005-2022 NVIDIA Corporation</span>
<span class="c1"># Built on Thu_Feb_10_18:23:41_PST_2022</span>
<span class="c1"># Cuda compilation tools, release 11.6, V11.6.112</span>
<span class="c1"># Build cuda_11.6.r11.6/compiler.30978841_0</span>
<span class="c1"># GPU Hardware Info:</span>
<span class="c1"># NVIDIA A100-SXM4-40GB : 8</span>
<span class="kn">from</span> <span class="nn">torch.nn</span> <span class="kn">import</span> <span class="o">*</span>
<span class="k">class</span> <span class="nc">Repro</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Module</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">add</span><span class="p">):</span>
<span class="n">_foobar</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ops</span><span class="o">.</span><span class="n">aten</span><span class="o">.</span><span class="n">_foobar</span><span class="o">.</span><span class="n">default</span><span class="p">(</span><span class="n">add</span><span class="p">);</span> <span class="n">add</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">return</span> <span class="p">(</span><span class="n">_foobar</span><span class="p">,)</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">),</span> <span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">torch</span><span class="o">.</span><span class="n">float32</span><span class="p">,</span> <span class="s1">'cpu'</span><span class="p">)]</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="n">rand_strided</span><span class="p">(</span><span class="n">shape</span><span class="p">,</span> <span class="n">stride</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">device</span><span class="p">)</span> <span class="k">for</span> <span class="n">shape</span><span class="p">,</span> <span class="n">stride</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">device</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span>
<span class="n">mod</span> <span class="o">=</span> <span class="n">make_fx</span><span class="p">(</span><span class="n">Repro</span><span class="p">())(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
<span class="kn">from</span> <span class="nn">torch._inductor.compile_fx</span> <span class="kn">import</span> <span class="n">compile_fx_inner</span>
<span class="n">compiled</span> <span class="o">=</span> <span class="n">compile_fx_inner</span><span class="p">(</span><span class="n">mod</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span>
<span class="n">compiled</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">forward</span></code> method of the <code class="docutils literal notranslate"><span class="pre">Repro</span></code> module contains the exact op
which causes the issue. When filing an issue, please include any
minified repros to aid in debugging.</p>
</section>
<section id="minifying-backend-compiler-errors">
<h3>Minifying Backend Compiler Errors<a class="headerlink" href="#minifying-backend-compiler-errors" title="Permalink to this heading">¶</a></h3>
<p>With backend compilers other than TorchInductor the process for finding
the subgraph causing the error is nearly identical to the procedure in
<a class="reference external" href="#torchinductor-errors">errors in TorchInductor</a> with one important
caveat. Namely, that the minifier will now be run on the graph that is
traced by TorchDynamo, not the output graph of AOTAutograd. Let’s walk
through an example.</p>
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">import</span> <span class="nn">torch._dynamo</span> <span class="k">as</span> <span class="nn">dynamo</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Sequential</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Linear</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">)])</span>
<span class="c1"># toy compiler which fails if graph contains relu</span>
<span class="k">def</span> <span class="nf">toy_compiler</span><span class="p">(</span><span class="n">gm</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">fx</span><span class="o">.</span><span class="n">GraphModule</span><span class="p">,</span> <span class="n">_</span><span class="p">):</span>
<span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">gm</span><span class="o">.</span><span class="n">graph</span><span class="o">.</span><span class="n">nodes</span><span class="p">:</span>
<span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">target</span> <span class="o">==</span> <span class="n">torch</span><span class="o">.</span><span class="n">relu</span><span class="p">:</span>
<span class="k">assert</span> <span class="kc">False</span>
<span class="k">return</span> <span class="n">gm</span>
<span class="k">def</span> <span class="nf">test_backend_error</span><span class="p">():</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
<span class="n">z</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">relu</span><span class="p">(</span><span class="n">z</span><span class="p">)</span>
<span class="k">return</span> <span class="n">model</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="n">compiled_test_backend_error</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">test_backend_error</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="n">toy_compiler</span><span class="p">)</span>
<span class="n">compiled_test_backend_error</span><span class="p">()</span>
</pre></div>
</div>
<p>In order to run the code after TorchDynamo has traced the forward graph,
you can use the <code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_REPRO_AFTER</span></code> environment variable. Running
this program with <code class="docutils literal notranslate"><span class="pre">TORCHDYNAMO_REPRO_AFTER=“dynamo”</span></code> (or
<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.repro_after="dynamo"</span></code>) should produce <a class="reference external" href="https://gist.github.com/mlazos/244e3d5b53667e44078e194762c0c92b">this
output</a>and
the following code in <code class="docutils literal notranslate"><span class="pre">{torch._dynamo.config.base_dir}/repro.py</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The other option for TORCHDYNAMO_REPRO_AFTER are <code class="docutils literal notranslate"><span class="pre">"aot"</span></code>, which
will run the minifier after the backward graph has been generated.</p>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">import</span> <span class="nn">torch._dynamo</span> <span class="k">as</span> <span class="nn">dynamo</span>
<span class="kn">from</span> <span class="nn">torch</span> <span class="kn">import</span> <span class="n">tensor</span><span class="p">,</span> <span class="n">device</span>
<span class="kn">import</span> <span class="nn">torch.fx</span> <span class="k">as</span> <span class="nn">fx</span>
<span class="kn">from</span> <span class="nn">torch._dynamo.testing</span> <span class="kn">import</span> <span class="n">rand_strided</span>
<span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">inf</span>
<span class="kn">from</span> <span class="nn">torch._dynamo.debug_utils</span> <span class="kn">import</span> <span class="n">run_fwd_maybe_bwd</span>
<span class="kn">from</span> <span class="nn">torch.nn</span> <span class="kn">import</span> <span class="o">*</span>
<span class="k">class</span> <span class="nc">Repro</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Module</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">add</span><span class="p">):</span>
<span class="n">relu</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">relu</span><span class="p">(</span><span class="n">add</span><span class="p">);</span> <span class="n">add</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">return</span> <span class="p">(</span><span class="n">relu</span><span class="p">,)</span>
<span class="n">mod</span> <span class="o">=</span> <span class="n">Repro</span><span class="p">()</span><span class="o">.</span><span class="n">cuda</span><span class="p">()</span>
<span class="n">opt_mod</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">mod</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="s2">"None"</span><span class="p">)</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">[((</span><span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">),</span> <span class="p">(</span><span class="mi">200</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">torch</span><span class="o">.</span><span class="n">float32</span><span class="p">,</span> <span class="s1">'cpu'</span><span class="p">,</span> <span class="kc">False</span><span class="p">)]</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="n">rand_strided</span><span class="p">(</span><span class="n">sh</span><span class="p">,</span> <span class="n">st</span><span class="p">,</span> <span class="n">dt</span><span class="p">,</span> <span class="n">dev</span><span class="p">)</span><span class="o">.</span><span class="n">requires_grad_</span><span class="p">(</span><span class="n">rg</span><span class="p">)</span> <span class="k">for</span> <span class="p">(</span><span class="n">sh</span><span class="p">,</span> <span class="n">st</span><span class="p">,</span> <span class="n">dt</span><span class="p">,</span> <span class="n">dev</span><span class="p">,</span> <span class="n">rg</span><span class="p">)</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span>
<span class="k">with</span> <span class="n">torch</span><span class="o">.</span><span class="n">cuda</span><span class="o">.</span><span class="n">amp</span><span class="o">.</span><span class="n">autocast</span><span class="p">(</span><span class="n">enabled</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="n">ref</span> <span class="o">=</span> <span class="n">run_fwd_maybe_bwd</span><span class="p">(</span><span class="n">mod</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">run_fwd_maybe_bwd</span><span class="p">(</span><span class="n">opt_mod</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span>
</pre></div>
</div>
<p>The minifier successfully reduced the graph to the op that raises the
error in <code class="docutils literal notranslate"><span class="pre">toy_compiler</span></code>. The other difference from the procedure in
<a class="reference external" href="#torchinductor-errors">TorhInductor Errors</a> is that the minifier is
automatically run after encountering a backend compiler error. After a
successful run, the minifier writes <code class="docutils literal notranslate"><span class="pre">repro.py</span></code> to
<code class="docutils literal notranslate"><span class="pre">torch._dynamo.config.base_dir</span></code>.</p>
</section>
</section>
<section id="performance-profiling">
<h2>Performance Profiling<a class="headerlink" href="#performance-profiling" title="Permalink to this heading">¶</a></h2>
<section id="accessing-torchdynamo-profiler">
<h3>Accessing TorchDynamo Profiler<a class="headerlink" href="#accessing-torchdynamo-profiler" title="Permalink to this heading">¶</a></h3>
<p>TorchDynamo has a builtin stats function for collecting and displaying
the time spent in each compilation phase. These stats can be accessed by
calling <code class="docutils literal notranslate"><span class="pre">torch._dynamo.utils.compile_times()</span></code> after executing
Torch._Dynamo. By default, this returns a string representation of the
compile times spent in each TorchDynamo function by name.</p>
</section>
<section id="torchinductor-debugging-using-torch-compile-debug">
<h3>TorchInductor Debugging using TORCH_COMPILE_DEBUG<a class="headerlink" href="#torchinductor-debugging-using-torch-compile-debug" title="Permalink to this heading">¶</a></h3>
<p>TorchInductor has a builtin stats and trace function for displaying time
spent in each compilation phase, output code, output graph visualization
and IR dump. This is a debugging tool designed to make it easier to
understand and troubleshoot the internals of TorchInductor.</p>
<p>Let’s run an example with the following test program (repro.py):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="nd">@torch</span><span class="o">.</span><span class="n">compile</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">test_model</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Sequential</span><span class="p">(</span>
<span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Linear</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">),</span>
<span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">LayerNorm</span><span class="p">(</span><span class="mi">10</span><span class="p">),</span>
<span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">ReLU</span><span class="p">(),</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">model</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">test_model</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span>
</pre></div>
</div>
<p>Setting the environment variable <code class="docutils literal notranslate"><span class="pre">TORCH_COMPILE_DEBUG=1</span></code> will cause a
debug trace directory to be created, by default this directory will be in the current directory and named torch_compile_debug
(this can be overridden in the torchdynamo configuration field <code class="docutils literal notranslate"><span class="pre">debug_dir_root</span></code> and also the env var TORCH_COMPILE_DEBUG_DIR).
Inside this directory, each run will have a separate folder named with the timestamp and process id of the run:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ env TORCH_COMPILE_DEBUG=1 python repro.py
$ cd torch_compile_debug
$ ls
run_2023_03_01_08_20_52_143510-pid_180167
</pre></div>
</div>
<p>In the run folder there will be a torchdynamo directory which contains debug logs, and an torchinductor
folder which contains a subfolder for each compiled kernel with inductor debug artifacts.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd
run_2023_03_01_08_20_52_143510-pid_180167
$ ls
torchinductor torchdynamo
</pre></div>
</div>
<p>Moving further into the torchinductor directory, the *.log files are logs from the aot autograd phase of compilation, model__0_forward_1.0 contains the inductor debug artifacts.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ cd torchinductor
$ ls
aot_model___0_debug.log model__0_forward_1.0
$ cd model__0_forward_1.0
$ ls
debug.log fx_graph_readable.py fx_graph_runnable.py fx_graph_transformed.py ir_post_fusion.txt ir_pre_fusion.txt output_code.py
</pre></div>
</div>
<dl class="simple">
<dt>Here is a summary of the contents:</dt><dd><ul class="simple">
<li><p>fx_graph_readable.py and fx_graph_runnable.py are the readable and runnable versions of the fx_graph received by inductor.</p></li>
<li><p>fx_graph_transformed.py is the fx graph after inductor has run all fx passes.</p></li>
<li><p>ir*.txt is the inductor ir pre and post fusion.</p></li>
<li><p>output_code.py is the compiled triton kernel for the subgraph.</p></li>
</ul>
</dd>
</dl>
<p>Here are <a class="reference external" href="https://gist.github.com/jansel/f4af078791ad681a0d4094adeb844396">example debug directory contents</a>
for the test program:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torch</span>
<span class="nd">@torch</span><span class="o">.</span><span class="n">compile</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">test_model</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Sequential</span><span class="p">(</span>
<span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">Linear</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">),</span>
<span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">LayerNorm</span><span class="p">(</span><span class="mi">10</span><span class="p">),</span>
<span class="n">torch</span><span class="o">.</span><span class="n">nn</span><span class="o">.</span><span class="n">ReLU</span><span class="p">(),</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">model</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">test_model</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">))</span>
</pre></div>
</div>
<p>Each file in that debug trace can be enabled and disabled through
<code class="docutils literal notranslate"><span class="pre">torch._inductor.config.trace.*</span></code>. The profile and the diagram are both
disabled by default since they are expensive to generate.</p>
<p>A single node in this new debug format looks like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">buf1</span><span class="p">:</span> <span class="n">SchedulerNode</span><span class="p">(</span><span class="n">ComputedBuffer</span><span class="p">)</span>
<span class="n">buf1</span><span class="o">.</span><span class="n">writes</span> <span class="o">=</span>
<span class="p">{</span> <span class="n">MemoryDep</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'buf1'</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">()),</span>