Skip to content

Commit fb04aaf

Browse files
committed
Initial implementation for the docs site and setup for LLM Compressor
1 parent 9a11f52 commit fb04aaf

21 files changed

+725
-2
lines changed

.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

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.
21 KB
Loading

docs/assets/llmcompressor-icon.png

5.61 KB
Loading
676 KB
Loading

docs/developer/index.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
weight: -3
3+
---
4+
5+
# Developer
6+
7+
Welcome to the Developer section of LLM Compressor! This area provides essential resources for developers who want to contribute to or extend LLM Compressor. Whether you're interested in fixing bugs, adding new features, improving documentation, or understanding the project's governance, you'll find comprehensive guides to help you get started.
8+
9+
LLM Compressor is an open-source project that values community contributions. We maintain high standards for code quality, documentation, and community interactions to ensure that LLM Compressor remains a robust, reliable, and user-friendly tool for compressing large language models.
10+
11+
## Developer Resources
12+
13+
<div class="grid cards" markdown>
14+
15+
- :material-handshake:{ .lg .middle } Code of Conduct
16+
17+
---
18+
19+
Our community guidelines ensure that participation in the LLM Compressor project is a positive, inclusive, and respectful experience for everyone.
20+
21+
[:octicons-arrow-right-24: Code of Conduct](code-of-conduct.md)
22+
23+
- :material-source-pull:{ .lg .middle } Contributing Guide
24+
25+
---
26+
27+
Learn how to effectively contribute to LLM Compressor, including reporting bugs, suggesting features, improving documentation, and submitting code.
28+
29+
[:octicons-arrow-right-24: Contributing Guide](contributing.md)
30+
31+
- :material-tools:{ .lg .middle } Development Guide
32+
33+
---
34+
35+
Detailed instructions for setting up your development environment, implementing changes, and adhering to the project's coding standards and best practices.
36+
37+
[:octicons-arrow-right-24: Development Guide](developing.md)
38+
39+
</div>

docs/examples/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
weight: -4
3+
---
4+
5+
# Examples
6+
7+
Welcome to the LLM Compressor examples section! Here, you'll find practical demonstrations showing how to use LLM Compressor to optimize large language models for faster and more efficient deployment with vLLM. These examples will help you understand the various compression techniques and functionalities available in LLM Compressor, making it easier to apply them to your own models.
8+
9+
To explore the examples, you can either navigate through the list provided in the sidebar or click next to see the next example in the series. Each example is designed to be self-contained, with clear instructions and code snippets that you can run directly.

docs/getting-started/compress.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
weight: -8
3+
---
4+
5+
# Compress Your Model
6+
7+
LLM Compressor provides a straightforward way to compress your models using various optimization techniques. This guide will walk you through the process of compressing a model using different quantization methods.
8+
9+
## Prerequisites
10+
11+
Before you begin, ensure you have the following prerequisites:
12+
- **Operating System:** Linux (recommended for GPU support)
13+
- **Python Version:** 3.9 or newer
14+
- **Available GPU:** For optimal performance, it's recommended to use a GPU. LLM Compressor supports the latest PyTorch and CUDA versions for compatability with NVIDIA GPUs.
15+
16+
## Select a Model and Dataset
17+
18+
Before you start compressing, select the model you'd like to compress and a calibration dataset that is representative of your use case. LLM Compressor supports a variety of models and integrates natively with Hugging Face Transformers and Model Hub, so a great starting point is to use a model from the Hugging Face Model Hub. LLM Compressor also supports many datasets from the Hugging Face Datasets library, making it easy to find a suitable dataset for calibration.
19+
20+
For this guide, we'll use the `TinyLlama` model and the `open_platypus` dataset for calibration. You can replace these with your own model and dataset as needed.
21+
22+
## Select a Quantization Method and Scheme
23+
24+
LLM Compressor supports several quantization methods and schemes, each with its own strengths and weaknesses. The choice of method and scheme will depend on your specific use case, hardware capabilities, and desired trade-offs between model size, speed, and accuracy.
25+
26+
Some common quantization schemes include:
27+
28+
| Scheme | Description | Hardware Compatibility |
29+
|--------|-------------|------------------------|
30+
| **FP W8A8** | 8-bit floating point (FP8) quantization for weights and activations, providing ~2X smaller weights with 8-bit arithmetic operations. Good for general performance and compression, especially for server and batch inference. | Latest NVIDIA GPUs (Ada Lovelace, Hopper, and later) and latest AMD GPUs |
31+
| **INT W8A8** | 8-bit integer (INT8) quantization for weights and activations, providing ~2X smaller weights with 8-bit arithmetic operations. Good for general performance and compression, especially for server and batch inference. | All NVIDIA GPUs, AMD GPUs, TPUs, CPUs, and other accelerators |
32+
| **W4A16** | 4-bit integer (INT4) weights with 16-bit floating point (FP16) activations, providing ~3.7X smaller weights but requiring 16-bit arithmetic operations. Maximum compression for latency-sensitive applications with limited memory. | All NVIDIA GPUs, AMD GPUs, TPUs, CPUs, and other accelerators |
33+
34+
Some common quantization methods include:
35+
36+
| Method | Description | Accuracy Recovery vs. Time |
37+
|--------|-------------|----------------------------|
38+
| **GPTQ** | Utilizes second-order layer-wise optimizations to prioritize important weights/activations and enables updates to remaining weights | High accuracy recovery but more expensive/slower to run |
39+
| **AWQ** | Uses channelwise scaling to better preserve important outliers in weights and activations | Moderate accuracy recovery with faster runtime than GPTQ |
40+
| **SmoothQuant** | Smooths outliers in activations by folding them into weights, ensuring better accuracy for weight and activation quantized models | Good accuracy recovery with minimal calibration time; composable with other methods |
41+
42+
For this guide, we'll use `GPTQ` composed with `SmoothQuant` to create an `INT W8A8` quantized model. This combination provides a good balance for performance, accuracy, and compatability across a wide range of hardware.
43+
44+
## Apply the Recipe
45+
46+
LLM Compressor provides the `oneshot` API for simple and straightforward model compression. This API allows you to apply a pre-defined recipe to your model and dataset, making it easy to get started with compression. To apply what we discussed above, we'll import the necessary modifiers and create a recipe to apply to our model and dataset:
47+
48+
```python
49+
from llmcompressor.modifiers.smoothquant import SmoothQuantModifier
50+
from llmcompressor.modifiers.quantization import GPTQModifier
51+
from llmcompressor import oneshot
52+
53+
recipe = [
54+
SmoothQuantModifier(smoothing_strength=0.8),
55+
GPTQModifier(scheme="W8A8", targets="Linear", ignore=["lm_head"]),
56+
]
57+
oneshot(
58+
model="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
59+
dataset="open_platypus",
60+
recipe=recipe,
61+
output_dir="TinyLlama-1.1B-Chat-v1.0-INT8",
62+
max_seq_length=2048,
63+
num_calibration_samples=512,
64+
)
65+
```
66+
67+
Once the above code is run, it will save the compressed model to the specified output directory: `TinyLlama-1.1B-Chat-v1.0-INT8`. You can then load this model using the Hugging Face Transformers library or vLLM for inference and testing.

docs/getting-started/deploy.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
weight: -6
3+
---
4+
5+
# Deploy with vLLM
6+
7+
Once you've compressed your model using LLM Compressor, you can deploy it for efficient inference using vLLM. This guide walks you through the deployment process, using the output from the [Compress Your Model](compress.md) guide. If you haven't completed that step, change the model arguments in the code snippets below to point to your desired model.
8+
9+
vLLM is a high-performance inference engine designed for large language models, providing support for various quantization formats and optimized for both single and multi-GPU setups. It also offers an OpenAI-compatible API for easy integration with existing applications.
10+
11+
## Prerequisites
12+
13+
Before deploying your model, ensure you have the following prerequisites:
14+
- **Operating System:** Linux (recommended for GPU support)
15+
- **Python Version:** 3.9 or newer
16+
- **Available GPU:** For optimal performance, it's recommended to use a GPU. vLLM supports a range of accelerators, including NVIDIA GPUs, AMD GPUs, TPUs, and other accelerators.
17+
- **vLLM Installed:** Ensure you have vLLM installed. You can install it using pip:
18+
```bash
19+
pip install vllm
20+
```
21+
22+
## Python API
23+
24+
vLLM provides a Python API for easy integration with your applications, enabling you to load and use your compressed model directly in your Python code. To test the compressed model, use the following code:
25+
26+
```python
27+
from vllm import LLM
28+
29+
model = LLM("./TinyLlama-1.1B-Chat-v1.0-INT8")
30+
output = model.generate("What is machine learning?", max_tokens=256)
31+
print(output)
32+
```
33+
34+
After running the above code, you should see the generated output from your compressed model. This confirms that the model is loaded and ready for inference.
35+
36+
## HTTP Server
37+
38+
vLLM also provides an HTTP server for serving your model via a RESTful API that is compatible with OpenAI's API definitions. This allows you to easily integrate your model into existing applications or services.
39+
To start the HTTP server, use the following command:
40+
41+
```bash
42+
vllm serve "./TinyLlama-1.1B-Chat-v1.0-INT8"
43+
```
44+
45+
By default, the server will run on `localhost:8000`. You can change the host and port by using the `--host` and `--port` flags. Now that the server is running, you can send requests to it using any HTTP client. For example, you can use `curl` to send a request:
46+
47+
```bash
48+
curl -X POST http://localhost:8000/v1/chat/completions \
49+
-H "Content-Type: application/json" \
50+
-d '{
51+
"model": "TinyLlama-1.1B-Chat-v1.0-INT8",
52+
"messages": [{"role": "user", "content": "What is machine learning?"}],
53+
"max_tokens": 256
54+
}'
55+
```
56+
57+
This will return a JSON response with the generated text from your model. You can also use any HTTP client library in your programming language of choice to send requests to the server.

docs/getting-started/index.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
weight: -10
3+
---
4+
5+
# Getting Started
6+
7+
Welcome to LLM Compressor! This section will guide you through the process of installing the library, compressing your first model, and deploying it with vLLM for faster, more efficient inference.
8+
9+
LLM Compressor makes it simple to optimize large language models for deployment, offering various quantization techniques that help you find the perfect balance between model quality, performance, and resource efficiency.
10+
11+
## Quick Start Guides
12+
13+
Follow the guides below to get started with LLM Compressor and optimize your models for production deployment.
14+
15+
<div class="grid cards" markdown>
16+
17+
- :material-package-variant:{ .lg .middle } Installation
18+
19+
---
20+
21+
Learn how to install LLM Compressor using pip or from source.
22+
23+
[:octicons-arrow-right-24: Installation Guide](install.md)
24+
25+
- :material-memory:{ .lg .middle } Compress Your Model
26+
27+
---
28+
29+
Learn how to apply quantization to your models using different algorithms and formats.
30+
31+
[:octicons-arrow-right-24: Compression Guide](compress.md)
32+
33+
- :material-rocket-launch:{ .lg .middle } Deploy with vLLM
34+
35+
---
36+
37+
Deploy your compressed model for efficient inference using vLLM.
38+
39+
[:octicons-arrow-right-24: Deployment Guide](deploy.md)
40+
41+
</div>

0 commit comments

Comments
 (0)