Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

296 Commits

Repository files navigation

PyGPUkit — Lightweight GPU Runtime for Python

A minimal, modular GPU runtime with Rust-powered scheduler, NVRTC JIT compilation, and a clean NumPy-like API.

PyPI versionCUDAGitHub stars

PythonLicense: MITSMDownloadsCode style: ruff

When GPU optimizations change your results, something is wrong.

A minimal, deterministic GPU runtime for Python.
Built for people who care about correctness, reproducibility, and real performance.

  • CUDA Graph that doesn't lie
  • cuBLASLt without hidden state
  • FP8 / NVF4 / w8a16 done explicitly
  • Rust-powered scheduler for real GPU concurrency

This is not a framework. This is a GPU runtime.

Why PyGPUkit Exists

Modern GPU stacks optimize aggressively.
Sometimes, they optimize correctness away.

PyGPUkit exists because:

  • CUDA Graph replay can change numerical results
  • cuBLASLt may depend on hidden workspace state
  • Stream-0 synchronization hides performance bugs
  • “It’s faster” often means “it’s nondeterministic”

PyGPUkit chooses:

  • Explicit over implicit
  • Determinism over magic
  • Measurable behavior over benchmark-only claims

What PyGPUkit Is NOT

  • ❌ Not a PyTorch replacement
  • ❌ Not a training framework
  • ❌ Not a convenience-first library
  • ❌ Not safe if you ignore GPU semantics
  • ❌ Not designed for "just works" expectations

PyGPUkit is for people who want to see and control what their GPU is actually doing.


Core Capabilities (TL;DR)

  • 🚀 Driver-only deployment (no CUDA Toolkit required)
  • 🧠 Deterministic CUDA Graph execution
  • ⚙️ Explicit stream & memory control
  • 🧮 FP8 / NVF4 / BF16 / TF32 done right
  • 🎛️ Rust-based GPU scheduler with QoS & partitioning
  • 🔊 GPU-native audio & DSP (no cuFFT dependency)

Real-World GPU Pathologies (Observed)

  • Same input, different output with CUDA Graph replay
  • FP8 GEMM producing correct averages but wrong tokens
  • cuBLASLt performance variance across runs
  • H2D stalls masked by stream-0 synchronization

All of these are reproducible.
All of them are documented.
All of them are why PyGPUkit exists.

These are not theoretical. They were all observed in production or real benchmarks.


Documentation

GuideDescription
Getting StartedInstallation, quick start, basic usage
API ReferenceComplete API documentation with examples
LLM GuideSafeTensors, GPT-2/LLaMA/Qwen3 inference
Performance TuningTF32, FP16, CUTLASS optimization
Scheduler GuideMulti-LLM concurrent execution

What's New in v0.2.19

FLUX.1 Image Generation

Text-to-image generation with Black Forest Labs' FLUX.1 model:

frompygpukit.diffusionimportFluxPipeline# Load FLUX.1-schnell (fast variant)pipeline=FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell")
# Generate imageimage=pipeline.generate(
prompt="a photo of a cat sitting on a windowsill",
num_inference_steps=4, # schnell uses few stepsguidance_scale=0.0, # schnell doesn't use CFG
)
image.save("output.png")
ComponentDescription
FluxTransformer19 joint blocks + 38 single blocks
FluxSchedulerFlow matching Euler scheduler
GPU-native opsTranspose, batched matmul, RoPE on GPU
RoPE frequenciesCached on GPU for efficient reuse

Lazy Model Loading with Streaming

Memory-efficient model loading strategies for large models:

frompygpukit.llmimportQwenModel, StreamingStrategy# Progressive loading - load layers as neededmodel=QwenModel.from_safetensors(
"path/to/model",
streaming=StreamingStrategy.PROGRESSIVE
)
# Layer-by-layer streaming for memory-constrained environmentsmodel=QwenModel.from_safetensors(
"path/to/model",
streaming=StreamingStrategy.LAYER_BY_LAYER
)
StrategyDescription
EAGERLoad all weights at once (default)
PROGRESSIVELoad weights progressively during first forward
LAYER_BY_LAYERStream one layer at a time, minimal memory

cuBLAS Dynamic Loader

Runtime cuBLAS/cuBLASLt loading without compile-time CUDA Toolkit dependency:

FeatureDescription
Dynamic DLL loadingSearches CUDA_PATH, system PATH
Version detectionAuto-selects cublasLt64_13/12/11.dll
Graceful fallbackUses native kernels if cuBLAS unavailable

C++ Kernel Profiler

Built-in CUDA kernel profiling with minimal overhead:

frompygpukitimportenable_profiling, get_profile_statsenable_profiling(True)
# ... run your code ...stats=get_profile_stats()
forname, infoinstats.items():
print(f"{name}: {info['avg_ms']:.3f} ms ({info['count']} calls)")

HuggingFace T5 Encoder Support

T5 text encoder with sharded safetensors for FLUX/SD3:

FeatureDescription
Sharded loadingSupports model-00001-of-00002.safetensors format
T5EncoderModelFull T5 encoder implementation
Automatic detectionFinds encoder in model directories

DiT Architecture Support

Diffusion Transformer (DiT) components for PixArt and similar models:

ModuleDescription
dit/model.pyPixArt transformer with AdaLN-Zero
dit/attention.pySelf/cross attention with GQA
dit/embeddings.pyPatch embed, timestep embed, 2D sincos pos
dit/adaln.pyAdaptive LayerNorm modulation
dit/ffn.pyGEGLU feed-forward network

New GPU Operations

OperationDescription
transpose_4d_0213GPU-native 4D transpose [B,S,H,D] -> [B,H,S,D]
transpose_3d_012GPU-native 3D transpose [B,S,D] -> [B,D,S]
gpu_batched_matmulBatched matrix multiplication
gpu_softmaxGPU-native softmax
gpu_apply_ropeApply rotary position embedding
cross_attentionCross-attention for text conditioning
conv2d2D convolution for VAE/UNet
group_normGroup normalization

What's New in v0.2.18

Major Codebase Refactoring

Complete modularization of the codebase for better maintainability:

  • Split monolithic files into modular .inl components
  • Reorganized matmul kernel directory structure
  • Standardized GEMM/GEMV naming conventions
  • Modular pybind11 bindings

Kokoro-82M TTS

Text-to-speech synthesis with Japanese/English support:

frompygpukit.ttsimportKokoroModelmodel=KokoroModel.from_safetensors("kokoro-v1.0-82m.safetensors")
audio=model.generate("Hello world", voice="af_heart")

Positional Encoding Operations

New neural network operations for attention mechanisms:

FunctionDescription
pope_init_encodingSinusoidal positional encoding (PoPE)
pope_inplaceApply additive encoding to Q/K
alibi_init_slopesALiBi head-specific slopes
alibi_compute_biasALiBi attention bias matrix
rope_init_ntk_awareNTK-aware RoPE for context extension
rope_init_yarnYaRN dimension-wise interpolation
rope_init_linearLinear position interpolation
relu2ReLU squared activation (Primer)

Unified Benchmark Suite

New scripts/benchmark.py for comprehensive performance testing across all dtypes and sizes.

QAT/Pruning/Sparsity Config

Model config support for quantization-aware training, pruning, and sparsity patterns.

Optimized BF16 GEMV

New optimized BF16 GEMV kernel with B[N,K] layout achieves 98-101% peak bandwidth for typical LLM dimensions:

MatrixBandwidth% of Peak
2048 x 81921763 GB/s98%
4096 x 143361810 GB/s101%

W8A16 GEMM Fix

Fixed MMA A-fragment register mapping for m16n8k16 instruction. MoE models now produce correct output.


What's New in v0.2.17

Triton Backend MVP

Optional Triton backend for rapid kernel prototyping without C++ recompilation:

ComponentDescription
pygpukit.tritonTriton wrapper module with GPUArray compatibility
TritonArrayWrapper bridging PyGPUkit GPUArray to Triton
Triton KernelsRMSNorm, LayerNorm, Softmax, Rotary
Hybrid ExecutionMix Triton + Native CUDA in same model
# Install Triton (Windows)pipinstalltriton-windows# Or: pip install pygpukit[triton]# Hybrid chat examplepythonexamples/chat_cli_triton.py--model/path/to/model--tokenizer/path/to/tokenizer.json

Kernel Routing Example:

RMSNorm -> Triton (kernels/rmsnorm.py) - easy to modify
MatMul -> Native CUDA (cuBLASLt) - production performance
SDPA -> Native CUDA (optimized)
KV Cache -> Native CUDA

Usage Pattern

frompygpukit.tritonimportfrom_gpuarray, kernels, triton_availableiftriton_available():
# Wrap GPUArray for Tritonx_triton=from_gpuarray(x_gpu)
w_triton=from_gpuarray(weight_gpu)
out_triton=from_gpuarray(out_gpu)
# Call Triton kernelkernels.rmsnorm(x_triton, w_triton, out_triton, eps=1e-5)

