Skip to content

Commit dee8bac

Browse files
committed
fix: output result file to folder && add error info in log
1 parent 3ef7115 commit dee8bac

4 files changed

Lines changed: 69 additions & 19 deletions

File tree

infinimetrics/common/constants.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ class AcceleratorType(str, Enum):
2222
GENERIC = "generic"
2323

2424

25+
class TestCategory(str, Enum):
26+
"""Test category classifications - single source of truth for test type categorization"""
27+
28+
HARDWARE = "hardware"
29+
OPERATOR = "operator"
30+
INFER = "infer"
31+
COMM = "comm"
32+
TRAIN = "train"
33+
34+
35+
# Valid test categories (derived from TestCategory enum)
36+
# Used for testcase prefix matching and output directory organization
37+
TEST_CATEGORIES = {cat.value: cat.value for cat in TestCategory}
38+
39+
2540
# Common execution defaults
2641
DEFAULT_WARMUP_ITERATIONS = 10
2742
DEFAULT_MEASURED_ITERATIONS = 100

infinimetrics/dispatcher.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99

1010
from infinimetrics.adapter import BaseAdapter
1111
from infinimetrics.executor import Executor, TestResult
12+
from infinimetrics.common.constants import TestCategory
1213

1314
logger = logging.getLogger(__name__)
1415

1516
# Adapter registry: maps (test_type, framework) -> adapter factory
17+
# test_type must use TestCategory enum (not string literals)
1618
_ADAPTER_REGISTRY = {
17-
("operator", "infinicore"): lambda: _create_infinicore_adapter(),
18-
("hardware", "cudaunified"): lambda: _create_hardware_adapter(),
19-
("comm", "nccltest"): lambda: _create_nccltests_adapter(),
20-
("infer", "infinilm"): lambda: _create_inference_adapter(),
21-
("infer", "vllm"): lambda: _create_inference_adapter(),
19+
(TestCategory.OPERATOR, "infinicore"): lambda: _create_infinicore_adapter(),
20+
(TestCategory.HARDWARE, "cudaunified"): lambda: _create_hardware_adapter(),
21+
(TestCategory.COMM, "nccltest"): lambda: _create_nccltests_adapter(),
22+
(TestCategory.INFER, "infinilm"): lambda: _create_inference_adapter(),
23+
(TestCategory.INFER, "vllm"): lambda: _create_inference_adapter(),
2224
}
2325

2426

@@ -99,9 +101,9 @@ def dispatch(self, inputs: Any) -> Dict[str, Any]:
99101

100102
for test_input in valid_test_inputs:
101103
testcase = test_input["testcase"]
102-
test_type, framework = self._parse_testcase(testcase)
103104

104105
try:
106+
test_type, framework = self._parse_testcase(testcase)
105107
adapter = self._create_adapter(test_type, framework)
106108
valid_executions.append((test_input, adapter))
107109
logger.debug(f"Validated {testcase} - adapter ready")
@@ -168,14 +170,23 @@ def _parse_testcase(self, testcase: str) -> tuple[str, str]:
168170

169171
if len(parts) < 2:
170172
logger.warning(f"Invalid testcase format: {testcase}, using defaults")
171-
return "operator", "infinicore"
173+
return TestCategory.OPERATOR.value, "infinicore"
174+
175+
# First part is test_type - validate against TestCategory enum
176+
test_type_str = parts[0].lower()
177+
try:
178+
test_type = TestCategory(test_type_str)
179+
except ValueError:
180+
valid_types = ", ".join(c.value for c in TestCategory)
181+
raise ValueError(
182+
f"Invalid test_type '{test_type_str}' in '{testcase}'. "
183+
f"Must be one of: {valid_types}"
184+
)
172185

173-
# First part is test_type
174-
test_type = parts[0].lower()
175186
# Second part is framework
176187
framework = parts[1].lower()
177188

178-
return test_type, framework
189+
return test_type.value, framework
179190

