Skip to content

[Feat] Use torchbenchmark configuration #47

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 9 commits 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
1 change: 0 additions & 1 deletion .ci/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
import os
import sys
from src.benchmark.utils import read_metrics, to_markdown_table


Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/_ascend_npu_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ jobs:
- name: Checkout benchmark
uses: actions/checkout@v4
with:
repository: pytorch/benchmark
# TODO(shink): https://github.com/pytorch/benchmark/pull/2592
# repository: pytorch/benchmark
repository: shink/benchmark
ref: feat/test_bench/config
path: benchmark

# TODO
Expand Down Expand Up @@ -127,6 +130,11 @@ jobs:
run: |
pip install ${{ inputs.torch-npu-artifact }}

- name: Install torchvision and torchaudio
run: |
# pip install --pre torchvision torchaudio --no-deps --index-url https://download.pytorch.org/whl/nightly/cpu
pip install --pre torchvision torchaudio --no-deps --index-url https://download.pytorch.org/whl/test/cpu

- name: Install benchmark dependencies
run: |
pip install -r benchmark/requirements.txt \
Expand All @@ -137,26 +145,19 @@ jobs:
run: |
python benchmark/install.py --userbenchmark test_bench --continue_on_fail

- name: Install nightly torchvision and torchaudio
run: |
pip install --pre torchvision torchaudio --no-deps --index-url https://download.pytorch.org/whl/nightly/cpu

- name: Install project dependencies
run: |
pip install -r requirements.txt

- name: Show environment info
- name: List installed python packages
if: ${{ always() }}
run: |
npu_is_available=$(python -c "import torch; print(torch.npu.is_available())")
npu_count=$(python -c "import torch; print(torch.npu.device_count())")
echo "NPU is available: ${npu_is_available}"
echo "NPU count: ${npu_count}"
pip list | grep -E 'torch|numpy'

- name: Run benchmarks
working-directory: benchmark
run: |
python run_benchmark.py test_bench --accuracy --device npu --test eval \
python benchmark/run_benchmark.py test_bench \
--config ascend_npu/torchbenchmark-config.yml \
--output ascend_npu_benchmark.json

- name: Upload the benchmark report file
Expand All @@ -166,7 +167,7 @@ jobs:
name: ascend_npu_benchmark.json
path: benchmark/ascend_npu_benchmark.json
if-no-files-found: error
retention-days: 1
retention-days: 3
overwrite: true

- name: Write to workflow job summary
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/_ascend_npu_build_torch_npu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ jobs:
- name: Checkout torch_npu
uses: actions/checkout@v4
with:
# TODO(shink): Use Ascend/pytorch once this pr merged:
# https://gitee.com/ascend/pytorch/pulls/12854
# repository: Ascend/pytorch
repository: shink/torchnpu
ref: feat/autoload
repository: Ascend/pytorch
submodules: recursive
path: torch_npu

Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/_ascend_npu_ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ jobs:
- name: Checkout torch_npu
uses: actions/checkout@v4
with:
# TODO(shink): Use Ascend/pytorch once this pr merged:
# https://gitee.com/ascend/pytorch/pulls/12854
# repository: Ascend/pytorch
repository: shink/torchnpu
ref: feat/autoload
repository: Ascend/pytorch
path: torch_npu

- name: Install pip dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dispatch-event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# List PRs created in the past 24 hours
# List PRs created in the past 24 hours and labeled 'ciflow/out-of-tree'
- name: List PyTorch PRs
id: list-pr
uses: ./.github/actions/list-pr
with:
token: ${{ secrets.COSDT_BOT_TOKEN }}
owner: pytorch
repository: pytorch
labels: ${{ github.event.inputs.labels || '' }}
labels: ${{ github.event.inputs.labels || 'ciflow/out-of-tree' }}
hours: ${{ github.event.inputs.hours || '24' }}

dispatch-pr:
Expand All @@ -49,7 +49,7 @@ jobs:
- list-pr
strategy:
fail-fast: false
max-parallel: 1
max-parallel: 1 # TODO: We now only support running 1 job at the same time on NPU CI runer
matrix:
data: ${{ fromJSON(needs.list-pr.outputs.prs) }}
steps:
Expand Down
10 changes: 0 additions & 10 deletions ascend_npu/matadata.yml

This file was deleted.

10 changes: 10 additions & 0 deletions ascend_npu/torchbenchmark-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
devices:
- "npu"
backend_extension: "torch_npu"
link: https://github.com/Ascend/pytorch
models:
- model: llava
skip: true # Out of memory
batch_size: 1
extra_args:
- "--accuracy"
6 changes: 4 additions & 2 deletions src/benchmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TorchBenchModelConfig:
extra_args: List[str]
extra_env: Optional[Dict[str, str]] = None
output_dir: Optional[pathlib.Path] = None
skip: bool = False


@dataclasses.dataclass
Expand Down Expand Up @@ -68,6 +69,7 @@ def read_metrics(path: str, *, metric=None) -> List[TorchBenchModelMetric]:
extra_args=key_dict.get("extra_args"),
extra_env=key_dict.get("extra_env"),
output_dir=key_dict.get("output_dir"),
skip=key_dict.get("skip"),
)
model_metric = TorchBenchModelMetric(config, metric_value)
metrics.append(model_metric)
Expand All @@ -79,7 +81,7 @@ def generate_table_rows(metrics: List[TorchBenchModelMetric]):
models = list({metric.key.name for metric in metrics})
models = sorted(models, key=lambda x: x.lower())

def filter_metric(metrics: List[TorchBenchModelMetric], *, model, device):
def _filter_metric(metrics: List[TorchBenchModelMetric], *, model, device):
for metric in metrics:
if metric.key.name == model and metric.key.device == device:
return metric
Expand All @@ -88,7 +90,7 @@ def filter_metric(metrics: List[TorchBenchModelMetric], *, model, device):
for model in models:
row = [model]
for device in devices:
metric = filter_metric(metrics, model=model, device=device)
metric = _filter_metric(metrics, model=model, device=device)
if metric is not None:
if metric.value == "pass":
cell = "✅"
Expand Down
Loading