Skip to content

Allow StridedMemoryView to be constructed from dlpacks type code#1623

Draft
isVoid wants to merge 2 commits intoNVIDIA:mainfrom
isVoid:fea-bf16-dlpack-smv
Draft

Allow StridedMemoryView to be constructed from dlpacks type code#1623
isVoid wants to merge 2 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 build of cupy. 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
],
)
@pytest.mark.skipif(torch is None, reason="PyTorch is not installed")
def test_ml_dtypes_bfloat16_torch_dlpack(init_cuda, slices):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This tests interop between pytorch tensor, it passes for me locally. But would require adding torch into test environment. Should we do that?

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

1 participant