ScienceDiscovery
中文 GitHub

Ascend NPU Host Broker Design

This page records the problem background, design boundary, and documentation entry points for the Ascend NPU Broker. Deployment variables, tool contracts, and Runner security boundaries live in the existing topic documents so operational reference and design rationale do not duplicate each other.

1. Background

On the verified Ascend 910B3 host, MindSpore can use the NPU directly on the host. The same probe inside the Runner Bubblewrap namespace fails with a typical error:

Container ID verify failed (session ct_id=0; device ct_id=...)

That measurement was taken with the host's whole /dev visible, and it is what the driver does in that situation rather than a limit on device passthrough: inside a mount namespace the driver enumerates the cards visible under the caller's /dev, all-or-nothing, so a single card claimed by another tenant fails the call for every card.

Chips selected by an operator are therefore handed to the sandbox after all — a fresh /dev carrying only those chips, renumbered from 0 — and npu-smi info and MindSpore both run inside it on this host. See Sandbox execution §3.2 for how that launch is built and how a chip is judged usable.

The Broker below is a separate, opt-in path that remains for allowlisted host workloads which are not ordinary Agent executions.

2. Design boundary

3. Documentation map

Need Document
Enable/disable Broker and .env variables Configuration reference
Model-visible NPU tool and parameters Built-in tools
How selected chips reach the sandbox and how usability is judged Sandbox execution
Why the Broker is a sandbox exception and how it is constrained Sandbox execution
Broker placement in the runtime model Runtime architecture
Default workload allowlist services/runner/workloads/npu-workloads.default.json

4. Extension principles

Broker extensibility comes from registering workload manifests, not from opening arbitrary commands. A new model should add or deploy an allowlist entry while preserving:

Direct NPU passthrough into bwrap may be a future optimization only after a real Ascend operation probe succeeds on that deployment. Probe failure should fall back to the Broker.

5. Known limitations

6. Test entry point

Runner-side NPU Broker tests:

pnpm --filter @sciencediscovery/runner build
node --test --test-name-pattern "NPU Broker" services/runner/dist/server.test.js

Coverage includes default-off behavior, explicit enablement, HMAC submit, workload allowlist, workspace path escape rejection, ${repo:...} realpath boundaries, Protenix workload execution, AF3-intent rejection for the Protenix entry point, artifact collection, and interrupted state after Runner restart.