Is it possible to create a virtual NPU device on macOS using Hypervisor.framework + CoreML?

Is it possible to expose a custom VirtIO device to a Linux guest running inside a VM — likely using QEMU backed by Hypervisor.framework. The guest would see this device as something like /dev/npu0, and it would use a kernel driver + userspace library to submit inference requests.

On the macOS host, these requests would be executed using CoreML, MPSGraph, or BNNS. The results would be passed back to the guest via IPC.

Does the macOS allow this kind of "fake" NPU / GPU

Answered by Engineer in 851755022

There is no limit, it's up to you.

The Hypervisor.framework interface exposes the primitives to virtualize CPU and memory.

The device emulation is written on top of the Hypervisor.framework APIs by the various virtual machine applications on macOS.

The device emulation, such as done by QEMU, can expose macOS capabilities as long as you write a virtual device, and a Linux driver for it.

Exposing MPSGraph and BNNS is likely easier than for Linux since they are lower level primitives. Exposing CoreML would require some more work to expose proxy APIs in Linux.

There is no limit, it's up to you.

The Hypervisor.framework interface exposes the primitives to virtualize CPU and memory.

The device emulation is written on top of the Hypervisor.framework APIs by the various virtual machine applications on macOS.

The device emulation, such as done by QEMU, can expose macOS capabilities as long as you write a virtual device, and a Linux driver for it.

Exposing MPSGraph and BNNS is likely easier than for Linux since they are lower level primitives. Exposing CoreML would require some more work to expose proxy APIs in Linux.

Is it possible to create a virtual NPU device on macOS using Hypervisor.framework + CoreML?
 
 
Q