Commit 61ea196
Support 3D Weights in GPTQ Algorithm (#3835)
### Changes
The approach here is quite straightfoward, `_quantize_weights` works as
usual for 2D weights. The difference is in calculate hessian where the
hessian is 3D in both 3D and 2D weights case. By default hessian has the
shape (1, hidden_dim, hidden_dim).
Before this was just (hidden_dim, hidden_dim). For 3D, it is
(num_experts/batch, hidden_dim, hidden_dim).
Now, this 3D hessian or "batched" hessian is looped over and the 2D
weight is extracted and passed to the old `_quantize_weights` function
as usual and scale/zp are returned. These scales and zp are then stacked
together in a collector variable. For 2D case, it is flattened. For 3D
the stacked scale, zp are returned.
NOTE: Scale Estimation + GPTQ support is not added for 3D weights yet
### Reason for changes
Support 3D weights for models like MoE in GPTQ
### Related tickets
175789 & 175212
### Tests
Model: Qwen/Qwen3-30B-A3B
NNCF Backend: OpenVINO
Higher is better.
Task: gsm8k
Limit: 100
Max New Tokens: 10000
OpenVINO version: 2026.0.0.dev20251111 (with WA for 176465)
n-shots: 5(default)
Precision Type | Filter | Value
-- | -- | --
INT4 SYM GS128 (with GPTQ) Calibrated on GSM8k with 128 samples |
flexible-extract | 0.79
| strict-match | 0.64
INT4 SYM GS128 (with GPTQ after bug fix commit
dc355fe)
Calibrated on GSM8k with 128 samples | flexible-extract | 0.78
| strict-match | 0.57
INT4 SYM GS128 | flexible-extract | 0.55
| strict-match | 0.29
FP32 | flexible-extract | 0.92
| strict-match | 0.82
---------
Co-authored-by: Lyalyushkin Nikolay <nikolay.lyalyushkin@intel.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 4b3eed1 commit 61ea196
2 files changed
Lines changed: 163 additions & 50 deletions
File tree
- src/nncf/quantization/algorithms/weight_compression
- tests/openvino/native/quantization
Lines changed: 55 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | | - | |
134 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
135 | 168 | | |
136 | 169 | | |
137 | 170 | | |
| |||
163 | 196 | | |
164 | 197 | | |
165 | 198 | | |
166 | | - | |
| 199 | + | |
167 | 200 | | |
168 | 201 | | |
169 | 202 | | |
| |||
179 | 212 | | |
180 | 213 | | |
181 | 214 | | |
182 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
183 | 218 | | |
184 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
185 | 222 | | |
186 | 223 | | |
187 | 224 | | |
188 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
189 | 229 | | |
190 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
191 | 234 | | |
192 | | - | |
| 235 | + | |
193 | 236 | | |
194 | 237 | | |
195 | 238 | | |
196 | | - | |
| 239 | + | |
197 | 240 | | |
198 | 241 | | |
199 | 242 | | |
200 | 243 | | |
201 | 244 | | |
202 | | - | |
203 | | - | |
204 | 245 | | |
205 | 246 | | |
| 247 | + | |
206 | 248 | | |
207 | 249 | | |
208 | 250 | | |
| |||
221 | 263 | | |
222 | 264 | | |
223 | 265 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 266 | + | |
228 | 267 | | |
229 | 268 | | |
230 | 269 | | |
| |||
323 | 362 | | |
324 | 363 | | |
325 | 364 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | 365 | | |
330 | 366 | | |
331 | 367 | | |
| |||
339 | 375 | | |
340 | 376 | | |
341 | 377 | | |
342 | | - | |
| 378 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
323 | 325 | | |
324 | 326 | | |
325 | 327 | | |
326 | | - | |
327 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
328 | 357 | | |
329 | | - | |
330 | | - | |
331 | 358 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
336 | 364 | | |
337 | | - | |
338 | | - | |
339 | | - | |
| 365 | + | |
| 366 | + | |
340 | 367 | | |
341 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
342 | 371 | | |
343 | | - | |
344 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
345 | 405 | | |
346 | 406 | | |
347 | | - | |
| 407 | + | |
348 | 408 | | |
349 | 409 | | |
350 | 410 | | |
351 | | - | |
| 411 | + | |
| 412 | + | |
352 | 413 | | |
353 | | - | |
| 414 | + | |
354 | 415 | | |
355 | | - | |
356 | | - | |
| 416 | + | |
| 417 | + | |
357 | 418 | | |
358 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
359 | 426 | | |
360 | | - | |
| 427 | + | |
361 | 428 | | |
362 | 429 | | |
363 | 430 | | |
364 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
365 | 450 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | 451 | | |
373 | | - | |
374 | | - | |
375 | | - | |
| 452 | + | |
0 commit comments