pyxrt not compatible with numpy v2.0.0
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 686
- Forks
- 549
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 70
Description
Using pyxrt with numpy v2.0.0 results in all bytes being read as 1.
Minimal reproduction script below.
Uses xclbin file available here: https://gitlab.com/ska-telescope/low-cbf/ska-low-cbf-fw-cnic/-/packages/26156556
but I think any xclbin file or different Alveo card is likely to produce the same result.
import pyxrt
device = pyxrt.device("0000:d2:00.1")
xclbin = pyxrt.xclbin("./cnic.xclbin")
uuid = device.load_xclbin(xclbin)
kernel_names = [kernel.get_name() for kernel in xclbin.get_kernels()]
cu_name = kernel_names[0]
kernel = pyxrt.kernel(device, uuid, cu_name, pyxrt.kernel.cu_access_mode(0))
mem_group_ids = []
num_args = 0
for n in range(100):
try:
gid = kernel.group_id(n)
num_args += 1
if gid not in (-1, 0xFFFF):
mem_group_ids.append(gid)
print(f"Kernel group: {n}, memory bank {gid}")
except IndexError as e:
print(f"_load_firmware; n:{n}, {e}")
break
buf = pyxrt.bo(device, 128<<10, pyxrt.bo.flags.normal, mem_group_ids.pop(0))
task = kernel(0, 0x8000*4, buf, 64)
task.wait()
buf.sync(pyxrt.xclBOSyncDirection.XCL_BO_SYNC_BO_FROM_DEVICE, 64, 0)
result = buf.read(64, 0)
print(result)
# Wrong result w/ numpy v2.0.0
# array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
# 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
# 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
# dtype=int8)
# Correct result w/ numpy v1.23.0
# array([ 1, 112, 106, -7, 18, 25, 9, 35, 1, 0, 0, 0, 0,
# 0, 0, 0, 102, 102, 102, 102, 0, 0, 0, 0, 1, 0,
# 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 67, 73, 78,
# 67, 18, 39, -49, 99, 78, 73, 65, 77, 64, 2, 0, 0,
# 1, 117, -57, 57, 62, 2, 0, 0, 0, 0, 0, 0],
# dtype=int8)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproduction script in the issue, using the linked xclbin, and compare pyxrt.buf.read() under numpy 2.0.0 and 1.23.0. Investigate the difference in returned byte data and verify the fix against the script; done means the bytes read with numpy 2.0.0 match the expected result rather than all being 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100