Refactor torchada patching into focused compatibility modules#67
Refactor torchada patching into focused compatibility modules#67yeahdongcn wants to merge 1 commit into
Conversation
Signed-off-by: Xiaodong Ye <xiaodong.ye@mthreads.com>
|
@popsiclexu @froststeam Please help with testing on |
🤖 Augment PR SummarySummary: Refactors torchada’s CUDA→MUSA patching into focused compatibility modules and expands CUDA-shaped API coverage. Key changes:
🤖 Was this summary useful? React with 👍 or 👎 |
| return _CDLLWrapper(cdll_instance, name_str) | ||
| return cdll_instance | ||
|
|
||
| ctypes.CDLL = PatchedCDLL |
There was a problem hiding this comment.
patch_ctypes_cdll() replaces ctypes.CDLL, but callers using ctypes.cdll.LoadLibrary (whose _dlltype is captured at import time) may bypass this wrapper and lose symbol translation. Is that an intended compatibility gap?
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| elif name in self._REMAP_ATTRS: | ||
| value = getattr(self._musa_module, self._REMAP_ATTRS[name]) | ||
| else: | ||
| value = getattr(self._musa_module, name) |
There was a problem hiding this comment.
If getattr(self._musa_module, name) raises, the resulting AttributeError message will mention torch.musa rather than torch.cuda, which can be confusing for downstream debugging/handlers. You may want to ensure missing attributes raise a torch.cuda-shaped error message.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
=================================================================================================================== short test summary info ====================================================================================================================
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_original_accelerator_takes_precedence_over_musa - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_musa_overrides_take_precedence_when_both_exist - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_fallback_to_musa_when_accelerator_missing - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_override_takes_precedence_over_everything - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_missing_everywhere_raises_attribute_error - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_resolved_attribute_is_cached - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_dir_includes_attributes_from_both_modules - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_remap_used_when_accel_and_musa_lack_index_suffix_name - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_remap_not_used_when_accelerator_has_official_impl - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_remap_keys_listed_in_dir - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_cuda_patching.py::TestAcceleratorModuleWrapper::test_special_attrs_for_nested_lookups - ImportError: cannot import name '_AcceleratorModuleWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
FAILED tests/test_mappings.py::TestCDLLWrapper::test_cdll_wrapper_class_exists - ImportError: cannot import name '_CDLLWrapper' from 'torchada._patch' (/home/dist/zhenxue/github/torchada/src/torchada/_patch.py)
==================================================================================================== 12 failed, 336 passed, 15 skipped, 4 warnings in 3.21s =================================================================================================== |
Summary
compatibility helpers.
memory APIs, and CUDA device wrappers.
mapping rules.
Testing
docker exec -w /ws yeahdongcn1 python -m pytest tests/ --tb=short -q333 passed, 30 skippedgit diff --cached --check