Skip to content

Conversation

@zhuhan0
Copy link
Contributor

@zhuhan0 zhuhan0 commented Apr 23, 2025

New contributor declaration

  • I am not making a trivial change, such as fixing a typo in a comment.

  • I have written a PR description following these
    rules.

  • I have run pre-commit run --from-ref origin/main --to-ref HEAD.

  • Select one of the following.

    • I have added tests.
      • /test for lit tests
      • /unittest for C++ tests
      • /python/test for end-to-end tests
    • This PR does not need a test because FILL THIS IN.
  • Select one of the following.

    • I have not added any lit tests.
    • The lit tests I have added follow these best practices,
      including the "tests should be minimal" section. (Usually running Python code
      and using the instructions it generates is not minimal.)

Fixes #6150.

When running on a CPU host, triton.autotune() throws an error:

RuntimeError: 0 active drivers ([]). There should only be one.

This issue was introduced by #4496,
which forces the caller to specify do_bench. But this may not be easy in a
large codebase.

Default do_bench to triton.testing.do_bench when there's no GPU. Add a
unit test.

@zhuhan0 zhuhan0 requested a review from ptillet as a code owner April 23, 2025 02:34

if do_bench is None:
self.do_bench = driver.active.get_benchmarker()
import torch
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is the ideal solution. Maybe we could query if there's any backend exists and just set do_bench = None if no backend is available

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look. I updated V2 to lazily initialize do_bench. Could you please see if that looks good?

@Jokeren Jokeren enabled auto-merge (squash) April 24, 2025 01:07
@Jokeren Jokeren merged commit ba2d7f5 into triton-lang:main Apr 24, 2025
8 checks passed
FindHao pushed a commit to FindHao/triton that referenced this pull request Apr 30, 2025
<!---
The core Triton is a small number of people, and we receive many PRs
(thank
you!).  To help us review your code more quickly, **if you are a new
contributor (less than 3 PRs merged) we ask that you complete the
following
tasks and include the filled-out checklist in your PR description.**

Complete the following tasks before sending your PR, and replace `[ ]`
with
`[x]` to indicate you have done them.
-->

# New contributor declaration
- [x] I am not making a trivial change, such as fixing a typo in a
comment.

- [x] I have written a PR description following these
  [rules](https://cbea.ms/git-commit/#why-not-how).

- [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`.

- Select one of the following.
  - [x] I have added tests.
    - `/test` for `lit` tests
    - `/unittest` for C++ tests
    - `/python/test` for end-to-end tests
  - [ ] This PR does not need a test because `FILL THIS IN`.

- Select one of the following.
  - [ ] I have not added any `lit` tests.
- [x] The `lit` tests I have added follow these [best
practices](https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices),
including the "tests should be minimal" section. (Usually running Python
code
    and using the instructions it generates is not minimal.)

Fixes triton-lang#6150.

When running on a CPU host, `triton.autotune()` throws an error:
```
RuntimeError: 0 active drivers ([]). There should only be one.
```
This issue was introduced by
triton-lang#4496,
which forces the caller to specify `do_bench`. But this may not be easy
in a
large codebase.

Default `do_bench` to `triton.testing.do_bench` when there's no GPU. Add
a
unit test.
weiji14 added a commit to weiji14/staged-recipes that referenced this pull request Apr 30, 2025
Until patch triton-lang/triton#6570 is available in a new triton release.
weiji14 added a commit to weiji14/staged-recipes that referenced this pull request Aug 14, 2025
Since patch from triton-lang/triton#6570 is out in triton=3.4.0 on conda-forge now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Triton code cannot be imported on a CPU machine

2 participants