-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Sync mlia #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Sync mlia #19
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
170b03d
docs: Add high-level documentation (#33)
IsabellaARM 9a30209
ci: Gate release publishing on tags (#34)
Mousius 6c005c4
build: Add public repo sync workflow (#8)
Mousius bf46c3b
fix: Remove duplicate if-block from release.yml (#37)
Mousius f8abc8d
feat: Add availability-aware standardized performance metrics (#32)
jedgar-arm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| <!--- | ||
| SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates. | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| ---> | ||
|
|
||
| # End-to-end Execution Flow | ||
|
|
||
| This page follows a typical `mlia check` run from the command line to final | ||
| reports. Plugin-specific collectors, analyzers, converters, and backend tools may | ||
| vary, but the core orchestration path is shared. | ||
|
|
||
| Use this page for runtime ordering and failure handling. For the static module | ||
| layout, see [High-level Architecture](high_level_architecture.md). For plugin | ||
| discovery and extension points, see [Plugin Architecture](plugin_architecture.md). | ||
|
|
||
| ## Command flow | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| participant User | ||
| participant CLI as mlia CLI | ||
| participant Commands as mlia.cli.commands | ||
| participant API as mlia.api | ||
| participant TargetReg as Target registry | ||
| participant BackendReg as Backend registry | ||
| participant BackendMgr as Backend manager | ||
| participant Advisor as Target advisor | ||
| participant Workflow as Workflow executor | ||
| participant Reports as Output handlers | ||
|
|
||
| User->>CLI: mlia check model --target-profile profile --performance | ||
| CLI->>CLI: Parse args and create ExecutionContext | ||
| CLI->>Commands: check(ctx, target_profile, model, flags, backends) | ||
| Commands->>API: get_advice(target_profile, model, category, context, backends) | ||
| API->>TargetReg: Resolve profile and target | ||
| TargetReg->>BackendReg: Ensure backend plugins loaded | ||
| TargetReg->>TargetReg: Ensure target plugins loaded | ||
| API->>API: Validate advice category and backend selection | ||
| API->>BackendMgr: ensure_backends_installed(validated_backends) | ||
| API->>TargetReg: Get target advisor factory | ||
| TargetReg-->>API: Advisor factory | ||
| API->>Advisor: Create advisor for target profile and model | ||
| API->>Advisor: run(context) | ||
| Advisor->>Workflow: Configure collectors/analyzers/producers/events | ||
| Workflow->>Workflow: Collect data | ||
| Workflow->>Workflow: Analyze data | ||
| Workflow->>Workflow: Detect patterns when configured | ||
| Workflow->>Reports: Produce advice and publish events | ||
| Reports-->>User: Console output, JSON output, files, logs | ||
| ``` | ||
|
|
||
| ## Runtime responsibilities | ||
|
|
||
| | Step | Core owner | What happens | | ||
| | --- | --- | --- | | ||
| | Parse command | `mlia.cli.main` | Builds an argument parser from core and CLI plugin commands. | | ||
| | Build context | `mlia.cli.main.setup_context()` | Creates `ExecutionContext`, resolves output format, output directory, action resolver, and logging. | | ||
| | Select advice category | `mlia.cli.commands.check()` | Converts `--compatibility` and `--performance` flags into an advice-category set. | | ||
| | Validate target/profile | `mlia.cli.command_validators`, `mlia.target.registry` | Confirms the selected target profile supports the requested category. | | ||
| | Validate backends | `mlia.api.get_advice()` | Resolves requested backends against the target and supported backend registry. | | ||
| | Ensure backend installation | `mlia.backend.manager` | Checks or installs backends as required, subject to EULA and noninteractive settings. | | ||
| | Create advisor | `mlia.api.get_advisor()` | Finds the target from the profile and calls the target's advisor factory. | | ||
| | Run workflow | `mlia.core.advisor`, `mlia.core.workflow` | Executes collectors, analyzers, optional pattern analyzers, and advice producers. | | ||
| | Produce output | `mlia.core.reporting`, event handlers, output schema helpers | Emits console output, logs, generated files, and JSON-compatible data when requested. | | ||
|
|
||
| ## Conceptual data flow | ||
|
|
||
| ```mermaid | ||
| graph LR | ||
| model[Input model] --> command[mlia check] | ||
| profile[Target profile TOML] --> command | ||
| backendOptions[Backend options] --> command | ||
|
|
||
| command --> context[ExecutionContext] | ||
| context --> outputDir[Output directory] | ||
| context --> logs[logs/mlia.log] | ||
|
|
||
| model --> collectors[Data collectors] | ||
| profile --> advisor[Target advisor] | ||
| advisor --> collectors | ||
| collectors --> maybeConvert{Converter needed?} | ||
| maybeConvert -->|yes| converter[Converter plugin] | ||
| converter --> intermediate[Converted/intermediate artifact] | ||
| maybeConvert -->|no| backendInput[Backend input artifact] | ||
| intermediate --> backendInput | ||
| backendInput --> backend[Backend tool or service] | ||
| backend --> rawResults[Raw backend output] | ||
| rawResults --> analyzers[Data analyzers] | ||
| analyzers --> facts[Analyzed facts] | ||
| facts --> producers[Advice producers] | ||
| producers --> advice[Advice] | ||
| advice --> events[Events] | ||
| events --> handlers[Event handlers and reporters] | ||
| handlers --> reports[Reports and JSON output] | ||
| reports --> outputDir | ||
| ``` | ||
|
|
||
| The exact collector inputs, converted artifact names, backend outputs, and | ||
| analyzer facts are plugin-owned. The core guarantees the shared execution | ||
| context, workflow stages, event publishing, and output/reporting mechanisms. | ||
|
|
||
| ## Failure flow | ||
|
|
||
| MLIA failures normally terminate the command and return a non-zero exit status. | ||
| The CLI always reports the run output directory at the end of command execution. | ||
| Unless `--output-dir` is set, logs and generated artifacts are written under | ||
| `mlia-output` in the current working directory. The main log file is | ||
| `mlia-output/logs/mlia.log`. | ||
|
|
||
| In normal CLI output, handled errors are intentionally short: | ||
|
|
||
| ```text | ||
| Execution finished with error: <message> | ||
| Please check the log files in the mlia-output/logs for more details, or enable debug mode (--debug) | ||
| This execution of MLIA used output directory: mlia-output | ||
| ``` | ||
|
|
||
| With `--debug`, MLIA prints debug logging to the console and records debug logs | ||
| in `mlia-output/logs/mlia.log`. For unexpected exceptions, `--debug` also shows | ||
| the Python traceback. Handled error categories, such as configuration errors, | ||
| backend availability errors, and interrupted execution, are still displayed as | ||
| concise messages. | ||
|
|
||
| The CLI handles these categories specially: | ||
|
|
||
| | Failure category | User-visible behavior | | ||
| | --- | --- | | ||
| | Configuration error | Prints the configuration error message directly. | | ||
| | Backend unavailable | Prints `Error: Backend <name> is not available.` Some optional backends also include an installation hint, for example `mlia-backend install "<name>"`. | | ||
| | Interrupted execution | Prints `Execution has been interrupted`. | | ||
| | Internal error | Prints `Internal error: <message>`. | | ||
| | Other exception | Prints `Execution finished with error: <message>`, points to the log directory, and shows a traceback when `--debug` is enabled. | | ||
|
|
||
| Inside the workflow, exceptions from collection, analysis, pattern detection, or | ||
| advice production are first published as an `ExecutionFailedEvent`. That event | ||
| contains the original exception in its `err` field so event handlers can observe | ||
| or transform the failure. The default workflow event handler re-raises that | ||
| exception, so the CLI error handling described above still decides what the user | ||
| sees. | ||
|
|
||
| ## API flow | ||
|
|
||
| Python callers can use `mlia.api` directly instead of invoking the CLI. The API | ||
| path still validates target profiles, backend selection, backend installation, | ||
| and advisor creation. `run_advisor()` additionally supports returning a | ||
| standardized JSON-compatible dictionary and optional schema validation modes. | ||
|
|
||
| Use the CLI when you want the standard command-line user experience. Use the API | ||
| when another Python tool needs to run MLIA and consume structured results. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| <!--- | ||
| SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates. | ||
| SPDX-License-Identifier: Apache-2.0 | ||
| ---> | ||
|
|
||
| # High-level Architecture | ||
|
|
||
| MLIA is a Python application and library built around one core package and | ||
| installable plugins. The core package owns the shared user experience and | ||
| runtime contracts; plugins add target, backend, converter, or CLI functionality | ||
| through Python entry points. | ||
|
|
||
| Use this page for the static system shape. For plugin loading details, see | ||
| [Plugin Architecture](plugin_architecture.md). For the step-by-step | ||
| `mlia check` path, see [End-to-end Execution Flow](execution_flow.md). | ||
|
|
||
| ## System view | ||
|
|
||
| ```mermaid | ||
| graph TD | ||
| user[User] --> mainCli[mlia] | ||
| user --> backendCli[mlia-backend] | ||
| user --> targetCli[mlia-target] | ||
| automation[Automation or Python caller] --> api[Python API] | ||
|
|
||
| mainCli --> checkCommand[mlia.cli.commands.check] | ||
| mainCli --> cliPlugins[CLI plugin commands] | ||
| checkCommand --> api | ||
|
|
||
| backendCli --> backendCommands[backend install/list/uninstall] | ||
| targetCli --> targetCommands[target list] | ||
|
|
||
| api --> context[ExecutionContext] | ||
| api --> targetRegistry[Target registry] | ||
| api --> backendRegistry[Backend registry] | ||
| api --> backendManager[Installation manager] | ||
| api --> advisorFactory[Target advisor factory] | ||
|
|
||
| targetRegistry --> targetPlugins[Target plugins] | ||
| backendRegistry --> backendPlugins[Backend plugins] | ||
| advisorFactory --> advisor[InferenceAdvisor] | ||
|
|
||
| advisor --> workflow[DefaultWorkflowExecutor] | ||
| workflow --> collectors[Data collectors] | ||
| workflow --> analyzers[Data analyzers] | ||
| workflow --> patterns[Pattern analyzers] | ||
| workflow --> producers[Advice producers] | ||
| workflow --> events[Event publisher and handlers] | ||
|
|
||
| collectors --> backends[Backend tools and services] | ||
| backendManager --> backends | ||
| backendCommands --> backendManager | ||
| targetCommands --> targetRegistry | ||
| producers --> advice[Advice] | ||
| advice --> events | ||
| events --> handlers[Event handlers and reporters] | ||
| handlers --> reports[Console, JSON, and output files] | ||
| ``` | ||
|
|
||
| ## Main runtime layers | ||
|
|
||
| | Layer | Core modules | Responsibility | | ||
| | --- | --- | --- | | ||
| | CLI | `mlia.cli.main`, `mlia.cli.commands`, `mlia.cli.options` | Parse `mlia`, `mlia-backend`, and `mlia-target` commands, create `ExecutionContext`, configure logging and output format, and call command functions. | | ||
| | Public API | `mlia.api` | Validate inputs, resolve targets and backends, ensure required backends are installed, create advisors, optionally return standardized output. | | ||
| | Registries | `mlia.target.registry`, `mlia.backend.registry`, `mlia.plugins.*` | Load plugin entry points once and expose registered target, backend, converter, and CLI capabilities. | | ||
| | Backend management | `mlia.backend.manager`, `mlia.backend.install`, `mlia.backend.config` | Show backend status, install/uninstall backends, resolve dependencies, and provide backend configuration metadata. | | ||
| | Execution context | `mlia.core.context` | Carry advice category, config parameters, output directory, action resolver, event publisher, handlers, and output format. | | ||
| | Advisor/workflow | `mlia.core.advisor`, `mlia.core.workflow` | Build and run the target-specific workflow stages. | | ||
| | Reporting/output | `mlia.core.reporting`, `mlia.core.reporters`, `mlia.core.output_schema`, `mlia.core.output_validation` | Produce human-readable and JSON-compatible results and validate standardized output. | | ||
|
|
||
| ## Ownership boundaries | ||
|
|
||
| The core package should not need target-specific conditionals for every new | ||
| hardware family or converter. Instead: | ||
|
|
||
| - target plugins register target metadata and advisor factories | ||
| - backend plugins register backend configuration and installation metadata | ||
| - converter plugins register named converter callables | ||
| - CLI plugins can append commands to the command list | ||
|
|
||
| This keeps core orchestration stable while allowing target, backend, and | ||
| converter packages to evolve independently. |
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
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
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
2 changes: 2 additions & 0 deletions
2
openspec/changes/add-standard-performance-metrics/.openspec.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| schema: spec-driven | ||
| created: 2026-05-13 |
2 changes: 2 additions & 0 deletions
2
openspec/changes/add-standard-performance-metrics/.openspec.yaml.license
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates. | ||
| SPDX-License-Identifier: Apache-2.0 |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.