Skip to content

Comments

Allow StridedMemoryView to be constructed from dlpacks type code#1623

Merged
Andy-Jost merged 8 commits intoNVIDIA: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 intoNVIDIA:mainfrom
isVoid:fea-bf16-dlpack-smv

Conversation

@isVoid
Copy link
Contributor

@isVoid isVoid commented Feb 13, 2026

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
Contributor

copy-pr-bot bot commented Feb 13, 2026

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.

@isVoid isVoid 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-py312 Allow StridedMemoryView to be constructed from dlpacks type code Feb 13, 2026
Copy link
Contributor

@cpcloud cpcloud left a comment

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
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
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
Contributor Author

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
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.

@leofang
Copy link
Member

leofang commented Feb 18, 2026

@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!

@leofang leofang added this to the cuda.core v0.6.0 milestone Feb 18, 2026
@isVoid isVoid marked this pull request as ready for review February 18, 2026 18:08
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 18, 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.

@isVoid isVoid requested review from cpcloud and leofang February 18, 2026 18:09
@isVoid
Copy link
Contributor Author

isVoid commented Feb 18, 2026

UPDATE: Done.

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

@isVoid
Copy link
Contributor Author

isVoid commented Feb 18, 2026

/ok to test 948cb4e

@github-actions
Copy link

@isVoid
Copy link
Contributor Author

isVoid commented Feb 18, 2026

/ok to test 2c746f1

@isVoid
Copy link
Contributor Author

isVoid commented Feb 18, 2026

/ok to test bcd291d

@Andy-Jost Andy-Jost merged commit 5985ee1 into NVIDIA:main Feb 18, 2026
86 checks passed
github-actions bot 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
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.

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

4 participants