llmcompressor.entrypoints.higgs
HIGGS: Heuristic ILP-Guided Grouped Scheme Mixed-Precision Quantization
Modules:
-
base–HIGGS: Heuristic ILP-Guided Grouped Scheme Mixed-Precision Quantization
-
ilp_solver–ILP-based optimization for mixed-precision quantization scheme selection.
-
utils–Utility functions for HIGGS mixed-precision quantization.
Classes:
-
HiggsMSECollectorConverter–First-pass converter that collects per-layer MSE data, solves the ILP,
Functions:
-
compute_fused_layer_mse–Compute MSE for layers that share an NVFP4 global scale.
-
compute_heuristic_alphas–Compute importance weights: log(size+1) * (1 + depth*0.05) * type_multiplier.
-
compute_layer_mse–Compute MSE between original and fake-quantized weight.
-
generate_config_groups–Convert ILP assignments into config groups with targets and formats.
-
get_higgs_config–Compute optimal mixed-precision config via ILP on per-layer MSE.
-
solve_ilp_mixed_precision–Solve ILP to select optimal quantization scheme for each layer.
HiggsMSECollectorConverter
HiggsMSECollectorConverter(
candidate_schemes: List[Union[str, QuantizationScheme]],
targets: Union[str, List[str]] = "Linear",
ignore: List[str] = None,
device: Union[str, device] = None,
target_avg_bitwidth: Optional[float] = None,
target_avg_act_bitwidth: Optional[float] = None,
allow_unquantized: bool = False,
)
Bases: Converter
First-pass converter that collects per-layer MSE data, solves the ILP, and produces an optimal QuantizationConfig. Does NOT modify tensors.
Methods:
-
create_config–Solve ILP after all shards processed and return optimized config.
-
process–Compute MSE for each candidate scheme; return tensors unchanged.
-
set_weight_names–Precompute fused dependencies from the complete checkpoint index.
-
validate–Validate HIGGS inputs without materializing checkpoint tensors.
Source code in src/llmcompressor/entrypoints/higgs/base.py
create_config
Solve ILP after all shards processed and return optimized config.
Source code in src/llmcompressor/entrypoints/higgs/base.py
process
Compute MSE for each candidate scheme; return tensors unchanged.
Source code in src/llmcompressor/entrypoints/higgs/base.py
set_weight_names
Precompute fused dependencies from the complete checkpoint index.
Source code in src/llmcompressor/entrypoints/higgs/base.py
validate
Validate HIGGS inputs without materializing checkpoint tensors.
Source code in src/llmcompressor/entrypoints/higgs/base.py
compute_fused_layer_mse
Compute MSE for layers that share an NVFP4 global scale.
Source code in src/llmcompressor/entrypoints/higgs/utils.py
compute_heuristic_alphas
compute_heuristic_alphas(
layer_names: List[str],
layer_param_counts: Dict[str, int],
) -> Dict[str, float]
Compute importance weights: log(size+1) * (1 + depth*0.05) * type_multiplier.
Source code in src/llmcompressor/entrypoints/higgs/utils.py
compute_layer_mse
Compute MSE between original and fake-quantized weight.
generate_config_groups
generate_config_groups(
ilp_solution: Dict[str, str],
candidate_schemes: Dict[str, QuantizationScheme],
) -> Dict[str, QuantizationScheme]
Convert ILP assignments into config groups with targets and formats.
Source code in src/llmcompressor/entrypoints/higgs/utils.py
get_higgs_config
get_higgs_config(
model_stub: Union[str, PathLike],
candidate_schemes: List[Union[str, QuantizationScheme]],
targets: Union[str, List[str]] = "Linear",
ignore: List[str] = None,
target_avg_bitwidth: Optional[float] = None,
target_avg_act_bitwidth: Optional[float] = None,
device: Optional[Union[str, device]] = None,
allow_unquantized: bool = False,
return_collector: bool = False,
) -> QuantizationConfig
Compute optimal mixed-precision config via ILP on per-layer MSE.
Reads model weights (model-free, no GPU model load), evaluates each candidate scheme's MSE on every layer, and solves an ILP to minimize weighted MSE under a bitwidth budget.
The returned QuantizationConfig can be applied via oneshot() or model_free_ptq().
Args: model_stub: HuggingFace model ID or path to model directory candidate_schemes: List of quantization schemes to choose from targets: Layer types to quantize (e.g., "Linear") ignore: Layers to skip (e.g., ["lm_head"]) target_avg_bitwidth: Optional constraint on average weight bitwidth target_avg_act_bitwidth: Optional constraint on average activation bitwidth device: Device for MSE computation (GPU recommended) allow_unquantized: Allow the ILP to leave layers unquantized at 16 bits return_collector: Return the collector alongside the optimized config.
Returns: QuantizationConfig with optimized config_groups
Source code in src/llmcompressor/entrypoints/higgs/base.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 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 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 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 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
solve_ilp_mixed_precision
solve_ilp_mixed_precision(
mse_matrix: Dict[str, Dict[str, float]],
alphas: Dict[str, float],
candidate_schemes: List[str],
fused_groups: List[List[str]] = None,
target_avg_bitwidth: Optional[float] = None,
layer_param_counts: Optional[Dict[str, int]] = None,
scheme_bitwidths: Optional[Dict[str, float]] = None,
target_avg_act_bitwidth: Optional[float] = None,
scheme_act_bitwidths: Optional[Dict[str, float]] = None,
) -> Dict[str, str]
Solve ILP to select optimal quantization scheme for each layer.
Formulation: Decision variables: x[layer][scheme] ∈ {0, 1}
Objective:
minimize: Σ_layer Σ_scheme (
MSE[layer][scheme] * alpha[layer] * x[layer][scheme]
)
Constraints:
1. Each layer gets exactly one scheme:
Σ_scheme x[layer][scheme] = 1 ∀ layer
2. Fused layers use same scheme (if fused_groups provided):
x[layer_i][scheme] = x[layer_j][scheme] ∀ scheme,
∀ (layer_i, layer_j) in same group
3. Optional: Average weight bitwidth constraint
(if target_avg_bitwidth provided):
Σ_layer (bitwidth[scheme] * params[layer] * x[layer][scheme])
/ Σ_layer params[layer] <= target_avg_bitwidth
4. Optional: Average activation bitwidth constraint
(if target_avg_act_bitwidth provided):
Σ_layer (act_bitwidth[scheme] * params[layer] * x[layer][scheme])
/ Σ_layer params[layer] <= target_avg_act_bitwidth
Args: mse_matrix: Nested dict mapping layer_name -> scheme_name -> mse_value alphas: Dict mapping layer_name -> importance weight candidate_schemes: List of scheme names (must match keys in mse_matrix) fused_groups: Optional list of layer name groups that must use same scheme target_avg_bitwidth: Optional constraint on weighted average weight bitwidth layer_param_counts: Required if either average bitwidth target is set scheme_bitwidths: Required if target_avg_bitwidth is set target_avg_act_bitwidth: Optional constraint on weighted average activation bitwidth scheme_act_bitwidths: Required if target_avg_act_bitwidth is set
Returns: Dict mapping layer_name -> selected_scheme_name
Raises: ValueError: If ILP is infeasible or unbounded
Source code in src/llmcompressor/entrypoints/higgs/ilp_solver.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |