Skip to content

refactor(task): relocate map_task_synonym to loader.task as to_optimum_task#801

Merged
timenick merged 3 commits into
mainfrom
zhiwang/task-to-optimum-boundary
Jun 3, 2026
Merged

refactor(task): relocate map_task_synonym to loader.task as to_optimum_task#801
timenick merged 3 commits into
mainfrom
zhiwang/task-to-optimum-boundary

Conversation

@timenick

@timenick timenick commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

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.

timenick added 2 commits June 2, 2026 17:48
…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.
@timenick timenick requested a review from a team as a code owner June 2, 2026 09:50
Comment thread src/winml/modelkit/export/htp/exporter.py
@timenick timenick enabled auto-merge (squash) June 3, 2026 03:16
@timenick timenick merged commit dbfb072 into main Jun 3, 2026
9 checks passed
@timenick timenick deleted the zhiwang/task-to-optimum-boundary branch June 3, 2026 03:17
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants