Skip to content

Commit

Permalink
Merge branch 'pytorch:main' into default_train_bsize
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrowskimarcin authored Jan 13, 2025
2 parents e6fde3b + 9b7cac9 commit 512fbdd
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/userbenchmark-a100-bisection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
cp -r "${BISECT_WORKDIR}" ../bisection-result
- name: Upload artifact
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Bisection result
path: bisection-result/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/userbenchmark-a100-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
cp -r ./.userbenchmark/release-test ../benchmark-output
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench result
path: benchmark-output/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/userbenchmark-a100.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
cp -r ./.userbenchmark/"${{ github.event.inputs.userbenchmark_name }}" ../benchmark-output
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench result
path: benchmark-output/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/userbenchmark-ai-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
python ./.github/scripts/userbenchmark/schedule-benchmarks.py --platform ${PLATFORM_NAME}
cp -r ./.userbenchmark ../benchmark-output
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench result
path: benchmark-output/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/userbenchmark-c5-24xlarge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
python ./scripts/userbenchmark/upload_s3.py --upload-file "${r}" --userbenchmark_platform "${PLATFORM_NAME}"
done
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench result
path: benchmark-output/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/userbenchmark-ibmcloud-testrunner.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TorchBench Userbenchmark test on IBM Cloud
name: TorchBench Userbenchmark test on IBM Cloud
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
python ./scripts/userbenchmark/upload_s3.py --upload-file "${r}" --userbenchmark_platform "${PLATFORM_NAME}"
done
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench result
path: benchmark-output/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/userbenchmark-regression-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
python ./scripts/userbenchmark/upload_s3.py --upload-file "${r}" --userbenchmark_platform "${PLATFORM_NAME}"
done
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench result
path: benchmark-output/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/userbenchmark-t4-metal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
cp -r ./.userbenchmark/"${{ github.event.inputs.userbenchmark_name }}" ../benchmark-output
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench result
path: benchmark-output/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v2-bisection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
labels: |
torchbench-perf-report
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Bisection result
path: bisection-result/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v2-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
# Upload result to Scribe
python scripts/upload_scribe_${CONFIG_VER}.py --pytest_bench_json "${LATEST_RESULT}" --torchbench_score_file "${SCORE_FILE}"
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Benchmark result
path: benchmark-output/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v3-bisection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
torchbench-perf-report
- name: Upload artifact
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Bisection result
path: bisection-result/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/v3-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
https://api.github.com/repos/pytorch/benchmark/actions/workflows/57994037/dispatches \
-d '{"ref": "main", "inputs": {"regression_date": "${{ env.TORCHBENCH_REGRESSION_DETECTED }}" } }'
- name: Upload result to GH Actions Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: TorchBench V3 result
path: benchmark-output/
Expand Down
8 changes: 6 additions & 2 deletions userbenchmark/dynamo/dynamobench/_dynamo/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
Optional,
overload,
Sequence,
Tuple,
TypeVar,
Union,
)
Expand Down Expand Up @@ -141,7 +140,7 @@ def reduce_to_scalar_loss(out: torch.Tensor) -> torch.Tensor:

@overload
def reduce_to_scalar_loss(
out: Union[List[Any], Tuple[Any, ...], Dict[Any, Any]]
out: Union[List[Any], tuple[Any, ...], Dict[Any, Any]]
) -> float:
...

Expand Down Expand Up @@ -255,6 +254,11 @@ def __call__(
self.graphs.append(gm)
return lookup_backend(self.backend)(gm, example_inputs)

def clear(self) -> None:
self.frame_count = 0
self.op_count = 0
self.graphs = []


# Equivalent to backend="eager", but also records graphs that
# we can assert on
Expand Down
28 changes: 15 additions & 13 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
Optional,
overload,
Set,
Tuple,
Type,
TypeVar,
Union,
Expand Down Expand Up @@ -106,7 +105,7 @@

# NOTE: Make sure `NP_SUPPORTED_MODULES` and `NP_TO_TNP_MODULE` are in sync.
if np:
NP_SUPPORTED_MODULES: Tuple[types.ModuleType, ...] = (
NP_SUPPORTED_MODULES: tuple[types.ModuleType, ...] = (
np,
np.fft,
np.linalg,
Expand Down Expand Up @@ -202,8 +201,8 @@ def log(cls):


def tabulate(
rows: Union[List[Tuple[str, object]], List[List[object]]],
headers: Union[Tuple[str, ...], List[str]],
rows: Union[List[tuple[str, object]], List[List[object]]],
headers: Union[tuple[str, ...], List[str]],
) -> str:
try:
import tabulate
Expand Down Expand Up @@ -590,7 +589,7 @@ def compile_times(repr: Literal["str"], aggregate: bool = False) -> str:
@overload
def compile_times(
repr: Literal["csv"], aggregate: bool = False
) -> Tuple[List[str], List[object]]:
) -> tuple[List[str], List[object]]:
...


Expand Down Expand Up @@ -658,7 +657,7 @@ def __init__(self, maxsize: int = 4096) -> None:
def reset(self):
self.set = OrderedDict()

def add(self, key: Union[str, Tuple[object, object]]) -> bool:
def add(self, key: Union[str, tuple[object, object]]) -> bool:
if key in self.set:
self.set.move_to_end(key, last=True)
if not config.verbose:
Expand Down Expand Up @@ -797,7 +796,7 @@ def istype(obj: object, allowed_types: Type[T]) -> TypeIs[T]:

@overload
def istype(
obj: object, allowed_types: Tuple[Type[List[T]], Type[Tuple[T, ...]]]
obj: object, allowed_types: tuple[Type[List[T]], Type[tuple[T, ...]]]
) -> TypeIs[T]:
...

Expand Down Expand Up @@ -940,7 +939,7 @@ def is_numpy_ndarray(value):

def istensor(obj):
"""Check of obj is a tensor"""
tensor_list: Tuple[type, ...] = (
tensor_list: tuple[type, ...] = (
torch.Tensor,
torch.nn.Parameter,
*config.traceable_tensor_subclasses,
Expand Down Expand Up @@ -1241,7 +1240,10 @@ def default(self, o):
del inductor_config_copy[key]
# Stringify Inductor config
inductor_conf_str = json.dumps(
inductor_config_copy, cls=TypeSafeSerializer, skipkeys=True
inductor_config_copy,
cls=TypeSafeSerializer,
skipkeys=True,
sort_keys=True,
)
except Exception:
# Don't crash because of runtime logging errors
Expand Down Expand Up @@ -1897,7 +1899,7 @@ def is_namedtuple_cls(cls):


@functools.lru_cache(1)
def namedtuple_fields(cls) -> Tuple[str, ...]:
def namedtuple_fields(cls) -> tuple[str, ...]:
"""Get the fields of a namedtuple or a torch.return_types.* quasi-namedtuple"""
if cls is slice:
return ("start", "stop", "step")
Expand Down Expand Up @@ -2185,7 +2187,7 @@ def tuple_iterator_getitem(it, index):
iter_next = next


def normalize_range_iter(range_iter) -> Tuple[int, int, int]:
def normalize_range_iter(range_iter) -> tuple[int, int, int]:
_, (range_obj,), maybe_idx = range_iter.__reduce__()
# In 3.12+, `maybe_idx` could be None, and `range_obj.start` would've been
# already incremented by the current index.
Expand Down Expand Up @@ -2492,7 +2494,7 @@ def to_tensor(t):
return True
score = torch.nn.functional.cosine_similarity(ref, res, dim=0, eps=1e-6)
if score < 0.99:
log.warning("Similarity score=%s", score.cpu().detach().item())
log.warning("Similarity score=%s", score.detach().cpu().item())
return score >= 0.99
else:
if not exact_dtype:
Expand Down Expand Up @@ -3067,7 +3069,7 @@ def tensor_always_has_static_shape(
tensor: Union[torch.Tensor, Any],
is_tensor: bool,
tensor_source: Source,
) -> Tuple[bool, Optional[TensorStaticReason]]:
) -> tuple[bool, Optional[TensorStaticReason]]:
"""
Given a tensor, source, and is_tensor flag, determine if a shape should be static.
Expand Down
7 changes: 3 additions & 4 deletions userbenchmark/dynamo/dynamobench/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
NamedTuple,
Optional,
Sequence,
Tuple,
Type,
TYPE_CHECKING,
)
Expand Down Expand Up @@ -677,7 +676,7 @@ def print_summary_table(data, print_dataframe=False):
print(col.ljust(width), f"mean={data[col].mean():.3f}x")
elif col in ("accuracy"):
pass_rate = (data[col] == "pass").mean()
print(col.ljust(width), f"pass_rate={100*pass_rate:.2f}%")
print(col.ljust(width), f"pass_rate={100 * pass_rate:.2f}%")
else:
cdata = data[col]
print(
Expand Down Expand Up @@ -746,7 +745,7 @@ def timed(
return (time_total, result) if return_result else time_total


def _normalize_bench_inputs(example_inputs) -> Tuple[Tuple[Any], Mapping[str, Any]]:
def _normalize_bench_inputs(example_inputs) -> tuple[tuple[Any], Mapping[str, Any]]:
# NOTE(bowbao): For huggingface benchmark, example_inputs are formatted as dictionary,
# and consumed like `model(**example_inputs)`.
# For other benchmarks, example_inputs are formatted as tuple and consumed
Expand Down Expand Up @@ -4994,7 +4993,7 @@ def detect_and_mark_batch(t):
for i, name in enumerate(model_names):
current_name = name
if args.progress:
print(f"Running model {i+1}/{nmodels}", flush=True)
print(f"Running model {i + 1}/{nmodels}", flush=True)

try:
timeout = args.timeout
Expand Down

0 comments on commit 512fbdd

Please sign in to comment.