Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ source $HOME/.local/bin/env

3. Set up the environment:
```bash
sudo apt install iperf -y
uv venv
sudo apt install iperf -y # or conda install -c conda-forge iperf
uv venv --python 3.12.1
source .venv/bin/activate
uv sync --extra all
git submodule update --init --recursive
Expand Down
26 changes: 23 additions & 3 deletions src/zeroband/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@
BENCH_TENSOR_SIZE = 1_000_000


def _detect_iperf_version() -> str:
"""Detect which version of iperf is available on the system.

Returns:
str: Either 'iperf3' or 'iperf' depending on which is available.
Prefers iperf3 if both are available.
"""
try:
subprocess.run(["iperf3", "--version"], capture_output=True, check=True)
return "iperf3"
except (subprocess.SubprocessError, FileNotFoundError):
try:
subprocess.run(["iperf", "--version"], capture_output=True, check=True)
return "iperf"
except (subprocess.SubprocessError, FileNotFoundError):
raise RuntimeError("Neither iperf nor iperf3 is available on the system")


class ElasticDeviceMesh:
"""A class to manage the process groups for elastic training without restarts.

Expand Down Expand Up @@ -500,10 +518,11 @@ def _start_iperf_server(self) -> None:

iperf_addr = get_ip_address(IPERF_IFNAME)
iperf_port = IPERF_PORT + self.world_info.global_rank
cmd: List[str] = ["iperf", "-s", "-p", str(iperf_port)]
iperf_cmd = _detect_iperf_version()
cmd: List[str] = [iperf_cmd, "-s", "-p", str(iperf_port)]
self.server_process = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
self.god_store.set(f"iperf_{self.world_info.global_unique_id}", f"{iperf_addr}:{iperf_port}")
self._logger.info(f"Started iperf server on {iperf_addr} with port {iperf_port}")
self._logger.info(f"Started {iperf_cmd} server on {iperf_addr} with port {iperf_port}")
except Exception as e:
self._logger.error(f"Failed to start iperf server: {str(e)}")
raise
Expand All @@ -529,8 +548,9 @@ def measure_bandwidth(self, target_host: str, target_port: int) -> int:
int: The time taken to transfer 10Tb of data in seconds
"""
try:
iperf_cmd = _detect_iperf_version()
cmd: List[str] = [
"iperf",
iperf_cmd,
"-c",
target_host,
"-p",
Expand Down