You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,13 @@
22
22
-`create_inference_layer()` builds `OneBitLinear` via `OneBitLinear.from_quantization_result()`
23
23
- Added `_build_quantization_bits()` static method for per-layer metadata
24
24
25
+
### Apple Silicon / macOS support
26
+
27
+
-**MPS quantization**: GPTQ (and AutoBit with GPTQ-only candidates) on `device="mps"`; cross-platform `empty_cache()` via new `onecomp/utils/device.py` (`runner.py`, `quantizer/gptq/_gptq.py`, `quantizer/_quantizer.py`)
28
+
- **MPS device placement (GPTQ on CPU, QEP correction on MPS)**: With `device="mps"`, `run_gptq` moves the Hessian and weights to **CPU** for the full column-wise GPTQ loop (including inverse-Hessian Cholesky). The main reason is not absent Cholesky kernels on MPS (recent PyTorch supports them); if the GPTQ loop stayed on MPS, `maxq.item()` inside `quantize()` would run once per column—each call waits for pending MPS work to finish and read back a single scalar to the host (per-column host sync), not a full matrix copy per column—and that overhead is often several times slower than CPU on Apple Silicon (~4× in internal benchmarks with PyTorch 2.12). When QEP weight correction runs (`adjust_weight`, typically under `qep=True`), per-layer work stays on **MPS** (e.g. `weight @ delta_hatX`); only the Cholesky solve uses CPU via `_safe_cholesky_and_solve` (one solve per layer). A full CPU fallback for QEP does not materially improve speed. Calibration forwards may still use MPS. Details: README (macOS / MPS).
29
+
-**MPS inference**: load saved quantized models on Mac with `QuantizedModelLoader` + Transformers `generate()` (GemLite/vLLM remain Linux + CUDA)
30
+
-**macOS `uv sync`**: added `darwin` to `tool.uv.environments`, `--extra mps` for MPS-enabled PyTorch from PyPI; `--extra cpu` is Linux-only (pytorch-cpu index); Linux-only markers on CUDA extras (`cu118`–`cu130`)
31
+
25
32
## New Feature : Dashboard
26
33
27
34
- Added `dashboard/`, a browser-based web app for OneCompression on **SLURM-managed HPC GPU nodes without Docker**: pick a Hugging Face model and quantization settings in the UI, run jobs on the GPU, deploy the quantized checkpoint, and validate inference via chat
Copy file name to clipboardExpand all lines: README.md
+47-4Lines changed: 47 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,30 @@ import torch
100
100
print(torch.cuda.is_available())
101
101
```
102
102
103
+
#### ✅ macOS (MPS)
104
+
105
+
On macOS, install PyTorch from PyPI (default wheels include MPS support). You do **not** need the CUDA index URLs above.
106
+
107
+
```bash
108
+
pip install torch torchvision torchaudio
109
+
```
110
+
111
+
Verify MPS:
112
+
```python
113
+
import torch
114
+
print(torch.backends.mps.is_available())
115
+
```
116
+
117
+
Then install OneComp from PyPI (see step 2 below). GPTQ quantization and Hugging Face `generate()` inference on MPS are supported; vLLM serving requires Linux with an NVIDIA GPU. An editable install from a git clone is **not** required for MPS use — see [for developers (pip)](#for-developers-pip) only if you are contributing to OneComp.
118
+
119
+
> **MPS device placement (GPTQ vs QEP)**
120
+
> With `device="mps"`, calibration and model forward passes can run on the GPU. The bottleneck is usually not missing Cholesky ops on MPS (recent PyTorch builds implement them); the implementation splits work as follows:
121
+
>
122
+
> - GPTQ (`run_gptq`): Hessian and weights are moved to CPU for the full column-wise loop (including inverse-Hessian Cholesky). If that loop stayed on MPS, `quantize()` would call `maxq.item()` once per column; each call triggers **per-column host sync** (wait for pending MPS ops, then read one scalar—not a full Hessian/weight copy every column)—often several times slower than CPU on Apple Silicon (e.g. ~4× in internal benchmarks with PyTorch 2.12). Keeping GPTQ on CPU avoids that overhead. With `mse=True`, `find_params` also calls `quantize()` in a grid loop and benefits from the same CPU placement.
123
+
> - QEP weight correction (`adjust_weight`, when QEP correction runs—typically `qep=True` with error propagation enabled): Per-layer work stays on MPS (e.g. `weight @ delta_hatX`, diagonal damping). Only the Cholesky solve uses CPU via `_safe_cholesky_and_solve` (one solve per layer, not per column); moving all of QEP to CPU does not materially improve speed. The subsequent GPTQ step still uses the CPU path above.
124
+
>
125
+
> DBF-based AutoBit fallback and multi-GPU quantization are not supported on MPS.
126
+
103
127
#### 2. Install `onecomp`
104
128
105
129
Once PyTorch is installed, you can install `onecomp`:
@@ -128,27 +152,42 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --extra cu128 --extra dev --extra visualize
132
155
```
133
156
134
157
The `uv sync` command creates a Python virtual environment and installs all dependent libraries.
135
158
159
+
#### Linux (CUDA quantization / vLLM)
160
+
161
+
```bash
162
+
uv sync --extra cu128 --extra dev --extra visualize
163
+
```
164
+
136
165
The `--extra cu128` option installs the CUDA-enabled version of PyTorch (along with `torchvision` from the same CUDA index).
137
166
Replace `cu128` with the appropriate variant for your environment: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, `cu128`, or `cu130`.
138
167
PyTorch will be automatically downloaded by `uv`, so you do not need to install it beforehand.
139
168
169
+
#### macOS (development / MPS inference)
170
+
171
+
```bash
172
+
uv sync --extra mps --extra dev --extra visualize
173
+
```
174
+
175
+
On macOS, use `--extra mps` only. CUDA extras (`cu118`–`cu130`), `--extra cpu` (Linux-only), and `--extra vllm` are not supported on macOS.
176
+
After `uv sync`, you can run GPTQ quantization and Hugging Face `generate()` inference on MPS; vLLM serving still requires Linux with an NVIDIA GPU.
177
+
See the **MPS device placement (GPTQ vs QEP)** note under [macOS (MPS)](#macos-mps) above for why GPTQ runs on CPU while QEP correction uses MPS.
178
+
140
179
Adding `--extra dev` installs development tools (black, pre-commit, pytest, pylint).
141
180
Adding `--extra visualize` installs matplotlib for visualization features.
142
181
Adding `--extra distributed` installs DeepSpeed for multi-GPU training.
143
182
Adding `--extra hydra` installs `hydra-core` for the example scripts and `model_validation/` runners that use Hydra-based configuration.
144
183
145
-
To use vLLM for serving quantized models, add `--extra vllm` together with `--extra cu130`:
184
+
To use vLLM for serving quantized models on Linux, add `--extra vllm` together with `--extra cu130`:
146
185
147
186
```bash
148
187
uv sync --extra cu130 --extra dev --extra visualize --extra vllm
149
188
```
150
189
151
-
> **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.
190
+
> **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` / `mps` / `cu118` / `cu121` / `cu124` / `cu126` / `cu128` is rejected by `uv` at lock time.
152
191
153
192
> **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.
154
193
@@ -175,6 +214,8 @@ black --check onecomp/
175
214
176
215
### for developers (pip)
177
216
217
+
> **Note:** The editable install below is for developing OneComp from a local clone. **macOS users who only want MPS inference or quantization should use the [for users (pip)](#for-users-pip) flow** (`pip install torch` then `pip install onecomp` from PyPI); `pip install -e` is not needed for MPS.
218
+
178
219
```bash
179
220
git clone <git repository URL>
180
221
cd OneCompression
@@ -224,8 +265,10 @@ uv run pre-commit run --all-files
224
265
225
266
### Building Documentation Locally
226
267
268
+
`--extra docs` alone is sufficient (no PyTorch `mps` / `cu*` extra required):
The `uv sync` command creates a virtual environment and installs all dependencies.
130
+
131
+
### Linux (CUDA quantization / vLLM)
132
+
133
+
```bash
103
134
uv sync --extra cu128 --extra dev --extra visualize
104
135
```
105
136
106
-
The `uv sync` command creates a virtual environment and installs all dependencies (including `torchvision` from the same CUDA index as PyTorch).
107
-
Replace `cu128` with the appropriate CUDA variant for your system: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, `cu128`, or `cu130`.
137
+
The `--extra cu128` option installs the CUDA-enabled version of PyTorch (along with `torchvision` from the same CUDA index).
138
+
Replace `cu128` with the appropriate variant for your environment: `cpu`, `cu118`, `cu121`, `cu124`, `cu126`, `cu128`, or `cu130`.
139
+
PyTorch will be automatically downloaded by `uv`, so you do not need to install it beforehand.
140
+
141
+
### macOS (development / MPS inference)
142
+
143
+
```bash
144
+
uv sync --extra mps --extra dev --extra visualize
145
+
```
146
+
147
+
On macOS, use `--extra mps` only. CUDA extras (`cu118`–`cu130`), `--extra cpu` (Linux-only),
148
+
and `--extra vllm` are not supported on macOS.
149
+
After `uv sync`, you can run GPTQ quantization and Hugging Face `generate()` inference on MPS;
150
+
vLLM serving still requires Linux with an NVIDIA GPU.
151
+
See the [macOS / MPS guide](../user-guide/mps.md) for device placement and usage details.
108
152
109
153
Adding `--extra dev` installs development tools (black, pytest, pylint).
110
154
Adding `--extra visualize` installs matplotlib for visualization features.
111
155
Adding `--extra distributed` installs DeepSpeed for multi-GPU training.
112
156
113
-
To use vLLM for serving quantized models, add `--extra vllm` together with `--extra cu130`:
157
+
To use vLLM for serving quantized models on Linux, add `--extra vllm` together with `--extra cu130`:
114
158
115
159
```bash
116
160
uv sync --extra cu130 --extra dev --extra visualize --extra vllm
117
161
```
118
162
119
163
!!! note "vLLM requires the `cu130` extra"
120
-
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.
164
+
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`, `mps`, `cu118`, `cu121`, `cu124`, `cu126`, and `cu128`; combining any of these with `--extra vllm` is rejected by `uv` at lock time.
121
165
122
166
!!! warning "vLLM 0.22+ is not supported"
123
167
vLLM 0.22.0 removed the legacy Exllama GPTQ kernel that OneComp's GPTQ serving relies on for low bit-widths (2-/3-bit, and Marlin-ineligible 4-/8-bit), so `pyproject.toml` pins `vllm>=0.10,<0.22`. See [vLLM Inference](../user-guide/vllm-inference.md#installation) for details.
|`--wbits WBITS`|`None` (auto)| Target bitwidth. When omitted, estimated from VRAM |
46
-
|`--total-vram-gb GB`|`None` (auto)| VRAM budget in GB for bitwidth estimation. When omitted, detected from GPU |
46
+
|`--total-vram-gb GB`|`None` (auto)| VRAM budget in GB for bitwidth estimation. When omitted, detected from CUDA GPU. **Required on MPS** when `--wbits` is omitted|
47
47
|`--groupsize GROUPSIZE`|`128`| GPTQ group size (`-1` to disable grouping) |
48
-
|`--device DEVICE`|`cuda:0`| Device to place the model on |
48
+
|`--device DEVICE`|`cuda:0`| Device to place the model on (`mps` on macOS)|
49
49
|`--no-qep`|| Disable QEP (enabled by default) |
50
50
|`--no-eval`|| Skip perplexity and accuracy evaluation |
51
51
|`--eval-original`|| Also evaluate the original (unquantized) model |
0 commit comments