Skip to content

Commit c1b8ce8

Browse files
committed
Merge branch 'lab/docs-v1-1-0' into export/v1-1-0
- Add overview figure, ArXiv citation, and quick-start usage to README - Fix pre-process and DBF docs to match v1.1.0 API signatures - Add LPCD documentation See merge request onecomp/onecomp-lab!57
2 parents dc11173 + 4152fe1 commit c1b8ce8

5 files changed

Lines changed: 160 additions & 24 deletions

File tree

README.md

Lines changed: 26 additions & 1 deletion
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).

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/index.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,45 @@
22

33
**Open-source Python library for post-training quantization of Large Language Models**
44

5+
<p align="center">
6+
<img src="../figs/onecomp.gif" alt="OneComp" />
7+
</p>
8+
59
---
610

711
Fujitsu One Compression (OneComp) is an open-source Python library for post-training quantization of Large Language Models (LLMs).
812
It implements state-of-the-art quantization algorithms including GPTQ, DBF, RTN, and the
913
research methods **Quantization Error Propagation (QEP)** and
1014
**Layer-Projected Coordinate Descent (LPCD)**.
1115

16+
## Just one line.
17+
18+
```bash
19+
onecomp <generative AI>
20+
```
21+
22+
**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.
23+
24+
=== "CLI"
25+
26+
```bash
27+
onecomp meta-llama/Llama-2-7b-hf
28+
```
29+
30+
=== "Python"
31+
32+
```python
33+
from onecomp import Runner
34+
35+
Runner.auto_run(model_id="meta-llama/Llama-2-7b-hf")
36+
```
37+
38+
For full control over each step, see the [step-by-step workflow](user-guide/basic-usage.md#detailed-workflow).
39+
1240
## Key Features
1341

1442
- **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.
15-
- **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.
43+
- **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.
1644
- **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. See the [setup guide](user-guide/vllm-inference.md#3-chat-with-open-webui-optional).
1745
- **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.
1846
- **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).
@@ -91,11 +119,14 @@ If you use OneComp in your research, please cite our paper:
91119
OneComp technical report (coming soon on ArXiv):
92120

93121
```bibtex
94-
@misc{onecomp2026,
95-
title={TBD},
96-
author={TBD},
97-
year={2026},
98-
note={arXiv preprint coming soon}
122+
@misc{ichikawa2026onecomponelinerevolutiongenerative,
123+
title={OneComp: One-Line Revolution for Generative AI Model Compression},
124+
author={Yuma Ichikawa and Keiji Kimura and Akihiro Yoshida and Yudai Fujimoto and Hiroki Tokura and Yamato Arai and Yoshiyuki Ishii and Yusei Kawakami and Genki Shikada and Achille Jacquemond and Yoshihiko Fujisawa and Katsuki Fujisawa and Takumi Honda and Akira Sakai},
125+
year={2026},
126+
eprint={2603.28845},
127+
archivePrefix={arXiv},
128+
primaryClass={cs.LG},
129+
url={https://arxiv.org/abs/2603.28845},
99130
}
100131
```
101132

docs/user-guide/pre-process.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ runner = Runner(model_config=rotated_config, quantizer=gptq)
3939
runner.run()
4040
```
4141

42+
### Custom calibration data
43+
44+
Pass a `CalibrationConfig` to control the calibration dataset, sequence length,
45+
or sample count used during rotation training. See
46+
[Configuration › CalibrationConfig](configuration.md#calibrationconfig) for the
47+
full parameter list.
48+
49+
```python
50+
from onecomp import CalibrationConfig, prepare_rotated_model
51+
52+
rotated_config = prepare_rotated_model(
53+
model_config=model_config,
54+
save_directory="./rotated_model",
55+
wbits=4,
56+
groupsize=128,
57+
calibration_config=CalibrationConfig(
58+
max_length=2048,
59+
num_calibration_samples=256,
60+
),
61+
)
62+
```
63+
4264
## Supported Architectures
4365

4466
| Architecture | Status |
@@ -62,14 +84,13 @@ runner.run()
6284
| `norm` | Lp norm exponent for MSE search | `2.4` |
6385
| `grid` | Number of candidate shrink levels for MSE search | `100` |
6486
| `fp32_had` | Use FP32 for online Hadamard transform | `False` |
65-
| `num_calibration_samples` | Number of calibration samples | `512` |
66-
| `calibration_strategy` | Calibration strategy: `"concat_chunk"`, `"concat_chunk_align"`, `"drop_head"`, `"drop_rand"` | `"drop_rand"` |
67-
| `seed` | Seed for rotation init and calibration data | `0` |
87+
| `calibration_config` | Calibration data configuration. See [`CalibrationConfig`](configuration.md#calibrationconfig). When `None`, a default `CalibrationConfig()` is used. | `None` |
88+
| `seed` | Seed for rotation matrix initialisation. The calibration-data seed is controlled by `calibration_config.seed`. | `0` |
6889

6990
!!! note "Input validation"
7091
`prepare_rotated_model` validates all parameters on entry. Invalid values for
71-
`rotation_mode`, `scaling_mode`, `calibration_strategy`, or out-of-range numeric
72-
parameters (e.g. `wbits < 1`, `grid < 1`) raise `ValueError`.
92+
`rotation_mode`, `scaling_mode`, `calibration_config.strategy`, or out-of-range
93+
numeric parameters (e.g. `wbits < 1`, `grid < 1`) raise `ValueError`.
7394

7495
!!! warning "Parameter matching"
7596
The `wbits`, `groupsize`, and `sym` parameters **must match** the quantizer

figs/onecomp.gif

3.77 MB
Loading

0 commit comments

Comments
 (0)