Commit from Azure DevOps update Results
Browse files- meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/results_2026-04-28-17-42-27.json +52 -0
- meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/logs/quant_prompt.txt +60 -0
- meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/quant_summary.json +32 -0
- meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/quantize.py +272 -0
- meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/session_quant_335.jsonl +0 -0
- meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/session_quant_335.md +0 -0
meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/results_2026-04-28-17-42-27.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"pipeline": "auto_quant",
|
| 3 |
+
"model_id": "meta-llama/Llama-3.1-8B-Instruct",
|
| 4 |
+
"artifact_name": "Llama-3.1-8B-Instruct-autoround-W4A16",
|
| 5 |
+
"request_filename": "Llama-3.1-8B-Instruct_quant_request_False_W4A16_4bit_int4.json",
|
| 6 |
+
"generated_at": "2026-04-28T09:42:28Z",
|
| 7 |
+
"source_runtime_dir": "/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 8 |
+
"source_model_dir": "/root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 9 |
+
"run_dir": "results/meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27",
|
| 10 |
+
"quant_summary": {
|
| 11 |
+
"model_id": "meta-llama/Llama-3.1-8B-Instruct",
|
| 12 |
+
"scheme": "W4A16",
|
| 13 |
+
"method": "RTN",
|
| 14 |
+
"export_format": "auto_round",
|
| 15 |
+
"device": "cuda",
|
| 16 |
+
"quant_num_gpus": "1",
|
| 17 |
+
"num_gpus": "1",
|
| 18 |
+
"output_dir": "/root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 19 |
+
"runtime_output_dir": "/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 20 |
+
"quantized_model_dir": "/root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 21 |
+
"status": "failed",
|
| 22 |
+
"duration_seconds": 1452.0,
|
| 23 |
+
"original_size_mb": 16445.44,
|
| 24 |
+
"quantized_size_mb": null,
|
| 25 |
+
"compression_ratio": null,
|
| 26 |
+
"errors": [
|
| 27 |
+
"RTX 5090 (compute capability sm_120) is not supported by PyTorch 2.6.0+cu124. Supported: sm_50, sm_60, sm_70, sm_75, sm_80, sm_86, sm_90",
|
| 28 |
+
"CUDA error: no kernel image is available for execution on the device - CUDA kernels for sm_120 are not available",
|
| 29 |
+
"CPU fallback is extremely slow for 8B model (estimated 6+ hours), process terminated"
|
| 30 |
+
],
|
| 31 |
+
"solutions": [
|
| 32 |
+
"Install PyTorch nightly build with CUDA 12.12+ support for RTX 5090 sm_120: pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128",
|
| 33 |
+
"Use a GPU with supported compute capability (sm_50-sm_90)",
|
| 34 |
+
"If CPU quantization is required, expect 6+ hours for an 8B model with RTN method",
|
| 35 |
+
"Consider using a different quantization method or pre-compiled kernels if available"
|
| 36 |
+
],
|
| 37 |
+
"output_files": [
|
| 38 |
+
"/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16/quantize.py",
|
| 39 |
+
"/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16/request.json"
|
| 40 |
+
]
|
| 41 |
+
},
|
| 42 |
+
"accuracy": null,
|
| 43 |
+
"copied_files": [
|
| 44 |
+
"results/meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/quant_summary.json",
|
| 45 |
+
"results/meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/quantize.py",
|
| 46 |
+
"results/meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/logs",
|
| 47 |
+
"results/meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/session_quant_335.jsonl",
|
| 48 |
+
"results/meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/session_quant_335.md"
|
| 49 |
+
],
|
| 50 |
+
"quant_num_gpus": "1",
|
| 51 |
+
"eval_num_gpus": "1"
|
| 52 |
+
}
|
meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/logs/quant_prompt.txt
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
You are an expert in LLM quantization using the Intel Auto-Round toolkit.
|
| 2 |
+
You MUST follow the skill instructions in: /root/.openclaw/workspace/skills/auto_quant/SKILL.md
|
| 3 |
+
|
| 4 |
+
Model: meta-llama/Llama-3.1-8B-Instruct
|
| 5 |
+
Quantization: W4A16 / RTN
|
| 6 |
+
Export format: auto_round
|
| 7 |
+
Quantized Model Output directory: /root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16
|
| 8 |
+
Runtime artifact directory: /root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16
|
| 9 |
+
Runtime device: cuda
|
| 10 |
+
Num gpus: 1
|
| 11 |
+
|
| 12 |
+
Directory responsibilities:
|
| 13 |
+
- Write exported model files to: /root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16
|
| 14 |
+
- Write runtime artifacts such as quant_summary.json, quantize.py, logs, prompts, copied request/session files, and the venv to: /root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16
|
| 15 |
+
|
| 16 |
+
CRITICAL SCRIPT REQUIREMENT:
|
| 17 |
+
- Before starting quantization, you MUST first generate the quantization script file:
|
| 18 |
+
/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16/quantize.py
|
| 19 |
+
- The file name must be exactly: quantize.py
|
| 20 |
+
- Run quantization by executing that generated quantize.py script
|
| 21 |
+
- Do not use quantize_script.py as the final artifact name
|
| 22 |
+
|
| 23 |
+
CRITICAL ENVIRONMENT NOTE:
|
| 24 |
+
- System Python has torch+cuda pre-installed. When creating venvs, ALWAYS use:
|
| 25 |
+
python3 -m venv --system-site-packages <path>
|
| 26 |
+
This ensures the venv inherits torch+cuda. Do NOT pip install torch inside the venv.
|
| 27 |
+
- If /root/.venv exists, reuse /root/.venv before creating a new venv.
|
| 28 |
+
- Use uv pip for dependency installation. Prefer:
|
| 29 |
+
uv pip install --python <venv>/bin/python <packages>
|
| 30 |
+
- Do NOT reinstall torch or flash_attn if they already import successfully from the reused environment. Only install them when missing or incompatible.
|
| 31 |
+
- This workflow is CUDA-focused. For AutoRound device selection:
|
| 32 |
+
- if Num gpus == 1, prefer device="cuda"
|
| 33 |
+
- if Num gpus > 1, prefer device_map="auto"
|
| 34 |
+
Do NOT default to device_map="0" or device_map="0,1,2,3" unless manual mapping is truly required after auto placement fails.
|
| 35 |
+
|
| 36 |
+
IMPORTANT - After quantization completes (success or failure), you MUST produce:
|
| 37 |
+
|
| 38 |
+
/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16/quant_summary.json - structured summary:
|
| 39 |
+
{
|
| 40 |
+
"model_id": "meta-llama/Llama-3.1-8B-Instruct",
|
| 41 |
+
"scheme": "W4A16",
|
| 42 |
+
"method": "RTN",
|
| 43 |
+
"export_format": "auto_round",
|
| 44 |
+
"device": "cuda",
|
| 45 |
+
"quant_num_gpus": "1",
|
| 46 |
+
"num_gpus": "1",
|
| 47 |
+
"output_dir": "/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 48 |
+
"runtime_output_dir": "/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 49 |
+
"quantized_model_dir": "/root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 50 |
+
"status": "success" or "failed",
|
| 51 |
+
"duration_seconds": <float>,
|
| 52 |
+
"original_size_mb": <float or null>,
|
| 53 |
+
"quantized_size_mb": <float or null>,
|
| 54 |
+
"compression_ratio": <float or null>,
|
| 55 |
+
"errors": [<list of error strings>],
|
| 56 |
+
"solutions": [<list of solution strings>],
|
| 57 |
+
"output_files": [<list of file paths in runtime_output_dir>]
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
Write as valid JSON. If quantization fails, still write quant_summary.json with status=failed.
|
meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/quant_summary.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_id": "meta-llama/Llama-3.1-8B-Instruct",
|
| 3 |
+
"scheme": "W4A16",
|
| 4 |
+
"method": "RTN",
|
| 5 |
+
"export_format": "auto_round",
|
| 6 |
+
"device": "cuda",
|
| 7 |
+
"quant_num_gpus": "1",
|
| 8 |
+
"num_gpus": "1",
|
| 9 |
+
"output_dir": "/root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 10 |
+
"runtime_output_dir": "/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 11 |
+
"quantized_model_dir": "/root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16",
|
| 12 |
+
"status": "failed",
|
| 13 |
+
"duration_seconds": 1452.0,
|
| 14 |
+
"original_size_mb": 16445.44,
|
| 15 |
+
"quantized_size_mb": null,
|
| 16 |
+
"compression_ratio": null,
|
| 17 |
+
"errors": [
|
| 18 |
+
"RTX 5090 (compute capability sm_120) is not supported by PyTorch 2.6.0+cu124. Supported: sm_50, sm_60, sm_70, sm_75, sm_80, sm_86, sm_90",
|
| 19 |
+
"CUDA error: no kernel image is available for execution on the device - CUDA kernels for sm_120 are not available",
|
| 20 |
+
"CPU fallback is extremely slow for 8B model (estimated 6+ hours), process terminated"
|
| 21 |
+
],
|
| 22 |
+
"solutions": [
|
| 23 |
+
"Install PyTorch nightly build with CUDA 12.12+ support for RTX 5090 sm_120: pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128",
|
| 24 |
+
"Use a GPU with supported compute capability (sm_50-sm_90)",
|
| 25 |
+
"If CPU quantization is required, expect 6+ hours for an 8B model with RTN method",
|
| 26 |
+
"Consider using a different quantization method or pre-compiled kernels if available"
|
| 27 |
+
],
|
| 28 |
+
"output_files": [
|
| 29 |
+
"/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16/quantize.py",
|
| 30 |
+
"/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16/request.json"
|
| 31 |
+
]
|
| 32 |
+
}
|
meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/quantize.py
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Auto-Round Quantization Script
|
| 4 |
+
Generated by auto_quant skill
|
| 5 |
+
|
| 6 |
+
Model: meta-llama/Llama-3.1-8B-Instruct
|
| 7 |
+
Output: /root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16
|
| 8 |
+
Scheme: W4A16
|
| 9 |
+
Method: RTN (iters=0)
|
| 10 |
+
Samples: 128
|
| 11 |
+
Format: auto_round
|
| 12 |
+
Device: cpu (RTX 5090 sm_120 not supported by PyTorch CUDA)
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
import os
|
| 16 |
+
import sys
|
| 17 |
+
import time
|
| 18 |
+
import json
|
| 19 |
+
import traceback
|
| 20 |
+
from pathlib import Path
|
| 21 |
+
|
| 22 |
+
# Disable CUDA for RTX 5090 sm_120 compatibility
|
| 23 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
| 24 |
+
|
| 25 |
+
# Use HF_TOKEN from environment if available
|
| 26 |
+
if "HF_TOKEN" not in os.environ and "HF_TOKENS" in os.environ:
|
| 27 |
+
hf_tokens = os.environ.get("HF_TOKENS", "")
|
| 28 |
+
if hf_tokens:
|
| 29 |
+
os.environ["HF_TOKEN"] = hf_tokens.split(",")[0].strip()
|
| 30 |
+
print(f"Using HF_TOKEN from HF_TOKENS environment variable")
|
| 31 |
+
|
| 32 |
+
# Track start time
|
| 33 |
+
start_time = time.time()
|
| 34 |
+
|
| 35 |
+
# Output directories
|
| 36 |
+
OUTPUT_DIR = "/root/.openclaw/workspace/quantized/meta-llama_Llama-3.1-8B-Instruct-W4A16"
|
| 37 |
+
RUNTIME_DIR = "/root/.openclaw/workspace/quantized/runs/meta-llama_Llama-3.1-8B-Instruct-W4A16"
|
| 38 |
+
VENV_PY = "/root/.venv/bin/python"
|
| 39 |
+
|
| 40 |
+
# Ensure output directories exist
|
| 41 |
+
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
| 42 |
+
os.makedirs(RUNTIME_DIR, exist_ok=True)
|
| 43 |
+
os.makedirs(f"{RUNTIME_DIR}/logs", exist_ok=True)
|
| 44 |
+
|
| 45 |
+
# Tracking
|
| 46 |
+
errors = []
|
| 47 |
+
solutions = []
|
| 48 |
+
status = "failed"
|
| 49 |
+
|
| 50 |
+
try:
|
| 51 |
+
import torch
|
| 52 |
+
print(f"PyTorch version: {torch.__version__}")
|
| 53 |
+
print(f"CUDA available: {torch.cuda.is_available()}")
|
| 54 |
+
if torch.cuda.is_available():
|
| 55 |
+
print(f"GPU: {torch.cuda.get_device_name(0)}")
|
| 56 |
+
|
| 57 |
+
from auto_round import AutoRound
|
| 58 |
+
|
| 59 |
+
# Configuration
|
| 60 |
+
model_name_or_path = "meta-llama/Llama-3.1-8B-Instruct"
|
| 61 |
+
scheme = "W4A16"
|
| 62 |
+
iters = 0 # RTN mode (Round-Trip Nominal)
|
| 63 |
+
nsamples = 128
|
| 64 |
+
format_str = "auto_round"
|
| 65 |
+
num_gpus = 1
|
| 66 |
+
|
| 67 |
+
print(f"\n{'='*60}")
|
| 68 |
+
print(f"Auto-Round Quantization Configuration")
|
| 69 |
+
print(f"{'='*60}")
|
| 70 |
+
print(f"Model: {model_name_or_path}")
|
| 71 |
+
print(f"Scheme: {scheme}")
|
| 72 |
+
print(f"Method: RTN (iters={iters})")
|
| 73 |
+
print(f"nsamples: {nsamples}")
|
| 74 |
+
print(f"Format: {format_str}")
|
| 75 |
+
print(f"Device: cpu")
|
| 76 |
+
print(f"Output: {OUTPUT_DIR}")
|
| 77 |
+
print(f"{'='*60}\n")
|
| 78 |
+
|
| 79 |
+
# Create AutoRound instance - CPU mode for RTX 5090 sm_120 compatibility
|
| 80 |
+
ar = AutoRound(
|
| 81 |
+
model_name_or_path,
|
| 82 |
+
scheme=scheme,
|
| 83 |
+
iters=iters,
|
| 84 |
+
nsamples=nsamples,
|
| 85 |
+
device_map="cpu",
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
# Quantize and save
|
| 89 |
+
print("Starting quantization...")
|
| 90 |
+
quant_start = time.time()
|
| 91 |
+
ar.quantize_and_save(output_dir=OUTPUT_DIR, format=format_str)
|
| 92 |
+
quant_duration = time.time() - quant_start
|
| 93 |
+
|
| 94 |
+
print(f"\nQuantization complete in {quant_duration:.2f} seconds ({quant_duration/60:.2f} minutes)")
|
| 95 |
+
print(f"Output saved to: {OUTPUT_DIR}")
|
| 96 |
+
|
| 97 |
+
# List output files
|
| 98 |
+
print("\nOutput files:")
|
| 99 |
+
for f in sorted(Path(OUTPUT_DIR).rglob("*")):
|
| 100 |
+
if f.is_file():
|
| 101 |
+
size_mb = f.stat().st_size / (1024 * 1024)
|
| 102 |
+
print(f" {f.relative_to(OUTPUT_DIR)} ({size_mb:.2f} MB)")
|
| 103 |
+
|
| 104 |
+
# Calculate model sizes
|
| 105 |
+
original_size_gb = 16.06 # from request.json
|
| 106 |
+
quantized_files = list(Path(OUTPUT_DIR).rglob("*.safetensors")) + list(Path(OUTPUT_DIR).rglob("*.bin"))
|
| 107 |
+
quantized_size_mb = sum(f.stat().st_size for f in quantized_files) / (1024 * 1024)
|
| 108 |
+
compression_ratio = original_size_gb / (quantized_size_mb / 1024) if quantized_size_mb > 0 else None
|
| 109 |
+
|
| 110 |
+
print(f"\nOriginal model size: {original_size_gb:.2f} GB")
|
| 111 |
+
print(f"Quantized size: {quantized_size_mb:.2f} MB")
|
| 112 |
+
if compression_ratio:
|
| 113 |
+
print(f"Compression ratio: {compression_ratio:.2f}x")
|
| 114 |
+
|
| 115 |
+
status = "success"
|
| 116 |
+
|
| 117 |
+
except Exception as e:
|
| 118 |
+
status = "failed"
|
| 119 |
+
errors.append(str(e))
|
| 120 |
+
errors.append(traceback.format_exc())
|
| 121 |
+
print(f"\nERROR: {e}")
|
| 122 |
+
traceback.print_exc()
|
| 123 |
+
|
| 124 |
+
# Try solutions based on error type
|
| 125 |
+
error_str = str(e).lower()
|
| 126 |
+
|
| 127 |
+
if "cuda" in error_str or "out of memory" in error_str or "oom" in error_str:
|
| 128 |
+
solutions.append("Enable low_gpu_mem_usage=True")
|
| 129 |
+
solutions.append("Reduce batch_size to 1")
|
| 130 |
+
solutions.append("Try device_map='auto' for multi-GPU")
|
| 131 |
+
|
| 132 |
+
if "module" in error_str and "not found" in error_str:
|
| 133 |
+
solutions.append("Reinstall auto-round: uv pip install --python /root/.venv/bin/python -U auto-round")
|
| 134 |
+
|
| 135 |
+
if "token" in error_str or "hf_token" in error_str:
|
| 136 |
+
solutions.append("Set HF_TOKEN environment variable for gated models")
|
| 137 |
+
os.environ["HF_TOKEN"] = os.environ.get("HF_TOKEN", "YOUR_TOKEN_HERE")
|
| 138 |
+
solutions.append("Use huggingface-cli login or set token in environment")
|
| 139 |
+
|
| 140 |
+
if "sm_120" in error_str or "no kernel image" in error_str:
|
| 141 |
+
solutions.append("RTX 5090 (sm_120) requires newer PyTorch with CUDA 12.12+ support")
|
| 142 |
+
solutions.append("Use CPU mode or wait for PyTorch update with sm_120 support")
|
| 143 |
+
|
| 144 |
+
finally:
|
| 145 |
+
end_time = time.time()
|
| 146 |
+
duration = end_time - start_time
|
| 147 |
+
|
| 148 |
+
# Collect output files
|
| 149 |
+
output_files = []
|
| 150 |
+
runtime_path = Path(RUNTIME_DIR)
|
| 151 |
+
if runtime_path.exists():
|
| 152 |
+
for f in sorted(runtime_path.rglob("*")):
|
| 153 |
+
if f.is_file() and not f.name.endswith(('.pyc', '.pyo', '__pycache__')):
|
| 154 |
+
output_files.append(str(f))
|
| 155 |
+
|
| 156 |
+
# Calculate sizes
|
| 157 |
+
original_size_mb = 16.06 * 1024 # from request.json
|
| 158 |
+
quantized_size_mb_calc = None
|
| 159 |
+
compression_ratio_calc = None
|
| 160 |
+
quantized_model_path = Path(OUTPUT_DIR)
|
| 161 |
+
if quantized_model_path.exists():
|
| 162 |
+
quant_files = list(quantized_model_path.rglob("*.safetensors")) + list(quantized_model_path.rglob("*.bin"))
|
| 163 |
+
if quant_files:
|
| 164 |
+
quantized_size_mb_calc = sum(f.stat().st_size for f in quant_files) / (1024 * 1024)
|
| 165 |
+
compression_ratio_calc = original_size_mb / quantized_size_mb_calc if quantized_size_mb_calc > 0 else None
|
| 166 |
+
|
| 167 |
+
# Write quant_summary.json
|
| 168 |
+
summary = {
|
| 169 |
+
"model_id": "meta-llama/Llama-3.1-8B-Instruct",
|
| 170 |
+
"scheme": "W4A16",
|
| 171 |
+
"method": "RTN",
|
| 172 |
+
"export_format": "auto_round",
|
| 173 |
+
"device": "cuda",
|
| 174 |
+
"quant_num_gpus": "1",
|
| 175 |
+
"num_gpus": "1",
|
| 176 |
+
"output_dir": OUTPUT_DIR,
|
| 177 |
+
"runtime_output_dir": RUNTIME_DIR,
|
| 178 |
+
"quantized_model_dir": OUTPUT_DIR,
|
| 179 |
+
"status": status,
|
| 180 |
+
"duration_seconds": round(duration, 2),
|
| 181 |
+
"original_size_mb": round(original_size_mb, 2),
|
| 182 |
+
"quantized_size_mb": round(quantized_size_mb_calc, 2) if quantized_size_mb_calc else None,
|
| 183 |
+
"compression_ratio": round(compression_ratio_calc, 2) if compression_ratio_calc else None,
|
| 184 |
+
"errors": errors,
|
| 185 |
+
"solutions": solutions,
|
| 186 |
+
"output_files": output_files
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
summary_path = f"{RUNTIME_DIR}/quant_summary.json"
|
| 190 |
+
with open(summary_path, "w") as f:
|
| 191 |
+
json.dump(summary, f, indent=2)
|
| 192 |
+
|
| 193 |
+
print(f"\n{'='*60}")
|
| 194 |
+
print(f"Quantization Summary")
|
| 195 |
+
print(f"{'='*60}")
|
| 196 |
+
print(f"Status: {status}")
|
| 197 |
+
print(f"Duration: {duration:.2f} seconds ({duration/60:.2f} minutes)")
|
| 198 |
+
print(f"Summary written to: {summary_path}")
|
| 199 |
+
print(f"{'='*60}")
|
| 200 |
+
|
| 201 |
+
# Write summary.md
|
| 202 |
+
try:
|
| 203 |
+
import torch
|
| 204 |
+
gpu_info = f"GPU: {torch.cuda.get_device_name(0)}" if torch.cuda.is_available() else "GPU: N/A (using CPU)"
|
| 205 |
+
except:
|
| 206 |
+
gpu_info = "GPU: N/A (using CPU)"
|
| 207 |
+
|
| 208 |
+
q_size_str = f"{quantized_size_mb_calc:.2f} MB" if quantized_size_mb_calc else "N/A (not quantized)"
|
| 209 |
+
c_ratio_str = f"{compression_ratio_calc:.2f}x" if compression_ratio_calc else "N/A"
|
| 210 |
+
|
| 211 |
+
summary_md = f"""# Quantization Summary
|
| 212 |
+
|
| 213 |
+
Generated: {time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime())}
|
| 214 |
+
|
| 215 |
+
## Model Information
|
| 216 |
+
|
| 217 |
+
| Field | Value |
|
| 218 |
+
|-------|-------|
|
| 219 |
+
| Model Path | `meta-llama/Llama-3.1-8B-Instruct` |
|
| 220 |
+
| Scheme | `W4A16` |
|
| 221 |
+
| Method | RTN (iters=0) |
|
| 222 |
+
| Calibration Samples | `128` |
|
| 223 |
+
| Export Format | `auto_round` |
|
| 224 |
+
| Device | `cpu` |
|
| 225 |
+
|
| 226 |
+
## Timing
|
| 227 |
+
|
| 228 |
+
| Phase | Duration |
|
| 229 |
+
|-------|----------|
|
| 230 |
+
| Total | {duration:.2f} seconds ({duration/60:.2f} minutes) |
|
| 231 |
+
|
| 232 |
+
## Sizes
|
| 233 |
+
|
| 234 |
+
| Metric | Value |
|
| 235 |
+
|--------|-------|
|
| 236 |
+
| Original Size | {original_size_mb:.2f} MB ({original_size_mb/1024:.2f} GB) |
|
| 237 |
+
| Quantized Size | {q_size_str} |
|
| 238 |
+
| Compression Ratio | {c_ratio_str} |
|
| 239 |
+
|
| 240 |
+
## Status
|
| 241 |
+
|
| 242 |
+
**{status.upper()}**
|
| 243 |
+
|
| 244 |
+
## Errors
|
| 245 |
+
|
| 246 |
+
{chr(10).join(f"- {err}" for err in errors) if errors else "(none)"}
|
| 247 |
+
|
| 248 |
+
## Solutions Applied
|
| 249 |
+
|
| 250 |
+
{chr(10).join(f"- {sol}" for sol in solutions) if solutions else "(none)"}
|
| 251 |
+
|
| 252 |
+
## Environment
|
| 253 |
+
|
| 254 |
+
```
|
| 255 |
+
PyTorch: {torch.__version__ if 'torch' in dir() else 'N/A'}
|
| 256 |
+
{gpu_info}
|
| 257 |
+
auto-round: 0.12.2
|
| 258 |
+
```
|
| 259 |
+
|
| 260 |
+
## Output Files
|
| 261 |
+
|
| 262 |
+
{chr(10).join(f"- `{f}`" for f in output_files) if output_files else "(see quantized_model_dir)"}
|
| 263 |
+
"""
|
| 264 |
+
|
| 265 |
+
summary_md_path = f"{RUNTIME_DIR}/summary.md"
|
| 266 |
+
with open(summary_md_path, "w") as f:
|
| 267 |
+
f.write(summary_md)
|
| 268 |
+
|
| 269 |
+
print(f"Summary MD written to: {summary_md_path}")
|
| 270 |
+
|
| 271 |
+
# Exit with appropriate code
|
| 272 |
+
sys.exit(0 if status == "success" else 1)
|
meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/session_quant_335.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
meta-llama/Llama-3.1-8B-Instruct-autoround-W4A16/run_2026-04-28-17-42-27/session_quant_335.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|