refactor(task): relocate map_task_synonym to loader.task as to_optimum_task#801
Merged
Conversation
…m_task Establish a single WinML->Optimum task collapse boundary in loader/task.py. map_task_synonym and TASK_SYNONYM_EXTENSIONS move from export/io.py to loader/task.py as to_optimum_task; export.io keeps map_task_synonym as a backward-compatible alias. Optimum-boundary call sites (inspect command, HTP exporter, inspect resolver) call to_optimum_task directly. No behavior change. Part of #800.
zhenchaoni
approved these changes
Jun 3, 2026
timenick
added a commit
that referenced
this pull request
Jun 5, 2026
…nds (#807) ## 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_task` boundary), now on `main`. ## 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-level `image_size`/`patch_size` upgrades `feature-extraction` -> `image-feature-extraction`) applied to the **returned** task only. Internal model-class resolution keeps the Optimum-canonical task, so no Optimum API receives `image-feature-extraction`. - **`inspect/resolver.py::detect_task`** delegates to the loader detector (drops its own dispatch + now-dead imports). - **`eval/evaluate.py::_resolve_task`** uses `detect_task` and drops the reverse io_config reconstruction (`to_hf_pipeline_task` / `HF_TASK_NAME_MAPPING`); an explicit `--task` is surfaced verbatim. - `config` / `perf` / `build` inherit modality-aware detection via `resolve_task_and_model_class` Case 1 — no code change. - New `tests/unit/loader/test_detect_task.py` and `tests/integration/test_task_consistency.py` (cross-resolver agreement on real configs); `tests/unit/eval/test_eval.py` updated. ## Behavior - Image-embedding models (DINOv2) auto-detect `image-feature-extraction` across inspect / config / export / eval / perf / build — source-level fix for #778, so calibration datasets and evaluators pick the image asset directly. - CLIP / SAM2 / timm / text models unchanged (CLIP's `image_size` is nested -> D2 does not fire). - **Accepted behavior change:** explicit `winml eval --task feature-extraction` on 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).
DingmaomaoBJTU
pushed a commit
that referenced
this pull request
Jun 5, 2026
…m_task (#801) ## What PR1 of #800. Relocate `map_task_synonym` -> `loader/task.py::to_optimum_task` to establish a single WinML->Optimum task-collapse boundary. ## Changes - `loader/task.py`: add `to_optimum_task` + `TASK_SYNONYM_EXTENSIONS` (moved from `export/io.py`); exported via `loader/__init__.py`. - `export/io.py`: local implementation removed; `map_task_synonym` kept as a backward-compatible alias (`= to_optimum_task`); internal use repointed. - Optimum-boundary call sites repointed to `to_optimum_task`: `commands/inspect.py`, `export/htp/exporter.py`, `inspect/resolver.py`. - `commands/build.py`: `TASK_SYNONYM_EXTENSIONS` now imported from `loader`. - New `tests/unit/loader/test_task_boundary.py` pins the collapse contract. ## Behavior No behavior change. `map_task_synonym` stays importable from `export.io`; the collapse semantics (`image-feature-extraction` -> `feature-extraction`, WinML extensions preserved) are byte-identical. Existing synonym and #777/#782 regression tests stay green. Sets up PR2 (#800), which adds the modality-aware `detect_task` and relies on this single collapse boundary.
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
PR1 of #800. Relocate
map_task_synonym->loader/task.py::to_optimum_taskto establish a single WinML->Optimum task-collapse boundary.Changes
loader/task.py: addto_optimum_task+TASK_SYNONYM_EXTENSIONS(moved fromexport/io.py); exported vialoader/__init__.py.export/io.py: local implementation removed;map_task_synonymkept as a backward-compatible alias (= to_optimum_task); internal use repointed.to_optimum_task:commands/inspect.py,export/htp/exporter.py,inspect/resolver.py.commands/build.py:TASK_SYNONYM_EXTENSIONSnow imported fromloader.tests/unit/loader/test_task_boundary.pypins the collapse contract.Behavior
No behavior change.
map_task_synonymstays importable fromexport.io; the collapse semantics (image-feature-extraction->feature-extraction, WinML extensions preserved) are byte-identical. Existing synonym and #777/#782 regression tests stay green.Sets up PR2 (#800), which adds the modality-aware
detect_taskand relies on this single collapse boundary.