feat(ascend): implement DCMI V2 API support for device detection and usage - #20
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for the Ascend A5 generation (Ascend950) and the DCMI V2 API. It adds new CDI utility functions to handle directory-based device nodes and glob-based mounts, implements V2 API wrappers in the pydcmi package, and updates the Ascend detector to support V2-based device discovery, usage tracking, and topology reporting. Additionally, comprehensive tests have been added to verify these changes. A critical issue was identified in _get_device_memory_status_v2 where a premature return statement inside a loop prevents checking subsequent memory types (like DDR) if the first type is healthy or has its enable flag set to false.
| if dev_ecc_info.enable_flag and ( | ||
| dev_ecc_info.single_bit_error_cnt > 0 | ||
| or dev_ecc_info.double_bit_error_cnt > 0 | ||
| ): | ||
| return DeviceMemoryStatusEnum.UNHEALTHY | ||
| return DeviceMemoryStatusEnum.HEALTHY |
There was a problem hiding this comment.
In _get_device_memory_status_v2, returning DeviceMemoryStatusEnum.HEALTHY immediately when enable_flag is false (or when there are no errors) prematurely terminates the loop. This prevents subsequent memory types (such as DDR on DDR-only devices where HBM is not enabled but the query succeeds with enable_flag = False) from being checked.
The loop should only return early if an unhealthy status is detected. If the loop completes without finding any unhealthy memory, it should fall through to return HEALTHY at the end of the function.
| if dev_ecc_info.enable_flag and ( | |
| dev_ecc_info.single_bit_error_cnt > 0 | |
| or dev_ecc_info.double_bit_error_cnt > 0 | |
| ): | |
| return DeviceMemoryStatusEnum.UNHEALTHY | |
| return DeviceMemoryStatusEnum.HEALTHY | |
| if dev_ecc_info.enable_flag and ( | |
| dev_ecc_info.single_bit_error_cnt > 0 | |
| or dev_ecc_info.double_bit_error_cnt > 0 | |
| ): | |
| return DeviceMemoryStatusEnum.UNHEALTHY |
There was a problem hiding this comment.
Pull request overview
This PR adds Ascend DCMI V2 support to improve device detection/usage on newer Ascend generations (notably A5/950), and updates CDI generation to account for A5’s UB device/mount requirements.
Changes:
- Add DCMI V2 initialization + V2 wrapper functions in the
pydcmibinding and route Ascend detection/usage/topology logic based on the initialized API version. - Extend Ascend SoC naming/variant handling for the A5 (Ascend950*) generation, including fallback UUID behavior when die IDs aren’t readable.
- Update CDI generation to enumerate UB device directories and mount additional A5 UB user-space libraries; add comprehensive tests for the new behaviors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/gpustack_runtime/detector/test_ascend.py | Adds tests covering A5 SoC naming, CDI UB enumeration/mounting, and DCMI V2-only driver behavior (info/usage/topology). |
| gpustack_runtime/detector/pydcmi/init.py | Introduces V2 init + V2 wrappers and tracks which API version initialized the library. |
| gpustack_runtime/detector/ascend.py | Implements V2 detection/usage paths, V2-aware topology behavior, and A5 (Ascend950*) naming support. |
| gpustack_runtime/deployer/cdi/ascend.py | Enumerates UB device directories and conditionally mounts A5 UB libraries based on detected arch family/variant. |
| gpustack_runtime/deployer/cdi/utils.py | Adds helpers to enumerate device nodes from a directory and to expand mount globs into CDI mounts. |
Suppressed comments (1)
gpustack_runtime/detector/pydcmi/init.py:877
dcmiv2_init()sets the global_apiVersionto 2, butdcmi_shutdown()does not reset it. After a shutdown + re-init cycle (or simply after shutdown),dcmi_api_version()can keep reporting 2 even though the library is no longer initialized, which can send callers down the V2-only code path against a V1-only driver.
Reset _apiVersion in dcmi_shutdown() so the next initialization establishes the correct version again.
def dcmi_shutdown():
global _libInitialized, _libInitializedException
with libLoadLock:
if not _libInitialized:
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
283d1cd to
3f5fa0b
Compare
gpustack/gpustack#6148