Skip to content
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

torchbench is now a library #1933

Closed
wants to merge 12 commits into from
Closed

torchbench is now a library #1933

wants to merge 12 commits into from

Conversation

msaroufim
Copy link
Member

@msaroufim msaroufim commented Sep 25, 2023

import torchbenchmark.models.densenet121
model, example_inputs = torchbenchmark.models.densenet121.Model(test="eval", device="cuda", batch_size=1).get_module()
model(*example_inputs)

So making the above example work with import torchbenchmark alone is a bit trickier there's a lot of relative imports that need to be fixed in pretty much every single file

I also added a simple test_imports.py file to make sure this doesn't break anything, I can setup a standalone github action or plug into an existing one (would rather do the latter to avoid another job that needs to run install.py again

This also solves @voznesenskym favorite design pattern from https://github.com/pytorch/pytorch/blob/main/benchmarks/dynamo/torchbench.py

    for torchbench_dir in (
        "./torchbenchmark",
        "../torchbenchmark",
        "../torchbench",
        "../benchmark",
        "../../torchbenchmark",
        "../../torchbench",
        "../../benchmark",
    ):

@msaroufim msaroufim temporarily deployed to docker-s3-upload September 25, 2023 17:26 — with GitHub Actions Inactive
@msaroufim msaroufim temporarily deployed to docker-s3-upload September 25, 2023 17:26 — with GitHub Actions Inactive
@msaroufim msaroufim changed the title msaroufim/setup.py torchbench is now a library Sep 25, 2023
@xuzhao9
Copy link
Contributor

xuzhao9 commented Sep 25, 2023

Looking good! Though I am not sure what we should do about install.py. Just running pip install git+https://www.github.com:pytorch/benchmark.git does not mean we can run all the models. We still need to run install.py to install all the model dependencies, download data to the directory, etc.

@msaroufim
Copy link
Member Author

I think you should keep install.py as is since you do expect users to bring their own torch versions and there's a large number of dependencies that will be included in the torchbench package

So user should do

# Install torch/audio/text from source or nightlies
python install.py
pip install .

from . import canary_models
from . import data
from . import e2e_models
from . import score
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Score is only for archiving purpose and is to be removed - we can skip importing it.

setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@facebook-github-bot
Copy link
Contributor

@msaroufim has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@xuzhao9
Copy link
Contributor

xuzhao9 commented Sep 25, 2023

I think you should keep install.py as is since you do expect users to bring their own torch versions and there's a large number of dependencies that will be included in the torchbench package

So user should do

# Install torch/audio/text from source or nightlies
python install.py
pip install .

Sounds reasonable, it is better to clarify in the README.md that they need to run both python install.py and pip install .

@msaroufim msaroufim temporarily deployed to docker-s3-upload September 25, 2023 19:42 — with GitHub Actions Inactive
@msaroufim msaroufim temporarily deployed to docker-s3-upload September 25, 2023 19:42 — with GitHub Actions Inactive
@facebook-github-bot
Copy link
Contributor

@msaroufim has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@msaroufim msaroufim temporarily deployed to docker-s3-upload September 25, 2023 21:41 — with GitHub Actions Inactive
@msaroufim msaroufim temporarily deployed to docker-s3-upload September 25, 2023 21:41 — with GitHub Actions Inactive
@facebook-github-bot
Copy link
Contributor

@msaroufim has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@msaroufim merged this pull request in f2d615b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants