Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eb604b0
Update cudnnFE to v1.20.0 (#2774)
ksivaman Mar 18, 2026
0608bde
fix merge conflicts, now things working
vthumbe1503 Mar 2, 2026
93e8b9a
[PyTorch] torch.compile support for permutation functions (#2686)
pggPL Mar 18, 2026
6da802e
[PyTorch] Add an API restore from function context to ensure tensors …
kainzhong Mar 19, 2026
56366bb
[PyT] Install pytest in onnx L1 test as Pyt container no longer packa…
KshitijLakhani Mar 19, 2026
f943147
[Core] Fix MXFP8 grouped quantize for zero-sized groups in update_tma…
jberchtold-nvidia Mar 19, 2026
4f0f7f9
Revert "fix merge conflicts, now things working"
vthumbe1503 Mar 22, 2026
6b95e60
change distributed tests infra for fsdp2
vthumbe1503 Mar 22, 2026
a91d17b
verbose flag for reporting
vthumbe1503 Mar 22, 2026
2e26b05
add back coments
vthumbe1503 Mar 22, 2026
5ca65c9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 22, 2026
9e91caf
another minor fix
vthumbe1503 Mar 22, 2026
a88eac4
Merge branch 'main' into fsdp_pytest_infra_change
vthumbe1503 Mar 23, 2026
47f8513
not needed for this PR
vthumbe1503 Mar 23, 2026
d669748
Merge branch 'fsdp_pytest_infra_change' of github.com:vthumbe1503/Tra…
vthumbe1503 Mar 23, 2026
7d9785f
address review comments
vthumbe1503 Mar 23, 2026
3ac0ccd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 23, 2026
075b6aa
unecessary comments
vthumbe1503 Mar 23, 2026
43dc77b
Merge branch 'fsdp_pytest_infra_change' of github.com:vthumbe1503/Tra…
vthumbe1503 Mar 23, 2026
14c1c48
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 23, 2026
947bb39
address revire comments
vthumbe1503 Mar 23, 2026
c385be1
Merge branch 'fsdp_pytest_infra_change' of github.com:vthumbe1503/Tra…
vthumbe1503 Mar 23, 2026
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
85 changes: 85 additions & 0 deletions tests/pytorch/distributed/fsdp2_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# See LICENSE for license information.

"""Shared pytest fixtures for FSDP2 distributed tests.

Fixtures defined here (dist_init, _cleanup, recipe_name) are auto-discovered
by pytest for every test module in this directory.
"""

import gc
import os
import pytest
import torch
import torch.distributed as dist
from transformer_engine.pytorch import fp8

# Ensure the correct CUDA device is active before _parametrize_recipes()
# runs at collection time, since the session-scoped dist_init fixture
# has not executed yet.
_local_rank = int(os.environ.get("LOCAL_RANK", "0"))
torch.cuda.set_device(_local_rank)


# ── FP8 recipe parametrization ──────────────────────────────────────
def _check_nvfp4_support():
supported, reason = fp8.check_nvfp4_support()
if supported and torch.cuda.get_device_capability()[0] == 12:
return (
False,
(
"NVFP4BlockScaling is failing on SM120 with "
"hadamard_transform/hadamard_transform_cast_fusion.cu:672 in function "
"rht_gemm_ntt_w_sfc: CUDA Error: invalid argument"
),
)
return supported, reason


_FP8_RECIPE_CONFIGS = [
("DelayedScaling", fp8.check_fp8_support),
("Float8CurrentScaling", fp8.check_fp8_support),
("Float8BlockScaling", fp8.check_fp8_block_scaling_support),
("MXFP8BlockScaling", fp8.check_mxfp8_support),
("NVFP4BlockScaling", _check_nvfp4_support),
]


def _parametrize_recipes():
params = []
for name, check_fn in _FP8_RECIPE_CONFIGS:
supported, reason = check_fn()
params.append(
pytest.param(name, id=name, marks=pytest.mark.skipif(not supported, reason=reason))
)
return params


# ── Session / per-test fixtures ──────────────────────────────────────
@pytest.fixture(scope="session", autouse=True)
def dist_init():
"""Initialize the distributed process group once for the entire pytest session."""
Comment thread
vthumbe1503 marked this conversation as resolved.
local_rank = int(os.environ["LOCAL_RANK"])
torch.cuda.set_device(local_rank)
dist.init_process_group(backend="cpu:gloo,cuda:nccl")
torch.manual_seed(42)
torch.cuda.manual_seed(42)
yield
if dist.is_initialized():
dist.destroy_process_group()


@pytest.fixture(autouse=True)
def _cleanup():
"""Release GPU memory and stale NCCL state between tests."""
yield
if dist.is_initialized():
dist.barrier()
gc.collect()
torch.cuda.empty_cache()


@pytest.fixture(params=_parametrize_recipes())
def recipe_name(request):
return request.param
31 changes: 31 additions & 0 deletions tests/pytorch/distributed/fsdp2_tests/fsdp2_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# See LICENSE for license information.

"""Shared utility functions for FSDP2 distributed tests."""

import transformer_engine.common.recipe
from transformer_engine.pytorch import QuantizedTensor


def get_recipe_from_string(recipe):
return getattr(transformer_engine.common.recipe, recipe)()


def save_custom_attrs(module):
custom_attrs = {}
for name, param in module.named_parameters():
if isinstance(param, QuantizedTensor):
ignore_keys = [key for key in param.__dict__.keys() if key.startswith("_")]
else:
ignore_keys = []
attrs = vars(param)
custom_attrs[name] = {k: v for k, v in attrs.items() if k not in ignore_keys}
return custom_attrs


def restore_custom_attrs(module, custom_attrs):
for name, param in module.named_parameters():
if name in custom_attrs:
for attr_name, attr_value in custom_attrs[name].items():
setattr(param, attr_name, attr_value)
Loading
Loading