Skip to content

fix(cuda.core): declare cdef attrs for system event wrappers and decode packed gpu_id - #2606

Open
rluo8 wants to merge 4 commits into
NVIDIA:mainfrom
rluo8:fix/system-event-missing-cdef-attrs
Open

fix(cuda.core): declare cdef attrs for system event wrappers and decode packed gpu_id#2606
rluo8 wants to merge 4 commits into
NVIDIA:mainfrom
rluo8:fix/system-event-missing-cdef-attrs

Conversation

@rluo8

@rluo8 rluo8 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

Two issues were found when adding coverage tests (internal bug 6595639):

  1. Missing cdef attributes on SystemEvent, SystemEvents, EventData, and DeviceAttributes. These are Cython cdef class types (no __dict__), so undeclared self._event_data / self._attributes assignments raise AttributeError. RegisteredSystemEvents.wait() therefore crashes as soon as a real bind/unbind event arrives.

  2. SystemEvent.device type mismatch. NVML's packed int gpu_id (domain[31:16] | bus[15:8] | device[7:0]), which requires an NVML-style PCI bus ID string (NVML_DEVICE_PCI_BUS_ID_FMT). Decode at the call site via _pci_bus_id_from_gpu_id.

Adds regression tests for construction, packing decode, and end-to-end SystemEvent.device resolution against live pci_info.

Verification:

  • B10: new regression tests 8 passed; live unbind of 0000:c1:00.0
    yields SystemEvents with gpu_id=0xC10000000000:C1:00.0, and
    post-rebind SystemEvent.device resolves correctly
  • A100 MIG: DeviceAttributes cdef fix verified
  • System Event register/wait remains Linux-only (Windows/WSL/WOA skip)

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Aug 12, 2026
@rluo8 rluo8 self-assigned this Aug 12, 2026
@rluo8
rluo8 requested a review from mdboom August 12, 2026 03:05
@rluo8

rluo8 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Hi @mdboom , this issue is about system event. Could you please help review it?
Thanks!

@github-actions

Copy link
Copy Markdown

@rwgk rwgk added this to the cuda.core 1.2.0 milestone Aug 12, 2026
@rwgk rwgk added the P0 High priority - Must do! label Aug 12, 2026

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

What is the root issue this is trying to solve?

This is making these objects mutable and they definitely shouldn't be -- their intention is to return values from the NVML API, not to set things on them.

The gpu_id / pci_id bridge in _system_events.pyx added here makes sense, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants