Skip to content

Add MLIA NX Learning Path - #3876

Draft
annietllnd wants to merge 3 commits into
ArmDeveloperEcosystem:mainfrom
annietllnd:mlia-nt
Draft

annietllnd wants to merge 3 commits into
ArmDeveloperEcosystem:mainfrom
annietllnd:mlia-nt

Conversation

@annietllnd

Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this is a good start but it's quite hard to follow and understand. The commands used here generic, I feel like a specific example which uses a pre made scenario and also simplified bash commands instead of multi line confusing stuff.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's great feedback. I think some of the multilines will be needed (like changing the GPU settings), but trying to focus on what's important and remove extracirrucular stuff :) Let's jump on a call to discuss in more detail if you have ideas on simplification after this iteration?

--target-profile neural-technology \
--performance \
--profiling-data "nx-demo/captures/$CAPTURE_NAME" \
--output-dir runs/baseline-measured

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it would be good to add the model explorer command in this. Just to say something like this is best viewed with model explorer and then link to another learning path.

layout: learningpathall
---

## Verify ADB and build Scenario Runner

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think a short introductory paragraph could be beneficial before launching into the steps.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great point!

<device-serial> device
```

Your device should appear with the status `device`. If several devices are connected, set `ANDROID_SERIAL` to the intended serial. This workflow assumes that ADB can install APKs and configure GPU debug-layer settings on your device.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Might be worth clarifying the ANDROID_SERIAL refers to an environment variable


Follow the [Scenario Runner Android build instructions](https://github.com/arm/ai-ml-sdk-scenario-runner#building-with-the-script) to build a debuggable Android arm64 APK. This experimental build needs the Android NDK, Android SDK, Gradle, and public SDK source dependencies. Use VGF Library `release/v0.11.0` to match the host tools used here.

Use the unmodified runner with the public Neural Statistics layer. The capture setup enables **Enable GPU debug layers**, selects the runner application, and activates `VK_LAYER_LGL_neural_statistics` through ADB.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This sentence seems a little out of place. Is it an instruction of what the user should do, or a description of the following steps?


Use the unmodified runner with the public Neural Statistics layer. The capture setup enables **Enable GPU debug layers**, selects the runner application, and activates `VK_LAYER_LGL_neural_statistics` through ADB.

## Prepare the baseline scenario on the host

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What does 'baseline' mean here? (Perhaps this is mentioned on previous pages of the LP, I'm afraid I've only read this one page)


## Prepare the baseline scenario on the host

Run the remaining host commands from `mlia-demo` in the same Bash shell, and stop if any command fails. Create a separate environment for the public VGF tools and LiteRT CPU runtime. This keeps their packages separate from the tested MLIA installation:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

" and stop if any command fails." < is this really necessary to say?


## Validate output and capture completion

First, check the device's output against the CPU reference:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As mentioned above, I'm not sure this is necessary.

Captured dispatches: 1; warnings: []
```

The equality check is deliberately strict. If it fails, investigate conversion, bindings, preprocessing, and your driver's documented numerical behavior. Don't silently relax it to make the test pass; assess any accepted tolerance with representative data and application accuracy requirements. Review capture warnings before using the measurements.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This line seems related to the output tensor reference check, rather than the neural statistics capture. Therefore it should probably be moved further up (though as I mentioned above, ideally we could get rid of this entirely)

--output-dir runs/baseline-measured
```

The output is similar to this abbreviated result. The `<measured ...>` placeholders are numeric cycle counts in your run; their values depend on your device and workload:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This LP deals with a specific workload, so saying it "depends on your workload" is confusing.

Showing some representative example values here may be quite useful to give readers confidence that their data is reasonable.

└────────────────┴────────────────────┴────────┘
```

`Status ok` confirms that MLIA analyzed the capture. `Mode measured` and the `neural-technology-profiling-data` producer distinguish these results from the compiler estimates. The command also prints per-entity breakdowns. Some metrics, such as inference time and throughput, can be unavailable; don't interpret a missing value as zero.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"don't interpret a missing value as zero." < not sure this is a useful phrase


The full results are saved in `runs/baseline-measured/mlia-output/mlia-output.json`. Supplying `--profiling-data` selects the measured backend automatically, so don't add `--backend nx-performance-estimator`. Use the complete schema-version-2 capture hierarchy, not the runner's timestamp JSON or a statistics file alone.

This synthetic-input run validates execution and profiling, not model accuracy or representative performance. For benchmarks, follow the [SDK performance guidance](https://github.com/arm/ai-ml-sdk-for-vulkan/blob/main/docs/source/performance.rst) and collect repeated runs under controlled conditions.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a good point, but doesn't really give the user enough guidance on how to use the profiling workflow along with the linked ML SDK documentation.

source mlia-venv/bin/activate
python -m pip install --upgrade pip
python -m pip install \
mlia==0.12.3 \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this can be avoided, mlia-neural-technolody will pull the correct dependency of mlia automatically

Install the backend from the public wheel's bundled payload:

```bash
mlia backend install nx-performance-estimator

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is now optional, it will be installed at first run if not pre-install


Keep the model in your working directory. No model binaries need to be added to the Learning Paths repository.

## Convert the model before analysis

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why the manual step? if converter is installed that will be done automatically

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Think we wanted this to just showcase you can start with other formats too - but makes sense to remove now to simplify

Run a compatibility check on the converted model. Use a dedicated output directory to keep this report separate from performance results:

```bash
mlia check mlia-demo-models/baseline.tosamlir \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

in theory we could skip the conversion to tosamlir and use the tflite here instead, the beauty of MLIA is actually avoid any manual conversion

@annietllnd

Copy link
Copy Markdown
Collaborator Author

Thanks all, all addressed and ready for round 2 :)

`Status ok` confirms that MLIA analyzed the capture. The full results are saved in `runs/baseline-measured/mlia-output/mlia-output.json`.


## (Optional) Inspect the graph with Model Explorer

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This section shows doesn't show how to actually view the performance stats in Model Explorer, which is missing the whole point! The user doesn't need to install model explorer separately, just passing --model-explorer open is all that's needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great point - old ME habits die hard! Updated now

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.

4 participants