Skip to content

Allow StridedMemoryView to be constructed from dlpacks type code - #1623

Merged
Andy-Jost merged 8 commits into
NVIDIA:mainfrom
isVoid:fea-bf16-dlpack-smv
Feb 18, 2026
Merged

Allow StridedMemoryView to be constructed from dlpacks type code#1623
Andy-Jost merged 8 commits into
NVIDIA:mainfrom
isVoid:fea-bf16-dlpack-smv

Conversation

@isVoid

@isVoidisVoid commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Description

closes#1624

Patched dtype handler in _memoryview.pyx to handle dlpack type code of kDLBfloat. Added tests to construct from an external object (currently, cupy) can communicate via dlpack bfloat16 type code.

ml_dtypes is added as an optional dependency, when ml_dtypes isn't present, this code path should gracefully raise with readable error.

Note: this still depends on an unreleased now released build of cupy (14.0.0). cupy/cupy#9670

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

Copy link
Copy Markdown
Contributor

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

Contributors can view more details about this message here.

@isVoidisVoid changed the title Allow StridedMemoryView to be constructed from dlpacks type code/home/wangm/.pixi/bin/pixi shell --manifest-path /home/wangm/numba-cuda-fp8/pixi.toml --environment cu-13-0-py312Allow StridedMemoryView to be constructed from dlpacks type codeFeb 13, 2026
Comment threadcuda_core/tests/test_utils.py

@cpcloudcpcloud left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good except for the torch testing input.

Comment on lines +15 to +18
try:
import torch
except ImportError:
torch = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should really use pytest.importorskip inside your test. The current pattern is definitely an anti-pattern.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this one is fine, since it matches the style in this file (and a few other places).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Can probably leave a TODO here for a general refactoring.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Definitely an anti pattern to address. We shouldn't just keep accumulating them. Not blocking.

Comment threadcuda_core/tests/test_utils.py Outdated
Comment threadcuda_core/tests/test_utils.py Outdated
Comment threadcuda_core/tests/test_utils.py
Comment threadcuda_core/tests/test_utils.py
@leofang

Copy link
Copy Markdown
Member

@isVoid CuPy v14.0.0 is out and we are preparing to release cuda.core v0.6.0. Let's try to squeeze this in!

@isVoid
isVoid marked this pull request as ready for review February 18, 2026 18:08
@copy-pr-bot

Copy link
Copy Markdown
Contributor

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.

@isVoid

isVoid commented Feb 18, 2026

Copy link
Copy Markdown
ContributorAuthor

UPDATE: Done.

Just one more thing - I need to push some documentation addition.

@isVoid

Copy link
Copy Markdown
ContributorAuthor

/ok to test 948cb4e

@github-actions

Copy link
Copy Markdown

@isVoid

Copy link
Copy Markdown
ContributorAuthor

/ok to test 2c746f1

@isVoid

Copy link
Copy Markdown
ContributorAuthor

/ok to test bcd291d

@Andy-Jost
Andy-Jost merged commit 5985ee1 into NVIDIA:mainFeb 18, 2026
86 checks passed
github-actionsBot pushed a commit that referenced this pull request Feb 19, 2026
Removed preview folders for the following PRs:
- PR #1218
- PR #1606
- PR #1623
- PR #1648
leofang added a commit to NVIDIA/numba-cuda that referenced this pull request Mar 2, 2026
Depends on NVIDIA/cuda-python#1623
---------
Co-authored-by: Michael Wang <isVoid@users.noreply.github.com>
Co-authored-by: Leo Fang <leof@nvidia.com>
Sign up for freeto 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.

[FEA]: Support StridedMemoryView dlpack construction from kDLBfloat type code

4 participants

@isVoid@leofang@cpcloud@Andy-Jost