Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

virtio-accel logo

CI Crates.io docs.rs GitHub last commit License: MIT OR Apache-2.0 MSRV: Rust 1.85+ no_std supported

virtio-accel defines a protocol and contains executable no_std guest, device, transport, queue, and TOSA layers for exposing an accelerator to a guest: contexts, buffers, programs, execution queues, submissions, and events.

Actual Intel NPU image generation: a trained FP16 digit decoder, with CPU, GPU and NPU round-trip measurements
Learned image generation through the Python SDK. Actual NPU output; animation playback is illustrative.

Run the inference showcase · Watch the video · Measurement details · Earlier Kerr demo

An experimental Linux vhost-user host and QEMU Virtio MMIO binding is available, using development device ID 65535 with a patched QEMU frontend. No official Virtio device ID has been assigned. The vAccel adapter remains available for vAccel environments. virtio-accel is currently pre-standardization; protocol 1.0 is frozen as a versioned review input for independent implementation — it is stable enough to build against and to disagree with in writing, not an approved Virtio specification.

The experimental Linux guest driver lets the Python SDK inside QEMU use the host accelerator through devices(provider="virtio"), with a booted Linux integration test and vendor runtimes kept on the host.

Backend support

“Supported” below means that the backend admits the declared program and dtype and exercises it end-to-end; support in the TOSA parser or shared numerical corpus alone does not imply hardware execution. “Not implemented” describes this repository, not necessarily the underlying hardware.

This table is organized by program and dtype. For the physical devices behind it — which parts are validated on hardware, which are merely reachable, and which still need implementation, including the non-NPU CPU and GPU paths Core ML and OpenVINO already expose — see the device support matrix.

BackendStatus / program admissionFP32FP16BF16FP8 E4M3/E5M2INT8 / INT32Program-visible buffers
Apple Core ML / GPU / ANE (virtio-accel-coreml)macOS 14+ floating tier; macOS 26+ integer, FP8 and mixed tiersSupportedSupportedNot implementedPacked storage, casts and widened MATMULIdentity + bounded MATMUL → INT32Direct host/shared bindings
Intel OpenVINO (virtio-accel-openvino)OpenVINO 2026.x; static TOSA floating, integer, FP8 and mixed tiersSupported, device dependentSupportedNot advertisedStorage, casts and widened tier; device-probedIdentity + bounded MATMUL → INT32Direct host/shared bindings
AMD XDNA (virtio-accel-xdna)Experimental; HRX on XDNA2Accumulator outputs onlyNot implementedIdentity, MATMUL → FP32, MAX_POOL2DE4M3/E5M2 → BF16 CASTIdentity + MATMUL → INT32 + RESCALEDirect host/shared bindings
Qualcomm Hexagon (virtio-accel-hexagon)Experimental; QAIRT 2.49 on Windows ARM64Blocked by v73 precision evidence41/42 shared operators (ERF blocked)Not implementedBlocked: ambiguous encodingIdentity + MATMUL → INT32Direct host/shared bindings
Vulkan (virtio-accel-vulkan)Experimental; Vulkan 1.3 loaderSupportedSupportedNot implemented11-operator tier (ADR 0009)INT32 auxiliaries; INT8 target not advertisedDirect host/shared/device bindings

Low-bit weight formats have separate execution and storage contracts:

BackendConstant INT4/INT8 weights, FP16 activationsFour-bit palette weightsRuntime NVFP4 E2M1 weights + E4M3 block scales
Core ML (macOS 26+)Native compressed constants; policy-dependent placementFP16 palettes via native lookup compressionFP16/FP32 projections; packed inputs, graph decoding
OpenVINOGPU compressed INT4/INT8 path; CPU/NPU predecode constants to FP16Not implementedFP16/FP32 on CPU/GPU; FP16 on validated Lunar Lake NPU
XDNANot implementedNot implementedNot implemented
HexagonNot implementedNot implementedNot implemented
VulkanNot implementedNot implementedNot implemented

Constant weight formats require program reload when weights or scales change. NVFP4 weights/scales can change per invocation; packed inputs do not promise native FP4 arithmetic or compressed resident intermediates. TOSA INT4 tensor execution remains unimplemented across these backends. Core ML/OpenVINO integer MATMUL admission bounds the worst-case absolute dot-product sum to 2**24 to preserve exact results (K <= 1024 with zero zero-points); compressed FP16 weight projections are a separate tier.

Core ML (Apple GPU and Neural Engine)

  • Execution: Explicit CPU/ANE, CPU/GPU and combined CPU/GPU/ANE policies. Core ML chooses per-operation placement; combined mode does not guarantee simultaneous GPU/ANE use. FP32 NeuralNetwork graphs exclude ANE to preserve precision (CPUOnly under CPU/ANE, CPU/GPU under combined mode). FP16 retains the full policy. The support table refers to model-boundary dtypes; restricted INT32 outputs are also available.
  • INT8: Direct INT8 model boundaries require macOS 26+ and support identity plus zero-point-aware MATMUL with INT32 output, subject to the exactness bound above.
  • FP8 and packed weights: macOS 26+ adds E4M3/E5M2 storage/casts, widened MATMUL, explicit NVFP4 projections, and immutable INT4/INT8 or palette weight compression. FP8 storage uses byte carriers; decoding stays in the submitted graph. See ADR 0014 and ADR 0016.
  • Explicit limits: TOSA INT4 tensors and unsupported integer operators are rejected. Compression and compute-policy selection do not guarantee GPU/ANE placement or speedup.

See the virtio-accel-coreml support boundary.

OpenVINO (Intel NPU/GPU/CPU)

  • Execution: The backend compiles separately for each available device—NPU, then GPU, then CPU by default—using OpenVINO’s accuracy-preserving mode. A submission completes only after the runtime writes into the caller’s output allocation.
  • INT8: Direct INT8 model boundaries are supported; MATMUL uses explicit INT32 zero-point legalization and the exactness bound above. Restricted INT32 outputs are also available.
  • FP8 tier: E4M3/E5M2 storage, activations and weight constants are supported on devices that pass the native compilation probe. CPU/GPU pass the activation/cache tests; the validated Lunar Lake NPU withholds this tier. Sharing a TOSA target with another backend does not imply identical graph admission. MATMUL widens operands to FP16; pooling widens around the window. Exact FP32 casts, cache windows and pure storage graphs use byte carriers, preserving storage bits without host-side conversion. See ADR 0009 and ADR 0014.
  • Packed weights: Constant INT4/INT8 projections keep FP16 activations. GPU compilation can retain compressed weights; CPU/NPU expand constants once at load time with explicit FP16 rounding. Runtime NVFP4 uses separate packed E2M1 weights, E4M3 block scales and a tensor scale; CPU/GPU support FP32 and FP16, while the validated Lunar Lake NPU supports the FP16 variant.
  • Runtime: NPU and GPU require their Intel Level Zero driver or compute runtime. The CPU plugin is exercised in CI.
  • Explicit limits: TOSA INT4 tensors and unsupported integer operators remain rejected. FP8 elementwise arithmetic requires explicit widening; CPU/NPU constant expansion carries no compressed-residency claim.

See the virtio-accel-openvino support boundary.

Hexagon (Qualcomm Snapdragon X126100/QAIRT 2.49)

  • Evidence scope: The supported configuration is Snapdragon X126100 with QAIRT 2.49 on Windows ARM64.
  • FP16: 41 of the 42 operators shared by Core ML and OpenVINO work. ERF is excluded because QAIRT’s public operation definitions provide no ERF node.
  • INT8: Exact identity and zero-point-aware MATMUL are supported, with INT32 output.
  • Explicit limits: FP32 is rejected because the v73 probe observed FP16-rounded MATMUL even for FLOAT_32 tensors. FP8 is rejected because this client path has no unambiguous E4M3/E5M2 QAIRT selector. A missing complete SDK reports RuntimeUnavailable.

See the virtio-accel-hexagon support boundary and the operator matrix.

XDNA/2 (AMD XDNA2 NPU over HRX runtime)

  • Execution: The backend uses HRX-owned buffers and a serialized dispatch worker; submitted program buffers bind directly, without a submission-time bounce copy.
  • BF16: IDENTITY, BF16→FP32 MATMUL, and NHWC MAX_POOL2D are implemented within documented static shape envelopes. FP32 is exposed only where TOSA requires the MATMUL accumulator output; FP32 and FP16 arithmetic are rejected.
  • FP8 storage: Explicit TOSA CAST from E4M3 or E5M2 to BF16 runs on the NPU and is bit-exact for every finite value. NaN payload canonicalization is permitted. FP8 arithmetic is not advertised.
  • INT8: Exact identity, zero-point-aware MATMUL with INT32 output, and signed per-tensor INT32→INT8 RESCALE are supported. The CONST/IDENTITY/MATMUL baseline mirrors OpenVINO; RESCALE is an intentional released-TOSA expansion needed to turn exact accumulator output back into INT8. XDNA admission adds a one-core static memory envelope and explicit four-byte DMA slot padding where a logical tensor is not word-sized.
  • Runtime: Native execution requires the pinned amdxdna-native HRX runtime and compiler toolchain. Portable admission and offline artifact compilation remain available without a device.

Vulkan (FP32, FP16, and FP8 tiers on any Vulkan 1.3 compute device)

virtio-accel-vulkan is a vendor-neutral Vulkan 1.3 compute backend bound through the pinned ash crate with run-time loader discovery. It admits static single-block TOSA 1.0 graphs over the same 42 FP32-tier operators Core ML and OpenVINO share — elementwise, activation, comparison and logical, reduction, ARGMAX, MATMUL, MAX_POOL2D, and data-movement operators with BOOL and INT32 auxiliaries — and executes a whole graph as one submission: crate-authored SPIR-V kernels specialized at load_program, constants and intermediates in a per-program arena, compute barriers between dependent dispatches. Buffers are dedicated directly bound storage buffers in Host/Shared/Device memory domains; completion is a bounded per-context ring polled through vkGetFenceStatus.

  • Numerics: every float operation is NoContraction; SIN, COS, TANH, and ERF are crate-authored range reductions and polynomials (Payne–Hanek beyond |x| = 8192) rather than the driver’s loosely specified built-ins; NaN modes follow the TOSA pseudocode literally. MATMUL is a register-tiled shared-memory kernel, or a split-k streaming kernel for eight rows or fewer, accumulating in binary32 with fused multiply-add — within a stated bound of the exact sum and deterministic per device (ADR 0011).
  • FP16 tier (ADR 0008): the same 42 operators over binary16 tensors, advertised on every device the backend opens — the tier needs no device feature. Packed binary16 tensors are unpacked and widened to binary32 by crate-owned integer code, the float lanes evaluate in binary32 — the implementation choice TOSA 1.0 §1.10.3 names explicitly, and the correctly rounded binary16 result for ADD/SUB/MUL — and results narrow back through crate-owned round-to-nearest-even code that produces subnormals on every device. NEGATE/ABS are integer sign operations and data movement copies lanes as integers, both exact for every bit pattern; MATMUL and reductions accumulate in binary32 (the accumulator width TOSA assigns FP16). Numerics are bit-identical across devices by construction for every operator but MATMUL, whose fused multiply-add is deterministic per device.
  • FP8 tier (ADR 0009): a separate target, because TOSA gates FP8 on the FP8E4M3 and FP8E5M2 extensions rather than the base floating-point profile, carrying eleven operators: TOSA’s (FP8, FP8) -> FP16 MATMUL over either encoding, CAST in both directions, MAX_POOL2D, ARGMAX, and exact data movement. It is a subset rather than the shared 42 because TOSA admits no FP8 elementwise operator at all — no arithmetic, comparison, selection, reduction or transcendental lane takes FP8. Like the FP16 tier it needs no device feature: packed bytes widen to binary32 by crate-owned integer code — every FP8 value is representable in binary32, so the widening is exact — and nothing writes FP8 except a raw byte copy, so the tier is advertised on every device the backend opens and its numerics cannot vary by device. Float-to-FP8 overflow is this crate’s policy rather than TOSA’s, which leaves it undefined: a value too large for E4M3 becomes NaN, because saturation stays expressible as a CLAMP before the cast while a saturated 448 would be indistinguishable from a genuine one.
  • Constraints: MATMUL and NEGATE admit zero zero-points only, MUL a zero shift, and RESHAPE a constant shape (the TOSA 1.0 CONST-producer forms).
  • Evidence: the shared FP32 operator corpus, the conformance suite, and the kernel-level tests pass on Mesa lavapipe in CI; on 2026-09-06 on Intel Arc 140V (Lunar Lake, Mesa 26.0.8 ANV, Vulkan 1.4.335) and the same host’s llvmpipe (LLVM 21.1.8); on 2026-09-08 on AMD Radeon 860M (Krackan Point, RADV Mesa 26.1.8, Vulkan 1.4.354), which also runs clean under Khronos synchronization validation in every advertised memory domain; and on 2026-09-17 on Apple M4 via MoltenVK 1.4.2. sin/cos/tanh land within 1 ulp and erf within 2 ulp of binary64 on every one. The FP16 corpus — every bit-exact case, the ulp-tolerated groups, an exhaustive 65536-pattern NEGATE round trip, the higher-precision lanes within 1 ulp of the binary64 references over the whole finite binary16 domain, and the subnormal-arithmetic probe — passes on Apple M4 via MoltenVK 1.4.2 and, against the final kernels, is owed the confirmation runs on Intel Arc LNL (Mesa ANV) and AMD Radeon 860M (RADV), whose earlier runs passed the corpus identically. The FP8 corpus — all 256 patterns of both encodings through IDENTITY bit-for-bit, MATMUL against a widened host reference with input and with constant operands, CAST round-tripping every encoding in both directions and honouring the overflow policy, two FP8 matmuls chained through a CAST, and MAX_POOL2D/ARGMAX — passed on 2026-09-18 on Intel Arc B390 (Panther Lake, Mesa 26.0.8 ANV), independently on a Lunar Lake host (Xe2, Mesa ANV), and on an Apple M3 via MoltenVK, in every advertised memory domain with identical results; all 170 assembled kernel variants pass spirv-val --target-env vulkan1.3. INT8 gating remains under the Vulkan wayfinder map; design decisions are recorded in docs/adr/ (ADR 0007 covers the FP32 tier, ADR 0008 the FP16 tier, ADR 0009 the FP8 tier).

TOSA 1.0

Independently of backend execution, virtio-accel-tosa validates the declared TOSA 1.0 profiles and dtype extensions, and virtio-accel-conformance ships shared fixtures and oracles for them. virtio-accel-tosa-build provides matching borrowed and incrementally owned safe authoring paths for static single-block graphs and validates every result through that ingestion boundary. The byte-oriented virtio-accel-mock backend remains test infrastructure rather than a typed hardware implementation.

Workspace

CrateTierDescription
virtio-accel-vaccelcoreAdapter seam for mapping native provider contracts (including vAccel-style backends) to virtio-accel-core
virtio-accel-coremlstdTOSA-to-Core ML lowering, direct buffers, and asynchronous GPU/ANE-capable prediction
virtio-accel-openvinostdTOSA-to-OpenVINO IR lowering, direct host-pointer tensors, and asynchronous NPU/GPU/CPU inference
virtio-accel-vulkanstdVendor-neutral Vulkan 1.3 compute backend over ash: crate-authored SPIR-V kernels, direct storage-buffer binding, and the shared FP32 plus native FP16 and FP8 operator tiers
virtio-accel-xdnastdAMD XDNA2 NPU backend over HRX with direct buffers, asynchronous dispatch, and strict BF16/FP8/INT8 TOSA tiers
virtio-accel-hexagonstd (Windows ARM64)Strict FP16/INT8 TOSA-to-QNN lowering, direct buffers, and asynchronous Hexagon HTP execution
virtio-accelcore + allocFacade re-exporting the portable layers
virtio-accel-protocorePointer-free, little-endian protocol 1.0 wire structures
virtio-accel-transportcoreDependency-free descriptor-chain, queue, reset, and notification ports
virtio-accel-corecoreBackend lifecycle, memory, program, queue, and event contracts
virtio-accel-tosacore + allocBounded zero-copy TOSA 1.0 validation, lowering analysis, specialization, and packed low-precision utilities
virtio-accel-tosa-buildcore + allocBorrowed and incrementally owned static TOSA 1.0 authoring with mandatory validation round trips
virtio-accel-split-queuecore + allocBounded in-memory split-ring reference model
virtio-accel-shared-queuecoreBoth halves of the split ring over memory a driver and a device share, behind a platform-supplied memory trait
virtio-accel-guestcore + allocTyped reference client with bounded request tracking
virtio-accel-devicecore + allocDevice-owned state, including bounded generational IDs
virtio-accel-mockstdIn-memory backend with deterministic test-only artifacts and scripted faults
virtio-accel-conformancestdTransport-free semantic suite and shared FP32/FP16/FP8/INT8/INT4 numerical TOSA corpus
virtio-accel-cleanroomcoreIndependent conformance codec, written without the shared protocol types

