Skip to content

muna-ai/muna-py

Repository files navigation

Muna for Python

muna transpile

Run AI models anywhere.

Installing Muna

Muna is distributed on PyPi. This distribution contains both the Python client and the command line interface (CLI). Run the following command in terminal:

# Install Muna
$ pip install --upgrade muna

Note

Muna requires Python 3.11+

Transpiling a Python Function

Muna can transpile Python functions into C++, generating a self-contained header-only library that pulls all of its dependencies automatically (e.g. llama.cpp, mlx, CUDA). First, add the @compile decorator to your function:

from muna import compile

@compile()
def do_stuff():
    ...

Then use the Muna CLI to transpile to C++:

# Transpile the Python function to C++
$ muna transpile do_stuff.py

Muna will create a cloud sandbox to setup your Python function, trace it, lower to C++, then generate a folder containing the header-only library and a corresponding CMakeLists.txt.

Tip

Even though the compiler is not open-source, you can read up on how it works.

Once compiled, you can then build the included example app and test it from the command line. Here's an example using Kokoro TTS 🔊:

kokoro.mp4

Useful Links

Muna is a product of NatML Inc.