Skip to content

Commit

Permalink
add contributions and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlsondre committed Nov 1, 2024
1 parent 0d04824 commit 7679cf7
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 30 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,7 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/

# MacOS
.DS_Store
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies = [
# "prov4ml@git+https://github.com/HPCI-Lab/ProvML@main", # Prov4ML
# "prov4ml@git+https://github.com/matbun/ProvML@main",
"pandas",
"seaborn"
]

# dynamic = ["version", "description"]
Expand Down
31 changes: 19 additions & 12 deletions src/itwinai/cli.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
"""
Command line interface for out Python application.
You can call commands from the command line.
Example
>>> $ itwinai --help
"""

# NOTE: import libs in the command"s function, not here.
# Otherwise this will slow the whole CLI.
# --------------------------------------------------------------------------------------
# Part of the interTwin Project: https://www.intertwin.eu/
#
# Created by: Matteo Bunino
#
# Credits:
# - Matteo Bunino <[email protected]> - CERN
# - Jarl Sondre Sæther <[email protected]> - CERN
#
# --------------------------------------------------------------------------------------
# Command-line interface for the itwinai Python library.
# Example:
#
# >>> itwinai --help
#
# --------------------------------------------------------------------------------------
#
# NOTE: import libraries in the command's function, not here, as having them here will
# slow down the CLI commands significantly.

from pathlib import Path
from typing import List, Optional
Expand Down Expand Up @@ -80,7 +88,6 @@ def generate_gpu_data_plots(
energy_plot_path = plot_dir_path / "gpu_energy_plot.png"
utilization_plot_path = plot_dir_path / "utilization_plot.png"

# Plotting and saving figures to file
energy_fig, _ = gpu_bar_plot(
data_df=energy_df,
plot_title="Energy Consumption by Strategy and Number of GPUs",
Expand Down
27 changes: 16 additions & 11 deletions src/itwinai/scalability.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# --------------------------------------------------------------------------------------
# Part of the interTwin Project: https://www.intertwin.eu/
#
# Created by: Jarl Sondre Sæther
#
# Credits:
# - Jarl Sondre Sæther <[email protected]> - CERN Openlab
# - Matteo Bunino <[email protected]> - CERN Openlab
#
# Created by: Jarl Sondre Sæther
#
# Credits:
# - Jarl Sondre Sæther <[email protected]> - CERN
# - Matteo Bunino <[email protected]> - CERN
# --------------------------------------------------------------------------------------

import glob
Expand Down Expand Up @@ -118,6 +118,7 @@ def create_absolute_plot(avg_epoch_time_df: pd.DataFrame) -> None:

marker_cycle = cycle("ov^s*dXpD.+12348")

unique_nodes = list(avg_epoch_time_df["nodes"].unique())
unique_names = avg_epoch_time_df["name"].unique()
for name in unique_names:
# color, marker = next(color_marker_combinations)
Expand All @@ -133,16 +134,18 @@ def create_absolute_plot(avg_epoch_time_df: pd.DataFrame) -> None:
markersize=6,
)

# Labeling the axes and setting the title
ax.set_yscale("log")
ax.set_xscale("log")

ax.set_xticks(unique_nodes)

ax.set_xlabel("Number of Nodes")
ax.set_ylabel("Average Time")
ax.set_ylabel("Average Time (s)")
ax.set_title("Average Time vs Number of Nodes")

# Show legend and grid
ax.legend(title="Method")
ax.grid(True)

# Save the plot as an image
output_path = Path("plots/absolute_scalability_plot.png")
plt.savefig(output_path)
print(f"Saving absolute plot to '{output_path.resolve()}'.")
Expand Down Expand Up @@ -181,7 +184,9 @@ def create_relative_plot(avg_epoch_time_df: pd.DataFrame, gpus_per_node: int = 4
# Plotting the linear line
num_gpus = np.array(avg_epoch_time_df["num_gpus"].unique())
linear_speedup = np.array(avg_epoch_time_df["linear_speedup"].unique())
ax.plot(num_gpus, linear_speedup, ls="dashed", lw=1.0, c="k", label="linear speedup")
ax.plot(
num_gpus, linear_speedup, ls="dashed", lw=1.0, c="k", label="linear speedup"
)

ax.legend(ncol=1)
ax.set_xticks(num_gpus)
Expand Down
9 changes: 9 additions & 0 deletions src/itwinai/torch/monitoring/monitoring.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# --------------------------------------------------------------------------------------
# Part of the interTwin Project: https://www.intertwin.eu/
#
# Created by: Jarl Sondre Sæther
#
# Credits:
# - Jarl Sondre Sæther <[email protected]> - CERN
# --------------------------------------------------------------------------------------

import functools
import time
from multiprocessing import Manager, Process
Expand Down
10 changes: 5 additions & 5 deletions src/itwinai/torch/monitoring/plotting.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# --------------------------------------------------------------------------------------
# Part of the interTwin Project: https://www.intertwin.eu/
#
# Created by: Jarl Sondre Sæther
#
# Credits:
# - Jarl Sondre Sæther <[email protected]> - CERN Openlab
#
# Created by: Jarl Sondre Sæther
#
# Credits:
# - Jarl Sondre Sæther <[email protected]> - CERN
# --------------------------------------------------------------------------------------

from typing import Tuple
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions src/itwinai/torch/profiling/communication_plot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# --------------------------------------------------------------------------------------
# Part of the interTwin Project: https://www.intertwin.eu/
#
# Created by: Jarl Sondre Sæther
#
# Credits:
# - Jarl Sondre Sæther <[email protected]> - CERN
# --------------------------------------------------------------------------------------

from typing import Any, List, Tuple

import matplotlib
Expand Down
9 changes: 8 additions & 1 deletion src/itwinai/torch/profiling/profiler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from __future__ import annotations
# --------------------------------------------------------------------------------------
# Part of the interTwin Project: https://www.intertwin.eu/
#
# Created by: Jarl Sondre Sæther
#
# Credits:
# - Jarl Sondre Sæther <[email protected]> - CERN
# --------------------------------------------------------------------------------------

import functools
from pathlib import Path
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added use-cases/eurac/plots/communication_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added use-cases/eurac/plots/gpu_energy_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added use-cases/eurac/plots/utilization_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7679cf7

Please sign in to comment.