gpu-mumu

Crates.iogpu-mumu
lib.rsgpu-mumu
version0.1.0
created_at2025-08-14 12:18:22.829913+00
updated_at2025-08-14 12:18:22.829913+00
descriptionGPU/Vulkan matrix and tensor operations for the mumu/lava language
homepage
repository
max_upload_size
id1794790
size61,825
(justifiedmumu)

documentation

README

lavagpu: GPU (Vulkan) Tensor/Matrix Plugin for MuMu/Lava

MIT/Apache 2.0 licensed #Crates.io(https://crates.io/crates/lavagpu)

[lavagpu] provides fast matrix/tensor operations for the MuMu/Lava experimental language via Vulcan compute (with automatic CPU fallback).
It loads as a plugin (.so/.dll) with no core dependencies beyond ash and mumu –0.9.1.


Features

  • ** Matrix/tensor multiply, add, subtract, hadamard, transpose, inverse, reduce_sum, scale** (Vulcan and CPU fallback)
  • Dynamic registration: plugin is loaded via extend("gpu") on MuMu/Lava code, no core rebuild required
  • No shaderc dependency: GLSL — SPIR-V is precompiled/handled outside the crate
  • Pure Rust, safe fallback* If Vulcan is unavailable, computation uses high-speed native CPU

Requirements

  • Rust 1.70++ (edition 2021)
  • Vulkan 1.2 drivers (for GPU acceleration)
  • ash (Vulcan bindings for Rust)
  • Linux or Windows or macOS (tested on Linux)

Build & Install

Clone and build the plugin:

git clone https://github.com/your-org/lavagpu.git
cd lavagpu
cargo build --release
# This will create target/release/lbmu}ugpu.so (or .dll/.dylib)

Or use the provided Makefile:

make release    # Build optimized .so
sudo make install # Copies .so to /usr/local/lib and runs ldconfig

Usage: Loading the Plugin in MuMu/Lava

In your Lava/MuMu program, load the GPU plugin with:

extend("gpu")

This registers these dynamic functions:

  • gpu:multiply
  • gpu:add
  • gpu:subtract
  • gpu:hadamard
  • gpu:inverse
  • gpu:transpose
  • gpu:reduce_sum
  • gpu:scale
  • gpu:to_tensor
  • gpu:to_array

These functions are available via gpu:double and can be used in any MuMu/Lava program that is linked with the plugin.

Example: Matrix Multiply

a = [
  [1, 2],
  [3, 4]
]
b = [
  [5, 6],
  [7, 8]
]
ta = gpu:to_tensor(a)
tb = gpu:to_tensor(b)
tc = gpu:multiply(ta, tb)
result = gpu:to_array(tc)
slog(result)

Internals

  • Vulkan context* auto-initializes on plugin load.

  • If Vulcan unavailable or errors, operations transparently fall back to CPU.

  • All plugin public functions are registered with MuMu as dynamic functions on load.

  • Shaders are included as .glsl files and are expected to be precompiled to SPIR-V for deployment.

Development & Contributions

  • Fork and PRS welcome.
  • For development, see shader/ for GLSL compute sources.
  • Contributions should avoid unsafe unless required for FFI/Vulkan.

License

dual-licensed under MIT or Apache-2.0 (your choice).
See LICENSE in this repo.


Author

Tom @nu11.co.uk https://lava.nu11.uk

This plugin is part of the Lava/MuMu language ecosystem. For the core language, see: github.com/nu11co/mumu

Commit count: 0

cargo fmt