Dependency graph

virtio-accel-split-queue ---> virtio-accel-transport
virtio-accel-shared-queue --> virtio-accel-transport
                                      ^
                                      |
virtio-accel-device ----------+-------+------> virtio-accel-core
          |
          +-----> virtio-accel-proto

virtio-accel-guest -----------> virtio-accel-transport
          |
          +--------------------> virtio-accel-proto

virtio-accel-conformance --------------------> virtio-accel-core
virtio-accel-tosa ---------------------------> virtio-accel-core
virtio-accel-tosa-build ---------------------> virtio-accel-tosa
virtio-accel-xdna ---------+--------------> virtio-accel-core
                              |
                              +--------------> virtio-accel-tosa
virtio-accel-coreml ----------+--------------> virtio-accel-core
                              |
                              +--------------> virtio-accel-tosa
virtio-accel-openvino --------+--------------> virtio-accel-core
                              |
                              +--------------> virtio-accel-tosa
virtio-accel-vulkan ----------+--------------> virtio-accel-core
                              |
                              +--------------> virtio-accel-tosa
virtio-accel-hexagon ---------+--------------> virtio-accel-core
                              |
                              +--------------> virtio-accel-tosa
virtio-accel-vaccel -----------------------> virtio-accel-core
other provider adapters --------------------> virtio-accel-core

The transport crate exposes reset-scoped chain identities, flattened direction/length metadata, and owned publication/completion tokens. Neither it nor the device-state layer leaks guest addresses, ring pointers, or concrete descriptor types into the command engine or provider backend.

Python SDK

The experimental Python SDK provides NumPy-style tracing, TOSA export and explicit native execution across the available accelerator backends. It exposes FP16/BF16/FP32, FP8 E4M3FN/E5M2 and INT8/INT32 storage, with explicit operation limits. The virtio_accel.quantized API authors INT4/INT8, palette and runtime NVFP4 projections through the same jit and execution interface. Python authoring support does not expand a backend’s admission tier.

python -m pip install virtio-accel==0.1.0a2

Start with the Python guide and generated API reference. Backend runtimes and supported dtypes vary by platform; Windows ARM64/Hexagon currently requires a source build with QAIRT rather than a PyPI wheel.

Install

[dependencies]
virtio-accel = "0.5"

The facade is no_std. Add the reference backend as a dev-dependency to run the example below:

[dev-dependencies]
virtio-accel-mock = "0.5"

Host backends are separate dependencies and are never re-exported by the portable facade. Add virtio-accel-coreml = "0.5" on an ANE-capable Mac, virtio-accel-openvino = "0.5" on a host with OpenVINO 2026.x, or virtio-accel-vulkan = "0.5" on a supported host with a Vulkan 1.3 loader and compute device. Each accepts the device-neutral TOSA 1.0 program format and owns its provider-specific validation, lowering, and execution path.

For portable adapter-boundary validation while the native vAccel path is wired, add virtio-accel-vaccel = "0.5". The crate exposes a vAccel seam with an in-repo representative conformance recipe and explicit copy-path diagnostics.

Adapter profiles

  • Portable-only profile: use virtio-accel (+ virtio-accel-mock) to keep all portable layers and conformance fixtures inside the workspace.
  • Adapter profile: add virtio-accel-vaccel when you need an adapter seam for native/vAccel-like implementations that still re-export the Accelerator contract from virtio-accel-core.
  • Production host profile: add virtio-accel-coreml, virtio-accel-openvino, virtio-accel-hexagon, virtio-accel-xdna, and/or virtio-accel-vulkan instead of any mock backend once provider licensing and native runtime availability are in place.

virtio-accel-hexagon = "0.5" exposes the separate Qualcomm adapter. A complete QAIRT/QNN SDK on Windows ARM64 enables its HTP backend; SDK-free builds validate its strict FP16 graph planner and constructors return RuntimeUnavailable.

virtio-accel-vulkan = "0.5" loads the platform Vulkan loader at run time. It admits the shared FP32 and FP16 operator tiers (with BOOL/INT32 auxiliaries) and a separate eleven-operator FP8 tier. It returns RuntimeUnavailable or DeviceUnavailable when no suitable Vulkan 1.3 compute path exists; it does not silently fall back to the mock backend.

Add virtio-accel-tosa = "0.5" separately to validate TOSA 1.0 artifacts, inspect safe borrowed graph and typed-attribute views, enforce complete stable-op semantics for a declared target, and construct the device-neutral TOSA artifact envelope. Model::analyze_for also produces bounded dense IDs, topological order, liveness, runtime obligations, and specialization keys for Core ML, OpenVINO, or another provider. It is intentionally not re-exported by the facade.

Add virtio-accel-tosa-build = "0.5" to produce static single-block TOSA artifacts through typed tensor and operator definitions. Borrowed definitions suit graph literals; owned definitions let compiler frontends assemble runtime-discovered metadata without a parallel owned-to-borrowed adapter, while existing constant storage can remain borrowed. Both surfaces pass the same parser and target validator providers use at admission.

Production backend examples

On macOS 14+ with an accessible Apple Neural Engine, the backend-local example sends a TOSA 1.0 IDENTITY graph through the real lowering, compilation, direct-binding, asynchronous prediction, and teardown path:

cargo run -p virtio-accel-coreml --example tosa_coreml
TOSA -> Core ML -> ANE-capable result: 3.25

On a Linux host with an OpenVINO 2026.x runtime, the equivalent backend-local example executes the same graph on the preferred available Intel inference device (NPU, then GPU, then CPU):

cargo run -p virtio-accel-openvino --example tosa_openvino
TOSA -> OpenVINO -> CPU result: 3.25

With the documented QAIRT environment, the Qualcomm adapter’s example executes FP16 identity on HTP and verifies the shared numerical oracle. SDK-free builds fail explicitly without a CPU/GPU fallback:

cargo run -p virtio-accel-hexagon --example tosa_hexagon
cargo run -p virtio-accel-hexagon --example mock_classifier

On any supported host with a Vulkan 1.3 loader and compute-capable device, the Vulkan example runs the FP32 identity artifact on the preferred device (discrete, integrated, virtual, then CPU). It reports a clean skip when no loader or device is available:

cargo run -p virtio-accel-vulkan --example tosa_vulkan

The portable facade, device engine, transport, and guest layers see only the TOSA artifact format, target identity, and opaque bytes. Provider objects, shaders, generated models, native runtimes, and FFI bridges remain owned by their adapter crates.

Portable lifecycle example

A full submission against the in-memory reference backend — allocate a buffer, load an artifact, bind it to a slot, submit, and observe the event:

#![allow(unused)]
fn main() {
use virtio_accel::core::{
    Accelerator, AccessMode, ArtifactRef, BindingRef, BufferDesc, BufferRange, BufferUsage,
    ContextDesc, EventState, MemoryDomain, QueueDesc, SubmitFailure, Timeout,
};
use virtio_accel_mock::{MockAccelerator, reference};

let backend = MockAccelerator::default();
let context = backend.create_context(ContextDesc::default())?;

// An 8-byte shared buffer the program may read and write.
let desc = BufferDesc::new(
    8,
    8,
    MemoryDomain::Shared,
    BufferUsage::TRANSFER_SOURCE
        | BufferUsage::TRANSFER_DESTINATION
        | BufferUsage::PROGRAM_INPUT
        | BufferUsage::PROGRAM_OUTPUT
        | BufferUsage::MUTABLE_STATE,
)?;
let (mut buffer, _) = backend.allocate_buffer(&context, desc)?.into_parts();
backend.write_buffer(&mut buffer, 0, &[0x00, 0x11, 0x7f, 0x80, 0xa5, 0xff, 0x3c, 0xc3])?;

// A deterministic test-only artifact: XOR every byte bound to slot 7 with 0x5a.
let artifact = reference::ReferenceArtifact::xor(7, 0x5a);
let program = backend.load_program(
    &context,
    ArtifactRef {
        format: reference::ARTIFACT_FORMAT,
        target: reference::TARGET_IDENTITY,
        payload: artifact.as_bytes(),
        resident_bytes: reference::RESIDENT_BYTES,
    },
)?;
let queue = backend.create_queue(&context, QueueDesc::default())?;

let bindings = [BindingRef {
    slot: 7,
    buffer: &buffer,
    range: BufferRange::new(0, 8)?,
    access: AccessMode::ReadWrite,
}];

// Submission is asynchronous at the ownership boundary, so it always yields an event.
let event = backend
    .submit(&queue, &program, &bindings, Timeout::Infinite)
    .map_err(|failure| match failure {
        SubmitFailure::Rejected(error) | SubmitFailure::Indeterminate { error, .. } => error,
    })?;
assert_eq!(backend.poll_event(&event)?, EventState::Pending);

// The mock backend runs under harness control, so the caller drives completion.
backend.complete(&event)?;
assert_eq!(backend.poll_event(&event)?, EventState::Complete);

let mut output = [0_u8; 8];
backend.read_buffer(&buffer, 0, &mut output)?;
assert_eq!(output, [0x5a, 0x4b, 0x25, 0xda, 0xff, 0xa5, 0x66, 0x99]);
}

Every object is released explicitly, and a release can itself fail; see examples/reference_execution.rs for the teardown path.

cargo run --example reference_execution

Protocol 1.0

The protocol defines fixed headers and payloads for device discovery, contexts, buffers, programs, execution queues, submissions, and events. Two properties shape most of the API:

  1. Unknown values stay raw. Unrecognized opcodes, statuses, and event states remain integers until validated, so decoding untrusted bytes never constructs an invalid Rust enum.
  2. Failure still returns an event. A successful submit returns an event; an indeterminate failure must also return one, because the operation’s resources are still owned by the device. Guest-visible object IDs are opaque, kind-tagged, generational, and never reused after generation exhaustion.

The primary zerocopy ABI and the manual clean-room codec both decode and re-encode every canonical frame. Their bridge test exchanges bytes only, providing an independent implementation check without making the conformance codec a production dependency.

Non-Rust device and driver implementations can include include/virtio_accel.h. The header is a packed C projection of the wire contract, not a host backend plugin ABI. CI compiles it as C11 and C++11 and derives constant, size, alignment, and offset assertions from the frozen layout manifest.

Writing a backend

Implement the Accelerator contract from virtio-accel-core, then run the standard semantic suite against it. The suite is transport-free: no wire format, virtqueue, OS, or vendor dependency.

cargo run --example backend_conformance
memory.shared: Passed
buffer.transfer-permissions: Passed
submission.context-isolation: Passed
event.cancellation-races: Passed
accounting.resource-lifecycle: Passed
...

The backend implementer guide walks through the hooks, the optional resource-accounting and progress adapters, and the fault-injection harness.

Documentation

