Spaces:
Sleeping
Sleeping
Commit
Β·
f3114ba
1
Parent(s):
a49281c
Fix modifiers initialization: ensure it's always defined
Browse files- Initialize modifiers and quant_config to None
- Ensure modifiers is always created before use
- Add final fallback to default AWQModifier if all config approaches fail
- quantize_to_awq_colab.ipynb +15 -7
quantize_to_awq_colab.ipynb
CHANGED
|
@@ -258,6 +258,9 @@
|
|
| 258 |
" # Try multiple approaches to create the config\n",
|
| 259 |
" print(f\" β Creating quantization config for 4-bit AWQ...\")\n",
|
| 260 |
" \n",
|
|
|
|
|
|
|
|
|
|
| 261 |
" try:\n",
|
| 262 |
" # Approach 1: Try importing BaseQuantizationConfig\n",
|
| 263 |
" from compressed_tensors.quantization import QuantizationConfig, BaseQuantizationConfig\n",
|
|
@@ -288,16 +291,21 @@
|
|
| 288 |
" except Exception as e:\n",
|
| 289 |
" # Approach 3: Try AWQModifier without quantization_config (use defaults)\n",
|
| 290 |
" print(f\" β οΈ Could not create QuantizationConfig: {e}\")\n",
|
| 291 |
-
" print(f\" β
|
| 292 |
" modifiers = [AWQModifier()]\n",
|
| 293 |
" print(f\" β
AWQModifier created with default settings\")\n",
|
| 294 |
-
" # Skip quantization_config creation and use default AWQModifier\n",
|
| 295 |
-
" quant_config = None\n",
|
| 296 |
" \n",
|
| 297 |
-
" if
|
| 298 |
-
"
|
| 299 |
-
"
|
| 300 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
" \n",
|
| 302 |
" # Call oneshot with the modifier\n",
|
| 303 |
" print(f\" β Starting quantization process...\")\n",
|
|
|
|
| 258 |
" # Try multiple approaches to create the config\n",
|
| 259 |
" print(f\" β Creating quantization config for 4-bit AWQ...\")\n",
|
| 260 |
" \n",
|
| 261 |
+
" modifiers = None\n",
|
| 262 |
+
" quant_config = None\n",
|
| 263 |
+
" \n",
|
| 264 |
" try:\n",
|
| 265 |
" # Approach 1: Try importing BaseQuantizationConfig\n",
|
| 266 |
" from compressed_tensors.quantization import QuantizationConfig, BaseQuantizationConfig\n",
|
|
|
|
| 291 |
" except Exception as e:\n",
|
| 292 |
" # Approach 3: Try AWQModifier without quantization_config (use defaults)\n",
|
| 293 |
" print(f\" β οΈ Could not create QuantizationConfig: {e}\")\n",
|
| 294 |
+
" print(f\" β Using AWQModifier with default settings...\")\n",
|
| 295 |
" modifiers = [AWQModifier()]\n",
|
| 296 |
" print(f\" β
AWQModifier created with default settings\")\n",
|
|
|
|
|
|
|
| 297 |
" \n",
|
| 298 |
+
" # Create modifiers if we have a quant_config\n",
|
| 299 |
+
" if modifiers is None:\n",
|
| 300 |
+
" if quant_config is not None:\n",
|
| 301 |
+
" print(f\" β Creating AWQModifier with quantization config...\")\n",
|
| 302 |
+
" modifiers = [AWQModifier(quantization_config=quant_config)]\n",
|
| 303 |
+
" print(f\" β
AWQModifier created successfully\")\n",
|
| 304 |
+
" else:\n",
|
| 305 |
+
" # Final fallback: use default AWQModifier\n",
|
| 306 |
+
" print(f\" β Using AWQModifier with default settings (no config)...\")\n",
|
| 307 |
+
" modifiers = [AWQModifier()]\n",
|
| 308 |
+
" print(f\" β
AWQModifier created with default settings\")\n",
|
| 309 |
" \n",
|
| 310 |
" # Call oneshot with the modifier\n",
|
| 311 |
" print(f\" β Starting quantization process...\")\n",
|