|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -set -e |
4 | | - |
5 | | -# Get model_id as first positional argument (optional) |
6 | | -MODEL_ID="${1:-meta-llama/Llama-3.1-8B}" |
| 3 | +# eval_accuracy_for_readme.sh - Evaluate quantization recipe accuracy |
| 4 | +# |
| 5 | +# Usage: ./eval_accuracy_for_readme.sh [TAG_OR_RECIPE] [MODEL_ID] [LOG_FILE] |
| 6 | +# |
| 7 | +# Arguments: |
| 8 | +# TAG_OR_RECIPE (optional) Tag group, single recipe name, or "all" (default: all) |
| 9 | +# Valid tags: all, h100 |
| 10 | +# Valid recipes: None, float8_rowwise, |
| 11 | +# int4_groupwise_weight_float8_rowwise_activation, |
| 12 | +# int4_groupwise_hqq_weight_only, |
| 13 | +# int8_rowwise_weight_only, int8_rowwise |
| 14 | +# MODEL_ID (optional) HuggingFace model ID (default: meta-llama/Llama-3.1-8B) |
| 15 | +# LOG_FILE (optional) Output log file path (default: benchmarks/data/eval_accuracy_for_readme_log.txt) |
| 16 | +# |
| 17 | +# Examples: |
| 18 | +# ./eval_accuracy_for_readme.sh # Run all recipes with default model |
| 19 | +# ./eval_accuracy_for_readme.sh h100 # Run H100-compatible recipes only |
| 20 | +# ./eval_accuracy_for_readme.sh float8_rowwise # Run single recipe |
| 21 | +# ./eval_accuracy_for_readme.sh h100 meta-llama/Llama-3.2-8B # Custom model with H100 recipes |
| 22 | +# ./eval_accuracy_for_readme.sh int8_rowwise meta-llama/Llama-3.2-8B my_log.txt # All custom args |
7 | 23 |
|
8 | | -# Get log file as second positional argument (optional) |
9 | | -LOG_FILE="${2:-benchmarks/data/eval_accuracy_for_readme_log.txt}" |
10 | | -rm $LOG_FILE |
11 | | -touch $LOG_FILE |
| 24 | +set -e |
12 | 25 |
|
13 | | -QUANT_RECIPES=( |
| 26 | +# Define all available quantization recipes |
| 27 | +QUANT_RECIPES_ALL=( |
14 | 28 | # no quantization (baseline) |
15 | 29 | "None" |
16 | 30 | "float8_rowwise" |
17 | | - # note: below doesn't work with dtype_map auto: https://gist.github.com/vkuzo/6b128681b628744d445c553cdeac8a85 |
18 | 31 | "int4_groupwise_weight_float8_rowwise_activation" |
19 | 32 | # note: below only works on A100 |
20 | 33 | "int4_groupwise_hqq_weight_only" |
21 | 34 | "int8_rowwise_weight_only" |
22 | 35 | "int8_rowwise" |
23 | 36 | ) |
24 | 37 |
|
| 38 | +# Define H100-compatible recipes (excludes A100-only recipes) |
| 39 | +# TODO(future PR): add `int4_groupwise_weight_float8_rowwise_activation` here, |
| 40 | +# need to fix https://gist.github.com/vkuzo/6b128681b628744d445c553cdeac8a85 |
| 41 | +QUANT_RECIPES_H100=( |
| 42 | + "None" |
| 43 | + "float8_rowwise" |
| 44 | + "int8_rowwise_weight_only" |
| 45 | + "int8_rowwise" |
| 46 | +) |
| 47 | + |
| 48 | +# TODO(future PR): add A100 and B200 tag groups |
| 49 | + |
| 50 | +# Get tag/recipe as first positional argument (optional, default: all) |
| 51 | +TAG_OR_RECIPE="${1:-all}" |
| 52 | + |
| 53 | +# Get model_id as second positional argument (optional) |
| 54 | +MODEL_ID="${2:-meta-llama/Llama-3.1-8B}" |
| 55 | + |
| 56 | +# Get log file as third positional argument (optional) |
| 57 | +LOG_FILE="${3:-benchmarks/data/eval_accuracy_for_readme_log.txt}" |
| 58 | + |
| 59 | +# Select recipes based on tag or specific recipe |
| 60 | +if [ "$TAG_OR_RECIPE" = "all" ]; then |
| 61 | + QUANT_RECIPES=("${QUANT_RECIPES_ALL[@]}") |
| 62 | +elif [ "$TAG_OR_RECIPE" = "h100" ]; then |
| 63 | + QUANT_RECIPES=("${QUANT_RECIPES_H100[@]}") |
| 64 | +else |
| 65 | + # Check if it's a valid recipe name |
| 66 | + VALID_RECIPE=false |
| 67 | + for recipe in "${QUANT_RECIPES_ALL[@]}"; do |
| 68 | + if [ "$recipe" = "$TAG_OR_RECIPE" ]; then |
| 69 | + VALID_RECIPE=true |
| 70 | + QUANT_RECIPES=("$TAG_OR_RECIPE") |
| 71 | + break |
| 72 | + fi |
| 73 | + done |
| 74 | + |
| 75 | + if [ "$VALID_RECIPE" = false ]; then |
| 76 | + echo "Error: Invalid tag or recipe name: '$TAG_OR_RECIPE'" |
| 77 | + echo "" |
| 78 | + echo "Valid tags:" |
| 79 | + echo " - all" |
| 80 | + echo " - h100" |
| 81 | + echo "" |
| 82 | + echo "Valid recipe names:" |
| 83 | + for recipe in "${QUANT_RECIPES_ALL[@]}"; do |
| 84 | + echo " - $recipe" |
| 85 | + done |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | +fi |
| 89 | + |
| 90 | +rm $LOG_FILE |
| 91 | +touch $LOG_FILE |
| 92 | + |
25 | 93 | for quant_recipe in "${QUANT_RECIPES[@]}"; do |
26 | 94 |
|
27 | 95 | echo "processing $quant_recipe" |
|
0 commit comments