~kem@1.0 device
The Kernel Execution Machine device
Last updated
The Kernel Execution Machine device
Last updated
The kernel-em
NIF (kernel execution machine - kem@1.0
device) is a HyperBEAM Rust device built on top of to offer a general GPU-instructions compute execution machine for .wgsl
functions (shaders, kernels).
With wgpu
being a cross-platform GPU graphics API, hyperbeam node operators can add the KEM device to offer a compute platform for KEM functions. And with the ability to be called from within an ao process through ao.resolve
(kem@1.0
device), KEM functions offer great flexibility to run as GPU compute sidecars alongside ao processes.
This device is experimental, in PoC stage
KEM function source code is deployed on Arweave (example, double integer: ), and the source code TXID is used as the KEM function ID.
A KEM function execution takes 3 parameters: function ID, binary input data, and output size hint ratio (e.g., 2
means the output is expected to be no more than 2x the size of the input).
The KEM takes the input, retrieves the kernel source code from Arweave, and executes the GPU instructions on the hyperbeam node operator's hardware against the given input, then returns the byte results.
As the kernel execution machine (KEM) is designed to have I/O as bytes, and having the shader entrypoint standardized as main
, writing a kernel function should have the function's entrypoint named main
, the shader's type to be @compute
, and the function's input/output should be in bytes; here is an example of skeleton function:
Uniform parameters have been introduced as well, allowing you to pass configuration data and constants to your compute shaders. Uniforms are read-only data that remains constant across all invocations of the shader.
Here is an example of a skeleton function with uniform parameters:
Using the image glitcher kernel function -
device source code:
hb device interface:
nif tests:
ao process example: