fix: restore accuracy-first route admission
This commit is contained in:
@@ -66,6 +66,7 @@ DEFAULT_LEDGER_PATH = Path("ledger/submissions.jsonl")
|
||||
ADAPTIVE_SCAN_MAX_MODELS = 3000
|
||||
ADAPTIVE_SCAN_MIN_FALLBACK_MODELS = 500
|
||||
MAX_ROUTES_PER_MODEL = 6
|
||||
MAX_PENDING_ROUTES_PER_MODEL = 2
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
@@ -572,9 +573,11 @@ def process_model_for_candidates(
|
||||
if hasattr(modelhub_client, "model_submission_precheck"):
|
||||
precheck = modelhub_client.model_submission_precheck(model.repo_id)
|
||||
processed_gpus = set(precheck.get("processedGpus") or set())
|
||||
successful_gpus = set(precheck.get("successfulGpus") or set())
|
||||
failed_frameworks_by_gpu = precheck.get("failedFrameworksByGpu") or {}
|
||||
else:
|
||||
processed_gpus = modelhub_client.processed_gpus_for_model(model.repo_id)
|
||||
successful_gpus = set()
|
||||
failed_frameworks_by_gpu = {}
|
||||
except Exception as exc:
|
||||
return (
|
||||
@@ -582,6 +585,31 @@ def process_model_for_candidates(
|
||||
[{"repoId": model.repo_id, "reason": "community_precheck_unavailable_fail_closed"}],
|
||||
[{"repoId": model.repo_id, "reason": f"community_precheck_error:{exc}"}],
|
||||
)
|
||||
if len(processed_gpus) >= MAX_ROUTES_PER_MODEL:
|
||||
return (
|
||||
[],
|
||||
[{
|
||||
"repoId": model.repo_id,
|
||||
"reason": "model_route_limit_reached",
|
||||
"processedGpuCount": len(processed_gpus),
|
||||
}],
|
||||
[],
|
||||
)
|
||||
pending_route_count = (
|
||||
outcome_tracker.pending_route_count_for_model(model.repo_id)
|
||||
if outcome_tracker is not None
|
||||
else 0
|
||||
)
|
||||
if pending_route_count >= MAX_PENDING_ROUTES_PER_MODEL:
|
||||
return (
|
||||
[],
|
||||
[{
|
||||
"repoId": model.repo_id,
|
||||
"reason": "model_pending_feedback_limit",
|
||||
"pendingRouteCount": pending_route_count,
|
||||
}],
|
||||
[],
|
||||
)
|
||||
candidates: list[dict[str, Any]] = []
|
||||
skipped: list[dict[str, Any]] = []
|
||||
failed: list[dict[str, Any]] = []
|
||||
@@ -605,33 +633,14 @@ def process_model_for_candidates(
|
||||
if target_gpu in processed_gpus:
|
||||
skipped.append({"repoId": model.repo_id, "targetGpu": target_gpu, "reason": "already_processed_for_gpu"})
|
||||
continue
|
||||
if target_gpu in failed_frameworks_by_gpu and market_intelligence is None:
|
||||
if target_gpu in failed_frameworks_by_gpu:
|
||||
skipped.append({
|
||||
"repoId": model.repo_id,
|
||||
"targetGpu": target_gpu,
|
||||
"reason": "prior_failed_gpu_requires_public_framework_evidence",
|
||||
"reason": "prior_failed_gpu_closed_accuracy_first",
|
||||
})
|
||||
continue
|
||||
failed_frameworks = set(failed_frameworks_by_gpu.get(target_gpu) or set())
|
||||
if (
|
||||
failed_frameworks
|
||||
and market_intelligence is not None
|
||||
and hasattr(market_intelligence, "has_vetted_alternative_framework")
|
||||
and allowed_task_types_set
|
||||
and all(market_intelligence.has_framework_route(task_type, target_gpu) for task_type in allowed_task_types_set)
|
||||
and not any(
|
||||
market_intelligence.has_vetted_alternative_framework(
|
||||
task_type, target_gpu, failed_frameworks
|
||||
)
|
||||
for task_type in allowed_task_types_set
|
||||
)
|
||||
):
|
||||
skipped.append({
|
||||
"repoId": model.repo_id,
|
||||
"targetGpu": target_gpu,
|
||||
"reason": "prior_failed_framework_no_alternative",
|
||||
})
|
||||
continue
|
||||
if outcome_tracker and outcome_tracker.is_model_gpu_failed(model.repo_id, target_gpu):
|
||||
skipped.append({"repoId": model.repo_id, "targetGpu": target_gpu, "reason": "local_failure_cooldown_24h"})
|
||||
continue
|
||||
@@ -734,6 +743,9 @@ def process_model_for_candidates(
|
||||
record = candidate_to_record(best)
|
||||
if excluded_frameworks:
|
||||
record["previousFailedFrameworks"] = sorted(excluded_frameworks)
|
||||
record["communitySuccessfulGpuCount"] = len(successful_gpus)
|
||||
if successful_gpus:
|
||||
record["communitySuccessfulGpus"] = sorted(successful_gpus)
|
||||
if outcome_tracker is not None:
|
||||
record["transformersPrerequisiteSatisfied"] = (
|
||||
outcome_tracker.has_non_transformers_failure(model.repo_id)
|
||||
@@ -810,20 +822,6 @@ def build_adaptive_scan_stages(
|
||||
"limit": max_models,
|
||||
}
|
||||
)
|
||||
if allow_older_than_recent_window:
|
||||
# ModelScope only exposes the first 3,000 raw rows for a sort order.
|
||||
# Downloads ordering reaches a different older, established slice
|
||||
# after the recent-update slice has produced too few candidates.
|
||||
stages.append(
|
||||
{
|
||||
"name": "popular_history",
|
||||
"updatedAfter": None,
|
||||
"limit": min(max_models, 200),
|
||||
"sort": "downloads",
|
||||
"rotatePages": True,
|
||||
}
|
||||
)
|
||||
|
||||
deduped: list[dict[str, Any]] = []
|
||||
seen: set[tuple[str | None, int, str]] = set()
|
||||
for stage in stages:
|
||||
@@ -951,20 +949,20 @@ def submit_candidate(
|
||||
"candidate": candidate,
|
||||
"reason": "already_processed_for_gpu",
|
||||
}
|
||||
failed_frameworks = set(
|
||||
(precheck.get("failedFrameworksByGpu") or {}).get(candidate["targetGpu"]) or set()
|
||||
)
|
||||
if candidate["framework"] in failed_frameworks:
|
||||
if len(set(precheck.get("processedGpus") or set())) >= MAX_ROUTES_PER_MODEL:
|
||||
return {
|
||||
"outcome": "duplicate",
|
||||
"candidate": candidate,
|
||||
"reason": "prior_failed_framework_for_gpu",
|
||||
"reason": "model_route_limit_reached",
|
||||
}
|
||||
if failed_frameworks and not candidate.get("frameworkEvidenceQualified"):
|
||||
failed_frameworks = set(
|
||||
(precheck.get("failedFrameworksByGpu") or {}).get(candidate["targetGpu"]) or set()
|
||||
)
|
||||
if failed_frameworks:
|
||||
return {
|
||||
"outcome": "framework_evidence_deferred",
|
||||
"outcome": "duplicate",
|
||||
"candidate": candidate,
|
||||
"reason": "prior_failed_gpu_requires_public_framework_evidence",
|
||||
"reason": "prior_failed_gpu_closed_accuracy_first",
|
||||
}
|
||||
|
||||
payload = {
|
||||
|
||||
Reference in New Issue
Block a user