Skip to content

Commit 3cd8bbf

Browse files
committed
temp save
1 parent c225f96 commit 3cd8bbf

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

backends/cuda/cuda_backend.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def preprocess(
152152
# Separate weight constants from the .so file
153153
"aot_inductor.package": True,
154154
"aot_inductor.package_constants_in_so": False,
155+
"aot_inductor.freezing": True,
155156
# Store weight constants on disk in a binary blob
156157
"aot_inductor.package_constants_on_disk_format": "binary_blob",
157158
# Enable maximum automatic tuning for optimal performance
@@ -187,6 +188,8 @@ def preprocess(
187188
f"Could not find required files in compiled paths, got {paths}"
188189
)
189190

191+
print("--- Generate .so lives at", so_path)
192+
190193
# pyre-ignorep[6]: Incompatible parameter type
191194
with open(so_path, "rb") as f:
192195
so_data = f.read()

eval.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# 用法: ./evaluate_kernel.sh <kernel_name> <n_evaluation>
4+
KERNEL_NAME=$1
5+
N_EVAL=$2
6+
7+
# 路径前缀
8+
BASE_PATH=~/kernel-gen/whisper-large-v3-turbo/${KERNEL_NAME}/
9+
10+
MODEL_PATH=${BASE_PATH}model.pte
11+
DATA_PATH=${BASE_PATH}aoti_cuda_blob.ptd
12+
TOKENIZER_PATH=${BASE_PATH}
13+
AUDIO_PATH=${BASE_PATH}output.wav
14+
PROCESSOR_PATH=${BASE_PATH}whisper_preprocessor.pte
15+
16+
CMD="cmake-out/examples/models/whisper/whisper_runner \
17+
--model_path ${MODEL_PATH} \
18+
--data_path ${DATA_PATH} \
19+
--temperature 0 \
20+
--tokenizer_path ${TOKENIZER_PATH} \
21+
--audio_path ${AUDIO_PATH} \
22+
--processor_path ${PROCESSOR_PATH}"
23+
24+
rates=()
25+
for ((i=1; i<=N_EVAL; i++)); do
26+
echo "Running evaluation $i/$N_EVAL..."
27+
output=$($CMD 2>&1)
28+
# 推荐用 awk
29+
rate=$(echo "$output" | grep "Generated 128 tokens:" | awk '{print $(NF-1)}')
30+
echo "Generated token rate for run $i: $rate"
31+
if [[ ! -z "$rate" ]]; then
32+
rates+=($rate)
33+
fi
34+
done
35+
36+
# 计算平均值
37+
sum=0
38+
count=0
39+
for r in "${rates[@]}"; do
40+
# 只统计非空数值
41+
if [[ ! -z "$r" ]]; then
42+
sum=$(echo "$sum + $r" | bc)
43+
count=$((count+1))
44+
fi
45+
done
46+
47+
if [[ $count -gt 0 ]]; then
48+
avg=$(echo "scale=2; $sum / $count" | bc)
49+
echo "Average Generated token rate over $count runs: $avg tokens/second"
50+
else
51+
echo "No valid token rates found."
52+
fi

0 commit comments

Comments
 (0)