Skip to content

Commit 7540b63

Browse files
committed
merge export/v1-1-0 and resolve conflict
2 parents 508a557 + c1b8ce8 commit 7540b63

15 files changed

Lines changed: 2906 additions & 1939 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@
129129

130130
### Bug Fix
131131

132+
- Fixed `model_config.py`: `load_model()` VLM fallback did not trigger for models raising `"Unrecognized configuration class"` (e.g. Cohere2VisionForConditionalGeneration). Added the error pattern to `_vlm_hints`
133+
- Fixed `gptq/_gptq.py`: Cholesky decomposition in `run_gptq` could fail with `LinAlgError` on ill-conditioned Hessians (observed on large VLMs at deeper layers). Extracted `_compute_inverse_hessian()` with progressive damping fallback (up to 5 retries, 10x damping increase per retry). No impact on normal operation
132134
- Fixed `TypeError` in `QuantLinear.forward` when `S_qk` scaling was applied to MLP layers (`onecomp/pre_process/quant_models.py`)
133135
- Fixed wrong module grouping in `make_grouped_module` where GC-driven `id()` reuse caused attention projections (q/k/v) and MLP projections (gate/up) to be merged into the same group. (`qep/_quantize_with_qep_arch.py`)
134136
- Fixed silent weight corruption in `GPTQLinear` when `qzero=0` was stored through the GPTQ v1 zero-point path (`onecomp/quantizer/gptq/gptq_layer.py`)
@@ -138,6 +140,14 @@
138140
- Added regression tests for per-slot pack corruption, packed/unpacked forward paths, the `gptq_v2` branch, and the `from_saved_state` path for GPTQ v1 tensors
139141
- **NOTE**: If you have GPTQ models quantized with previous versions, please re-quantize them with this release, as they may contain corrupted internal data.
140142

143+
### Packaging
144+
145+
- Bumped minimum `transformers` requirement from `>=5.3.0` to `>=5.5.0` (`pyproject.toml`)
146+
- Added `cu130` optional-dependency extra and the `pytorch-cu130` wheel index (`https://download.pytorch.org/whl/cu130`) for CUDA 13 hosts (e.g. NVIDIA B200) (`pyproject.toml`)
147+
- Pinned the `vllm` extra to `vllm>=0.10` to prevent uv from falling back to legacy versions whose source build requires `CUDA_HOME` (`pyproject.toml`)
148+
- Added uv `conflicts` declarations between the `vllm` extra and the `cpu` / `cu118` / `cu121` / `cu124` / `cu126` / `cu128` extras: vLLM `>=0.20` requires `torch>=2.10`, which is only published for `cu130`. This forces `vllm` to be installed only with `--extra cu130` and prevents silent fallback to a `vllm` version incompatible with `transformers>=5` at runtime (`pyproject.toml`)
149+
- Restricted `tool.uv.environments` to `sys_platform == 'linux'` and `python_full_version >= '3.12', < '3.14'` to skip lock splits for unused Windows and out-of-range Python versions (`pyproject.toml`)
150+
141151
### Examples
142152

143153
- Added `example/example_custom_calibration.py`: Demonstrates `CalibrationConfig` with a custom calibration dataset (Python code snippets in `example/data/python_calibration.txt`). Quantizes TinyLlama with GPTQ 3-bit using both default C4 and custom Python-code calibration, then compares inference outputs across multiple prompts to show how calibration data choice affects quantization quality.
@@ -167,6 +177,7 @@
167177
- Added `docs/api/quantizers/onebit.md` (OneBit API reference)
168178
- Updated `mkdocs.yml` nav: added AutoBit/JointQ algorithm pages, OneBit API page; renamed Post-Process nav title to include Block-wise PTQ
169179
- Added example script links to `docs/user-guide/pre-process.md`
180+
- Added a Troubleshooting section to `docs/user-guide/vllm-inference.md` describing how to bypass the unconditional DeepGEMM (FP8) kernel warmup for non-FP8 quantization (GPTQ / DBF / Mixed-GPTQ) by setting `VLLM_USE_DEEP_GEMM=0` and `VLLM_DEEP_GEMM_WARMUP=skip`
170181

171182
### Tests
172183

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,39 @@
22

33
Fujitsu One Compression (OneComp) is a Python package for LLM compression.
44

5+
<p align="center">
6+
<img src="figs/onecomp.gif" alt="OneComp" />
7+
</p>
8+
9+
## ⚡ Just one line.
10+
11+
```bash
12+
onecomp <generative AI>
13+
```
14+
15+
**That's all you need.** OneComp detects your GPU VRAM, picks the best bit-width per layer, quantizes with error propagation, evaluates, and saves — fully automatic.
16+
17+
```bash
18+
# Example
19+
onecomp meta-llama/Llama-2-7b-hf
20+
```
21+
22+
Or from Python:
23+
24+
```python
25+
from onecomp import Runner
26+
27+
Runner.auto_run(model_id="meta-llama/Llama-2-7b-hf")
28+
```
29+
530
## 📖 Documentation
631

732
Full documentation is available at **[https://FujitsuResearch.github.io/OneCompression/](https://FujitsuResearch.github.io/OneCompression/)**.
833

934
## 📦 Features
1035

1136
- **Quantization Error Propagation (QEP)**: A post-training quantization method that corrects quantization errors by propagating them to subsequent layers, improving the accuracy of quantized LLMs. See [Arai & Ichikawa, NeurIPS 2025](https://openreview.net/forum?id=a3l3K9khbL) for details. The original reference implementation is available at [FujitsuResearch/qep](https://github.com/FujitsuResearch/qep).
12-
- **Layer-Projected Coordinate Descent (LPCD)**: A unified PTQ framework that extends layer-wise quantization to arbitrary submodules by optimising relaxed objectives and projecting the solutions with layer-wise quantizers. See [Ichikawa et al., 2025](https://arxiv.org/abs/2512.01546) for details.
37+
- **Layer-Projected Coordinate Descent (LPCD)**: A unified Post Training Quantization (PTQ) framework that extends layer-wise quantization to arbitrary submodules by optimising relaxed objectives and projecting the solutions with layer-wise quantizers. See [Ichikawa et al., 2025](https://arxiv.org/abs/2512.01546) for details.
1338
- **vLLM Plugin Integration**: Serve OneComp-quantized models with [vLLM](https://docs.vllm.ai/) via built-in plugins for DBF and Mixed-GPTQ quantization methods. Pair with [Open WebUI](https://github.com/open-webui/open-webui) for a ChatGPT-like chat experience on your local machine.
1439
- **AutoBit**: Mixed-precision quantization with ILP-based bitwidth assignment. Automatically estimates the target bitwidth from available VRAM and assigns per-layer bitwidths to minimize quantization error under the memory budget.
1540
- **JointQ**: Joint quantization method that optimizes weight assignments and scale parameters simultaneously for improved quantization accuracy. Supports group-wise quantization (e.g., 4-bit, groupsize=128).
@@ -54,6 +79,7 @@ Choose the appropriate CUDA version for your system:
5479
| CUDA 12.4 | `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124` |
5580
| CUDA 12.6 | `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126` |
5681
| CUDA 12.8 | `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128` |
82+
| CUDA 13.0 | `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130` |
5783

5884
Check your CUDA version:
5985
```bash
@@ -99,19 +125,21 @@ uv sync --extra cu128 --extra dev --extra visualize
99125
The `uv sync` command creates a Python virtual environment and installs all dependent libraries.
100126

101127
The `--extra cu128` option installs the CUDA-enabled version of PyTorch (along with `torchvision` from the same CUDA index).
102-
Replace `cu128` with the appropriate variant for your environment: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, or `cu128`.
128+
Replace `cu128` with the appropriate variant for your environment: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, `cu128`, or `cu130`.
103129
PyTorch will be automatically downloaded by `uv`, so you do not need to install it beforehand.
104130

105131
Adding `--extra dev` installs development tools (black, pytest, pylint).
106132
Adding `--extra visualize` installs matplotlib for visualization features.
107133
Adding `--extra hydra` installs `hydra-core` for the example scripts and `model_validation/` runners that use Hydra-based configuration.
108134

109-
To use vLLM for serving quantized models, add `--extra vllm`:
135+
To use vLLM for serving quantized models, add `--extra vllm` together with `--extra cu130`:
110136

111137
```bash
112-
uv sync --extra cu128 --extra dev --extra visualize --extra vllm
138+
uv sync --extra cu130 --extra dev --extra visualize --extra vllm
113139
```
114140

141+
> **Note:** `--extra vllm` is only compatible with `--extra cu130`. Recent vLLM releases require `torch>=2.10`, whose wheels are only published for the `cu130` index. Combining `--extra vllm` with `cpu` / `cu118` / `cu121` / `cu124` / `cu126` / `cu128` is rejected by `uv` at lock time.
142+
115143
> **Note:** `--extra vllm` may take a long time on the first run if a pre-built `xformers` wheel is not available for your Python/CUDA combination (e.g. Python 3.13). Using Python 3.12 typically avoids this.
116144
117145
#### Running commands (uv environment)
@@ -147,7 +175,7 @@ pip install torch --index-url https://download.pytorch.org/whl/cu128
147175
pip install -e ".[dev]"
148176
```
149177

150-
Replace `cu128` with the appropriate variant for your environment: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, or `cu128`.
178+
Replace `cu128` with the appropriate variant for your environment: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, `cu128`, or `cu130`.
151179

152180

153181
### Building Documentation Locally
@@ -185,8 +213,8 @@ OneComp-quantized models can be served with [vLLM](https://docs.vllm.ai/) via bu
185213
Combined with [Open WebUI](https://github.com/open-webui/open-webui), you can chat with your quantized model through a ChatGPT-like browser interface — entirely on your local machine.
186214

187215
```bash
188-
# uv users
189-
uv sync --extra cu128 --extra vllm
216+
# uv users (vLLM requires cu130; see Installation for details)
217+
uv sync --extra cu130 --extra vllm
190218

191219
# pip users
192220
pip install vllm

benchmark/llama3-8b-jointq/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ llama3-8b-fixed-lam0.3/
5454
llama3-8b-fixed-lam0.5/
5555
llama3-8b-incremental/
5656
llama3-8b-incremental-actorder-mse/
57+
58+
run_llama3-8b_diagonal_lam*_actorder.sh
59+
llama3-8b-diagonal-lam*-actorder/

benchmark/qwen3-14b-jointq/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ qwen3-14b-fixed-lam0.3/
5555
qwen3-14b-fixed-lam0.5/
5656
qwen3-14b-incremental/
5757
qwen3-14b-incremental-actorder-mse/
58+
59+
run_qwen3-14b_diagonal_lam*_actorder.sh
60+
qwen3-14b-diagonal-lam*-actorder/

benchmark/qwen3-8b-jointq/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ qwen3-8b-fixed-lam0.3/
5555
qwen3-8b-fixed-lam0.5/
5656
qwen3-8b-incremental/
5757
qwen3-8b-incremental-actorder-mse/
58+
59+
run_qwen3-8b_diagonal_lam*_actorder.sh
60+
qwen3-8b-diagonal-lam*-actorder/

docs/algorithms/dbf.md

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,91 @@ with optional weight balancing.
2525

2626
## Parameters
2727

28-
| Parameter | Type | Description | Default |
29-
|----------------|---------|----------------------------------------------|------------|
30-
| `target_bits` | `float` | Target bit-width (e.g., 1.5) ||
31-
| `iters` | `int` | Number of ADMM optimization iterations | `100` |
32-
| `reg` | `float` | Regularization coefficient | `1.0` |
33-
| `use_balancing` | `bool` | Apply weight balancing before factorization | `True` |
34-
| `balance_iters` | `int` | Number of balancing iterations | `20` |
35-
| `balance_alpha` | `float` | Balancing alpha parameter | `0.5` |
28+
| Parameter | Type | Description | Default |
29+
|---------------------|----------------------------|-----------------------------------------------------------------------------------|---------|
30+
| `target_bits` | `float` | Target bit-width (e.g., 1.5) | `1.5` |
31+
| `iters` | `int` | Number of ADMM optimization iterations | `600` |
32+
| `reg` | `float` | Regularization coefficient | `3e-2` |
33+
| `use_balancing` | `bool` | Apply weight balancing before factorization | `True` |
34+
| `balance_iters` | `int` | Number of balancing iterations | `40` |
35+
| `balance_alpha` | `float` | Balancing alpha parameter | `1.0` |
36+
| `balance_mode` | `str` | Balancing mode (`"l1"` or `"l2"`) | `"l1"` |
37+
| `use_adaptive_rho` | `bool` | Adapt the ADMM penalty parameter ρ during optimization | `True` |
38+
| `mlp_target_bits` | `Optional[float]` | Override `target_bits` for layers whose name contains `"mlp"` | `None` |
39+
| `module_target_bits` | `Optional[dict[str,float]]`| Per-layer override of `target_bits`, keyed by exact layer name (highest priority) | `None` |
3640

3741
## Usage
3842

43+
### Quick Start
44+
45+
For a first run, use a small model (TinyLlama) and a lightweight calibration
46+
configuration. This combination fits in a few GB of GPU memory and is the
47+
recommended way to verify the pipeline end-to-end.
48+
3949
```python
40-
from onecomp import ModelConfig, Runner
50+
from onecomp import CalibrationConfig, ModelConfig, Runner
4151
from onecomp.quantizer.dbf import DBF
4252

4353
model_config = ModelConfig(
44-
model_id="meta-llama/Llama-2-7b-hf",
54+
model_id="TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T",
4555
device="cuda:0",
4656
)
57+
calib_config = CalibrationConfig(
58+
max_length=512,
59+
num_calibration_samples=128,
60+
)
61+
dbf = DBF(target_bits=1.5)
62+
runner = Runner(
63+
model_config=model_config,
64+
quantizer=dbf,
65+
calibration_config=calib_config,
66+
)
67+
runner.run()
68+
```
69+
70+
### Recommended Configuration
4771

48-
dbf = DBF(target_bits=1.5, iters=100, use_balancing=True)
72+
For production use, run with longer sequences and more calibration samples to
73+
improve quantization quality. DBF holds fp32 ADMM buffers in addition to the
74+
model weights, so the per-forward GPU memory consumption is higher than GPTQ.
75+
To avoid `CUDA out of memory` with the default calibration settings on larger
76+
models such as Llama-2-7B, set `CalibrationConfig.batch_size` to enable
77+
chunked calibration.
78+
79+
```python
80+
from onecomp import CalibrationConfig, ModelConfig, Runner
81+
from onecomp.quantizer.dbf import DBF
4982

50-
runner = Runner(model_config=model_config, quantizer=dbf)
83+
model_config = ModelConfig(
84+
model_id="meta-llama/Llama-2-7b-hf",
85+
device="cuda:0",
86+
)
87+
calib_config = CalibrationConfig(
88+
max_length=2048,
89+
num_calibration_samples=128, # Increase to 256-512 for higher accuracy
90+
batch_size=32, # Tune to GPU free memory (8-32)
91+
)
92+
dbf = DBF(target_bits=1.5)
93+
runner = Runner(
94+
model_config=model_config,
95+
quantizer=dbf,
96+
calibration_config=calib_config,
97+
)
5198
runner.run()
5299
```
53100

101+
!!! note "Tuning `batch_size` to your GPU"
102+
`CalibrationConfig.batch_size` controls the number of calibration sequences
103+
forwarded through the model at once, and is the main knob for peak GPU
104+
memory. Rough guideline:
105+
106+
- H100 (80 GB): `batch_size=32`
107+
- A100 (40 GB): `batch_size=16`
108+
- When sharing the GPU with other processes: `batch_size=8`
109+
110+
If you still hit `CUDA out of memory`, halve the value until the run
111+
succeeds.
112+
54113
## Save and Load
55114

56115
DBF models can be saved in a format compatible with the OneComp loader:

docs/getting-started/installation.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ Install the appropriate version of PyTorch for your system.
4949
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
5050
```
5151

52+
=== "CUDA 13.0"
53+
54+
```bash
55+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
56+
```
57+
5258
Check your CUDA version:
5359

5460
```bash
@@ -92,17 +98,20 @@ uv sync --extra cu128 --extra dev --extra visualize
9298
```
9399

94100
The `uv sync` command creates a virtual environment and installs all dependencies (including `torchvision` from the same CUDA index as PyTorch).
95-
Replace `cu128` with the appropriate CUDA variant for your system: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, or `cu128`.
101+
Replace `cu128` with the appropriate CUDA variant for your system: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, `cu128`, or `cu130`.
96102

97103
Adding `--extra dev` installs development tools (black, pytest, pylint).
98104
Adding `--extra visualize` installs matplotlib for visualization features.
99105

100-
To use vLLM for serving quantized models, add `--extra vllm`:
106+
To use vLLM for serving quantized models, add `--extra vllm` together with `--extra cu130`:
101107

102108
```bash
103-
uv sync --extra cu128 --extra dev --extra visualize --extra vllm
109+
uv sync --extra cu130 --extra dev --extra visualize --extra vllm
104110
```
105111

112+
!!! note "vLLM requires the `cu130` extra"
113+
Recent vLLM releases depend on `torch>=2.10`, whose wheels are only published for the `cu130` index. The `--extra vllm` declaration in `pyproject.toml` therefore conflicts with `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, and `cu128`; combining any of these with `--extra vllm` is rejected by `uv` at lock time.
114+
106115
!!! warning
107116
Do **not** install vLLM with `uv pip install vllm` after `uv sync`. Packages installed via `uv pip` are not tracked by the lockfile and will be removed or overwritten by subsequent `uv sync` or `uv run` commands. Always use `--extra vllm` instead.
108117

0 commit comments

Comments
 (0)