Skip to content

PyTorch 'meta' device needs per-device capabilities #945

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
crusaderky opened this issue May 18, 2025 · 1 comment
Open

PyTorch 'meta' device needs per-device capabilities #945

crusaderky opened this issue May 18, 2025 · 1 comment

Comments

@crusaderky
Copy link
Contributor

crusaderky commented May 18, 2025

PyTorch has a special device, meta, which is a dummy device with no underlying data. This is a very powerful testing tool.
However, PyTorch has not implemented special support for unknown shapes just for this device. As a result, unique etc. fail.

Proposal

Change capabilities() to capabilities(*, device=None), matching the signature of default_dtypes() and dtypes().

Change array_api_compat.torch:

def capabilities(*, device=None):
    device = torch.get_default_device() if device is None else torch.device(device)
    is_material = device.type != "meta"
    return {
        "boolean indexing": is_material,
        "data-dependent shapes": is_material,
        "max dimensions": 64,
    }
@crusaderky
Copy link
Contributor Author

xref data-apis/array-api-extra#300

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

No branches or pull requests

1 participant