Skip to main content

VulkaNN: High-Performance Pure Vulkan Deep Learning Framework

VulkaNN Logo

Break free from proprietary CUDA lock-in. Train and deploy neural networks natively on any GPU via 100% Khronos Vulkan compute & Slang shaders.

Key Features • Architecture • Quick Start • Cookbook • Build • Agents & LLMs • License


🚀 Why VulkaNN?

Modern deep learning frameworks have locked developers into vendor-specific hardware stacks (CUDA, cuDNN, ROCm). VulkaNN is built from first principles on pure Khronos Vulkan 1.2+ and Slang compute shaders:

  • 100% Multi-Vendor Parity: Runs seamlessly on NVIDIA, AMD, Intel (Arc & Iris Xe integrated), Apple Silicon (MoltenVK), Qualcomm Adreno, ARM Mali, and Raspberry Pi 5.
  • Zero CUDA / Zero ROCm: Never requires proprietary driver toolchains or CUDA runtimes.
  • Zero .numpy() in Compute Kernels: Pure GPU tensor math, forward/backward autograd, optimizer updates, and loss evaluations execute directly on GPU buffers.
  • PyTorch 1:1 API Parity: Drop-in replacement for PyTorch tensors, autograd, nn.Module, optimizers, learning rate schedulers, mixed precision, and initialization.
  • Heterogeneous Multi-GPU: Combine integrated GPUs (e.g. Intel Iris Xe) and discrete GPUs (e.g. NVIDIA RTX) in a single balanced training loop with dynamic latency-aware work distribution.
  • Static Graph Capture & Replay: Near-zero CPU overhead via @vulkann.compile (VulkanGraph).
  • Modern Transformer & State-Space Models: Built-in FlashAttention-2, Mamba (Selective State Space), Snake/SnakeBeta, SwiGLU, Rotary Embeddings, and Transformer encoders.
  • Zero-Dependency Safetensors: Direct fast I/O without Hugging Face safetensors or PyTorch dependencies.

⚡ Key Features

