Skip to content

fix: Rename variable to control PG timeout to not refer to NCCL #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ run_training(

Below is a list of custom environment variables users can set in the training library.

1. `INSTRUCTLAB_NCCL_TIMEOUT_MS`, this environment variable controls the NCCL timeout in milliseconds. Consider increasing if seeing FSDP related NCCL errors.
1. `INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS`, this environment variable controls
the process group timeout in milliseconds. Consider increasing if seeing
FSDP related collective timeout errors.

## Developer Certificate of Origin

Expand Down
3 changes: 3 additions & 0 deletions src/instructlab/training/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS = "INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS"
7 changes: 3 additions & 4 deletions src/instructlab/training/main_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
TorchrunArgs,
TrainingArgs,
)

# pylint: disable=no-name-in-module
from instructlab.training.const import INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS
from instructlab.training.logger import (
propagate_package_logs,
setup_metric_logger,
Expand Down Expand Up @@ -278,7 +277,7 @@ def train(
# time of writing) default: to cover the unlikely event torch decides to tweak
# the default.
def _get_collective_timeout() -> datetime.timedelta | None:
timeout_var = os.getenv("INSTRUCTLAB_NCCL_TIMEOUT_MS")
timeout_var = os.getenv(INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS)
if timeout_var is None:
return None

Expand All @@ -289,7 +288,7 @@ def _get_collective_timeout() -> datetime.timedelta | None:

if timeout <= 0:
raise ValueError(
f"Invalid value for INSTRUCTLAB_NCCL_TIMEOUT_MS: {timeout_var}. Must be a positive integer."
f"Invalid value for {INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS}: {timeout_var}. Must be a positive integer."
)

return datetime.timedelta(milliseconds=timeout)
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/test_main_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# First Party
from instructlab.training import main_ds
from instructlab.training.const import INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS


def test__get_collective_timeout():
Expand All @@ -16,7 +17,7 @@ def test__get_collective_timeout():
# Test with custom timeout
timeout = 1234
with mock.patch.dict(
main_ds.os.environ, {"INSTRUCTLAB_NCCL_TIMEOUT_MS": str(timeout)}
main_ds.os.environ, {INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS: str(timeout)}
):
assert main_ds._get_collective_timeout() == datetime.timedelta(
milliseconds=timeout
Expand All @@ -25,15 +26,15 @@ def test__get_collective_timeout():
# Test with invalid timeout (negative)
invalid_timeout = "-100"
with mock.patch.dict(
main_ds.os.environ, {"INSTRUCTLAB_NCCL_TIMEOUT_MS": invalid_timeout}
main_ds.os.environ, {INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS: invalid_timeout}
):
with pytest.raises(ValueError):
main_ds._get_collective_timeout()

# Test with invalid timeout (string)
invalid_timeout = "invalid"
with mock.patch.dict(
main_ds.os.environ, {"INSTRUCTLAB_NCCL_TIMEOUT_MS": invalid_timeout}
main_ds.os.environ, {INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS: invalid_timeout}
):
with pytest.raises(ValueError):
main_ds._get_collective_timeout()
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ basepython = python3.11
[testenv:py3-unit]
description = run unit tests with pytest
passenv =
HF_HOME
INSTRUCTLAB_NCCL_TIMEOUT_MS
CMAKE_ARGS
HF_HOME
INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS
CMAKE_ARGS

# Use PyTorch CPU build instead of CUDA build in test envs. CUDA dependencies
# are huge. This reduces venv from 5.7 GB to 1.5 GB.
Expand All @@ -40,8 +40,8 @@ commands = {envpython} -m pytest tests/unit {posargs}
[testenv:py3-smoke]
description = run accelerated smoke tests with pytest
passenv =
HF_HOME
INSTRUCTLAB_NCCL_TIMEOUT_MS
HF_HOME
INSTRUCTLAB_PROCESS_GROUP_TIMEOUT_MS
deps =
-r requirements-dev.txt
-r requirements-cuda.txt
Expand Down
Loading