Metadata-Version: 2.2
Name: munet-nn
Version: 0.7.0
Summary: Experimental C++ graph compiler for portable Vulkan training and inference
Author: MuNet Contributors
License: Proprietary
Project-URL: Homepage, https://github.com/bryan-pakulski/MuNet
Project-URL: Repository, https://github.com/bryan-pakulski/MuNet
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Provides-Extra: interop
Requires-Dist: onnx>=1.16; extra == "interop"
Provides-Extra: vk
Requires-Dist: onnx>=1.16; extra == "vk"
Requires-Dist: onnxruntime>=1.18; extra == "vk"
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: onnx>=1.16; extra == "test"
Requires-Dist: onnxruntime>=1.18; extra == "test"
Requires-Dist: scipy>=1.10; extra == "test"
Provides-Extra: torch
Requires-Dist: torch>=2.6; extra == "torch"
Requires-Dist: onnx>=1.16; extra == "torch"
Requires-Dist: onnxscript>=0.3; extra == "torch"
Description-Content-Type: text/markdown

# MuNet

Train and run neural networks on any GPU with a Vulkan driver: NVIDIA, AMD, Intel, and mobile GPUs. MuNet has no
CUDA or ROCm dependency. It provides:

- PyTorch-style training in Python;
- ONNX import and export;
- fp16 / int8 inference;
- multi-GPU training, including mixed vendors;
- C, C++ and Rust runtimes for deployment, with zero-copy Vulkan interop for video pipelines.

```bash
pip install 'munet-nn[interop]'          # Linux x86_64 / aarch64, Python 3.10+
```

You also need a Vulkan driver and `glslangValidator`; see [Getting started](docs/getting-started.md).

## Run an ONNX model

```python
import numpy as np
from munet.interop import from_onnx

model = from_onnx("yolo11n.onnx", precision="fp16", input_shapes={"images": (1, 3, 640, 640)})
out = model(np.random.rand(1, 3, 640, 640).astype(np.float32))
print(out.numpy().shape)                 # (1, 84, 8400)
```

## Train a model

```python
import munet as mu
from munet.data import ArrayDataset, DataLoader

model = mu.nn.Sequential(mu.nn.Linear(784, 256), mu.nn.ReLU(), mu.nn.Linear(256, 10))
optimizer = mu.optim.AdamW(model.parameters(), lr=1e-3)

@mu.compile                              # the whole step becomes one GPU program
def train_step(x, y):
    optimizer.zero_grad()
    loss = mu.nn.functional.cross_entropy(model(x), y)
    loss.backward()
    optimizer.step()
    return loss

loader = DataLoader(ArrayDataset(images, labels), batch_size=128, shuffle=True)   # NumPy arrays
for epoch in range(5):
    for x, y in loader:
        loss = train_step(x, y)
    print(epoch, loss.item())
```

## Deploy from C, C++ or Rust

```python
model.eval()
program = mu.compile(model)
program(images[:1])                      # fixes the input shape (batch 1) and compiles
mu.save(program, "model.mnet")
```

```rust
let mut program = munet::Program::load("model.mnet", &munet::Options::default())?;
program.run(&[&image])?;
let scores = program.read(0)?;
```

## Guides

| I want to... | Read |
|---|---|
| Install MuNet and check my GPU works | [Getting started](docs/getting-started.md) |
| Train a model | [Training](docs/training.md) |
| Feed training data (datasets, shuffling, workers, prefetch) | [Data loading](docs/data.md) |
| Train on several GPUs, including different sizes (e.g. 24 + 12 + 8 GB) | [Multiple GPUs](docs/multi-gpu.md) |
| Import or export ONNX, or import PyTorch | [ONNX](docs/onnx.md) |
| Run models fast (precision, autotuning, batching, `.mnet`) | [Inference and performance](docs/inference.md) |
| Quantize to int8 / int4 | [Quantization](docs/quantization.md) |
| Configure NVIDIA, AMD or Intel GPUs, and containers | [GPU vendors](docs/gpus.md) |
| Run models from C or C++ | [C and C++](docs/c.md) |
| Run models from Rust | [Rust](rust/README.md) |
| Detect objects in video with zero copies | [Zero copy and video](docs/zero-copy.md) |
| Look up an environment variable | [Environment variables](docs/environment.md) |
| Fix an error | [Troubleshooting](docs/troubleshooting.md) |

Runnable examples are in [examples/python](examples/python/README.md), [examples/c](examples/c/run_model.cpp) and
[rust/examples](rust/examples). [examples/bench](examples/bench/README.md) checks correctness and speed of about 40
public models on your GPUs.

All docs, including internals and design notes: [docs/README.md](docs/README.md).

## License

The Python, C and Rust wrappers are MIT-licensed. The native engine runs in evaluation mode without a key and prints
a notice. Put production keys in `MUNET_LICENSE`, `MUNET_LICENSE_FILE` or `~/.config/munet/license.key`, and check
them with `munet.license()`.
