Spaces:
Sleeping
Sleeping
Commit
·
35d8225
1
Parent(s):
e9f4b24
Fix oneshot() API: use correct parameter names from documentation
Browse files- Change 'model_id' to 'model'
- Change 'modifiers' to 'recipe' (list of modifiers)
- Change 'calibration_data' to 'dataset' (list of strings)
- Remove 'token' parameter (not needed)
- Add optional 'max_seq_length' and 'num_calibration_samples'
- Based on official llm-compressor documentation
- quantize_to_awq_colab.ipynb +17 -25
quantize_to_awq_colab.ipynb
CHANGED
|
@@ -346,36 +346,28 @@
|
|
| 346 |
" print(f\" ✅ AWQModifier created successfully\")\n",
|
| 347 |
" \n",
|
| 348 |
" # Call oneshot with the modifier\n",
|
| 349 |
-
" #
|
|
|
|
| 350 |
" print(f\" → Starting quantization process...\")\n",
|
| 351 |
" \n",
|
| 352 |
" # Prepare calibration dataset (limit to reasonable size)\n",
|
| 353 |
" calibration_dataset = calibration_texts[:min(calibration_dataset_size, 128)]\n",
|
| 354 |
" \n",
|
| 355 |
-
" #
|
| 356 |
-
" #
|
| 357 |
-
" #
|
| 358 |
-
"
|
| 359 |
-
"
|
| 360 |
-
"
|
| 361 |
-
"
|
| 362 |
-
"
|
| 363 |
-
"
|
| 364 |
-
"
|
| 365 |
-
"
|
| 366 |
-
"
|
| 367 |
-
"
|
| 368 |
-
"
|
| 369 |
-
"
|
| 370 |
-
" print(f\" ⚠️ Parameter names incorrect, trying alternative API...\")\n",
|
| 371 |
-
" # Check if oneshot accepts **kwargs or needs different structure\n",
|
| 372 |
-
" # For now, try minimal parameters\n",
|
| 373 |
-
" oneshot(\n",
|
| 374 |
-
" model_id=repo_id,\n",
|
| 375 |
-
" output_dir=temp_output_dir\n",
|
| 376 |
-
" )\n",
|
| 377 |
-
" else:\n",
|
| 378 |
-
" raise\n",
|
| 379 |
" \n",
|
| 380 |
" print(f\"✅ Model quantized to AWQ successfully\")\n",
|
| 381 |
" except Exception as e:\n",
|
|
|
|
| 346 |
" print(f\" ✅ AWQModifier created successfully\")\n",
|
| 347 |
" \n",
|
| 348 |
" # Call oneshot with the modifier\n",
|
| 349 |
+
" # Correct API based on llm-compressor documentation:\n",
|
| 350 |
+
" # oneshot(model, dataset, recipe, output_dir, max_seq_length, num_calibration_samples)\n",
|
| 351 |
" print(f\" → Starting quantization process...\")\n",
|
| 352 |
" \n",
|
| 353 |
" # Prepare calibration dataset (limit to reasonable size)\n",
|
| 354 |
" calibration_dataset = calibration_texts[:min(calibration_dataset_size, 128)]\n",
|
| 355 |
" \n",
|
| 356 |
+
" # oneshot() API parameters:\n",
|
| 357 |
+
" # - model: model ID or path\n",
|
| 358 |
+
" # - dataset: dataset name (string) or list of calibration strings\n",
|
| 359 |
+
" # - recipe: list of modifiers\n",
|
| 360 |
+
" # - output_dir: output directory\n",
|
| 361 |
+
" # - max_seq_length: optional, max sequence length\n",
|
| 362 |
+
" # - num_calibration_samples: optional, number of calibration samples\n",
|
| 363 |
+
" oneshot(\n",
|
| 364 |
+
" model=repo_id,\n",
|
| 365 |
+
" dataset=calibration_dataset, # List of calibration strings\n",
|
| 366 |
+
" recipe=modifiers, # List of modifiers (e.g., [AWQModifier(...)])\n",
|
| 367 |
+
" output_dir=temp_output_dir,\n",
|
| 368 |
+
" max_seq_length=2048, # Optional: max sequence length\n",
|
| 369 |
+
" num_calibration_samples=len(calibration_dataset) # Optional: number of samples\n",
|
| 370 |
+
" )\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
" \n",
|
| 372 |
" print(f\"✅ Model quantized to AWQ successfully\")\n",
|
| 373 |
" except Exception as e:\n",
|