180191
def _aggregate_results(self, results: List[Dict[str, Any]]) -> Dict[str, Any]:
181192
"""Aggregate results from executors."""

infinimetrics/executor.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from infinimetrics.adapter import BaseAdapter
1616
from infinimetrics.input import TestInput
1717
from infinimetrics.utils.path_utils import sanitize_filename
18-
from infinimetrics.common.constants import ErrorCode
18+
from infinimetrics.common.constants import ErrorCode, TEST_CATEGORIES
1919

2020

2121
logger = logging.getLogger(__name__)
@@ -664,17 +664,27 @@ def _save_result(self, result: Dict[str, Any]) -> str:
664664
if not run_id:
665665
run_id = self.payload.get("run_id") or self.run_id
666666

667+
# 3) Determine output subdirectory based on testcase
668+
testcase = self.payload.get("testcase", "")
669+
670+
# Extract category from testcase (e.g., "hardware.cudaUnified.Comprehensive" -> "hardware")
671+
category = "other" # default fallback
672+
for prefix, subdir in TEST_CATEGORIES.items():
673+
if testcase.startswith(prefix):
674+
category = subdir
675+
break
676+
667677
if run_id:
668678
safe_run_id = sanitize_filename(run_id)
669679

670-
# Put final JSON next to timeseries csv files under infer/
671-
infer_dir = self.output_dir / "infer"
672-
infer_dir.mkdir(parents=True, exist_ok=True)
680+
# Put results in category-specific subdirectory
681+
category_dir = self.output_dir / category
682+
category_dir.mkdir(parents=True, exist_ok=True)
673683

674684
filename = f"{safe_run_id}_results.json"
675-
output_file = infer_dir / filename
685+
output_file = category_dir / filename
676686
else:
677-
# Final fallback to old naming
687+
# Final fallback to old naming (in root output_dir)
678688
safe_name = self.testcase.replace(".", "_").replace("/", "_")
679689
filename = f"{safe_name}_{timestamp}_results.json"
680690
output_file = self.output_dir / filename

scripts/common/install_deps.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ check_cuda() {
7070
# Check InfiniCore
7171
check_infinicore() {
7272
echo -n " InfiniCore... "
73-
if check_python_package infinicore; then
73+
74+
# Try to import and capture error details
75+
error_msg=$(python -c "import infinicore" 2>&1)
76+
if [ $? -eq 0 ]; then
7477
echo -e "${GREEN}[OK]${NC}"
7578
return 0
7679
else
77-
echo -e "${YELLOW}[WARNING]${NC} not installed"
80+
echo -e "${YELLOW}[WARNING]${NC}"
81+
echo " Failed to import infinicore:"
82+
echo " ${error_msg}" | head -n 15 | sed 's/^/ /'
7883
return 1
7984
fi
8085
}
@@ -164,11 +169,20 @@ install_infinicore() {
164169
echo -e "${BLUE}Verifying installation...${NC}"
165170
echo "INFINI_ROOT: $INFINI_ROOT"
166171
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
167-
if python -c "import infinicore" 2>/dev/null; then
172+
173+
error_msg=$(python -c "import infinicore" 2>&1)
174+
if [ $? -eq 0 ]; then
168175
echo -e "${GREEN}[OK] InfiniCore installation completed successfully!${NC}"
169176
return 0
170177
else
171178
echo -e "${RED}[ERROR] InfiniCore installation verification failed${NC}"
179+
echo " Import error:"
180+
echo " ${error_msg}" | head -n 15 | sed 's/^/ /'
181+
echo ""
182+
echo " Possible causes:"
183+
echo " - Dependencies not installed (run: python scripts/install.py --nv-gpu=y)"
184+
echo " - Library not built (run: xmake build _infinicore)"
185+
echo " - LD_LIBRARY_PATH not set correctly"
172186
return 1
173187
fi
174188
}

0 commit comments

Comments
 (0)