Alikestocode commited on
Commit
e9f4b24
·
1 Parent(s): 7e31310

Try alternative oneshot() API parameter names

Browse files

- First try: model_id, modifiers, dataset, token
- Fallback: minimal parameters (model_id, output_dir)
- Need to verify correct API from llmcompressor documentation

Files changed (1) hide show
  1. quantize_to_awq_colab.ipynb +25 -11
quantize_to_awq_colab.ipynb CHANGED
@@ -346,22 +346,36 @@
346
  " print(f\" ✅ AWQModifier created successfully\")\n",
347
  " \n",
348
  " # Call oneshot with the modifier\n",
349
- " # Note: oneshot() uses HfArgumentParser and expects specific parameter names\n",
350
- " # Use 'model_id' instead of 'model', and pass modifiers/calibration via recipe or separate args\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: model_id, output_dir, and recipe parameters\n",
357
- " # Pass modifiers and dataset via the recipe structure\n",
358
- " oneshot(\n",
359
- " model_id=repo_id,\n",
360
- " output_dir=temp_output_dir,\n",
361
- " recipe_modifiers=modifiers,\n",
362
- " recipe_dataset=calibration_dataset,\n",
363
- " hf_token=os.environ.get(\"HF_TOKEN\")\n",
364
- " )\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  " \n",
366
  " print(f\"✅ Model quantized to AWQ successfully\")\n",
367
  " except Exception as e:\n",
 
346
  " print(f\" ✅ AWQModifier created successfully\")\n",
347
  " \n",
348
  " # Call oneshot with the modifier\n",
349
+ " # Note: oneshot() uses HfArgumentParser - check actual API for correct parameter names\n",
 
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
+ " # Try different parameter combinations based on oneshot() API\n",
356
+ " # The error suggests 'calibration_data', 'modifiers', 'token' aren't recognized\n",
357
+ " # Let's try the most common parameter names\n",
358
+ " try:\n",
359
+ " # Attempt 1: Try with model_id, modifiers, dataset, token\n",
360
+ " oneshot(\n",
361
+ " model_id=repo_id,\n",
362
+ " output_dir=temp_output_dir,\n",
363
+ " modifiers=modifiers,\n",
364
+ " dataset=calibration_dataset,\n",
365
+ " token=os.environ.get(\"HF_TOKEN\")\n",
366
+ " )\n",
367
+ " except ValueError as e:\n",
368
+ " if \"not used by the HfArgumentParser\" in str(e):\n",
369
+ " # Attempt 2: Try with just model_id and output_dir, pass rest via kwargs\n",
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",