Skip to content

Commit

Permalink
Merge pull request #26 from facebookresearch/25-maintenance
Browse files Browse the repository at this point in the history
Skip coverage test for graph visualization
  • Loading branch information
anupambhatnagar authored Feb 3, 2023
2 parents 0205626 + 646cb1b commit 1e70b8a
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ install_repo: &install_repo
command: |
pip install .
install_dev_requirements: &install_dev_requirements
- run:
name: Install development packages
command: |
pip install -r requirements-dev.txt
# This is an alias to run all unit tests possible on a platform.
run_unittests: &run_unittests
Expand Down Expand Up @@ -85,6 +90,7 @@ jobs:
- checkout
- <<: *setup_venv
- <<: *install_repo
- <<: *install_dev_requirements

# Cache the venv directory that contains dependencies
- restore_cache:
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ HTA provides the following features:

HTA runs on Linux and Mac with Python >= 3.8.

### Create a Conda environment (optional)
### Setup a Conda environment (optional)

To install Miniconda see [here](https://docs.conda.io/en/latest/miniconda.html).
See [here](https://docs.conda.io/en/latest/miniconda.html) to install Miniconda.

To create the environment `env_name`
Create the environment `env_name`
``` bash
conda create -n env_name
```

To activate the environment
Activate the environment
``` bash
conda activate env_name
```

To deactivate the environment
Deactivate the environment
``` bash
conda deactivate
```
Expand Down
21 changes: 13 additions & 8 deletions docs/source/intro/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ We recommend using a Conda environment to install HTA. To install Anaconda, see
`here <https://docs.anaconda.com/anaconda/install/index.html>`_. Holistic Trace
Analysis runs on Linux and Mac with Python >= 3.8.

**Get the HTA source code**

.. code-block::
git clone https://github.com/facebookresearch/HolisticTraceAnalysis.git
**Using a Conda environment**
**Setup a Conda environment**

.. code-block::
Expand All @@ -26,8 +21,18 @@ Analysis runs on Linux and Mac with Python >= 3.8.
**Installing Holistic Trace Analysis**

Execute the command below from the root of the repo
Install using pip

.. code-block::
pip install HolisticTraceAnalysis
Install from source

.. code-block::
pip install -e .
# get the source code
git clone https://github.com/facebookresearch/HolisticTraceAnalysis.git
# execute the command below from the root of the repo
pip install -e .
6 changes: 3 additions & 3 deletions hta/analyzers/breakdown_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_gpu_kernel_breakdown(
inplace=True,
)

if visualize:
if visualize: # pragma: no cover
non_zero_kernel_df = kernel_type_df[(kernel_type_df["percentage"] > 0)]

fig = px.pie(
Expand Down Expand Up @@ -336,7 +336,7 @@ def idle_time_per_rank(trace_df: pd.DataFrame) -> Tuple[int, int, int, int]:
result_df["non_compute_time"] = result_df["non_compute_time(ns)"] / result_df["kernel_time(ns)"]
result_df["non_compute_time_pctg"] = round(100 * result_df["non_compute_time"], 2)

if visualize:
if visualize: # pragma: no cover
fig = px.bar(
result_df,
x="rank",
Expand Down Expand Up @@ -480,7 +480,7 @@ def get_idle_time_breakdown(
result_df.rename(mapper=idle_category_name_map, axis=0, inplace=True)
result_df.reset_index(inplace=True)

if visualize:
if visualize: # pragma: no cover
result_df["stream"] = result_df.stream.astype(str)
ycol = "idle_time_ratio" if visualize_pctg else "idle_time"
fig = px.bar(
Expand Down
2 changes: 1 addition & 1 deletion hta/analyzers/communication_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_comm_comp_overlap_value(trace_df: pd.DataFrame) -> float:
result_df = pd.DataFrame(result)
result_df["comp_comm_overlap_pctg"] = round(100 * result_df["comp_comm_overlap_ratio"], 2)

if visualize:
if visualize: # pragma: no cover
fig = px.bar(
result_df,
x="rank",
Expand Down
6 changes: 3 additions & 3 deletions hta/analyzers/cuda_kernel_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _generate_frequent_pattern_results(
'View the generated trace file using Chrome Tracing and search for "Patterns" to highlight the frequent patterns.'
)

if visualize:
if visualize: # pragma: no cover
vis_df = patterns_df[:top_k].copy()
# show the pattern in multiple lines in visualization
vis_df["pattern"] = vis_df["pattern"].str.replace("|", "<br>", regex=False)
Expand Down Expand Up @@ -259,7 +259,7 @@ def _compress_kernel_names(row):
@classmethod
def visualize_cuda_kernel_launch_stats(
cls, rank: int, df: pd.DataFrame, runtime_cutoff: int, launch_delay_cutoff: int
) -> None:
) -> None: # pragma: no cover
short_kernels = df[(df["cpu_duration"] <= runtime_cutoff) & (df["gpu_duration"] < df["cpu_duration"])]
runtime_outliers = df[df["cpu_duration"] > runtime_cutoff]
launch_delay_outliers = df[df["launch_delay"] > launch_delay_cutoff]
Expand Down Expand Up @@ -369,7 +369,7 @@ def cuda_kernel_launch_stats(
renamed_df = joined_df.rename(columns={"dur_x": "cpu_duration", "dur_y": "gpu_duration"})
events_df = renamed_df[["correlation", "cpu_duration", "gpu_duration", "launch_delay"]]

if visualize:
if visualize: # pragma: no cover
cls.visualize_cuda_kernel_launch_stats(rank, events_df, runtime_cutoff, launch_delay_cutoff)

result_dict[rank] = events_df
Expand Down
6 changes: 3 additions & 3 deletions hta/analyzers/straggler.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _compute_normalized_start_time_of_significant_comm_kernels(
long_comm_kernels = df.loc[
(df["stream"] > 0) & (df["iteration"] > 0) & (df["dur"] >= min_duration) & (df["name"].isin(comm_op_ids))
]
if visualize:
if visualize: # pragma: no cover
plot_timeline_gpu_kernels(
f"Timeline of Communication Kernels Longer Than {min_normalized_duration * 100:.2f}% of Iteration Time\n",
long_comm_kernels,
Expand All @@ -135,7 +135,7 @@ def _compute_normalized_start_time_of_significant_comm_kernels(
(last_long_comm_kernels["stream"].eq(stream)) & (last_long_comm_kernels["name"].eq(name))
]

if visualize:
if visualize: # pragma: no cover
plot_timeline_gpu_kernels(
f"Timeline of Candidate Kernels (Iterations={iterations})",
candidate_metric_kernels,
Expand Down Expand Up @@ -202,7 +202,7 @@ def _get_top_k_stragglers_with_metric(
metric[col] = pd.to_numeric(metric[col])

color_map = {"Yes": "red", "No": "blue"}
if visualize:
if visualize: # pragma: no cover
fig = px.bar(
metric,
x="rank",
Expand Down
4 changes: 2 additions & 2 deletions hta/trace_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def visualize_duration_diff(
width=1000,
height=1000,
)
if show_image:
if show_image: # pragma: no cover
fig.show()
if export_image_path:
if export_image_path: # pragma: no cover
fig.write_image(export_image_path)
7 changes: 7 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Python dependencies required for development
jupyterlab>=3.5.1
kaleido>=0.2.1
numpy>=1.23.5
pandas>=1.5.2
plotly>=5.11.0
coverage>=7.0.2
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Python dependencies required for development
# Python dependencies required for users
jupyterlab>=3.5.1
kaleido>=0.2.1
numpy>=1.23.5
pandas>=1.5.2
plotly>=5.11.0
coverage>=7.0.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def fetch_requirements():
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: BSD License",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Operating System :: OS Independent",
],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_call_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ def test_node_depth(self):
self.assertDictEqual(depth_from_csg, depth_from_nodes)


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
unittest.main()
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ def test_get_config_default_values(self):
self.assertEqual(config.get_config("d", 10), 10)


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
unittest.main()
2 changes: 1 addition & 1 deletion tests/test_symbol_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ def test_query_symbols_multi_processes(self):
self.assertTrue(all(is_consistent))


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
unittest.main()
2 changes: 1 addition & 1 deletion tests/test_trace_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,5 @@ def test_get_idle_time_breakdown(self):
)


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
unittest.main()
2 changes: 1 addition & 1 deletion tests/test_trace_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ def test_trace_iteration(self) -> None:
self.assertDictEqual(gpu_kernels_per_iteration, correlated_cpu_ops_per_iteration)


if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
unittest.main()

0 comments on commit 1e70b8a

Please sign in to comment.