What's New in v0.2.16

MoE (Mixture of Experts) Support

Full support for Mixtral-style MoE models with custom CUDA kernels:

ComponentDescription
MoE KernelsTopK routing, softmax, token permutation, gather/scatter
Grouped GEMMBatched expert dispatch with per-row expert IDs
MoELayerPython layer with router + expert FFN dispatch
MIXTRAL_SPECAuto-detection for Mixtral 8x7B models

Thinking Model Support

Qwen3 Thinking model support with <think>...</think> block parsing.

New GEMV Kernels (SM120)

KernelA dtypeB dtypeSpeedup vs BF16
FP8/FP8 (W8A8)FP8 E4M3FP8 E4M36-22x
NVF4/NVF4 (W4A4)NVF4NVF4Memory priority
Int4 GEMVBF16Int4Large K dimensions

New GEMM Kernels (SM120)

KernelDescription
W8A16 GEMMFP8 weight + BF16 activation (CUTLASS)
Int8 NativeExact int8 via dp4a (CUDA cores)
Int4 via Int84-bit approximation via TensorCore
Grouped GEMM v2Per-row expert IDs for MoE

Development Tooling

  • Claude Code Skills: Build, benchmark, lint, test automation
  • Subagents: kernel-reviewer, perf-analyzer, api-designer
  • CONTRIBUTING.md: Contribution guidelines

Previous versions (v0.2.4 - v0.2.15): See CHANGELOG.md for complete release history.

LLM Support

PyGPUkit includes built-in support for loading and running LLM models. See the LLM Guide for detailed documentation.

Important: PyGPUkit's core responsibility is GPU execution, not tokenization.

  • The model API expects token IDs as input, not raw text
  • For production tokenization, use HuggingFace tokenizers
  • The built-in Tokenizer class is experimental and intended for demos only
frompygpukit.llmimportSafeTensorsFile, load_model_from_safetensors, detect_model_spec# Load safetensors (memory-mapped, zero-copy)st=SafeTensorsFile("model.safetensors")
print(f"Tensors: {st.num_tensors}, Size: {st.file_size/1e9:.2f} GB")
# Load model with automatic architecture detectionspec=detect_model_spec(st.tensor_names)
model=load_model_from_safetensors("model.safetensors", dtype="float16", spec=spec)
# Generate with token IDs (use HuggingFace tokenizers for production)input_ids= [1, 2, 3, 4] # Your tokenizer's outputoutput_ids=model.generate(input_ids, max_new_tokens=32)
ComponentDescription
SafeTensorsFileMemory-mapped .safetensors loading
CausalTransformerModelUnified model for GPT-2, LLaMA, Qwen3
load_model_from_safetensorsLoad model with auto-detection
detect_model_specAuto-detect model architecture
TokenizerExperimental BPE tokenizer (demos only)

Performance

RTX 5090 Benchmark (SM120a, CUDA 13.1)

Standard Precision (8192x8192)

PrecisionTFLOPSNotes
FP3280CUDA cores
TF3287TensorCore
FP16170TensorCore
BF16173TensorCore

Quantized GEMM (M=8192, K=4096, N=14336)

FormatTFLOPSErrorNotes
FP8xFP8217~0.1%CUTLASS SM120 blockwise
W8A1650~0.1%FP8 weight, BF16 activation
Int8 (via FP8)142~3.5%TensorCore approximation
Int8 (dp4a)440%Exact, CUDA cores
Int4 (via Int8)121~0.1%TensorCore approximation

NVF4 (4-bit NormalFloat) GEMM

Matrix SizeTFLOPSNotes
8192x8192261Pre-quantized
12288x122883833-stage pipeline
16384x16384446Peak performance

Note: NVF4xNVF4 achieves 4x memory bandwidth reduction vs BF16 with minimal accuracy loss.

RTX 3090 Ti Benchmark (SM86)

Matrix SizeFP32TF32FP16BF16
2048×20489.6 TFLOPS13 TFLOPS15 TFLOPS21 TFLOPS
4096×409614.7 TFLOPS22 TFLOPS44 TFLOPS44 TFLOPS
8192×819218 TFLOPS31 TFLOPS63 TFLOPS63 TFLOPS

Note: CUTLASS is automatic for compatible sizes (16-aligned). Use PYGPUKIT_NO_TF32=1 for full FP32 precision.

GEMV Performance (RTX 5090, SM120a)

For LLM decode (M=1), custom GEMV kernels for different quantization formats:

GEMV Bandwidth Utilization (v0.2.18)

Optimized BF16 GEMV achieves near-peak memory bandwidth for large matrices:

KNBF16 BWBF16 %W8A16 BWW8A16 %
20482048434 GB/s24%278 GB/s16%
204881921763 GB/s98%434 GB/s24%
81922048543 GB/s30%363 GB/s20%
4096143361810 GB/s101%467 GB/s26%

Note: BF16 GEMV with optimized B[N,K] layout achieves 98-101% peak bandwidth for typical LLM FFN dimensions. W8A16 (FP8 weight) includes dequantization overhead.

GEMV Latency by Layer

LayerKNBF16W8A16W8A8W4A16W4A4Int4
Qwen-7B hidden4096409631 us108 us31 us142 us252 us33 us
Qwen-7B MLP up409614336100 us272 us43 us140 us253 us49 us
Qwen-7B MLP down143364096102 us330 us46 us403 us873 us59 us
Qwen-72B hidden81928192112 us326 us46 us246 us497 us51 us
Qwen-72B MLP up819229568324 us976 us180 us448 us509 us111 us
Qwen-72B MLP down295688192839 us204 us1395 us1294 us125 us
KernelFormatMemoryRel. Err (vs FP32)Best For
BF16A:BF16, B:BF16100%~0.6%Baseline (highest accuracy)
W8A16A:BF16, B:FP850%~12%Balanced speed/memory
W8A8A:FP8, B:FP850%~9%Speed priority (6-18x faster)
W4A16A:BF16, B:NVF425%~15%Memory priority
W4A4A:NVF4, B:NVF412.5%~20%Maximum compression
Int4A:BF16, B:Int425%~15%Large K dimensions

Note: W8A8 (FP8/FP8) is fastest for typical sizes. W4A4 has 2x dequant overhead (both A and B). Int4 excels at very large K (29568+). W8A16 has K size limit (~16K).

GEMV Quantization Trade-offs (Explicit)

Why is W4A16 faster than NVF4/NVF4 despite both using 4-bit weights?

KernelA (Activation)B (Weight)Dequant WorkSpeed
W4A16BF16 (native)NVF4 (4-bit)1x (B only)104 us
NVF4/NVF4NVF4 (4-bit)NVF4 (4-bit)2x (A + B)219 us

Per Scale Block (32 elements):

OperationW4A16NVF4/NVF4
Scale load1 (B)2 (A + B)
Scale decode (LUT)12
Pre-scaled LUT build16 mul16 mul

Per Element:

OperationW4A16NVF4/NVF4
A conversionBF16->float (free)LUT lookup
B conversionLUT lookupLUT lookup

Conclusion: NVF4/NVF4 trades speed for memory. Use when:

  • Memory-constrained (A is 4x smaller)
  • Batch inference with large A tensors

For single-token decode (M=1), W4A16 or FP8 is recommended.

Comprehensive GEMV Benchmark (RTX 5090, SM120a)

All GEMV kernels compared on Qwen2.5-7B gate_proj (K=3584, N=18944):

KernelA dtypeB dtypeWeight SizeTime (us)vs BF16
BF16BF16BF16129.5 MB1211.00x
FP8/BF16 (W8A16)BF16FP864.8 MB2750.44x
FP8/FP8 (W8A8)FP8FP864.8 MB196.2x
NVF4/BF16 (W4A16)BF16NVF432.4 MB1250.97x
NVF4/NVF4 (W4A4)NVF4NVF432.4 MB2410.50x

Performance by Layer Type:

LayerKNBest KernelSpeedup
gate_proj358418944FP8/FP86.2x
down_proj189443584FP8/FP821.6x
o_proj35843584FP8/FP86.8x
qkv_proj3584512FP8/FP88.7x

Recommendation: FP8/FP8 is optimal for SM120 (Blackwell). NVF4/BF16 (W4A16) provides the best balance when FP8 compute is unavailable.

NVF4-BF16 GEMM Performance (RTX 5090, SM120a)

4-bit NVF4 GEMM with BF16 I/O using CUTLASS block-scaled tensor operations:

Matrix SizeNVF4xBF16NVF4xNVF4Notes
4096×409664 TFLOPS87 TFLOPSGPU-side quantization
8192×8192168 TFLOPS261 TFLOPS3-stage async pipeline
16384×16384446 TFLOPSPeak performance

Note: GPU-side BF16->NVF4 quantization with unit scaling. No host-device copies. Ideal for memory-bound LLM inference with 4x bandwidth reduction vs BF16.


