Skip to content

Commit 685183d

Browse files
committed
Update test to be single threaded
Signed-off-by: ajrasane <[email protected]>
1 parent 3a76d28 commit 685183d

File tree

1 file changed

+12
-48
lines changed

1 file changed

+12
-48
lines changed

tests/examples/test_onnx_ptq.sh

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -137,38 +137,20 @@ for model_path in "${model_paths[@]}"; do
137137
model_name=$(basename "$model_path" .onnx)
138138
model_dir=build/$model_name
139139

140-
141-
echo "Quantizing model $model_name for all quantization modes in parallel"
142-
pids=()
143-
for i in "${!quant_modes[@]}"; do
144-
quant_mode="${quant_modes[$i]}"
145-
gpu_id=$((i % nvidia_gpu_count))
140+
echo "Quantizing model $model_name for all quantization modes"
141+
for quant_mode in "${quant_modes[@]}"; do
146142
if [ "$quant_mode" == "int8_iq" ]; then
147143
continue
148144
fi
149145

150-
echo "Starting quantization of $model_name for mode: $quant_mode on GPU $gpu_id"
151-
CUDA_VISIBLE_DEVICES=$gpu_id python -m modelopt.onnx.quantization \
146+
echo "Starting quantization of $model_name for mode: $quant_mode"
147+
python -m modelopt.onnx.quantization \
152148
--onnx_path=$model_dir/fp16/model.onnx \
153149
--quantize_mode=$quant_mode \
154150
--calibration_data=$calib_data_path \
155151
--output_path=$model_dir/$quant_mode/model.quant.onnx \
156-
--calibration_eps=cuda:0 &
157-
pids+=($!)
158-
done
159-
160-
# Wait for all quantization processes to complete for this model
161-
error_occurred=false
162-
for pid in "${pids[@]}"; do
163-
if ! wait $pid; then
164-
echo "ERROR: Quantization process (PID: $pid) failed"
165-
error_occurred=true
166-
fi
152+
--calibration_eps=cuda:0
167153
done
168-
if [ "$error_occurred" = true ]; then
169-
echo "Stopping execution due to quantization failure for model: $model_name"
170-
exit 1
171-
fi
172154

173155
echo "Completed quantization of all modes for model: $model_name"
174156
done
@@ -179,12 +161,8 @@ for model_path in "${model_paths[@]}"; do
179161
model_name=$(basename "$model_path" .onnx)
180162
model_dir=build/$model_name
181163

182-
echo "Evaluating model $model_name for all quantization modes in parallel"
183-
pids=()
184-
for i in "${!all_modes[@]}"; do
185-
quant_mode="${all_modes[$i]}"
186-
gpu_id=$((i % nvidia_gpu_count))
187-
164+
echo "Evaluating model $model_name for all quantization modes"
165+
for quant_mode in "${all_modes[@]}"; do
188166
if [ "$quant_mode" == "fp16" ]; then
189167
eval_model_path=$model_dir/fp16/model.onnx
190168
engine_path=$model_dir/fp16/model.engine
@@ -199,40 +177,26 @@ for model_path in "${model_paths[@]}"; do
199177
precision="stronglyTyped"
200178
fi
201179

202-
echo "Starting evaluation of $model_name for mode: $quant_mode on GPU $gpu_id"
180+
echo "Starting evaluation of $model_name for mode: $quant_mode"
203181
if [[ " ${latency_models[@]} " =~ " $model_name " ]]; then
204-
CUDA_VISIBLE_DEVICES=$gpu_id python evaluate.py \
182+
python evaluate.py \
205183
--onnx_path=$eval_model_path \
206184
--engine_path=$engine_path \
207185
--model_name="${timm_model_name[$model_name]}" \
208186
--engine_precision=$precision \
209-
--results_path=$model_dir/$quant_mode/${model_name}_${quant_mode}.csv &
187+
--results_path=$model_dir/$quant_mode/${model_name}_${quant_mode}.csv
210188
else
211-
CUDA_VISIBLE_DEVICES=$gpu_id python evaluate.py \
189+
python evaluate.py \
212190
--onnx_path=$eval_model_path \
213191
--engine_path=$engine_path \
214192
--imagenet_path=$imagenet_path \
215193
--eval_data_size=$calib_size \
216194
--batch_size $batch_size \
217195
--model_name="${timm_model_name[$model_name]}" \
218196
--engine_precision=$precision \
219-
--results_path=$model_dir/$quant_mode/${model_name}_${quant_mode}.csv &
220-
fi
221-
pids+=($!)
222-
done
223-
224-
# Wait for all evaluation processes to complete for this model
225-
error_occurred=false
226-
for pid in "${pids[@]}"; do
227-
if ! wait $pid; then
228-
echo "ERROR: Evaluation process (PID: $pid) failed"
229-
error_occurred=true
197+
--results_path=$model_dir/$quant_mode/${model_name}_${quant_mode}.csv
230198
fi
231199
done
232-
if [ "$error_occurred" = true ]; then
233-
echo "Stopping execution due to evaluation failure for model: $model_name"
234-
exit 1
235-
fi
236200

237201
echo "Completed evaluation of all modes for model: $model_name"
238202
done

0 commit comments

Comments
 (0)