11"""
2- (beta) Using TORCH_LOGS python API with torch.compile
2+ (beta) torch.compile๊ณผ ํจ๊ป TORCH_LOGS ํ์ด์ฌ API ์ฌ์ฉํ๊ธฐ
33==========================================================================================
4- **Author:** `Michael Lazos <https://github.com/mlazos>`_
4+ **์ ์:** `Michael Lazos <https://github.com/mlazos>`_
5+ **๋ฒ์ญ:** `์ฅํจ์ <https://github.com/hyoyoung>`_
56"""
67
78import logging
1011#
1112# This tutorial introduces the ``TORCH_LOGS`` environment variable, as well as the Python API, and
1213# demonstrates how to apply it to observe the phases of ``torch.compile``.
14+ # ์ด ํํ ๋ฆฌ์ผ์์๋ ``TORCH_LOGS`` ํ๊ฒฝ ๋ณ์์ ํจ๊ป Python API๋ฅผ ์๊ฐํ๊ณ ,
15+ # ์ด๋ฅผ ์ ์ฉํ์ฌ ``torch.compile``์ ๋จ๊ณ๋ฅผ ๊ด์ฐฐํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
1316#
1417# .. note::
1518#
16- # This tutorial requires PyTorch 2.2.0 or later .
19+ # ์ด ํํ ๋ฆฌ์ผ์๋ PyTorch 2.2.0 ์ด์ ๋ฒ์ ์ด ํ์ํฉ๋๋ค .
1720#
1821#
1922
2023
2124######################################################################
22- # Setup
25+ # ์ค์
2326# ~~~~~~~~~~~~~~~~~~~~~
2427# In this example, we'll set up a simple Python function which performs an elementwise
2528# add and observe the compilation process with ``TORCH_LOGS`` Python API.
29+ # ์ด ์์ ์์๋ ์์๋ณ ๋ง์
์ ์ํํ๋ ๊ฐ๋จํ ํ์ด์ฌ ํจ์๋ฅผ ์ค์ ํ๊ณ
30+ # ``TORCH_LOGS`` ํ์ด์ฌ API๋ฅผ ์ฌ์ฉํ์ฌ ์ปดํ์ผ ํ๋ก์ธ์ค๋ฅผ ๊ด์ฐฐํด ๋ณด๊ฒ ์ต๋๋ค.
2631#
2732# .. note::
2833#
29- # There is also an environment variable ``TORCH_LOGS``, which can be used to
30- # change logging settings at the command line. The equivalent environment
31- # variable setting is shown for each example .
34+ # ๋ช
๋ น์ค์์ ๋ก๊น
์ค์ ์ ๋ณ๊ฒฝํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋
35+ # ํ๊ฒฝ ๋ณ์ ``TORCH_LOGS``๋ ์์ต๋๋ค. ๊ฐ ์์ ์ ํด๋นํ๋
36+ # ํ๊ฒฝ ๋ณ์ ์ค์ ์ด ํ์๋์ด ์์ต๋๋ค .
3237
3338import torch
3439
35- # exit cleanly if we are on a device that doesn't support torch.compile
40+ # torch.compile์ ์ง์ํ์ง ์๋ ๊ธฐ๊ธฐ์ธ ๊ฒฝ์ฐ ์์ ํ ์ข
๋ฃํฉ๋๋ค.
3641if torch .cuda .get_device_capability () < (7 , 0 ):
3742 print ("Skipping because torch.compile is not supported on this device." )
3843else :
@@ -45,52 +50,51 @@ def fn(x, y):
4550 inputs = (torch .ones (2 , 2 , device = "cuda" ), torch .zeros (2 , 2 , device = "cuda" ))
4651
4752
48- # print separator and reset dynamo
49- # between each example
53+ # ๊ฐ ์์ ์ฌ์ด์ ๊ตฌ๋ถ ๊ธฐํธ๋ฅผ ์ถ๋ ฅํ๊ณ dynamo๋ฅผ resetํฉ๋๋ค
5054 def separator (name ):
5155 print (f"==================={ name } =========================" )
5256 torch ._dynamo .reset ()
5357
5458
5559 separator ("Dynamo Tracing" )
56- # View dynamo tracing
60+ # dynamo tracing ๋ณด๊ธฐ
5761# TORCH_LOGS="+dynamo"
5862 torch ._logging .set_logs (dynamo = logging .DEBUG )
5963 fn (* inputs )
6064
6165 separator ("Traced Graph" )
62- # View traced graph
66+ # traced ๊ทธ๋ํ ๋ณด๊ธฐ
6367# TORCH_LOGS="graph"
6468 torch ._logging .set_logs (graph = True )
6569 fn (* inputs )
6670
6771 separator ("Fusion Decisions" )
68- # View fusion decisions
72+ # fusion decision ๋ณด๊ธฐ
6973# TORCH_LOGS="fusion"
7074 torch ._logging .set_logs (fusion = True )
7175 fn (* inputs )
7276
7377 separator ("Output Code" )
74- # View output code generated by inductor
78+ # inductor๊ฐ ์์ฑํ ๊ฒฐ๊ณผ ์ฝ๋ ๋ณด๊ธฐ
7579# TORCH_LOGS="output_code"
7680 torch ._logging .set_logs (output_code = True )
7781 fn (* inputs )
7882
7983 separator ("" )
8084
8185######################################################################
82- # Conclusion
86+ # ๊ฒฐ๋ก
8387# ~~~~~~~~~~
8488#
85- # In this tutorial we introduced the TORCH_LOGS environment variable and python API
86- # by experimenting with a small number of the available logging options .
87- # To view descriptions of all available options, run any python script
88- # which imports torch and set TORCH_LOGS to "help".
89+ # ์ด ํํ ๋ฆฌ์ผ์์๋ ์ฌ์ฉ ๊ฐ๋ฅํ ๋ช ๊ฐ์ง ๋ก๊น
์ต์
์ ์คํํ์ฌ
90+ # TORCH_LOGS ํ๊ฒฝ ๋ณ์์ Python API๋ฅผ ์๊ฐํ์ต๋๋ค .
91+ # ์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ ์ต์
์ ๋ํ ์ค๋ช
์ ๋ณด๋ ค๋ฉด
92+ # ํ์ด์ฌ ์คํฌ๋ฆฝํธ์์ import torch๋ฅผ ์คํํ๊ณ TORCH_LOGS๋ฅผ "help"๋ก ์ค์ ํ์ธ์ .
8993#
90- # Alternatively, you can view the `torch._logging documentation `_ to see
91- # descriptions of all available logging options .
94+ # ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก๋, `torch._logging ๋ฌธ์ `_ ๋ฅผ ๋ณด๋ฉด,
95+ # ์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ ๋ก๊น
์ต์
์ ๋ํ ์ค๋ช
์ ํ์ธํ ์ ์์ต๋๋ค .
9296#
93- # For more information on torch.compile, see the `torch.compile tutorial`_ .
97+ # torch.compile์ ๊ดํ ๋ ๋ง์ ์ ๋ณด๋, `torch.compile ํํ ๋ฆฌ์ผ`_๋ฅผ ๋ณด์ธ์ .
9498#
95- # .. _torch._logging documentation : https://pytorch.org/docs/main/logging.html
96- # .. _torch.compile tutorial : https://tutorials.pytorch.kr/intermediate/torch_compile_tutorial.html
99+ # .. _torch._logging ๋ฌธ์ : https://pytorch.org/docs/main/logging.html
100+ # .. _torch.compile ํํ ๋ฆฌ์ผ : https://tutorials.pytorch.kr/intermediate/torch_compile_tutorial.html
0 commit comments