Skip to content

Commit c1eec9a

Browse files
Add codecov coverage reporting + CI updates (#246)
Signed-off-by: Keval Morabia <[email protected]>
1 parent 0bea1c3 commit c1eec9a

File tree

9 files changed

+42
-36
lines changed

9 files changed

+42
-36
lines changed

.github/workflows/gpu_tests.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ name: GPU tests
33
on:
44
push:
55
branches: ["pull-request/[0-9]+"]
6-
paths:
7-
- ".github/workflows/gpu_tests.yml"
8-
- "modelopt/**"
9-
- "tests/**"
10-
- "setup.py"
11-
- "tox.ini"
6+
# TODO: paths cannot be used since push happens to copied PR and only latest commit to PR is used
7+
# paths:
8+
# - ".github/workflows/gpu_tests.yml"
9+
# - "modelopt/**"
10+
# - "tests/gpu/**"
11+
# - "setup.py"
12+
# - "tox.ini"
1213

1314
# Cancel previous runs if new commit is pushed to the same PR
1415
concurrency:
@@ -28,7 +29,7 @@ jobs:
2829
PIP_CONSTRAINT: "" # Disable pip constraint for upgrading packages
2930
steps:
3031
- uses: actions/checkout@v4
31-
- name: Install dependencies
32-
run: pip install tox-current-env
32+
- name: Setup proxy cache
33+
uses: nv-gha-runners/setup-proxy-cache@main
3334
- name: Run gpu tests
34-
run: tox -e py312-cuda12-gpu --current-env
35+
run: pip install tox-current-env && tox -e py312-cuda12-gpu --current-env

.github/workflows/multi_version_unit_tests.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
paths:
88
- ".github/workflows/multi_version_unit_tests.yml"
99
- "modelopt/**"
10-
- "tests/**"
10+
- "tests/unit/**"
1111
- "setup.py"
1212
- "tox.ini"
1313

@@ -28,10 +28,8 @@ jobs:
2828
- uses: actions/setup-python@v5
2929
with:
3030
python-version: "3.${{ matrix.py }}"
31-
- name: Install dependencies
32-
run: pip install tox
3331
- name: Run unit tests
34-
run: tox -e py3${{ matrix.py }}-torch28-unit
32+
run: pip install tox && tox -e py3${{ matrix.py }}-torch28-unit
3533
multi-torch-unit:
3634
runs-on: ubuntu-latest
3735
timeout-minutes: 30
@@ -43,7 +41,5 @@ jobs:
4341
- uses: actions/setup-python@v5
4442
with:
4543
python-version: "3.12"
46-
- name: Install dependencies
47-
run: pip install tox
4844
- name: Run unit tests
49-
run: tox -e py312-torch${{ matrix.torch }}-unit
45+
run: pip install tox && tox -e py312-torch${{ matrix.torch }}-unit

.github/workflows/partial_unit_tests.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
paths:
77
- ".github/workflows/partial_unit_tests.yml"
88
- "modelopt/**"
9-
- "tests/**"
9+
- "tests/unit/**"
1010
- "setup.py"
1111
- "tox.ini"
1212

@@ -27,7 +27,5 @@ jobs:
2727
- uses: actions/setup-python@v5
2828
with:
2929
python-version: "3.12"
30-
- name: Install dependencies
31-
run: pip install tox
3230
- name: Run unit tests
33-
run: tox -e py312-partial-unit-${{ matrix.test-env }}
31+
run: pip install tox && tox -e py312-partial-unit-${{ matrix.test-env }}

.github/workflows/unit_tests.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
paths:
77
- ".github/workflows/unit_tests.yml"
88
- "modelopt/**"
9-
- "tests/**"
9+
- "tests/unit/**"
1010
- "setup.py"
1111
- "tox.ini"
1212

@@ -17,17 +17,28 @@ concurrency:
1717

1818
jobs:
1919
unit-tests:
20-
runs-on: ${{ matrix.os }}
20+
runs-on: ubuntu-latest
2121
timeout-minutes: 30
22-
strategy:
23-
matrix:
24-
os: [ubuntu-latest, windows-latest]
2522
steps:
2623
- uses: actions/checkout@v4
2724
- uses: actions/setup-python@v5
2825
with:
2926
python-version: "3.12"
30-
- name: Install dependencies
31-
run: pip install tox
3227
- name: Run unit tests
33-
run: tox -e py312-torch28-unit
28+
run: pip install tox && COV_ARGS="--cov" tox -e py312-torch28-unit
29+
- name: Upload coverage reports to Codecov
30+
uses: codecov/codecov-action@v5
31+
with:
32+
token: ${{ secrets.CODECOV_TOKEN }}
33+
fail_ci_if_error: true
34+
verbose: true
35+
unit-tests-windows:
36+
runs-on: windows-latest
37+
timeout-minutes: 30
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.12"
43+
- name: Run unit tests (without coverage)
44+
run: pip install tox && tox -e py312-torch28-unit

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[![Documentation](https://img.shields.io/badge/Documentation-latest-brightgreen.svg?style=flat)](https://nvidia.github.io/TensorRT-Model-Optimizer)
88
[![version](https://img.shields.io/pypi/v/nvidia-modelopt?label=Release)](https://pypi.org/project/nvidia-modelopt/)
99
[![license](https://img.shields.io/badge/License-Apache%202.0-blue)](./LICENSE)
10+
[![codecov](https://codecov.io/github/NVIDIA/TensorRT-Model-Optimizer/graph/badge.svg?token=r1bw4LC1WH)](https://codecov.io/github/NVIDIA/TensorRT-Model-Optimizer)
1011

1112
[Examples](#examples) |
1213
[Documentation](https://nvidia.github.io/TensorRT-Model-Optimizer) |

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ extend-ignore = [
5151
"PLR0402", "PLR0912", "PLR0913", "PLR0915", "PLR2004", "PLR0911",
5252
"PT011", "PT018",
5353
"RUF002", "RUF012",
54-
"SIM115",
55-
"UP038", "UP032",
56-
"SIM108", "SIM102",
54+
"SIM102", "SIM108", "SIM115",
55+
"UP032", "UP038",
5756
]
5857

5958

@@ -120,7 +119,7 @@ markers = ["manual: Only run when --run-manual is given"]
120119

121120
[tool.coverage.run]
122121
# measure branch coverage in addition to statement coverage
123-
branch = true
122+
branch = false
124123
include = ["modelopt/*"]
125124
omit = ["*/plugins/*", "*/export/*"]
126125

tests/gpu/torch/quantization/test_hadamard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_hadamard_transform(dim):
3939
xxt = x @ x.T
4040
x_h = normalized_hadamard_transform(x)
4141
xxt_h = x_h @ x_h.T
42-
assert torch.allclose(xxt_h, xxt, atol=1e-5)
42+
assert torch.allclose(xxt_h, xxt, atol=1e-3)
4343

4444

4545
def test_kv_rotate():
@@ -59,7 +59,7 @@ def test_kv_rotate():
5959
},
6060
):
6161
output_test = model(dummy_input)
62-
assert torch.allclose(output_ref, output_test, atol=1e-5)
62+
assert torch.allclose(output_ref, output_test, atol=1e-3)
6363

6464
set_quantizer_by_cfg(
6565
model,

tests/gpu/torch/quantization/test_tensor_quant_cuda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def _test_fp4_kernel(test_in, test_out):
231231
assert torch.allclose(quantized_outputs, expected_outputs)
232232
if triton_kernel.IS_AVAILABLE:
233233
quantized_outputs_triton = triton_kernel.fp4_fake_quant_block(
234-
inputs, inputs.abs().amax().item()
234+
inputs, inputs.abs().amax()
235235
)
236236
assert torch.allclose(quantized_outputs_triton, expected_outputs)
237237

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ deps =
2222

2323
-e .[all,dev-test]
2424
commands =
25-
python -m pytest tests/unit --cov
25+
python -m pytest tests/unit {env:COV_ARGS:}
2626

2727

2828
#####################################################################

0 commit comments

Comments
 (0)