1. Modern Vulkan Compute & Slang Shaders

  • Slang Compute Kernels: All GPU operations written in Khronos Slang (shaders/*.slang), compiled to SPIR-V via slangc.
  • Subgroup Wave Intrinsics: Workgroup reductions and softmax use WaveActiveSum and WaveActiveMax with explicit subgroup control (VK_EXT_subgroup_size_control, enforcing 32-lane execution) avoiding workgroup barrier stalls.
  • Hardware Float Atomics: Fast non-conflicting gradient scatter/embedding updates using VK_EXT_shader_atomic_float.
  • Persistent Pipeline Cache: Two-tier VkPipelineCache (in-memory + disk cache at ~/.cache/vulkann/) eliminating runtime shader re-compilation hitching.
  • Hardware Matrix Acceleration: Tensor cores and matrix engines accelerated via VK_KHR_cooperative_matrix with fallback to tiled GEMM.
  • Multi-Dtype Support: Native compute in float32, float16 (half), bfloat16, int64, int32, int8, uint8, and bool.

2. Comprehensive Deep Learning Modules (vulkann.nn)

  • Foundational Layers: Linear, Conv1d, Conv2d, Embedding, Dropout, Identity.
  • Recurrent & Sequence Models: LSTM, GRU, RNN, MultiheadAttention, TransformerEncoder, TransformerEncoderLayer.
  • State-of-the-Art Architectures:
    • Mamba: Selective state-space sequence model (S6) with selective discretization.
    • Snake / SnakeBeta: Periodic activation functions preserving inductive bias for audio, signals, and time series.
    • SwiGLU: Swish-Gated Linear Units used in modern LLMs (LLaMA, Mistral).
    • RotaryEmbedding (RoPE): Relative rotary positional encoding for modern attention models.
    • FlashAttention-2: Memory-efficient tiled multi-head attention avoiding $O(N^2)$ VRAM materialization.
  • Normalization & Activations: LayerNorm, BatchNorm1d, BatchNorm2d, RMSNorm, ReLU, GELU, SiLU, Sigmoid, Tanh, LeakyReLU, Softmax, LogSoftmax.
  • Loss Functions: CrossEntropyLoss, MSELoss, L1Loss, SmoothL1Loss, BCEWithLogitsLoss, NLLLoss.
  • Weight Initializers (vulkann.nn.init): xavier_uniform_, xavier_normal_, kaiming_uniform_, kaiming_normal_, uniform_, normal_, constant_, zeros_, ones_, eye_, orthogonal_.
  • Gradient Utilities: vulkann.nn.utils.clip_grad_norm_, clip_grad_value_.

3. Autograd Engine & Differentiability

  • Tape-Based Reverse-Mode Autograd: Dynamic computation graph tracking operations on tensors with requires_grad=True.
  • Custom Autograd Functions: Define user operations via vulkann.autograd.Function with static forward(ctx, ...) and backward(ctx, ...).
  • Activation Checkpointing: Trade compute for memory using vulkann.utils.checkpoint.checkpoint(fn, *args).
  • Analytical Gradient Verification: Comprehensive vulkann.autograd.gradcheck comparing analytical gradients against finite differences.
  • Slang Automatic Differentiation: Research integration with Slang [Differentiable] shaders.

4. Graph Capture & JIT Compilation (@vulkann.compile)

  • Capture static execution graphs into VulkanGraph to eliminate per-iteration Python overhead, dynamic command pool allocations, and host-device synchronization latency:
import vulkann as torch

model = MyModel().to("vk:0")
opt_model = torch.compile(model)  # Captures command buffers for replay

for x in batches:
    out = opt_model(x)  # Replays pre-recorded command buffers directly

5. Heterogeneous Multi-GPU (DataParallel)

  • Concurrently train models across any combination of GPUs (e.g. vk:0 Intel Iris Xe + vk:1 NVIDIA RTX).
  • Closed-Loop EMA Latency Balancer: Continuously monitors step execution latencies on each device and automatically adjusts batch shard splits proportionally to real-time throughput.
  • Small-Batch Bypass: Automatically avoids dispatch overhead by executing sub-device batches on the primary GPU.
  • Zero-Copy Parameter Broadcast & Async All-Reduce: Non-blocking parameter replication and gradient reduction.

6. Mixed Precision & Quantization

  • Automatic Mixed Precision (AMP): Context-managed vulkann.amp.autocast("vulkan", dtype=torch.float16) combined with vulkann.amp.GradScaler to prevent underflow.
  • Post-Training Quantization (vulkann.quantize):
    • In-place Int8 symmetric per-channel weight quantization (quantize_dynamic_int8).
    • In-place Int4 packed weight quantization (quantize_dynamic_int4) for 75% memory footprint reduction on resource-constrained devices.

7. Ecosystem & Standard Math Parity

  • Einstein Summation: High-performance vulkann.einsum(equation, *operands).
  • Linear Algebra (vulkann.linalg): Matrix norm, vector norm, trace, determinant, inverse, solve, dot, inner, outer products.
  • Fast Fourier Transforms (vulkann.fft): 1D/2D real and complex FFTs (fft, ifft, rfft, irfft, fft2, ifft2).
  • Optimization & Schedulers (vulkann.optim):
    • Optimizers: Adam, AdamW, SGD (with momentum & Nesterov), RMSprop, Adagrad.
    • Schedulers: StepLR, MultiStepLR, ExponentialLR, CosineAnnealingLR, LinearLR, ConstantLR.
  • Zero-Dependency Safetensors: Fast binary weight serialization via torch.save_safetensors and torch.load_safetensors.

🧱 Architecture & Performance Stack

┌────────────────────────────────────────────────────────────────────────┐
│                        User Deep Learning Code                         │
│       import vulkann as torch  /  import vulkann.nn as nn            │
├───────────────────────────────────┬────────────────────────────────────┤
│   High-Level Neural Architectures │   Ecosystem & Training Utilities   │
│   • FlashAttention-2, RoPE        │   • AMP Autocast & GradScaler      │
│   • Mamba (Selective S6)          │   • Optimizers & LR Schedulers     │
│   • Snake / SnakeBeta Periodic    │   • Weight Initializers (nn.init)  │
│   • SwiGLU, RMSNorm, LayerNorm    │   • Safetensors Zero-Copy I/O      │
│   • LSTM, GRU, TransformerEncoder │   • einsum, linalg, fft            │
├───────────────────────────────────┴────────────────────────────────────┤
│                    Autograd & Graph Execution Engine                   │
│   • Tape-based Autograd with custom autograd.Function & Checkpointing  │
│   • Static Graph Compilation: @vulkann.compile (VulkanGraph Replay)   │
│   • Dynamic Heterogeneous Multi-GPU DataParallel (EMA Latency-Balanced)│
├────────────────────────────────────────────────────────────────────────┤
│                       C++ Core Engine (vulkann_core)                  │
│   • Zero-copy Strided Tensor Views & Storage Slicing                   │
│   • Asynchronous Command Submission & Staging Memory Manager           │
│   • Persistent Two-Tier Disk VkPipelineCache (~/.cache/vulkann/)      │
│   • Extensions: VK_EXT_subgroup_size_control, atomic_float, coopmat    │
├────────────────────────────────────────────────────────────────────────┤
│                     Khronos Slang Compute Shaders                      │
│   • WaveActiveSum / WaveActiveMax Subgroup Shuffles (Zero Barriers)    │
│   • Tiled GEMM & Cooperative Matrix Hardware Math                      │
│   • Elementwise, Reductions, Fused Kernels, Quantized Dequant-GEMM     │
├────────────────────────────────────────────────────────────────────────┤
│                      Khronos Vulkan 1.2+ Drivers                       │
│    NVIDIA RTX / AMD Radeon / Intel Arc & Xe / Apple Silicon / Adreno   │
└────────────────────────────────────────────────────────────────────────┘

⚡ Quick Start

1. Drop-In Replacement for PyTorch

VulkaNN is designed to mirror PyTorch semantics:

import vulkann as torch
import vulkann.nn as nn
import vulkann.optim as optim

# Detect Vulkan GPU or fallback to CPU
device = "vk:0" if torch.vulkan.is_available() else "cpu"
print(f"Running on {device} ({torch.vulkan.get_device_name(0)})")


# Define an MLP
class MLP(nn.Module):

    def __init__(self):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(784, 256),
            nn.LayerNorm(256),
            nn.GELU(),
            nn.Linear(256, 10),
        )

    def forward(self, x):
        return self.net(x)


model = MLP().to(device)
optimizer = optim.AdamW(model.parameters(), lr=1e-3, weight_decay=1e-2)
criterion = nn.CrossEntropyLoss()

# Training step
x = torch.randn(64, 784, device=device)
y = torch.randint(0, 10, (64,), dtype=torch.int64, device=device)

optimizer.zero_grad()
loss = criterion(model(x), y)
loss.backward()
nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)
optimizer.step()

print(f"Step Loss: {loss.item():.4f}")

📖 Examples & Cookbook

VulkaNN ships with canonical, runnable examples in the examples/ directory:

Script Title Description
examples/01_quickstart_mlp.py Quickstart MLP Tensor creation, MLP training, autograd, optimizer, and loss evaluation.
examples/02_autograd_and_gradcheck.py Autograd & Gradcheck Custom autograd.Function, activation checkpointing, and finite-difference validation.
examples/03_transformer_flash_attention.py Modern Transformer FlashAttention-2, SwiGLU, RoPE, RMSNorm, and mixed-precision AMP training.
examples/04_mamba_and_snake.py Mamba & Snake Selective State Space sequence modeling and periodic Snake activations.
examples/05_multigpu_dataparallel.py Heterogeneous Multi-GPU Concurrent training across mixed vendor GPUs with auto-balancing and safetensors I/O.
examples/06_quantized_inference.py Quantized Inference In-place Int8 and Int4 weight quantization with cosine similarity verification.

Highlight: Modern Transformer with FlashAttention & AMP

import vulkann as torch
import vulkann.nn as nn
from vulkann.amp import GradScaler, autocast


class ModernTransformerBlock(nn.Module):

    def __init__(self, dim, num_heads):
        super().__init__()
        self.norm1 = nn.RMSNorm(dim)
        self.attn = nn.FlashAttention(embed_dim=dim, num_heads=num_heads)
        self.norm2 = nn.RMSNorm(dim)
        self.mlp = nn.Sequential(
            nn.Linear(dim, dim * 4),
            nn.SwiGLU(),
            nn.Linear(dim * 2, dim),
        )

    def forward(self, x):
        x = x + self.attn(self.norm1(x))
        x = x + self.mlp(self.norm2(x))
        return x


model = ModernTransformerBlock(dim=256, num_heads=8).to("vk:0")
scaler = GradScaler("vulkan")
x = torch.randn(8, 128, 256, device="vk:0")

# Mixed-precision forward and backward pass
with autocast("vulkan", dtype=torch.float16):
    out = model(x)
    loss = out.mean()

scaler.scale(loss).backward()
scaler.step(optimizer)
scaler.update()

Highlight: Heterogeneous Multi-GPU Training

Train seamlessly across an integrated Intel GPU and a discrete NVIDIA/AMD GPU simultaneously:

import vulkann as torch
import vulkann.nn as nn

model = BigNet()
# Automatically probes devices and balances batch shards via closed-loop latency feedback
parallel_model = nn.DataParallel(model, device_ids=["all"], balance="auto")

for x_batch, y_batch in dataloader:
    optimizer.zero_grad()
    parallel_model.zero_grad()

    # Forward pass executes concurrently across all GPUs
    outputs = parallel_model(x_batch)
    loss = criterion(outputs, y_batch)
    loss.backward()

    # Async all-reduce gradients to master parameters
    parallel_model.reduce_gradients()
    optimizer.step()

Highlight: Zero-Dependency Safetensors Serialization

Save and load models at line speed without third-party libraries:

import vulkann as torch

# Save weights to disk
torch.save_safetensors(model.state_dict(), "model.safetensors")

# Load weights directly to target GPU
state_dict = torch.load_safetensors("model.safetensors", device="vk:0")
model.load_state_dict(state_dict)

🛠️ Building & Developing

Prerequisites

  • C++20 Compiler: GCC $\ge 11$ or Clang $\ge 14$
  • CMake: $\ge 3.18$
  • Vulkan Loader & Headers: libvulkan-dev / vulkan-headers ($\ge 1.2$)
  • Slang Compiler: slangc $\ge 2024.1$ (from LunarG Vulkan SDK or package manager)
  • Python: $\ge 3.8$ with numpy, pytest, ruff

Build from Source

# 1. Fetch dependencies and Vulkan headers
scripts/fetch_deps.sh

# 2. Configure and build C++ backend + Slang SPIR-V shaders
cmake -S . -B build -DPython_EXECUTABLE=$(which python3)
cmake --build build -j$(nproc)

# 3. Run unit tests
PYTHONPATH=. pytest

Zero-Warning & Correctness Gate

VulkaNN enforces a strict zero-warning policy across all C++, Slang, and Python code:

scripts/check.sh
  • Enforces -Werror in C++ with Allman style via .clang-format.
  • Enforces strict formatting and linting via ruff format and ruff check.
  • Every operator undergoes finite-difference torch.gradcheck verification across CPU, integrated GPUs, and discrete GPUs.

🤖 Agent & Developer Resources

VulkaNN includes native discoverability files for AI coding agents, autonomous workflows, and LLMs:

  • AGENTS.md: Architectural patterns, constraints (no CUDA, no .numpy() in compute kernels, Allman C++ style), and standard idioms.
  • llms.txt: Structured project overview, core APIs, and cookbook links for LLM context injection.
  • llms-full.txt: Full comprehensive API surface reference including tensor math, neural layers, optimizers, and Vulkan driver flags.

📜 License

GNU Lesser General Public License v3.0 (LGPL-3.0-only) — see LICENSE and LICENSE.GPLv3.

  • Free to use in research, commercial, and proprietary applications: You can import vulkann in closed-source applications, cloud services, and training pipelines without having to open-source your models or application code.
  • Anti-plagiarism copyleft on VulkaNN internals: Any modification to VulkaNN's Slang shaders, C++ backend, or Python source, or any derivative library incorporating VulkaNN code, must be released under LGPLv3 (or GPLv3) with full source code and attribution.

Metadata

Release files for vulkann 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vulkann 0.1.0
File Size Uploaded Provenance Actions
vulkann-0.1.0.tar.gz 6.5 MB With provenance Details for vulkann-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for vulkann 0.1.0
File Actions
vulkann-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details for vulkann-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
vulkann-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details for vulkann-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
vulkann-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details for vulkann-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
vulkann-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details for vulkann-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl

Total release size: 10.2 MB

Release files / vulkann-0.1.0.tar.gz

Download URL vulkann-0.1.0.tar.gz
Size 6.5 MB
Tags Source
SHA-256 checksum
How to use checksums
793f827e300ad0cf4b3c22ce46a832dff607ab71419dd47bdb6992694a82d731
BLAKE2b-256 checksum
How to use checksums
6785a244e8d2a77c946973eec35f31206ab900b4c9c7bcadb79a17155253c983
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / vulkann-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL vulkann-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Size 936.4 kB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
f8138488dae7a6cf7a76df617a5d5977fc7059fef2386a4ba679d097bd03304e
BLAKE2b-256 checksum
How to use checksums
28fb420eea92611f44353dd0ad12f67b8f46a37bcaaef9838793743402ae72e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / vulkann-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL vulkann-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Size 936.5 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
339e793a85520240f7eaa83b42ff1e9c699284e4ab16b48f9f13d4accfd00281
BLAKE2b-256 checksum
How to use checksums
ffb8102798b3f963bbbf9981ad1878d8ad87bcd0e6b3ce890835354a4cebcd44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / vulkann-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL vulkann-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Size 930.9 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
97bb9efbf16df28970c02570a9e9c091c1784d8f759e4a33e36d3eeb44a8067c
BLAKE2b-256 checksum
How to use checksums
e065ceb29492da5f3f03086e84337dd271c1e3dbf81650c7e0113b3aeafbf2d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / vulkann-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL vulkann-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
Size 930.1 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
dcdc44def2cccf8f3349c32c767f89d2aee0eb617568506a1ccd6c9a01c747a8
BLAKE2b-256 checksum
How to use checksums
d7762962ce1ea7f4c503f15e4771d3a62b2aa578f374effa60914f4c9cf0f9d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for vulkann 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for vulkann-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

5 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page