Installation

pip install pygpukit

From source:

git clone https://github.com/m96-chan/PyGPUkit
cd PyGPUkit
pip install -e .

Requirements

  • Python 3.10+
  • NVIDIA GPU with drivers installed
  • CUDA 13.0+ (required for SM120/Blackwell features)
  • Optional: CUDA Toolkit (for JIT compilation of custom kernels)

Minimum Driver Versions (CUDA 13.x)

PlatformMinimum Driver
Linux590.44.01 or later
Windows572.16 or later (Game Ready/Studio)

Note: NVRTC (NVIDIA Runtime Compiler) is included in CUDA Toolkit. Pre-compiled GPU operations (matmul, add, mul, etc.) work with just GPU drivers.

Supported GPUs

GenerationArchitectureExamplesStatus
AmpereSM80-86A100, RTX 3090, RTX 3080Fully supported
Ada LovelaceSM89RTX 4090, RTX 4080Fully supported
HopperSM90H100, H200Fully supported
BlackwellSM100-120B100, B200, RTX 5090CUDA 13.0+ required
Turing/OlderSM < 80RTX 20XX, GTX 10XXNOT supported

Runtime Modes

ModeRequirementsFeatures
Full JITGPU drivers + CUDA ToolkitAll features including custom kernels
Pre-compiledGPU drivers onlyBuilt-in ops (matmul, add, mul)
CPU simulationNoneTesting/development without GPU

Quick Start

Basic Operations

importpygpukitasgp# Allocate arraysx=gp.zeros((1024, 1024), dtype="float32")
y=gp.ones((1024, 1024), dtype="float32")
# Operationsz=gp.add(x, y)
w=gp.matmul(x, y)
# CPU <-> GPU transferarr=z.to_numpy()
garr=gp.from_numpy(arr)

Custom JIT Kernel (requires CUDA Toolkit)

src='''extern "C" __global__void scale(float* x, float factor, int n) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < n) x[idx] *= factor;}'''ifgp.is_nvrtc_available():
kernel=gp.jit(src, func="scale")
kernel(x, factor=0.5, n=x.size)
else:
print("JIT not available. Using pre-compiled ops.")

Rust Scheduler

import_pygpukit_rustasrust# Memory Pool with LRU evictionpool=rust.MemoryPool(quota=100*1024*1024, enable_eviction=True)
block=pool.allocate(4096)
# QoS-aware task schedulingevaluator=rust.QosPolicyEvaluator(total_memory=8*1024**3, total_bandwidth=1.0)
task=rust.QosTaskMeta.guaranteed("task-1", "Critical Task", 256*1024*1024)
result=evaluator.evaluate(task)
# GPU Partitioningmanager=rust.PartitionManager(rust.PartitionConfig(total_memory=8*1024**3))
manager.create_partition("inference", "Inference",
rust.PartitionLimits().memory(4*1024**3).compute(0.5))

Features

Core Infrastructure (Rust)

FeatureDescription
Memory PoolLRU eviction, size-class free lists
SchedulerPriority queue, memory reservation
Transfer EngineSeparate H2D/D2H streams, priority
Kernel DispatchPer-stream limits, lifecycle tracking

Advanced Scheduler

FeatureDescription
Admission ControlDeterministic admission, quota enforcement
QoS PolicyGuaranteed/Burstable/BestEffort tiers
Kernel PacingBandwidth-based throttling per stream
GPU PartitioningResource isolation, multi-tenant support
Multi-LLM ExecutionConcurrent AI model execution with stream isolation
asyncio IntegrationNative Python async/await for concurrent inference

Project Goals

  1. Provide the smallest usable GPU runtime for Python
  2. Expose GPU scheduling (bandwidth, memory, partitioning)
  3. Make writing custom GPU kernels easy
  4. Serve as a building block for inference engines, DSP systems, and real-time workloads

Project Structure

PyGPUkit/
src/pygpukit/ # Python API (NumPy-compatible)
native/ # C++ backend (CUDA Driver API, NVRTC)
rust/ # Rust backend (memory pool, scheduler)
pygpukit-core/ # Pure Rust core logic
pygpukit-python/ # PyO3 bindings
.claude/ # Claude Code configuration
skills/ # Development workflow skills
agents/ # Specialized subagents
docs/ # Documentation guides
examples/ # Demo scripts
scripts/ # Build scripts, benchmarks
tests/ # Test suite

Roadmap

Released

