Fix CUDA cleanup and NPU/HCCL setup bugs#92
Open
morluto wants to merge 4 commits into
Open
Conversation
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.
Summary
This fixes three accelerator-specific failure modes in CUDA cleanup, NPU device discovery, and HCCL sub-communicator setup.
What was wrong
CUDA manual unpin could reject valid pinned memory
The in-place pin path registers memory with:
That flag is
cudaHostRegisterDefault. During unregister, the cleanup path only acceptedcudaHostRegisterMapped(0x02). On drivers that report the actual registration flag, cleanup can fail beforecudaHostUnregister()runs.NPU UUID generation scanned the wrong device IDs
npu_generate_uuid()needs to querynpu-smi -i <physical_id>, but the previous logic did not reliably choose physical IDs:torch.npu.device_count()alone breaks whenASCEND_RT_VISIBLE_DEVICESmasks/remaps physical devicesFor example, a process visible on physical NPU
4may report only one visible device, butnpu-smistill needs-i 4.HCCL config fields were misspelled
Two
HcclCommConfigassignments did not target the intended ctypes fields:hccl_op_expansize_modeinstead ofhccl_op_expansion_modehcll_world_rank_idinstead ofhccl_world_rank_idctypes accepts unknown kwargs as ordinary Python attributes, so the real struct fields stayed at their default values.
What changed
cudaHostRegisterDefault(0x00) andcudaHostRegisterMapped(0x02) in manual unpin validation.ASCEND_RT_VISIBLE_DEVICESwhen present.max(8, torch.npu.device_count()), preserving the old 0-7 coverage while supporting larger unmasked hosts.Testing
Result:
Both passed.