@@ -59,6 +59,12 @@ cleanup_server() {
5959run_profiling_tests () {
6060 # run profiling tests using JSON configuration
6161 local profiling_test_file=" $1 "
62+ local base_profiler_dir=" ${VLLM_TORCH_PROFILER_DIR:- } "
63+
64+ if [[ -z " ${base_profiler_dir} " ]]; then
65+ echo " Error: VLLM_TORCH_PROFILER_DIR is not set."
66+ exit 1
67+ fi
6268
6369 if [[ ! -f " $profiling_test_file " ]]; then
6470 echo " Error: Profiling test file $profiling_test_file not found!"
@@ -92,18 +98,29 @@ run_profiling_tests() {
9298 # Clean up any existing processes first
9399 kill_gpu_processes
94100
101+ # Create a profiling sub-directory for each test case to isolate the
102+ # generated traces (e.g. using the model name hierarchy)
103+ local sanitized_test_name=" ${TEST_NAME// / _} "
104+ local test_name_directory=" ${base_profiler_dir} /${sanitized_test_name} "
105+ mkdir -p " ${test_name_directory} "
106+ chmod 755 " ${test_name_directory} "
107+
108+ # Override the profiler output directory for this test only
109+ export VLLM_TORCH_PROFILER_DIR=" ${test_name_directory} "
110+
95111 # Run the profiling test
96112 if start_vllm_server " $server_args " ; then
97113 run_profiling " $client_args "
98114 cleanup_server
99115
100116 # Debug: Check if profiling files were created
101- echo " DEBUG: Checking profiling directory: ${VLLM_TORCH_PROFILER_DIR} "
102- if [ -d " ${VLLM_TORCH_PROFILER_DIR} " ]; then
117+ echo " DEBUG: Checking profiling directory: $test_name_directory "
118+ if [ -d " $test_name_directory " ]; then
103119 echo " DEBUG: Profiling directory exists for test $TEST_NAME "
104- ls -la " ${VLLM_TORCH_PROFILER_DIR} " || echo " DEBUG: Directory is empty or inaccessible"
105- find " ${VLLM_TORCH_PROFILER_DIR} " -type f 2> /dev/null | head -10 | while read file; do
120+ ls -la " $test_name_directory " || echo " DEBUG: Directory is empty or inaccessible"
121+ find " $test_name_directory " -type f 2> /dev/null | head -10 | while read file; do
106122 echo " DEBUG: Found profiling file: ${file} "
123+ rename_profiling_file " $file " " vllm"
107124 done
108125 else
109126 echo " DEBUG: Profiling directory does not exist for test $TEST_NAME !"
@@ -115,6 +132,9 @@ run_profiling_tests() {
115132 continue
116133 fi
117134 done
135+
136+ # Ensure the profiler directory is restored after processing all tests
137+ export VLLM_TORCH_PROFILER_DIR=" ${base_profiler_dir} "
118138}
119139
120140main () {
0 commit comments