Skip to content

Arm backend: Stop re-creating Ethos-U driver objects per inference on Linux - #22599

Open
vacu9708 wants to merge 1 commit into
pytorch:mainfrom
vacu9708:cortex-a-init-once
Open

Arm backend: Stop re-creating Ethos-U driver objects per inference on Linux#22599
vacu9708 wants to merge 1 commit into
pytorch:mainfrom
vacu9708:cortex-a-init-once

Conversation

@vacu9708

@vacu9708 vacu9708 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

On the Cortex-A path, the same driver setup is redone on every inference.

sequenceDiagram
    participant ET as EthosUBackend
    participant CA as Cortex-A platform
    participant K as Kernel driver
    ET->>CA: init()
    loop every execute()
        ET->>CA: execute(inputs)
        CA->>K: create network, weight, intermediate, IFM/OFM buffers<br/>(copies command stream and weights)
        CA->>K: write inputs
        CA->>K: run inference
        K-->>CA: outputs
        CA->>K: free all of them
        Note over K: allocated and freed on every inference
        CA-->>ET: outputs
    end
Loading

Changes

sequenceDiagram
    participant ET as EthosUBackend
    participant CA as Cortex-A platform
    participant K as Kernel driver
    ET->>CA: init()
    CA->>K: create network, weight, intermediate, IFM/OFM buffers<br/>(copies command stream and weights)
    Note over K: allocated once, freed in destroy()
    loop every execute()
        ET->>CA: execute(inputs)
        CA->>K: write inputs
        CA->>K: run inference
        K-->>CA: outputs
        CA-->>ET: outputs
    end
    ET->>CA: destroy()
    CA->>K: free all of them
Loading

This commit creates the driver objects once in platform_init() and keeps them in PlatformState for the lifetime of the loaded method.

invoke_linux_driver() now only writes the inputs, runs the inference, and reads the outputs.

Piece Change
PlatformState Holds the driver objects: network, weight buffer, intermediate buffer, IFM and OFM buffers
invoke_linux_driver() Setup removed; takes const PlatformState& and reuses its objects on each inference
create_driver_objects() The setup part moved out of invoke_linux_driver()

Measurement

These results were measured on the Corstone-1000 A320 FVP (Ethos-U85) using the CPU time report from #22596.
Additionally, I would like to ask if PR #22596, which I used to benchmark this PR, is mergeable as-is.

Model execute() CPU time per inference, before -> after Saved
ResNet8 2.60 -> 0.93 ms 64%
DS-CNN 1.99 -> 0.93 ms 53%
MobileNetV1 0.25 4.35 -> 1.01 ms 77%
DeepAutoEncoder 3.97 -> 0.93 ms 77%
  • Outputs byte-identical and NPU cycle counter unchanged for all four models.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

@pytorch-bot

pytorch-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22599

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 15 Awaiting Approval

As of commit 820f84a with merge base c9eee94 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 8, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Sep 8, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/trunk

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

… Linux

**Problem**
On the Cortex-A path, execute() created the driver objects (the network
and the DMA buffers, including a full copy of the weights) on every
inference.

**Fix**
Create them once in platform_init()
and keep them for the lifetime of the loaded method. Measured on the
Corstone-1000 FVP: 53-77% less CPU time in execute() per inference.

Signed-off-by: Youngsik Yang <vacu9708@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants