@@ -54,9 +54,6 @@ PT2E_QUANTIZE="${PT2E_QUANTIZE:-}"
5454# Default CMake Build Type to release mode
5555CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:- Release}
5656
57- # Default maximum export time.
58- MAX_EXPORT_TIME=${MAX_EXPORT_TIME:- 500}
59-
6057# Argument validation is done individually below for each required parameter
6158if [[ -z " ${MODEL_NAME:- } " ]]; then
6259 echo " Missing model name, exiting..."
@@ -140,6 +137,51 @@ else
140137 QNN_SDK_ROOT=" "
141138fi
142139
140+ # Set dynamic max export times
141+ PLATFORM=" x86"
142+ if [[ " $( uname) " == " Darwin" ]]; then
143+ PLATFORM=" macos"
144+ elif [[ " $( uname -m) " == " aarch64" ]] || [[ " $( uname -m) " == " arm64" ]]; then
145+ PLATFORM=" arm64"
146+ fi
147+
148+ # Lookup threshold based on platform:dtype:mode
149+ case " ${PLATFORM} :${DTYPE} :${MODE} " in
150+ # Linux x86 configurations
151+ " x86:fp32:portable" ) MAX_EXPORT_TIME=100 ;; # actual: 72s
152+ " x86:fp32:xnnpack+custom" ) MAX_EXPORT_TIME=360 ;; # actual: 276s
153+ " x86:fp32:xnnpack+custom+qe" ) MAX_EXPORT_TIME=360 ;;
154+ " x86:fp32:xnnpack+custom+quantize_kv" ) MAX_EXPORT_TIME=400 ;;
155+ " x86:fp32:xnnpack+quantize_kv" ) MAX_EXPORT_TIME=400 ;;
156+ " x86:bf16:portable" ) MAX_EXPORT_TIME=100 ;; # actual: 75s
157+ " x86:bf16:custom" ) MAX_EXPORT_TIME=130 ;;
158+
159+ # Linux ARM64 configurations
160+ " arm64:fp32:portable" ) MAX_EXPORT_TIME=162 ;; # actual: 124s
161+ " arm64:fp32:xnnpack+custom" ) MAX_EXPORT_TIME=630 ;; # actual: 483s
162+ " arm64:fp32:xnnpack+custom+qe" ) MAX_EXPORT_TIME=630 ;;
163+ " arm64:fp32:xnnpack+custom+quantize_kv" ) MAX_EXPORT_TIME=680 ;;
164+ " arm64:fp32:xnnpack+quantize_kv" ) MAX_EXPORT_TIME=680 ;;
165+ " arm64:bf16:portable" ) MAX_EXPORT_TIME=162 ;; # actual: 118s
166+ " arm64:bf16:custom" ) MAX_EXPORT_TIME=133 ;; # actual: 102s
167+
168+ # macOS configurations
169+ " macos:fp32:mps" ) MAX_EXPORT_TIME=60 ;; # actual: 30s
170+ " macos:fp32:coreml" ) MAX_EXPORT_TIME=80 ;; # actual: 61s
171+ " macos:fp32:xnnpack+custom+quantize_kv" ) MAX_EXPORT_TIME=170 ;; # actual: 133s
172+ " macos:fp32:xnnpack+custom" ) MAX_EXPORT_TIME=150 ;;
173+ " macos:fp32:portable" ) MAX_EXPORT_TIME=80 ;;
174+ " macos:bf16:portable" ) MAX_EXPORT_TIME=80 ;;
175+ " macos:bf16:custom" ) MAX_EXPORT_TIME=100 ;;
176+
177+ # Default fallback for unknown configurations
178+ * )
179+ MAX_EXPORT_TIME=500
180+ echo " Warning: No threshold defined for ${PLATFORM} :${DTYPE} :${MODE} , using default: ${MAX_EXPORT_TIME} s"
181+ ;;
182+ esac
183+
184+
143185echo " QNN option ${QNN} "
144186echo " QNN_SDK_ROOT: ${QNN_SDK_ROOT} "
145187
@@ -260,7 +302,6 @@ if [[ "${QUANTIZE_KV_CACHE}" == "ON" ]]; then
260302fi
261303
262304# Display the time
263- echo " Starting model export at $( date +" %Y-%m-%d %H:%M:%S" ) "
264305echo " Configuration: MODE=${MODE} , DTYPE=${DTYPE} , MODEL=${MODEL_NAME} "
265306EXPORT_START_TIME=$( date +%s)
266307
@@ -277,7 +318,7 @@ if [ $EXPORT_DURATION -gt $MAX_EXPORT_TIME ]; then
277318 exit 1
278319fi
279320
280- echo " Successl Export time check passed: ${EXPORT_DURATION} s <= ${MAX_EXPORT_TIME} s"
321+ echo " Success; Export time check passed: ${EXPORT_DURATION} s <= ${MAX_EXPORT_TIME} s"
281322
282323
283324# Create tokenizer.bin.
0 commit comments