Skip to content

Commit

Permalink
Adjust the wording based on suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nluu175 committed Nov 7, 2024
1 parent 368e062 commit 8859a58
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions recipes_source/torch_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


def env_setup():
"""Set up environment for running the example. Exit cleanly if CUDA is not available."""
"""Set up the environment to run the example. Exit cleanly if CUDA is not available."""
if not torch.cuda.is_available():
print("CUDA is not available. Exiting.")
sys.exit(0)
Expand All @@ -46,7 +46,7 @@ def env_setup():


def separator(name):
"""Print separator and reset dynamo between each example"""
"""Print a separator and reset dynamo between each example"""
print(f"\n{'='*20} {name} {'='*20}")
torch._dynamo.reset()

Expand Down Expand Up @@ -92,20 +92,41 @@ def fn(x, y):
run_debugging_suite()

######################################################################
# Use TORCH_TRACE/tlparse to produce produce compilation reports
# ~~~~~~~~~~
# Using ``TORCH_TRACE/tlparse`` to produce produce compilation reports (for PyTorch 2)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# In this section, we introduce ``TORCH_TRACE`` and ``tlparse`` to produce reports.
#
#
# 1. Generate the raw trace logs by running the following command:
#
# .. code-block:: bash
#
# TORCH_TRACE="/tmp/tracedir" python script.py`
#
# Ensure you replace ``/tmp/tracedir`` with the path to the directory where you want
# to store the trace logs and replace the script with the name of your script.
#
# 2. Install ``tlparse`` by running:
#
# .. code-block:: bash
#
# pip install tlparse
#
# 3. Pass the trace log to ``tlparse`` to generate compilation reports:
#
# .. code-block: bash
#
# tlparse /tmp/tracedir
#
# In this section, we introduce the usage of TORCH_TRACE and tlparse to produce reports.
# First, we run `TORCH_TRACE="/tmp/tracedir" python script.py` to generate the raw trace logs.
# We have replace `/tmp/tracedir` with a path to a directory you want to store the trace logs
# and reaplce script with the name of your script.
# This will open your browser with the HTML-like generated above.
#
# Next, we are going to pass the trace log to `tlparse` to generate compilation reports. We run
# `pip install tlparse` and then `tlparse /tmp/tracedir`. This will open up your browser with
# HTML like generated above.
# By default, reports generated by ``tlparse`` are stored in the ``tl_out`` directory.
# You can change that by running:
#
# .. code-block:: bash
#
# By default, reports generated by `tlparse` are
# stored in the directory `tl_out`. You can change that by doing `tlparse /tmp/tracedir -o output_dir/`.
# tlparse /tmp/tracedir -o output_dir/

######################################################################
# Conclusion
Expand Down

0 comments on commit 8859a58

Please sign in to comment.