Skip to content

Add manifest-driven ORT optimization level - #21567

Merged
TurboGit merged 1 commit into
darktable-org:masterfrom
andriiryzhkov:ort_optimization
Jul 23, 2026
Merged

Add manifest-driven ORT optimization level#21567
TurboGit merged 1 commit into
darktable-org:masterfrom
andriiryzhkov:ort_optimization

Conversation

@andriiryzhkov

Copy link
Copy Markdown
Collaborator

Lets a model manifest declare its ORT graph optimization level instead of the hard-coded ORT_ENABLE_ALL. Some models (SAM2 decoders) fail under aggressive optimization because ONNX Runtime's shape inference mis-computes intermediate tensors. Manifest-driven configuration means feature code stops needing per-model workarounds − the mechanism lives in the backend and applies uniformly.

Config keys

Both are top-level in config.json, siblings to attributes / cpu_only / coreml_format. Values: "all" (default), "basic", "disabled". Case-insensitive.

// simplest: applies to every file in the package, every provider
"ort_optimization": "disabled"

// per-file (encoder.onnx / decoder.onnx / …)
"ort_optimization": {
  "encoder": "disabled",
  "decoder": "all"
}

// per-provider (overrides the above only for that EP)
"ort_optimization_provider": {
  "migraphx": "basic"
}

// per-file per-provider (nest a stem object under the provider key)
"ort_optimization_provider": {
  "migraphx": {
    "encoder": "disabled",
    "decoder": "all"
  }
}

Resolution: per-provider override wins; falls through to ort_optimization; falls through to ORT_ENABLE_ALL. Unknown keys warn once on -d ai. Missing manifest − same behaviour as before this PR.

How feature code uses it

Nothing to change. dt_ai_load_model() now passes a DT_AI_OPT_DEFAULT sentinel that tells the backend to read from the manifest. Explicit callers of dt_ai_load_model_ext() who pass a concrete DT_AI_OPT_* still override.

Logging

Each session load now prints on -d ai:

[darktable_ai] loading <model_id>/<file> on <provider> (opt=<level>)

Handy for confirming a manifest setting took effect.

Scope

No feature-code changes. Fully backward-compatible; models without either key behave exactly as before.

@andriiryzhkov andriiryzhkov added this to the 5.8 milestone Jul 18, 2026
@andriiryzhkov andriiryzhkov added the scope: AI features AI features related issues and PR label Jul 18, 2026

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TurboGit
TurboGit merged commit ed18d3b into darktable-org:master Jul 23, 2026
5 checks passed
@TurboGit TurboGit added priority: low core features work as expected, only secondary/optional features don't release notes: pending labels Jul 23, 2026
@andriiryzhkov
andriiryzhkov deleted the ort_optimization branch July 24, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: low core features work as expected, only secondary/optional features don't release notes: pending scope: AI features AI features related issues and PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants