You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When maca_path/bin/macainfo binary does not exist, get_maca_arch() should gracefully fall back to the default architecture (xco re1000) instead of crashing.
2. Users should be able to set MACA_ARCH environment variable (e.g. MACA_ARCH=xcore2000) to skip the macainfo command entirely fo
r cross-compilation or non-GPU environments.
3. Tests should use from tvm.contrib import mxcc directly via standard import instead of polluting sys.modules globally.
Actual behavior
subprocess.check_output raises FileNotFoundError (a subclass of OSError) when the binary is missing, but only subprocess.Call edProcessError is caught, causing a crash.
No MACA_ARCH environment variable support — the only way to specify the architecture is by running macainfo, which requires a ph
ysical GPU.
The previous test file manually mocked sys.modules to inject fake tvm modules, which permanently pollutes sys.modules and caus
es AttributeError in other tests running in the same process.
Environment
TVM 0.23.dev0, MetaX MACA 3.5.3.20, Python 3.10, Linux
Steps to reproduce
For the crash (OSError not caught):
Set maca_path to a directory where bin/macainfo does not exist
When
maca_path/bin/macainfobinary does not exist,get_maca_arch()should gracefully fall back to the default architecture (xco re1000) instead of crashing.2. Users should be able to set
MACA_ARCHenvironment variable (e.g.MACA_ARCH=xcore2000) to skip themacainfocommand entirely for cross-compilation or non-GPU environments.
3. Tests should use
from tvm.contrib import mxccdirectly via standard import instead of pollutingsys.modulesglobally.Actual behavior
subprocess.check_outputraisesFileNotFoundError(a subclass ofOSError) when the binary is missing, but onlysubprocess.Call edProcessErroris caught, causing a crash.MACA_ARCHenvironment variable support — the only way to specify the architecture is by runningmacainfo, which requires a physical GPU.
sys.modulesto inject faketvmmodules, which permanently pollutessys.modulesand causes
AttributeErrorin other tests running in the same process.Environment
TVM 0.23.dev0, MetaX MACA 3.5.3.20, Python 3.10, Linux
Steps to reproduce
For the crash (OSError not caught):
maca_pathto a directory wherebin/macainfodoes not existget_maca_arch(maca_path="/valid/path/without/macainfo")FileNotFoundError/OSErrorcrashFor the test pollution:
pytest tests/python/contrib/test_mxcc_arch.pyin the same process as other TVM teststvmmodule injected viasys.modulesleaks into subsequent testsAttributeErroron realtvmmodule attributesFix
Changes in PR
fix/duplicate-maca-error-message(SHA: 485c4d1):python/tvm/contrib/mxcc.py: catch(subprocess.CalledProcessError, OSError)instead of onlyCalledProcessErrorpython/tvm/contrib/mxcc.py: checkMACA_ARCHenv var first; if set, return its value immediatelypython/tvm/contrib/mxcc.py: resolvemaca_pathfromMACA_PATHenv var as fallbacktests/python/contrib/test_mxcc_arch.py: rewrite to usefrom tvm.contrib import mxccwithunittest.mock.patch, covering 8 test cases
Triage