DocumentCovers
specification.mdNormative terminology, object model, compatibility rules, mandatory baseline
wire-abi.mdExact byte layouts and the coordinated change procedure
virtio_accel.hChecked C and C++ projection of the protocol 1.0 wire contract
virtqueue.mdCommand-chain rules
architecture.mdImplementation invariants
threat-model.mdTrust boundaries and finite resource policy
portability.mdEnforced target matrix and crate tiers
device-support-matrix.mdPhysical devices each backend reaches, and the named gate holding back the rest
performance.mdv1 performance and copy budgets
public-api.mdPublic rustdoc policy
release-policy.mdRelease governance and evolution rules
backend-implementer-guide.mdRunning the semantic suite against a new backend
releases/v1.0.mdProtocol 1.0 release note
conformance/v1.0Golden artifacts, canonical frames, and the freeze audit
CONTRIBUTING.mdDevelopment gates, protocol change classification, and scope boundaries
CODE_OF_CONDUCT.mdExpected conduct in project spaces
SECURITY.mdReporting a vulnerability

Portability

Project-authored portable and reference code forbids or denies unsafe code. The TOSA crate confines official generated FlatBuffers accessors to a private module behind bounded verification, while the five host backends isolate audited native FFI behind their host/runtime gates. CI enforces each portability tier, including compile-only checks of every adapter’s unsupported-platform surface.

TierAllowed runtime surface
corecore only; no allocation
core + alloccore + alloc; no OS, filesystem, sockets, threads, or host synchronization
stdPortable std; no host-OS or vendor-specific API
host-nativeCore ML, OpenVINO, QNN, HRX, or Vulkan behind an adapter-specific runtime gate

Concrete VMM, kernel, OS, and vendor adapters do not change the portable v1 protocol and must not become default dependencies of a portable crate. Cargo features must be additive: disabling default features may remove convenience behavior, but must never select a different protocol interpretation.

Development

Minimum supported Rust version is 1.85 (edition 2024), checked in CI.

cargo fmt --all -- --check
python3 ci/check-release-policy.py
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --workspace --all-targets --all-features
cargo run --example backend_conformance
cargo run --example reference_execution
cargo run -p virtio-accel-coreml --example tosa_coreml # macOS 14+ with ANE
cargo run -p virtio-accel-openvino --example tosa_openvino # Linux with OpenVINO 2026.x
cargo run -p virtio-accel-hexagon --example tosa_hexagon # Windows ARM64 with the documented QAIRT setup
cargo run -p virtio-accel-hexagon --example mock_classifier # FP16 linear classifier on Hexagon HTP
cargo run -p virtio-accel-vulkan --example tosa_vulkan # Vulkan 1.3 loader and compute device
python3 ci/publish-dry-run.py

Target checks need the corresponding standard libraries:

rustup target add aarch64-unknown-none riscv64gc-unknown-none-elf wasm32-unknown-unknown

Benchmarks

The separate Divan benchmark suite measures graph preparation, model loading, buffer transfers and native backend execution with validated outputs and captured provenance.

Status

Included in protocol 1.0:

  • one command virtqueue at index zero
  • device discovery and exact protocol compatibility checks
  • contexts, buffers, opaque programs, execution queues, submissions, and events
  • bounded explicit buffer transfers
  • event polling, optional cancellation, release, reset, and backend-discard recovery
  • direct-binding requirements for program-visible buffers
  • checked finite limits for untrusted byte counts, descriptor counts, object counts, and retained backend storage
  • an independent clean-room codec and a transport-free semantic conformance suite

Reserved and unadvertised — an implementation that advertises one of these is not 1.0 conformant until a future version assigns its negotiation, ownership, synchronization, and conformance rules:

  • multi-queue and event queues
  • external memory import/export
  • timeline fences
  • secure contexts
  • packed virtqueues
  • protocol-level negotiation for additional VMM, kernel, OS, and vendor integrations
  • a standardized graph IR, compiler, or executable format

Protocol 1.0 numeric opcodes, statuses, and payload layouts are frozen for the portable v1.0 baseline by the final freeze audit. Future changes must follow the coordinated change procedure in wire-abi.md and the release and evolution policy; incompatible changes require a new protocol major version.

Contributing

Contributions are welcome, including disagreement with frozen decisions — a reasoned objection is worth more than a workaround built on top of one. See CONTRIBUTING.md for the local gates, the scope boundaries, and how wire changes are classified before code is merged.

Citation

If virtio-accel supports your work, use GitHub’s Cite this repository control. The canonical citation metadata is in CITATION.cff.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Contributions are dual-licensed on the same terms, with no separate CLA.