Skip to content

Commit 4c36abe

Browse files
Add llm_ptq PR test, Cleanup dependency installation in modelopt docker (#338)
Signed-off-by: Keval Morabia <[email protected]>
1 parent fb875ac commit 4c36abe

File tree

16 files changed

+139
-47
lines changed

16 files changed

+139
-47
lines changed

.github/workflows/code_quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
jobs:
1616
code-quality:
1717
runs-on: ubuntu-latest
18-
timeout-minutes: 15
18+
timeout-minutes: 30
1919
steps:
2020
- uses: actions/checkout@v4
2121
- uses: actions/setup-python@v5
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# NOTE: Make sure this file is consistent with .gitlab/tests.yml
2+
name: E2E Example tests
3+
4+
on:
5+
push:
6+
branches: ["pull-request/[0-9]+"]
7+
# NOTE: paths cannot be used since push happens to copied PR and only latest commit to PR is used
8+
schedule:
9+
- cron: "0 0 * * *" # Nightly
10+
workflow_dispatch: # On-demand
11+
12+
# Cancel previous runs if new commit is pushed to the same PR
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ startsWith(github.ref, 'refs/heads/pull-request/') && github.ref || github.sha }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
check-file-changes:
19+
if: startsWith(github.ref, 'refs/heads/pull-request/')
20+
runs-on: ubuntu-latest
21+
outputs:
22+
any_changed: ${{ steps.changed-tests.outputs.any_changed }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
- id: get-pr-info
28+
uses: nv-gha-runners/get-pr-info@main
29+
# Get commit from main branch that is present in the PR to use as base for changed files
30+
- id: calculate-merge-base
31+
env:
32+
PR_SHA: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).head.sha }}
33+
BASE_SHA: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.sha }}
34+
run: |
35+
(echo -n "merge-base="; git merge-base "$BASE_SHA" "$PR_SHA") | tee --append "${GITHUB_OUTPUT}"
36+
- name: Check for changes in test-relevant directories
37+
id: changed-tests
38+
uses: step-security/[email protected]
39+
with:
40+
base_sha: ${{ steps.calculate-merge-base.outputs.merge-base }}
41+
sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).head.sha }}
42+
files: |
43+
.github/workflows/example_tests.yml
44+
examples/llm_ptq/**
45+
modelopt/torch/**
46+
tests/examples/llm_ptq/**
47+
setup.py
48+
fail_on_initial_diff_error: true
49+
wait-checks:
50+
needs: [check-file-changes]
51+
if: needs.check-file-changes.outputs.any_changed == 'true'
52+
uses: ./.github/workflows/_wait_for_checks.yml
53+
permissions:
54+
checks: read
55+
secrets: inherit
56+
with:
57+
match_pattern: '^DCO$|^linux$' # Wait for DCO and Unit tests / linux to pass
58+
delay: 300s
59+
example-tests-pr:
60+
needs: [check-file-changes, wait-checks]
61+
if: needs.check-file-changes.outputs.any_changed == 'true'
62+
# Runner list at https://github.com/nv-gha-runners/enterprise-runner-configuration/blob/main/docs/runner-groups.md
63+
runs-on: linux-amd64-gpu-h100-latest-1
64+
timeout-minutes: 90
65+
strategy:
66+
matrix:
67+
EXAMPLE: [llm_ptq]
68+
container: &example_container
69+
image: nvcr.io/nvidia/tensorrt-llm/release:1.1.0rc2.post2
70+
env:
71+
LD_LIBRARY_PATH: "/usr/lib/x86_64-linux-gnu:/usr/local/tensorrt/targets/x86_64-linux-gnu/lib:${LD_LIBRARY_PATH}"
72+
# PATH: "/usr/local/tensorrt/targets/x86_64-linux-gnu/bin:${PATH}"
73+
PIP_CONSTRAINT: "" # Disable pip constraint for upgrading packages
74+
steps: &example_steps
75+
- uses: actions/checkout@v4
76+
- uses: nv-gha-runners/setup-proxy-cache@main
77+
- name: Run example tests
78+
run: |
79+
pip install ".[all,dev-test]"
80+
find examples/${{ matrix.EXAMPLE }} -name "requirements.txt" | while read req_file; do pip install -r "$req_file" || exit 1; done
81+
pytest -s tests/examples/${{ matrix.EXAMPLE }}
82+
example-tests-non-pr:
83+
if: ${{ !startsWith(github.ref, 'refs/heads/pull-request/') }}
84+
# Runner list at https://github.com/nv-gha-runners/enterprise-runner-configuration/blob/main/docs/runner-groups.md
85+
runs-on: linux-amd64-gpu-h100-latest-1
86+
timeout-minutes: 90
87+
strategy:
88+
matrix:
89+
EXAMPLE: [llm_ptq]
90+
container: *example_container
91+
steps: *example_steps
92+
example-pr-required-check:
93+
# Run even if example-tests-pr is skipped
94+
if: ${{ startsWith(github.ref, 'refs/heads/pull-request/') && always() }}
95+
needs: [check-file-changes, example-tests-pr]
96+
runs-on: ubuntu-latest
97+
steps:
98+
- name: Required GPU tests did not succeed
99+
if: ${{ needs.check-file-changes.result != 'success' || (needs.check-file-changes.outputs.any_changed == 'true' && needs.example-tests-pr.result != 'success') }}
100+
run: exit 1

.github/workflows/gpu_tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
modelopt/**
4545
tests/gpu/**
4646
tox.ini
47-
pyproject.toml
4847
setup.py
4948
fail_on_initial_diff_error: true
5049
wait-checks:

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ permissions:
2323
jobs:
2424
build-docs:
2525
runs-on: ubuntu-latest
26-
timeout-minutes: 15
26+
timeout-minutes: 30
2727
steps:
2828
- uses: actions/checkout@v4
2929
- uses: actions/setup-python@v5

.github/workflows/unit_tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
- ".github/workflows/unit_tests.yml"
1111
- "modelopt/**"
1212
- "tests/unit/**"
13-
- "pyproject.toml"
1413
- "setup.py"
1514
- "tox.ini"
1615
schedule:

.gitlab/tests.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,24 @@ example:
4949
tags: [docker, linux, 2-gpu, sm<89]
5050
parallel:
5151
matrix:
52-
- TEST: [diffusers, llm_distill, llm_qat, llm_sparsity, onnx_ptq, speculative_decoding]
52+
- EXAMPLE: [diffusers, llm_distill, llm_qat, llm_sparsity, onnx_ptq, speculative_decoding]
5353
allow_failure: true # Allow to continue next stages even if job is canceled (e.g. during release)
5454
before_script:
55-
- pip install ".[all]" -U
55+
- pip install ".[all,dev-test]"
5656
script:
5757
# Uninstall apex since T5 Int8 (PixArt) + Apex is not supported as per https://github.com/huggingface/transformers/issues/21391
58-
- if [ "$TEST" = "diffusers" ]; then pip uninstall -y apex; fi
59-
- if [ "$TEST_TYPE" = "pytest" ]; then pytest -s tests/examples/$TEST; else bash tests/examples/test_$TEST.sh; fi
58+
- if [ "$EXAMPLE" = "diffusers" ]; then pip uninstall -y apex; fi
59+
- find examples/$EXAMPLE -name "requirements.txt" | while read req_file; do pip install -r "$req_file" || exit 1; done
60+
- if [ "$TEST_TYPE" = "pytest" ]; then pytest -s tests/examples/$EXAMPLE; else bash tests/examples/test_$EXAMPLE.sh; fi
6061

6162
example-ada:
6263
extends: example
6364
timeout: 60m
6465
tags: [docker, linux, 2-gpu, sm>=89]
6566
parallel:
6667
matrix:
67-
- TEST: [llm_eval, llm_ptq, vlm_ptq, llm_autodeploy]
68-
- TEST: [onnx_ptq]
68+
- EXAMPLE: [llm_eval, llm_ptq, vlm_ptq, llm_autodeploy]
69+
- EXAMPLE: [onnx_ptq]
6970
TEST_TYPE: bash
7071

7172
##### Megatron / NeMo Integration Tests #####

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ To install from source in editable mode with all development dependencies or to
6868

6969
```bash
7070
# Clone the Model Optimizer repository
71-
git clone https://github.com/NVIDIA/TensorRT-Model-Optimizer.git
71+
git clone git@github.com:NVIDIA/TensorRT-Model-Optimizer.git
7272
cd TensorRT-Model-Optimizer
7373

7474
pip install -e .[dev]

docker/Dockerfile

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
FROM nvcr.io/nvidia/tensorrt-llm/release:1.1.0rc2.post2
22

3-
ARG PIP_EXTRA_INDEX_URL="https://pypi.nvidia.com"
4-
ENV PIP_EXTRA_INDEX_URL=$PIP_EXTRA_INDEX_URL \
3+
ENV PIP_EXTRA_INDEX_URL="https://pypi.nvidia.com" \
54
PIP_NO_CACHE_DIR=off \
65
PIP_CONSTRAINT= \
7-
TORCH_CUDA_ARCH_LIST="8.0 8.6 8.7 8.9 9.0 10.0+PTX"
6+
TORCH_CUDA_ARCH_LIST="8.0 8.6 8.7 8.9 9.0 10.0 12.0+PTX"
87

98
RUN apt-get update && \
109
apt-get install -y libgl1 && \
@@ -18,17 +17,11 @@ RUN ln -s /app/tensorrt_llm /workspace/tensorrt_llm
1817
ENV LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu:/usr/local/tensorrt/targets/x86_64-linux-gnu/lib:${LD_LIBRARY_PATH}" \
1918
PATH="/usr/local/tensorrt/targets/x86_64-linux-gnu/bin:${PATH}"
2019

21-
# Install modelopt with all optional dependencies and pre-compile CUDA extensions otherwise they take several minutes on every docker run
22-
RUN pip install -U "nvidia-modelopt[all,dev-test]"
23-
RUN python -c "import modelopt.torch.quantization.extensions as ext; ext.precompile()"
24-
25-
# Find and install requirements.txt files for all examples excluding windows
20+
# Install modelopt from source with all optional dependencies and pre-compile CUDA extensions otherwise they take several minutes on every docker run
2621
COPY . TensorRT-Model-Optimizer
22+
RUN pip install -e "./TensorRT-Model-Optimizer[all]"
2723
RUN rm -rf TensorRT-Model-Optimizer/.git
28-
RUN find TensorRT-Model-Optimizer/examples -name "requirements.txt" | grep -v "windows" | while read req_file; do \
29-
echo "Installing from $req_file"; \
30-
pip install -r "$req_file" || exit 1; \
31-
done
24+
RUN python -c "import modelopt.torch.quantization.extensions as ext; ext.precompile()"
3225

3326
# Allow users to run without root
3427
RUN chmod -R 777 /workspace

docs/source/getting_started/_installation_for_Linux.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ Environment setup
3434

3535
To use Model Optimizer with full dependencies (e.g. TensorRT/TensorRT-LLM deployment), we recommend using our provided docker image
3636
which is based on the `TensorRT-LLM <https://catalog.ngc.nvidia.com/orgs/nvidia/teams/tensorrt-llm/containers/release/tags>`_
37-
docker image with additional example-specific dependencies installed.
37+
docker image with additional dependencies installed.
3838

3939
After installing the `NVIDIA Container Toolkit <https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html>`_,
40-
please run the following commands to build the Model Optimizer docker container which has all the necessary
41-
dependencies pre-installed for running the examples.
40+
please run the following commands to build the Model Optimizer docker container which has all the base
41+
dependencies pre-installed. You may need to install additional dependencies from the examples's `requirements.txt` file.
4242

4343
.. code-block:: shell
4444
4545
# Clone the ModelOpt repository
46-
git clone https://github.com/NVIDIA/TensorRT-Model-Optimizer.git
46+
git clone git@github.com:NVIDIA/TensorRT-Model-Optimizer.git
4747
cd TensorRT-Model-Optimizer
4848
4949
# Build the docker (will be tagged `docker.io/library/modelopt_examples:latest`)
@@ -60,8 +60,7 @@ Environment setup
6060

6161
For PyTorch, you can also use `NVIDIA NGC PyTorch container <https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch/tags>`_
6262
and for NVIDIA NeMo framework, you can use the `NeMo container <https://catalog.ngc.nvidia.com/orgs/nvidia/containers/nemo/tags>`_.
63-
Both of these containers come with Model Optimizer pre-installed. NeMo container also comes with the HuggingFace and TensorRT-LLM
64-
dependencies. Make sure to update the Model Optimizer to the latest version if not already.
63+
Both of these containers come with Model Optimizer pre-installed. Make sure to update the Model Optimizer to the latest version if not already.
6564

6665
For ONNX PTQ, you can use the optimized docker image from [onnx_ptq Dockerfile](https://github.com/NVIDIA/TensorRT-Model-Optimizer/tree/main/examples/onnx_ptq/docker).
6766

examples/cnn_qat/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
torchvision

0 commit comments

Comments
 (0)