-
Notifications
You must be signed in to change notification settings - Fork 6.5k
[CI] Add quantization #9832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[CI] Add quantization #9832
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e27d7c3
add quantization to nightly CI.
sayakpaul 737405d
prep.
sayakpaul 3628c7b
fix lib name.
sayakpaul 356c525
remove deps that are not needed.
sayakpaul 12849bc
fix slice.
sayakpaul 2d53f88
Merge branch 'main' into add-quantization-ci
sayakpaul d9bbd38
Merge branch 'main' into add-quantization-ci
sayakpaul ee6d836
Merge branch 'main' into add-quantization-ci
sayakpaul 110004b
Merge branch 'main' into add-quantization-ci
sayakpaul ac8afd8
Merge branch 'main' into add-quantization-ci
sayakpaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -347,6 +347,64 @@ jobs: | |
| pip install slack_sdk tabulate | ||
| python utils/log_reports.py >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| run_nightly_quantization_tests: | ||
| name: Torch quantization nightly tests | ||
| strategy: | ||
| fail-fast: false | ||
| max-parallel: 2 | ||
| matrix: | ||
| config: | ||
| - backend: "bitsandbytes" | ||
| test_location: "bnb" | ||
| runs-on: | ||
| group: aws-g6e-xlarge-plus | ||
| container: | ||
| image: diffusers/diffusers-pytorch-cuda | ||
| options: --shm-size "20gb" --ipc host --gpus 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a large shared memory here. |
||
| steps: | ||
| - name: Checkout diffusers | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 2 | ||
| - name: NVIDIA-SMI | ||
| run: nvidia-smi | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m venv /opt/venv && export PATH="/opt/venv/bin:$PATH" | ||
| python -m uv pip install -e [quality,test] | ||
| python -m uv pip install -U ${{ matrix.config.backend }} | ||
| python -m uv pip install pytest-reportlog | ||
| - name: Environment | ||
| run: | | ||
| python utils/print_env.py | ||
| - name: ${{ matrix.config.backend }} quantization tests on GPU | ||
| env: | ||
| HF_TOKEN: ${{ secrets.DIFFUSERS_HF_HUB_READ_TOKEN }} | ||
| # https://pytorch.org/docs/stable/notes/randomness.html#avoiding-nondeterministic-algorithms | ||
| CUBLAS_WORKSPACE_CONFIG: :16:8 | ||
| BIG_GPU_MEMORY: 40 | ||
| run: | | ||
| python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \ | ||
| --make-reports=tests_${{ matrix.config.backend }}_torch_cuda \ | ||
| --report-log=tests_${{ matrix.config.backend }}_torch_cuda.log \ | ||
| tests/quantization/${{ matrix.config.test_location }} | ||
| - name: Failure short reports | ||
| if: ${{ failure() }} | ||
| run: | | ||
| cat reports/tests_${{ matrix.config.backend }}_torch_cuda_stats.txt | ||
| cat reports/tests_${{ matrix.config.backend }}_torch_cuda_failures_short.txt | ||
| - name: Test suite reports artifacts | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: torch_cuda_${{ matrix.config.backend }}_reports | ||
| path: reports | ||
| - name: Generate Report and Notify Channel | ||
| if: always() | ||
| run: | | ||
| pip install slack_sdk tabulate | ||
| python utils/log_reports.py >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| # M1 runner currently not well supported | ||
| # TODO: (Dhruv) add these back when we setup better testing for Apple Silicon | ||
| # run_nightly_tests_apple_m1: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -369,7 +369,7 @@ def test_quality(self): | |
| output_type="np", | ||
| ).images | ||
| out_slice = output[0, -3:, -3:, -1].flatten() | ||
| expected_slice = np.array([0.0149, 0.0322, 0.0073, 0.0134, 0.0332, 0.011, 0.002, 0.0232, 0.0193]) | ||
| expected_slice = np.array([0.0376, 0.0359, 0.0015, 0.0449, 0.0479, 0.0098, 0.0083, 0.0295, 0.0295]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of the machine change. |
||
|
|
||
| max_diff = numpy_cosine_similarity_distance(expected_slice, out_slice) | ||
| self.assertTrue(max_diff < 1e-2) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to go with a matrix strategy to accommodate for future backends.