Skip to content

Commit 11d23fa

Browse files
committed
Merge remote-tracking branch 'origin' into kylesayrs/cleanup-moe-examples
2 parents 2f5de10 + dddc2f8 commit 11d23fa

File tree

105 files changed

+2563
-1145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2563
-1145
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: prepare code coverage
2+
description: installs code coverage dependencies and exports an updated 'PYTEST_ADDOPTS' env var
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- run: |-
8+
# install dependencies
9+
pip3 install coverage pytest-cov https://github.com/neuralmagic/pytest-nm-releng/archive/v0.4.0.tar.gz
10+
11+
# generate and source flags
12+
FLAGS_FILE="coverage_flags.sh"
13+
nmre-generate-coverage-flags --package "llmcompressor" --output-file "$FLAGS_FILE"
14+
source "$FLAGS_FILE"
15+
rm "$FLAGS_FILE"
16+
17+
# export defined/updated 'PYTEST_ADDOPTS' env var
18+
echo "PYTEST_ADDOPTS=$PYTEST_ADDOPTS" | tee -a "$GITHUB_ENV"
19+
shell: bash

.github/workflows/test-check-transformers.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: Test Checks (Transformers)
22
on:
33
pull_request:
4-
branches: main
4+
branches: [ main ]
55
types: [ labeled, synchronize ]
66
push:
7-
branches: main
7+
branches: [ main ]
8+
workflow_dispatch:
9+
inputs:
10+
code_coverage:
11+
description: if enabled, code coverage metrics will be collected during the test run
12+
type: boolean
13+
default: false
814

915
env:
1016
CADENCE: "commit"
@@ -72,6 +78,9 @@ jobs:
7278
BUILD_TYPE=nightly pip3 install .
7379
- name: "Clean compressed-tensors directory"
7480
run: rm -r compressed-tensors/
81+
- name: "⚙️ Prepare code coverage"
82+
if: inputs.code_coverage
83+
uses: ./.github/actions/prepare-code-coverage
7584
- name: "🔬 Running transformers tests"
7685
if: (success() || failure()) && steps.install.outcome == 'success'
7786
run: |
@@ -104,3 +113,18 @@ jobs:
104113
if: (success() || failure()) && steps.install.outcome == 'success'
105114
run: |
106115
pytest -v tests/llmcompressor/transformers/kv_cache
116+
- name: "Upload coverage report"
117+
if: (success() || failure()) && inputs.code_coverage
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: transformers-tests-coverage-results
121+
path: |
122+
.coverage
123+
coverage-html
124+
coverage.json
125+
include-hidden-files: true
126+
retention-days: 5
127+
- name: "Report coverage"
128+
if: (success() || failure()) && inputs.code_coverage
129+
run: |
130+
coverage report --data-file=".coverage" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"

.github/workflows/test-check.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ on:
44
branches:
55
- main
66
push:
7+
workflow_dispatch:
8+
inputs:
9+
code_coverage:
10+
description: if enabled, code coverage metrics will be collected during the test run
11+
type: boolean
12+
default: false
713

814
env:
915
CADENCE: "commit"
@@ -12,6 +18,8 @@ jobs:
1218

