Skip to content

Commit 883d231

Browse files
committed
refactor accuracy eval script to be organized by hardware
Summary: We have a many-to-many mapping of recipe to device it can run on. Reorganizing the accuracy script to reflect this, since we don't have a machine that can run all the workflows. Test Plan: ``` // test on h100 benchmarks/quantization/eval_accuracy_for_readme.sh h100 ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 3c697ac ghstack-comment-id: 3633684836 Pull-Request: #3472
1 parent fcf2c87 commit 883d231

File tree

1 file changed

+78
-10
lines changed

1 file changed

+78
-10
lines changed

benchmarks/quantization/eval_accuracy_for_readme.sh

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,95 @@
11
#!/bin/bash
22

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
723

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
1225

13-
QUANT_RECIPES=(
26+
# Define all available quantization recipes
27+
QUANT_RECIPES_ALL=(
1428
# no quantization (baseline)
1529
"None"
1630
"float8_rowwise"
17-
# note: below doesn't work with dtype_map auto: https://gist.github.com/vkuzo/6b128681b628744d445c553cdeac8a85
1831
"int4_groupwise_weight_float8_rowwise_activation"
1932
# note: below only works on A100
2033
"int4_groupwise_hqq_weight_only"
2134
"int8_rowwise_weight_only"
2235
"int8_rowwise"
2336
)
2437

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+
2593
for quant_recipe in "${QUANT_RECIPES[@]}"; do
2694

2795
echo "processing $quant_recipe"

0 commit comments

Comments
 (0)