feat: learn framework architecture incompatibilities
This commit is contained in:
@@ -4,6 +4,12 @@ import re
|
||||
from dataclasses import asdict, dataclass
|
||||
from typing import Iterable
|
||||
|
||||
from architecture_compatibility import (
|
||||
EXPLICIT_ARCHITECTURE_FAILURE_ACTION,
|
||||
EXPLICIT_ARCHITECTURE_FAILURE_CATEGORY,
|
||||
EXPLICIT_ARCHITECTURE_FAILURE_REASON,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class FailureClassification:
|
||||
@@ -70,6 +76,42 @@ DETERMINISTIC_LOG_PATTERNS = (
|
||||
(re.compile(r"config\.json.*(?:not found|no config)|Invalid repository ID or local directory", re.I), "MODEL_FILE_NOT_FOUND"),
|
||||
)
|
||||
|
||||
# These patterns deliberately require both framework and model/architecture
|
||||
# semantics. Generic messages such as "attention backend not supported" or
|
||||
# "GPU type not supported" must not create an architecture blacklist.
|
||||
EXPLICIT_FRAMEWORK_MODEL_UNSUPPORTED_PATTERNS = (
|
||||
re.compile(
|
||||
r"(?:当前|该|此)(?:推理)?框架.{0,100}(?:不支持|暂不支持|无法支持|不兼容)"
|
||||
r".{0,100}(?:该|此|当前)?(?:模型架构|模型|架构)",
|
||||
re.I,
|
||||
),
|
||||
re.compile(
|
||||
r"(?:该|此|当前)?(?:模型架构|模型|架构).{0,100}"
|
||||
r"(?:不被|不受).{0,50}(?:当前|该|此)?(?:推理)?框架.{0,30}支持",
|
||||
re.I,
|
||||
),
|
||||
re.compile(
|
||||
r"\b(?:this|the|current)\s+framework\b.{0,100}"
|
||||
r"\b(?:does\s+not|doesn't|cannot|can't)\s+support\b.{0,100}"
|
||||
r"\b(?:model|model\s+architecture|architecture)\b",
|
||||
re.I,
|
||||
),
|
||||
re.compile(
|
||||
r"\b(?:model|model\s+architecture|architecture)\b.{0,100}"
|
||||
r"\b(?:is\s+)?not\s+supported\s+by\b.{0,80}\bframework\b",
|
||||
re.I,
|
||||
),
|
||||
)
|
||||
|
||||
MODEL_NOT_SUPPORTED_SUGGESTION_PATTERNS = (
|
||||
re.compile(r"请(?:更换|换用|使用|选择).{0,50}(?:受支持|支持的)(?:模型|模型架构)", re.I),
|
||||
re.compile(
|
||||
r"\b(?:please\s+)?(?:change|switch|use|choose).{0,60}"
|
||||
r"\b(?:a\s+)?supported\s+(?:model|model\s+architecture)\b",
|
||||
re.I,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def classify_failure_report(report_code: str | None, log_lines: Iterable[str] = ()) -> FailureClassification:
|
||||
code = str(report_code or "").strip().upper()
|
||||
@@ -93,6 +135,18 @@ def classify_failure_report(report_code: str | None, log_lines: Iterable[str] =
|
||||
for pattern, inferred_code in DETERMINISTIC_LOG_PATTERNS:
|
||||
if pattern.search(text):
|
||||
return DETERMINISTIC_POLICIES[inferred_code]
|
||||
if any(pattern.search(text) for pattern in EXPLICIT_FRAMEWORK_MODEL_UNSUPPORTED_PATTERNS) or (
|
||||
code == "MODEL_NOT_SUPPORTED"
|
||||
and any(pattern.search(text) for pattern in MODEL_NOT_SUPPORTED_SUGGESTION_PATTERNS)
|
||||
):
|
||||
return FailureClassification(
|
||||
EXPLICIT_ARCHITECTURE_FAILURE_CATEGORY,
|
||||
"model_gpu_framework",
|
||||
EXPLICIT_ARCHITECTURE_FAILURE_ACTION,
|
||||
True,
|
||||
False,
|
||||
EXPLICIT_ARCHITECTURE_FAILURE_REASON,
|
||||
)
|
||||
if code in SEMANTIC_POLICIES:
|
||||
return SEMANTIC_POLICIES[code]
|
||||
return FailureClassification(
|
||||
|
||||
Reference in New Issue
Block a user