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

Add --device_only arg to test_bench.py #2542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shink
Copy link
Contributor

@shink shink commented Nov 19, 2024

I noticed that test_bench.py only supports there devices: cpu, cuda and mps. And I think there should be a power to allow users to run benchmarks on other devices (e.g. xpu, npu, etc.). So I added an --device_only arg which can receive a string. Running pytest test_bench.py --device_only foo will make benchmarks to run on the foo device.

BTW, test.py use ACCELERATOR environment variable to custom devices, should we make consistent?

benchmark/test.py

Lines 174 to 175 in 75c0f31

if device := os.getenv("ACCELERATOR"):
devices.append(device)

Comment on lines +34 to 38
if device_only := metafunc.config.option.device_only:
devices = [device_only]

if metafunc.config.option.cpu_only:
devices = ["cpu"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Look, device_only arg has lower priority, pytest test_bench.py --cpu_only --device_only cuda will make benchmarks to run on cpu deivices.

@shink shink changed the title Add --device_only arg to test_benchmark.py Add --device_only arg to test_bench.py Nov 19, 2024
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.

2 participants