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

Make get_iree_devices read IREE_DEVICE env var if provided #891

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

Conversation

sogartar
Copy link
Contributor

@sogartar sogartar commented Jan 31, 2025

This allows to inject what exact IREE device(s) are to be used without propagating all the way to program arguments.
Example:

IREE_DEVICE=hip://5,hip://3 pytest sharktank/tests

@sogartar sogartar force-pushed the iree-device-env-var branch from ed78ac0 to 4546492 Compare January 31, 2025 01:17
This allows to inject what exact IREE device(s) are to be used without
propagating all the way to program arguments.
Copy link
Collaborator

@archana-ramalingam archana-ramalingam left a comment

Choose a reason for hiding this comment

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

If this change is specifically targeting CIs, our runners pick whichever gpu is available atm. We had a PR making this change for llama benchmark/ppl CIs. @ScottTodd can confirm.

@sogartar
Copy link
Contributor Author

sogartar commented Jan 31, 2025

It is not just for CIs, but when running locally as well. There should be some way of overriding the device list.
Are CI machines actually allocating devices to different jobs? Where is this code hosted?

@ScottTodd
Copy link
Member

It is not just for CIs, but when running locally as well. There should be some way of overriding the device list. Are CI machines actually allocating devices to different jobs? Where is this code hosted?

I believe on servers with multiple GPUs, we have one runner per GPU, using ROCR_VISIBLE_DEVICES=1 or equivalent on runner 1, ROCR_VISIBLE_DEVICES=2 on runner 2, etc. We also have a cluster of runners with labels like linux-mi300-gpu-1 getting set up as part of #793. I think we'd create a linux-mi300-gpu-2 label for workflows that request two GPUs?

That's my understanding anyways. @yamiyysu and @saienduri would know more, and we should write that all down somewhere and get the code used to configure the runners checked in too.

Comment on lines +26 to +28
def get_iree_devices(
*, driver: str | None = None, device_count: int = 1
) -> List[iree.runtime.HalDevice]:
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a docstring to this function and mention the IREE_DEVICE environment variable with a few examples? You can lift some text from the PR description

This allows to inject what exact IREE device(s) are to be used without propagating all the way to program arguments. Example:

IREE_DEVICE=hip://5,hip://3 pytest sharktank/tests
def get_iree_devices(
    *, driver: str | None = None, device_count: int = 1
) -> List[iree.runtime.HalDevice]:
    """Gets a list of IREE HAL devices for the given driver.
    
    The first available device_count devices will be created,
    unless the IREE_DEVICE environment variable is set to an
    explicit list of device URIs.

    For example, to select HIP devices 5 and 3:
    ```
    export IREE_DEVICE=hip://5,hip://3
    python ... device=hip # (something here)
    ```
    """

(could wordsmith that a bit, just getting the general idea across)

@@ -22,7 +23,28 @@
from .tree import Tree


def get_iree_devices(driver: str, device_count: int) -> List[iree.runtime.HalDevice]:
def get_iree_devices(
Copy link
Member

Choose a reason for hiding this comment

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

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.

3 participants