You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: prototype_source/flight_recorder_tutorial.rst
+86-80Lines changed: 86 additions & 80 deletions
Original file line number
Diff line number
Diff line change
@@ -25,61 +25,66 @@ A distributed AI training job is considered `stuck` when it stops making meaning
25
25
time.
26
26
27
27
A job can get stuck for various reasons:
28
-
- **Data Starvation:** This occurs when the training job is not receiving data at the expected rate, possibly due to
29
-
issues with the data pipeline or the data source.
30
-
- **Resource Constraints:** If the system running the job does not have enough computational resources (such as CPU, GPU, or
31
-
memory), the job might not be able to proceed.
32
-
- **Network Issues:** In a distributed training setup, different parts of the model or data may be processed on different
33
-
devices. If there are network issues, communication between these devices may be disrupted, causing the job to get
34
-
stuck.
35
-
- **Software Bugs or Errors:** Errors in the training code or the underlying libraries and frameworks can also cause a job to
36
-
get stuck.
37
-
- **Synchronization Issues:** In distributed training, different parts of the computation are often run in parallel and need
38
-
to be synchronized at certain points. If this synchronization fails, the job can get stuck. For example, a deadlock can
39
-
occur if one or more ranks fail to join a collective while the remaining ranks have joined. This results in an
40
-
indefinite wait for the job to progress.
28
+
29
+
- **Data Starvation:** This occurs when the training job is not receiving data at the expected rate, possibly due to issues with the data pipeline or the data source.
30
+
31
+
- **Resource Constraints:** If the system running the job does not have enough computational resources (such as CPU, GPU, or memory), the job might not be able to proceed.
32
+
33
+
- **Network Issues:** In a distributed training setup, different parts of the model or data may be processed on different devices. If there are network issues, communication between these devices may be disrupted, causing the job to get stuck.
34
+
35
+
- **Software Bugs or Errors:** Errors in the training code or the underlying libraries and frameworks can also cause a job to get stuck.
36
+
37
+
- **Synchronization Issues:** In distributed training, different parts of the computation are often run in parallel and need to be synchronized at certain points. If this synchronization fails, the job can get stuck. For example, a deadlock can occur if one or more ranks fail to join a collective while the remaining ranks have joined. This results in an indefinite wait for the job to progress.
41
38
42
39
Flight Recorder, as the name suggests, captures diagnostics information as collectives run. The captured diagnostic
43
-
information can be used to help identify the root cause of issues when jobs get stuck.
40
+
information is used to help root cause issues when jobs get stuck.
44
41
There are two core parts to Flight Recorder.
45
-
- The collection portion: when enabled, information about collectives is recorded in an in-memory circular buffer.
46
-
Upon job timeout, or on demand, the in-memory buffer can be retrieved or dumped to file.
47
-
- An analyzer script is available in the `pytorch/tools/flight_recorder` directory (details below).
42
+
43
+
- The collection portion: when enabled, information about collectives is recorded in an in-memory circular buffer. Upon job timeout, or on demand, the in-memory buffer can be retrieved or dumped to file.
44
+
45
+
- An analyzer script is available in the `tools/flight_recorder <https://github.com/pytorch/pytorch/tree/main/tools/flight_recorder>`__ directory (details below).
46
+
The analyzer script runs known heuristics using the collected data and attempts to automatically identify the underlying issue that caused the job to stall.
48
47
49
48
Enabling Flight Recorder
50
49
------------------------
51
50
There are two required environment variables to get the initial version of Flight Recorder working.
52
-
- ``TORCH_NCCL_TRACE_BUFFER_SIZE`` (``0``, ``N`` where ``N`` is a positive number): Setting ``N`` enables collection. N represents the number of entries that will be kept internally in a circular buffer. We recommended to set this value at 2000.
53
-
- ``TORCH_NCCL_DUMP_ON_TIMEOUT = (true, false)``: Setting this to ``true`` will write out diagnostic files to disk on job timeout. If enabled, there will be one file per rank output in the jobs running directory.
51
+
52
+
- ``TORCH_NCCL_TRACE_BUFFER_SIZE`` (``0``, ``N`` where ``N`` is a positive number): Setting ``N`` enables collection.
53
+
``N`` represents the number of entries that will be kept internally in a circular buffer.
54
+
We recommended to set this value at 2000.
55
+
- ``TORCH_NCCL_DUMP_ON_TIMEOUT = (true, false)``: Setting this to ``true`` will write out diagnostic files to disk on job timeout.
56
+
If enabled, there will be one file per rank output in the job's running directory.
54
57
55
58
**Optional settings:**
56
59
57
-
- ```TORCH_NCCL_TRACE_CPP_STACK (true, false)``: Setting this to true enables C++ stack stack trace captures in Flight Recorder. This is useful for slow
58
-
``addr2line`` - for more information, see additional settings.
59
-
- TORCH_NCCL_ENABLE_TIMING (true, false) true = enable additional cuda events at the start of each collective and
60
+
- ``TORCH_NCCL_TRACE_CPP_STACK (true, false)``: Setting this to true enables C++ stack stack trace captures in Flight Recorder.
61
+
C++ stack traces can be useful in providing the exact code path from a PyTorch Python call down to the primitive
62
+
C++ implementations. Also see ``TORCH_SYMBOLIZE_MODE`` in additional settings.
63
+
- ``TORCH_NCCL_ENABLE_TIMING (true, false)``: true = enable additional cuda events at the start of each collective and
60
64
records the `duration` of each collective. This may incur some CPU overhead. In the collected data, the
61
65
``duration`` field indicates how long each collective took to execute.
62
66
63
67
Additional Settings
64
68
-------------------
65
69
66
-
``TORCH_SYMBOLIZE_MODE {dladdr, addr2line, fast}:`` This setting determines the program used to retrieve C++ traces
67
-
from a running program. The default setting is ``addr2line``. ``fast`` is a new experimental mode that is shown to be much
68
-
faster than the traditional ``addr2line``. Use this setting in conjunction with ``TORCH_NCCL_TRACE_CPP_STACK`` to collect
69
-
C++ traces in the Flight Recorder` data.
70
+
- ``TORCH_SYMBOLIZE_MODE {dladdr, addr2line, fast}``: This setting determines the program used to retrieve C++ traces from a running program.
71
+
The default setting is ``addr2line``.
72
+
73
+
``fast`` is a new experimental mode that is shown to be much faster than the traditional ``addr2line``.
74
+
Use this setting in conjunction with ``TORCH_NCCL_TRACE_CPP_STACK`` to collect C++ traces in the Flight Recorder data.
70
75
71
76
Retrieving Flight Recorder Data via an API
72
77
------------------------------------------
73
78
74
79
You can also retrieve Flight Recorder data with an API call.
75
-
Below is the API with the default arguments:
80
+
The API with the default arguments is shown below:
0 commit comments