VersionHighlights
v0.1GPUArray, NVRTC JIT, add/mul/matmul, wheels
v0.2.0Rust scheduler (QoS, partitioning), memory pool (LRU), 106 tests
v0.2.1API stabilization, error propagation
v0.2.2Ampere SGEMM (cp.async, float4), 18 TFLOPS FP32
v0.2.3TF32 TensorCore (PTX mma.sync), 28 TFLOPS
v0.2.4Single-binary distribution, dynamic NVRTC, driver-only mode
v0.2.5FP16/BF16 support, reduction ops, operator overloads, TF32 v2 (~30 TFLOPS)
v0.2.6CUTLASS backend (31 TFLOPS TF32, 63 TFLOPS FP16/BF16), Multi-LLM concurrent execution
v0.2.7Epilogue fusion (linear+bias+gelu), Multi-SM kernels, API review
v0.2.8CUTLASS v4.3.3 update, auto-update workflow
v0.2.9Unified LLM interface (CausalTransformerModel), ModelSpec abstraction, GPT-2/LLaMA/Qwen3 support
v0.2.10Dynamic cuBLASLt loading, CUDA Graph optimizations, descriptor caching
v0.2.11Batch decode (6.8x speedup), Decode Strategy framework, Driver API async, Dual CUDA builds, RTX 5090 (SM120)
v0.2.12Advanced audio processing (ISTFT, Griffin-Lim, HPSS, CQT, pitch detection, time stretch)
v0.2.15FP8 I/O GEMM (blockwise scaling), Pure NVF4 (446 TFLOPS), New math ops (sin, cos, sqrt, rsqrt, abs, neg, clamp, where, sigmoid, tanh, argmax, min, sum_axis)
v0.2.16MoE support (Mixtral), Thinking models (Qwen3), W8A8/W4A4 GEMV, W8A16/Int8/Int4 GEMM, Kernel restructure
v0.2.17Triton backend MVP, hybrid execution (Triton + Native CUDA), TritonArray wrapper
v0.2.18Codebase refactoring, Kokoro TTS, Positional encoding (PoPE/ALiBi/YaRN/NTK), ReLU², Unified benchmark, BF16 GEMV (98% BW), W8A16 fix
v0.2.19FLUX.1 image generation, Lazy model loading (streaming), cuBLAS dynamic loader, C++ kernel profiler, T5 encoder, DiT architecture, GPU-native diffusion ops

Planned

VersionGoals
v0.3Advanced Triton ops (attention), MPS/MIG

API Stability & Backward Compatibility

Version Policy

  • v0.2.x: Backward compatible within minor versions. New features may be added, but existing APIs remain stable.
  • v0.3+: May introduce breaking changes with deprecation warnings in prior version.

Stable Public API (v0.2.x)

All functions exported via pygpukit.* are part of the stable public API:

CategoryFunctions
Factoryzeros, ones, empty, from_numpy
Elementwiseadd, sub, mul, div, neg, abs, clamp, where
Mathexp, log, sqrt, rsqrt, sin, cos, tanh, sigmoid, relu, gelu, softmax
Matrixmatmul, transpose
Reductionssum, sum_axis, mean, max, min, argmax
Neurallayernorm, rmsnorm, silu, sdpa_causal, rope_inplace, bias_add_inplace, linear_bias_gelu
TypesGPUArray, DataType, float32, float64, float16, bfloat16, int32, int64, int8, uint8
LLMllm.SafeTensorsFile, llm.CausalTransformerModel, llm.load_model_from_safetensors
LLM (Experimental)llm.Tokenizer (use HuggingFace tokenizers for production)

Deprecation Policy

APIs to be removed will emit DeprecationWarning for at least one minor version before removal.


Contributing

See CONTRIBUTING.md for guidelines.

Quick Start:

  1. Fork and clone
  2. Create feature branch
  3. Build: ./build.sh 86 (Git Bash)
  4. Run checks: ruff check, mypy, pytest
  5. Submit PR

We Accept: Performance improvements, bug fixes, new GPU ops, documentation We Reject: cuda-python dependencies, training features, SM < 80 support


License

MIT License


Acknowledgements

Inspired by and built upon:

PyGPUkit aims to fill the gap for a tiny, embeddable GPU runtime for Python.


If this project saved you from a silent GPU bug, or helped you trust your results again, consider giving it a ⭐.

Correctness deserves visibility.


About

Minimal GPU runtime for Python - high-performance CUDA kernels, memory management, and LLM inference without heavy dependencies

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages