Skip to content

Commit de06af0

Browse files
Bordalantiga
authored andcommitted
test: adjust is_timing_close (#17178)
1 parent 42eecaf commit de06af0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

tests/tests_fabric/parity/test_parity_ddp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def train_fabric_ddp(fabric):
130130
@pytest.mark.parametrize(
131131
"accelerator, devices, tolerance",
132132
[
133-
("cpu", 2, 0.01),
134-
pytest.param("cuda", 2, 0.005, marks=RunIf(min_cuda_gpus=2)),
133+
("cpu", 2, 0.02),
134+
pytest.param("cuda", 2, 0.01, marks=RunIf(min_cuda_gpus=2)),
135135
],
136136
)
137137
def test_parity_ddp(accelerator, devices, tolerance):

tests/tests_fabric/parity/test_parity_simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def test_parity_single_device(precision, accelerator):
145145
assert is_state_dict_equal(state_dict_torch, state_dict_fabric)
146146

147147
# Compare the time per iteration
148-
assert is_timing_close(timings_torch, timings_fabric, rtol=1e-3, atol=1e-3)
148+
assert is_timing_close(timings_torch, timings_fabric, rtol=1e-2, atol=0.1)
149149

150150
# Compare memory usage
151151
if accelerator == "cuda":

tests/tests_fabric/parity/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def is_state_dict_equal(state0, state1):
2424
return all(eq_fn(w0.cpu(), w1.cpu()) for w0, w1 in zip(state0.values(), state1.values()))
2525

2626

27-
def is_timing_close(timings_torch, timings_fabric, rtol=1e-3, atol=1e-3):
27+
def is_timing_close(timings_torch, timings_fabric, rtol=1e-2, atol=0.1):
2828
# Drop measurements of the first iterations, as they may be slower than others
2929
# The median is more robust to outliers than the mean
3030
# Given relative and absolute tolerances, we want to satisfy: |torch – fabric| < RTOL * torch + ATOL

0 commit comments

Comments
 (0)