Skip to content

Commit

Permalink
use larger multiplier for smaller tensors for a few models (#132952)
Browse files Browse the repository at this point in the history
Summary:
Fix pytorch/pytorch#132922  and pytorch/pytorch#132924

X-link: pytorch/pytorch#132952
Approved by: https://github.com/eellison, https://github.com/jansel

Reviewed By: PaliC

Differential Revision: D61000058

Pulled By: shunting314

fbshipit-source-id: cd4daa111f882336b03f49f91beec6897f0130d4
  • Loading branch information
shunting314 authored and facebook-github-bot committed Aug 9, 2024
1 parent a059298 commit 0ffd31a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ def same(
relax_numpy_equality,
ignore_non_fp,
log_error=log_error,
use_larger_multiplier_for_smaller_tensor=use_larger_multiplier_for_smaller_tensor,
)
for ai, bi, fp64_refi in zip(ref, res, fp64_ref)
)
Expand All @@ -1423,6 +1424,7 @@ def same(
relax_numpy_equality,
ignore_non_fp,
log_error=log_error,
use_larger_multiplier_for_smaller_tensor=use_larger_multiplier_for_smaller_tensor,
)
elif isinstance(ref, dict):
assert isinstance(res, dict)
Expand All @@ -1442,6 +1444,7 @@ def same(
relax_numpy_equality=relax_numpy_equality,
ignore_non_fp=ignore_non_fp,
log_error=log_error,
use_larger_multiplier_for_smaller_tensor=use_larger_multiplier_for_smaller_tensor,
)
):
log_error("Accuracy failed for key name %s", k)
Expand Down Expand Up @@ -1553,15 +1556,16 @@ def to_tensor(t):
passes_test = True
if not passes_test:
log_error(
"RMSE (res-fp64): %.5f, (ref-fp64): %.5f and shape=%s. res.dtype: %s, multiplier: %f, tol: %f",
"RMSE (res-fp64): %.5f, (ref-fp64): %.5f and shape=%s. res.dtype: %s, multiplier: %f, tol: %f"
", use_larger_multiplier_for_smaller_tensor: %d",
res_error,
ref_error,
res.size(),
res.dtype,
multiplier,
tol,
use_larger_multiplier_for_smaller_tensor,
)
# import pdb; pdb.set_trace()
return passes_test

if ignore_non_fp:
Expand Down Expand Up @@ -1597,6 +1601,7 @@ def to_tensor(t):
relax_numpy_equality=relax_numpy_equality,
ignore_non_fp=ignore_non_fp,
log_error=log_error,
use_larger_multiplier_for_smaller_tensor=use_larger_multiplier_for_smaller_tensor,
)
elif type(ref).__name__ in (
"MaskedLMOutput",
Expand Down Expand Up @@ -1624,6 +1629,7 @@ def to_tensor(t):
relax_numpy_equality=relax_numpy_equality,
ignore_non_fp=ignore_non_fp,
log_error=log_error,
use_larger_multiplier_for_smaller_tensor=use_larger_multiplier_for_smaller_tensor,
)
for key in ref.__dict__.keys()
)
Expand Down
1 change: 1 addition & 0 deletions userbenchmark/dynamo/dynamobench/timm_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def pip_install(package):
}

REQUIRE_LARGER_MULTIPLIER_FOR_SMALLER_TENSOR = {
"inception_v3",
"mobilenetv3_large_100",
}

Expand Down

0 comments on commit 0ffd31a

Please sign in to comment.