1319
base-tests:
1420
runs-on: ubuntu-22.04
21+
env:
22+
COVERAGE_FILE: ".coverage.base"
1523
steps:
1624
- uses: actions/setup-python@v5
1725
with:
@@ -36,11 +44,31 @@ jobs:
3644
BUILD_TYPE=nightly pip3 install .
3745
- name: "Clean compressed-tensors directory"
3846
run: rm -r compressed-tensors/
47+
- name: "⚙️ Prepare code coverage"
48+
if: inputs.code_coverage
49+
uses: ./.github/actions/prepare-code-coverage
3950
- name: "🔬 Running base tests"
4051
run: make test
52+
- name: "Upload coverage report"
53+
if: (success() || failure()) && inputs.code_coverage
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: base-tests-coverage-results
57+
path: |
58+
.coverage*
59+
coverage-html
60+
coverage.json
61+
include-hidden-files: true
62+
retention-days: 5
63+
- name: "Report coverage"
64+
if: (success() || failure()) && inputs.code_coverage
65+
run: |
66+
coverage report --data-file="$COVERAGE_FILE" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"
4167
4268
pytorch-tests:
4369
runs-on: ubuntu-22.04
70+
env:
71+
COVERAGE_FILE: ".coverage.pytorch"
4472
steps:
4573
- uses: actions/setup-python@v5
4674
with:
@@ -65,12 +93,32 @@ jobs:
6593
BUILD_TYPE=nightly pip3 install .
6694
- name: "Clean compressed-tensors directory"
6795
run: rm -r compressed-tensors/
96+
- name: "⚙️ Prepare code coverage"
97+
if: inputs.code_coverage
98+
uses: ./.github/actions/prepare-code-coverage
6899
- name: "🔬 Running pytorch tests"
69100
run: |
70101
pytest -v tests/llmcompressor/pytorch
102+
- name: "Upload coverage report"
103+
if: (success() || failure()) && inputs.code_coverage
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: pytorch-tests-coverage-results
107+
path: |
108+
.coverage*
109+
coverage-html
110+
coverage.json
111+
include-hidden-files: true
112+
retention-days: 5
113+
- name: "Report coverage"
114+
if: (success() || failure()) && inputs.code_coverage
115+
run: |
116+
coverage report --data-file="$COVERAGE_FILE" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"
71117
72118
compat-pytorch-1_9-pytorch-tests:
73119
runs-on: ubuntu-22.04
120+
env:
121+
COVERAGE_FILE: ".coverage.compat-pytorch-1.9"
74122
steps:
75123
- uses: actions/setup-python@v5
76124
with:
@@ -95,6 +143,71 @@ jobs:
95143
BUILD_TYPE=nightly pip3 install .
96144
- name: "Clean compressed-tensors directory"
97145
run: rm -r compressed-tensors/
146+
- name: "⚙️ Prepare code coverage"
147+
if: inputs.code_coverage
148+
uses: ./.github/actions/prepare-code-coverage
98149
- name: "🔬 Running pytorch tests"
99150
run: |
100151
pytest -v tests/llmcompressor/pytorch
152+
- name: "Upload coverage report"
153+
if: (success() || failure()) && inputs.code_coverage
154+
uses: actions/upload-artifact@v4
155+
with:
156+
name: compat-pytorch-tests-coverage-results
157+
path: |
158+
.coverage*
159+
coverage-html
160+
coverage.json
161+
include-hidden-files: true
162+
retention-days: 5
163+
- name: "Report coverage"
164+
if: (success() || failure()) && inputs.code_coverage
165+
run: |
166+
coverage report --data-file="$COVERAGE_FILE" --skip-empty --format="markdown" > "$GITHUB_STEP_SUMMARY"
167+
168+
combine-coverage:
169+
runs-on: ubuntu-22.04
170+
needs: [base-tests, pytorch-tests, compat-pytorch-1_9-pytorch-tests]
171+
if: (success() || failure()) && inputs.code_coverage
172+
steps:
173+
- name: "Checkout llm-compressor"
174+
uses: actions/checkout@v4
175+
176+
- name: "Download coverage artifacts"
177+
uses: actions/download-artifact@v4
178+
with:
179+
merge-multiple: true
180+
181+
- uses: actions/setup-python@v5
182+
with:
183+
python-version: '3.12'
184+
185+
- name: "Install dependencies"
186+
run: |
187+
pip3 install -U pip setuptools
188+
pip3 install coverage setuptools-scm
189+
make build # need to build to generate the version.py file
190+
191+
- name: "Combine and report coverage"
192+
run: |
193+
cat << EOF > .coveragerc
194+
[paths]
195+
source =
196+
src/
197+
*/site-packages/
198+
EOF
199+
coverage combine
200+
coverage report --skip-empty --format="markdown" >> "$GITHUB_STEP_SUMMARY"
201+
coverage html --directory coverage-html
202+
coverage json -o coverage.json
203+
204+
- name: "Upload coverage report"
205+
uses: actions/upload-artifact@v4
206+
with:
207+
name: combined-coverage-results
208+
path: |
209+
.coverage
210+
coverage-html
211+
coverage.json
212+
include-hidden-files: true
213+
retention-days: 5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ wheels/
5353
.installed.cfg
5454
*.egg
5555
MANIFEST
56+
.cache/*
5657

5758
# PyInstaller
5859
# Usually these files are written by a python script from a template

.readthedocs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the OS, Python version, and other tools you might need
8+
build:
9+
os: ubuntu-24.04
10+
tools:
11+
python: "3.12"
12+
13+
# Build documentation with Mkdocs
14+
mkdocs:
15+
configuration: mkdocs.yml
16+
17+
python:
18+
install:
19+
- method: pip
20+
path: .
21+
extra_requirements:
22+
- dev

CODE_OF_CONDUCT.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# LLM Compressor Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
- Demonstrating empathy and kindness toward other people
14+
- Being respectful of differing opinions, viewpoints, and experiences
15+
- Giving and gracefully accepting constructive feedback
16+
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
- Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
- The use of sexualized language or imagery, and sexual attention or advances of any kind
22+
- Trolling, insulting or derogatory comments, and personal or political attacks
23+
- Public or private harassment
24+
- Publishing others’ private information, such as a physical or email address, without their explicit permission
25+
- Other conduct which could reasonably be considered inappropriate in a professional setting
26+
27+
## Enforcement Responsibilities
28+
29+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32+
33+
## Scope
34+
35+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36+
37+
## Enforcement
38+
39+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement through GitHub, Slack, or Email. All complaints will be reviewed and investigated promptly and fairly.
40+
41+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42+
43+
## Enforcement Guidelines
44+
45+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46+
47+
### 1. Correction
48+
49+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50+
51+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52+
53+
### 2. Warning
54+
55+
**Community Impact**: A violation through a single incident or series of actions.
56+
57+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58+
59+
### 3. Temporary Ban
60+
61+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62+
63+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64+
65+
### 4. Permanent Ban
66+
67+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68+
69+
**Consequence**: A permanent ban from any sort of public interaction within the community.
70+
71+
## Attribution
72+
73+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
74+
75+
Community Impact Guidelines were inspired by [Mozilla’s code of conduct enforcement ladder](https://github.com/mozilla/diversity).
76+
77+
For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Big updates have landed in LLM Compressor! To get a more in-depth look, check ou
1818

1919
Some of the exciting new features include:
2020

21-
* **Large Model Support with Sequential Onloading** As of llm-compressor>=0.6.0, you can now quantize very large language models on a single GPU. Models are broken into disjoint layers which are then onloaded to the GPU one layer at a time. For more information on sequential onloading, see [Big Modeling with Sequential Onloading](examples/big_models_with_sequential_onloading/README.md) as well as the [DeepSeek-R1 Example](examples/quantizing_moe/deepseek_r1_example.py).
21+
* **Llama4 Quantization Support**: Quantize a Llama4 model to [W4A16](examples/multimodal_vision/llama4_example.py) or [NVFP4](examples/quantization_w4a4_fp4/llama4_example.py). The checkpoint produced can seamlessly run in vLLM.
22+
* **Large Model Support with Sequential Onloading**: As of llm-compressor>=0.6.0, you can now quantize very large language models on a single GPU. Models are broken into disjoint layers which are then onloaded to the GPU one layer at a time. For more information on sequential onloading, see [Big Modeling with Sequential Onloading](examples/big_models_with_sequential_onloading/README.md) as well as the [DeepSeek-R1 Example](examples/quantizing_moe/deepseek_r1_example.py).
2223
* **Preliminary FP4 Quantization Support:** Quantize weights and activations to FP4 and seamlessly run the compressed model in vLLM. Model weights and activations are quantized following the NVFP4 [configuration](https://github.com/neuralmagic/compressed-tensors/blob/f5dbfc336b9c9c361b9fe7ae085d5cb0673e56eb/src/compressed_tensors/quantization/quant_scheme.py#L104). See examples of [weight-only quantization](examples/quantization_w4a16_fp4/llama3_example.py) and [fp4 activation support](examples/quantization_w4a4_fp4/llama3_example.py). Support is currently preliminary and additional support will be added for MoEs.
2324
* **Updated AWQ Support:** Improved support for MoEs with better handling of larger models
2425
* **Axolotl Sparse Finetuning Integration:** Seamlessly finetune sparse LLMs with our Axolotl integration. Learn how to create [fast sparse open-source models with Axolotl and LLM Compressor](https://developers.redhat.com/articles/2025/06/17/axolotl-meets-llm-compressor-fast-sparse-open). See also the [Axolotl integration docs](https://docs.axolotl.ai/docs/custom_integrations.html#llmcompressor).
25-
* **Day 0 Llama 4 Support:** Meta utilized LLM Compressor to create the [FP8-quantized Llama-4-Maverick-17B-128E](https://huggingface.co/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8), optimized for vLLM inference using [compressed-tensors](https://github.com/neuralmagic/compressed-tensors) format.
2626

2727
### Supported Formats
2828
* Activation Quantization: W8A8 (int8 and fp8)
21 KB
Loading

docs/assets/llmcompressor-icon.png

5.61 KB
Loading
676 KB
Loading

0 commit comments

Comments
 (0)