feat(task): modality-aware detect_task unifies detection across commands#807
Open
timenick wants to merge 3 commits into
Open
feat(task): modality-aware detect_task unifies detection across commands#807timenick wants to merge 3 commits into
timenick wants to merge 3 commits into
Conversation
Add loader/task.py::detect_task — a single offline, config-only detector returning a modality-aware WinMLTask (e.g. image-feature-extraction) instead of Optimum's lossy feature-extraction. The D2 vision heuristic (top-level image_size/patch_size) is applied to the returned task only; internal model-class resolution keeps the Optimum-canonical task, so no Optimum API receives image-feature-extraction. Flip detection consumers: inspect resolver.detect_task delegates to the loader detector; eval _resolve_task uses detect_task and drops the reverse io_config reconstruction (to_hf_pipeline_task / HF_TASK_NAME_MAPPING) — an explicit --task is now surfaced verbatim. config / perf / build inherit via resolve_task_and_model_class Case 1. Source-level fix for #778: image-embedding models (DINOv2) auto-detect image-feature-extraction everywhere, so calibration datasets and evaluators pick the image asset directly. Part of #800.
…ger branch Add an explanatory comment to the empty 'except ValueError: pass' so it reads as deliberate control flow (fall through to HF_TASK_DEFAULTS) rather than a swallowed error. Resolves the CodeQL py/empty-except alert on #807.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PR2 of #800. Add a single, offline, modality-aware task detector and route every detection consumer through it, so the same model resolves to the same WinMLTask everywhere. Builds on #801 (the
to_optimum_taskboundary), now onmain.Changes
loader/task.py::detect_task(config) -> (WinMLTask, source)— new single detector. Config-only dispatch (HF_MODEL_CLASS_MAPPING -> wrapped-library -> TasksManager -> HF_TASK_DEFAULTS), then a D2 vision heuristic (top-levelimage_size/patch_sizeupgradesfeature-extraction->image-feature-extraction) applied to the returned task only. Internal model-class resolution keeps the Optimum-canonical task, so no Optimum API receivesimage-feature-extraction.inspect/resolver.py::detect_taskdelegates to the loader detector (drops its own dispatch + now-dead imports).eval/evaluate.py::_resolve_taskusesdetect_taskand drops the reverse io_config reconstruction (to_hf_pipeline_task/HF_TASK_NAME_MAPPING); an explicit--taskis surfaced verbatim.config/perf/buildinherit modality-aware detection viaresolve_task_and_model_classCase 1 — no code change.tests/unit/loader/test_detect_task.pyandtests/integration/test_task_consistency.py(cross-resolver agreement on real configs);tests/unit/eval/test_eval.pyupdated.Behavior
image-feature-extractionacross inspect / config / export / eval / perf / build — source-level fix for winml build and eval command fails on image embedding model like facebook/dinov2-base #778, so calibration datasets and evaluators pick the image asset directly.image_sizeis nested -> D2 does not fire).winml eval --task feature-extractionon a vision model no longer auto-upgrades; per the canonical rule it is out-of-domain and surfaced as-is (fails downstream rather than being silently rewritten). A clean early rejection would need model-aware validation (out of scope).