PyTorch 'meta' device needs per-device capabilities

Open
#945 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, pytorch
Domain
api, tooling

Research direction

Start in array_api_compat.torch at capabilities(), then compare the signatures of default_dtypes() and dtypes(). Check the existing tests for capabilities and device handling; done means capabilities accepts device and reports boolean indexing and data-dependent shapes correctly for meta versus material devices.

Written by the indexing model from the issue text.

Description

API change

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,
    }
Dominant language
Python
Stars
281
Forks
52
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api

All issues in data-apis/array-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.