11[tox]
22envlist =
33 pre-commit-all
4- py312-torch27-unit
4+ py312-torch27-{ unit,gpu}
55skipsdist = True
66toxworkdir = /tmp/{env:USER}-modelopt-tox
77
@@ -11,6 +11,9 @@ toxworkdir = /tmp/{env:USER}-modelopt-tox
1111# ###########################
1212[testenv:{py39,py310,py311,py312}-torch{24,25,26,27}-unit]
1313deps =
14+ # Build onnxsim from sdists for Python 3.12 until http://github.com/daquexian/onnx-simplifier/pull/353
15+ py312: onnxsim
16+
1417 # torch version auto-selected based on torchvision version
1518 torch24: torchvision~=0.19.0
1619 torch25: torchvision~=0.20.0
@@ -22,6 +25,53 @@ commands =
2225 python -m pytest tests/unit --cov
2326
2427
28+ # ####################################################################
29+ # Environment to run unit tests with subset of dependencies installed
30+ # ####################################################################
31+ [testenv:{py39,py310,py311,py312}-ext-unit-{onnx,torch,torch_deploy}]
32+ allowlist_externals =
33+ bash, rm
34+ deps =
35+ # Build onnxsim from sdists for Python 3.12 until http://github.com/daquexian/onnx-simplifier/pull/353
36+ py312: onnxsim
37+
38+ # ONNX unit tests heavily rely on torch / torchvision
39+ onnx: .[onnx,dev-test]
40+ onnx: torchvision
41+
42+ # Install megatron-core to test torch-only install can still import plugins
43+ torch: megatron-core
44+ torch: .[dev-test]
45+
46+ torch_deploy: .[onnx,torch,dev-test]
47+ commands =
48+ onnx: python -m pytest tests/unit/onnx
49+ torch: python -m pytest tests/unit/torch --ignore tests/unit/torch/deploy
50+ torch_deploy: python -m pytest tests/unit/torch/deploy
51+
52+
53+ # #######################################################
54+ # GPU test environments (Can be used with --current-env)
55+ # #######################################################
56+ [testenv:{py39,py310,py311,py312}-cuda12-gpu]
57+ commands_pre =
58+ # Install deps here so that it gets installed even in --current-env
59+ pip install -U megatron-core
60+ pip install git+https://github.com/Dao-AILab/fast-hadamard-transform.git
61+
62+ # Install Eagle-3 test dependencies
63+ pip install tiktoken blobfile sentencepiece
64+
65+ # Build onnxsim from sdists for Python 3.12 until http://github.com/daquexian/onnx-simplifier/pull/353
66+ py312: pip install onnxsim
67+
68+ # NOTE: User is expected to have correct torch-cuda version pre-installed if using --current-env
69+ # to avoid possible CUDA version mismatch
70+ pip install -e .[all,dev-test]
71+ commands =
72+ # Coverage fails with "Can't combine line data with arc data" error so not using "--cov"
73+ python -m pytest tests/gpu
74+
2575# ############################################
2676# Code quality checks on all files or on diff
2777# ############################################
@@ -33,9 +83,9 @@ commands =
3383 diff: pre-commit run --from-ref origin/main --to-ref HEAD {posargs}
3484
3585
36- # ####################
37- # Documentation build
38- # ####################
86+ # ########################
87+ # Run documentation build
88+ # ########################
3989[testenv:{build,debug}-docs]
4090allowlist_externals =
4191 rm
@@ -50,3 +100,26 @@ commands_pre =
50100commands =
51101 sphinx-build source build/html --fail-on-warning --show-traceback --keep-going
52102 debug: sphinx-autobuild source build/html --host 0.0.0.0
103+
104+
105+ # ################
106+ # Run wheel build
107+ # ################
108+ [testenv:build-wheel]
109+ allowlist_externals =
110+ bash, cd, rm
111+ passenv =
112+ SETUPTOOLS_SCM_PRETEND_VERSION
113+ deps =
114+ twine
115+ commands =
116+ # Clean build directory to avoid any stale files getting into the wheel
117+ rm -rf build
118+
119+ # Build and check wheel
120+ pip wheel --no-deps --wheel-dir =dist .
121+ twine check dist/*
122+
123+ # Install and test the wheel
124+ bash -c " find dist -name 'nvidia_modelopt-*.whl' | xargs pip install -f dist"
125+ bash -c " cd dist; python -c 'import modelopt; print(modelopt.__version__);'"
0 commit comments