Skip to content

Aligned NumPy dtypes caching#792

Merged
gmarkall merged 2 commits intoNVIDIA:mainfrom
Jlisowskyy:main
Feb 27, 2026
Merged

Aligned NumPy dtypes caching#792
gmarkall merged 2 commits intoNVIDIA:mainfrom
Jlisowskyy:main

Conversation

@Jlisowskyy
Copy link
Contributor

Proposed solution for #791

def _dtype_cache_key(dtype):
    return (
        dtype,
        getattr(dtype, "isalignedstruct", None),
    )

@functools.lru_cache
def _from_dtype_impl(dtype_cached):
    dtype = dtype_cached[0]
    ...

def from_dtype(dtype):
    return _from_dtype_impl(_dtype_cache_key(dtype))

Instead of alignment unaware:

@functools.lru_cache
def from_dtype(dtype):
    ...

** How it works **

Create a cache key for dtype that includes the isalignedstruct attribute to account for alignment data

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 17, 2026

Automatic reviews are disabled for this repository.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 17, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@rparolin rparolin added this to the numba-cuda backlog milestone Feb 18, 2026
@ZzEeKkAa
Copy link
Contributor

/ok to test

@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 19, 2026

/ok to test

@ZzEeKkAa, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 19, 2026

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ZzEeKkAa
Copy link
Contributor

/ok to test

@isVoid
Copy link
Contributor

isVoid commented Feb 27, 2026

I got the idea from the offline convo with @seberg that dtype ==(equivalence) is only to address whether two dtypes can be viewed as the same bytes without casts. By that definition, it's a bit too weak using its own identity as the cache key. So the change makes sense here.

@isVoid
Copy link
Contributor

isVoid commented Feb 27, 2026

/ok to test f2017c9

@gmarkall gmarkall added 4 - Waiting on CI Waiting for a CI run to finish successfully 5 - Ready to merge Testing and reviews complete, ready to merge and removed 4 - Waiting on CI Waiting for a CI run to finish successfully labels Feb 27, 2026
@gmarkall gmarkall merged commit db95b2a into NVIDIA:main Feb 27, 2026
205 of 208 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Testing and reviews complete, ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants