Skip to content

[Core] Add result objects - #25341

Open
devtbi wants to merge 2 commits into
iree-org:mainfrom
devtbi:core-result-objects
Open

devtbi wants to merge 2 commits into
iree-org:mainfrom
devtbi:core-result-objects

Conversation

@devtbi

@devtbi devtbi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

stacked on top of #25336 - review first

Why

Compiling and running a model consumes results of previous steps. Currently, a user has to pass these to each step by hand, together with the matching configuration/flags. This enables a compiler/runtime driver to read a json file in an output directory containing paths (relative to a shared output dir) to artifacts and configuration options.

Change

Added Compile and Import result. The result objects record what an import or compile step produced, and the used configuration, in a metadata.json. The json file is expected to be place inside an output folder where the artifacts reside.

Add `iree.core.config`, the configuration that is recorded with an
imported or compiled model:

* `CompileConfig` describes how a model is compiled (target device,
  flags, flag templates, conditional flags) and what running the
  compiled artifact requires (drivers, lead allocator, runtime flags).
  It loads from and saves to JSON. Loading rejects unknown keys, so
  that a misspelled key does not go unnoticed.
* `ImportConfig` is the importer-side configuration. An importer
  subclasses it to record its own settings and the files it needs at
  runtime, and registers the subclass for its framework with
  `register_import_config`, so that the right class can be rebuilt when
  saved metadata is loaded. A framework has exactly one class:
  registering a second one is an error instead of depending on import
  order.

Nothing uses these classes yet: the compiler and runtime layers built on
them follow.

The classes are loaded with dacite, which becomes the first third-party
dependency of the iree-base-core wheel. `pyproject.toml` declares it as
a version range; builds and CI install it pinned to an exact version
with hashes (`requirements.txt`). The requirements of the Bazel pip hub
become a generated lock with hashes as well. It pins the dependencies of
the wheel and the other packages that Bazel targets use, which
`build_tools/bazel/requirements.in` lists: so far only numpy, which the
hub already had without a pin. The pkgci unit test job now runs every
test of the package against the installed wheel.

Assisted-by: Claude Code
Signed-off-by: Tobias Fuchs <fuchs@roofline.ai>
Add `iree.core.result`: `ImportResult` and `CompileResult` describe what
importing and compiling a model produced. They are saved next to the
artifacts as `metadata.json` and loaded back from it.

* Artifact paths are stored as file names relative to the metadata file,
  so that a result directory can be moved or copied as a whole. Saving
  rejects an artifact that is not directly inside the output directory.
* Optional fields that are not set are left out of the file. The
  configurations are written in full, defaults included, so that a file
  keeps its meaning if a default changes.
* Loading rebuilds the import configuration with the class registered
  for its framework. If no class is registered and the file holds
  importer-specific settings, loading fails instead of dropping them.
* Both results use the same file name, so the file states its `type`,
  and loading one as the other is reported as such. It also carries a
  `schema_version`, so that a later change of the layout is reported
  instead of misread. A file without these keys is read as version 1 of
  the requested type.
* Loading rejects unknown keys, as for configuration files. Errors
  while loading name the file.

Nothing uses these classes yet: the compiler and runtime layers built on
them follow.

Assisted-by: Claude Code
Signed-off-by: Tobias Fuchs <fuchs@roofline.ai>
@devtbi devtbi changed the title [Core] result objects [Core] Add result objects Nov 26, 2026

This branch has not been deployed

No deployments
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.

1 participant