Skip to content

Make ONNX graph optimization configurable per model (default off)#37252

Merged
arnej27959 merged 1 commit into
masterfrom
arnej/configurable-onnx-optimize
Jun 19, 2026
Merged

Make ONNX graph optimization configurable per model (default off)#37252
arnej27959 merged 1 commit into
masterfrom
arnej/configurable-onnx-optimize

Conversation

@arnej27959

Copy link
Copy Markdown
Member

Previously the ONNX graph optimization level was hardcoded to ENABLE (ORT_ENABLE_ALL) both in the proton model cache and the container stateless evaluator. Add an "optimize-model" setting to the onnx-model schema block, wired through onnx-models.def, that controls this per model. Default is false (DISABLE / NO_OPT), so optimization is off unless explicitly enabled.

Proton ranking path:

  • onnx-models.def: new model[].optimize_model bool default=false
  • OnnxModelCache::load takes an Onnx::Optimize argument and includes it in the cache key, so the same file with different optimize settings no longer shares an instance
  • fef::OnnxModel carries the bool; onnx_feature translates it to Onnx::Optimize when loading from the cache

Container stateless path:

  • OnnxEvaluatorOptions gains an optimizeModel field (part of the session cache key hash), honored in EmbeddedOnnxRuntime.createSessionOptions (ALL_OPT vs NO_OPT)
  • RankProfilesConfigImporter reads optimize_model() from config

Parsers:

  • SchemaParser.jj and the schema-language-server SchemaParser.ccc both accept "optimize-model: " in an onnx-model block

Previously the ONNX graph optimization level was hardcoded to ENABLE
(ORT_ENABLE_ALL) both in the proton model cache and the container
stateless evaluator. Add an "optimize-model" setting to the onnx-model
schema block, wired through onnx-models.def, that controls this per
model. Default is false (DISABLE / NO_OPT), so optimization is off
unless explicitly enabled.

Proton ranking path:
- onnx-models.def: new model[].optimize_model bool default=false
- OnnxModelCache::load takes an Onnx::Optimize argument and includes it
  in the cache key, so the same file with different optimize settings
  no longer shares an instance
- fef::OnnxModel carries the bool; onnx_feature translates it to
  Onnx::Optimize when loading from the cache

Container stateless path:
- OnnxEvaluatorOptions gains an optimizeModel field (part of the session
  cache key hash), honored in EmbeddedOnnxRuntime.createSessionOptions
  (ALL_OPT vs NO_OPT)
- RankProfilesConfigImporter reads optimize_model() from config

Parsers:
- SchemaParser.jj and the schema-language-server SchemaParser.ccc both
  accept "optimize-model: <bool>" in an onnx-model block

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@arnej27959 arnej27959 merged commit 1cb54bb into master Jun 19, 2026
4 checks passed
@arnej27959 arnej27959 deleted the arnej/configurable-onnx-optimize branch June 19, 2026 09:33
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