Repository navigation
fix(auto): detect Ascend NPU and configure Ray/server config by device type - #419
Open
Liuchenbing-2026 wants to merge 1 commit into
Open
Liuchenbing-2026 wants to merge 1 commit into
Liuchenbing-2026 wants to merge 1 commit into
Conversation
…e type
Detect Ascend NPUs alongside CUDA GPUs in _ServerTools via torch.npu and npu-smi info -l fallback, propagate device_type into generated server_config.yaml device groups and meshes, and start Ray nodes with ASCEND_RT_VISIBLE_DEVICES and --resources={"NPU": n} on NPU hosts while preserving existing CUDA behavior.
Signed-off-by: liuchenbing <chenliumail@163.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR type
PR information
Closes #370.
twinkle.serveralready supports'npu'viaTrainingConfig.device_typeandPlatform.get_platform('npu'), buttwinkle-auto(_ServerTools) previously assumed CUDA only (nvidia-smi/torch.cuda, hardcodeddevice_type: cuda,CUDA_VISIBLE_DEVICES, and--num-gpus).Changes
src/twinkle_client/auto/agent/server_tools.py:_detect_npu_count_from_smi()to parsenpu-smi info -l(Chip Countlines withTotal Countfallback)._detect_accelerator() -> tuple[str, int]checking CUDA (nvidia-smi/torch.cuda) and then Ascend NPU (torch.npu/npu-smi info -l), keeping_detect_gpu_count()delegating to it.device_typethrough_tool_start_server()into_generate_server_config()(updating training and non-CPU samplerdevice_groupanddevice_meshentries while keepingprocessoron'CPU') and_start_ray_cluster()(settingASCEND_RT_VISIBLE_DEVICESand--resources='{"NPU": <n>}'for'npu', while preservingCUDA_VISIBLE_DEVICESand--num-gpusfor'cuda').tests/twinkle_client/test_auto_agent_tools.py:npu-smi info -lsingle- and dual-chip outputs), NPU server config generation, Ray CLI/env args, and_tool_start_serverend-to-end wiring.Experiment results
pytest -v tests/twinkle_client/test_auto_agent_tools.py):c518c3335d91545d187c7273ae0de6f41fcf901f4a953b72ea176540effd5230):9 failed, 14 passed.23 passed._detect_accelerator()vianpu-smi info -lon an 8-NPU Ascend host returning('npu', 8).pre-commit run --all-files): all 11 hooks passed (flake8,isort,yapf,pyupgrade,trailing-whitespace,check-yaml,end-of-file-fixer,requirements-txt-fixer,double-quote-string-fixer,check-merge-conflict,mixed-line-ending).hypothesis) and 7 tests in unrelatedtests/twinkle_client/modules did not pass in the minimal client test environment due to missing optionalpeft/tinkerpackages.