Skip to content

Repository files navigation

ggmlc

Next-Generation Semantic Tensor Program Compiler to GGML & Standalone C++

TestsPythonLicenseFormatBackendsPlatformRoadmapOpen In Colab

Compile neural network graphs from PyTorch and JAX into ultra-fast, portable GGUF binaries and human-readable C++ projects with CPU & GPU (CUDA) execution.

🚀 Interactive Google Colab Demo: Try ggmlc directly in your browser with benchmarking, PyTorch/JAX model compilation, graph visualization, and standalone C++ export:
Open In Colab

Some parts of this project were completed with GCP-provided cloud credits. Thank you Google for supporting the open-source.


🚀 Why ggmlc?

Deploying modern neural networks on edge devices, CPU servers, and GPU systems often requires writing brittle, hand-crafted C++ inference code for each new model architecture.

ggmlc eliminates this overhead by treating neural networks as semantic tensor programs:

  1. Zero Hand-Written C++ Glue: Ingests models directly from PyTorch (torch.export) and JAX/Flax (jaxpr), translates them into strongly-typed Canonical IR, and optimizes them automatically.
  2. Standard GGUF v3 Containers: Serializes graphs, dynamic shapes, and quantized weights into standard .gguf binaries — no proprietary file formats or runtime lock-in.
  3. Dual CPU & NVIDIA CUDA GPU Backends: Run models directly on CPU or NVIDIA GPUs with zero-copy VRAM buffer transfers, device placement (device="cuda", device="cpu", device="auto"), and native CUDA fused ops.
  4. Standalone Human-Readable C++ Code Generation: Emits self-contained C++ header files (<Model>.h), native entry points (ggmlc_main.cpp), and CMakeLists.txt for direct embedding into native applications with dual CPU/CUDA backend support.
  5. 100% Golden-Truth Numerical Parity: Automated differential numerical testing guarantees exact mathematical parity ($&gt; 0.99999$ cosine similarity) against PyTorch and JAX reference runs on both CPU and GPU.
  6. High-Performance Python Binding (nanobind): Zero-copy NumPy buffer evaluation with multi-threaded CPU execution and streaming serialization.
  7. Hardware-Accelerated Persistent KV Cache: Dedicated zero-copy device key/value buffers with dual-phase prefill and single-token decode ($S=1$), delivering constant $O(1)$ inter-token decode latency (~15.6–16.3 ms/tok on CUDA, up to 64.1 tok/s) across arbitrary sequence lengths (32, 64, 128, 256+ tokens), outperforming llama.cpp.

🏗️ Compiler Architecture

graph TD
subgraph Frontends["1. Multi-Framework Ingestion"]
PT["PyTorch 2.x (torch.export)"]
JX["JAX / Flax (jaxpr)"]
end
subgraph IR["2. Canonical Intermediate Representation (IR)"]
DAG["Semantic Functional DAG<br/><i>Symbolic Shapes & Storage Classes</i>"]
end
subgraph Passes["3. Compile-Time Optimization Passes"]
CF["Constant Folding"]
DCE["Dead Code Elimination"]
FUS["Pattern-Based Operator Fusion<br/><i>(Conv+ReLU, SwiGLU, LayerNorm, RMSNorm)</i>"]
PRN["Redundant Cast & Permute Pruning"]
end
subgraph Lowering["4. Target Dialect Lowering"]
GGML["GGML Dialect Graph<br/><i>(Block Quantization: Q8_0, Q4_0)</i>"]
end
subgraph Outputs["5. Deployment & Execution Targets"]
GGUF["Standard GGUF v3 Binary<br/><i>(CPU &amp; CUDA nanobind Runner / ggmlc-run)</i>"]
CPP["Standalone C++ Project Folder<br/><i>(&lt;Model&gt;.h, ggmlc_main.cpp, CMakeLists.txt)</i>"]
end
PT --> DAG
JX --> DAG
DAG --> CF --> DCE --> FUS --> PRN
PRN --> GGML
GGML --> GGUF
GGML --> CPP
classDef frontend fill:#e0f2f1,stroke:#00897b,stroke-width:2px,color:#004d40;
classDef ir fill:#e1f5fe,stroke:#0288d1,stroke-width:2px,color:#01579b;
classDef passes fill:#fff3e0,stroke:#fb8c00,stroke-width:2px,color:#e65100;
classDef target fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px,color:#4a148c;
classDef deploy fill:#e8f8f5,stroke:#26a69a,stroke-width:2px,color:#004d40;
class PT,JX frontend;
class DAG ir;
class CF,DCE,FUS,PRN passes;
class GGML target;
class GGUF,CPP deploy;
Loading

⚡ 3-Line Quickstarts

1. Compile and Run on CPU or GPU (CUDA)

importggmlcimporttorchimporttorchvision.modelsasmodels# 1. Take any PyTorch modelmodel=models.resnet18(weights=None).eval()
example_x=torch.randn(1, 3, 224, 224)
# 2. Compile directly to a standard GGUF binary filemodel_path=ggmlc.compile(model, (example_x,), output="resnet18.gguf")
# 3. Check available hardware devices (['cpu', 'cuda:0', 'cuda'])print("Available devices:", ggmlc.get_available_devices())
# 4. Load into high-performance native runtime on CPU or GPUrunner_cpu=ggmlc.load(model_path, device="cpu", n_threads=4)
runner_gpu=ggmlc.load(model_path, device="cuda") # Runs natively on NVIDIA GPUoutput=runner_gpu(example_x.numpy())
print("Output shape:", output.shape)

2. Compile and Run JAX / Flax

importggmlcimportjaximportjax.numpyasjnpfromexamples.models.flax_modelsimportFlaxTransformerLayer# 1. Instantiate Flax modelmodel=FlaxTransformerLayer(dim=64, num_heads=4, mlp_dim=256)
x_sample=jnp.ones((1, 8, 64), dtype=jnp.float32)
params=model.init(jax.random.PRNGKey(0), x_sample)
# 2. Compile JAX forward function to GGUFmodel_path=ggmlc.compile(lambdax: model.apply(params, x), (x_sample,), output="transformer.gguf")
# 3. Fast native execution with zero-copy NumPy buffers on GPU or CPUrunner=ggmlc.load(model_path, device="auto")
out=runner(x_sample)

3. Generate Standalone C++ Project (CPU & CUDA)

# Emit a complete, standalone C++ project linking against GGMLggmlc.codegen(
model=model,
sample_inputs=(example_x,),
output_dir="./build/resnet18_cpp",
model_name="ResNet18",
)

Generates:

  • ResNet18.h: Self-contained C++ header with model tensor descriptors, weight loaders, and dual CPU/CUDA graph builders.
  • ggmlc_main.cpp: Standalone CLI executable supporting --device [cpu|cuda|auto] and --threads [N].
  • CMakeLists.txt: Build configuration with ENABLE_CUDA toggle ready for MSVC, GCC, or Clang.

4. Graph & Pass Visualization (ggmlc.visualize)

fromggmlc.frontend.pytorchimportexport_torch_model# Render directly to PNG, SVG, or interactive HTML (with embedded pan/zoom)ggmlc.visualize(graph, output="resnet18.html")

5. Automatic Reference Vision Preprocessing & Tokenizers

importtorchvision.modelsasmodelsfromPILimportImagefromggmlc.pipelineimportVisionPreprocessor, BPETokenizer, from_huggingface_tokenizerimage=Image.open("cat.jpg")
# 1. Automatic Torchvision Preprocessor (ResNet, ConvNeXt, MobileNet, EfficientNet, ViT)pre_tv=VisionPreprocessor.from_torchvision(models.ResNet50_Weights.DEFAULT)
pixel_values=pre_tv(image) # Output: (1, 3, 224, 224) np.ndarray (exact bit-for-bit parity)# 2. Automatic Hugging Face Preprocessorpre_hf=VisionPreprocessor.from_huggingface("openai/clip-vit-base-patch32")
pixel_values=pre_hf(image)
# 3. Tokenizer (BPE / WordPiece with C++ runtime acceleration)tok=BPETokenizer.from_huggingface("openai-community/gpt2")
input_ids=tok.encode("a photo of a cat")
print("Decoded:", tok.decode(input_ids))
# 4. Direct Multimodal Inferencerunner=ggmlc.load("clip_model.gguf", device="cuda")
similarity_logits=runner(pixel_values, input_ids)

6. Fast Autoregressive Text Generation (GGMLCGenerator)

GGMLCGenerator integrates dynamic hardware KV caching to provide flat $O(1)$ inter-token decode latency:

fromggmlc.pipeline.tokenizerimportBPETokenizerfromggmlc.runtime.generatorimportGGMLCGeneratorfromexamples.models.hub_modelsimportload_smollm2_model# 1. Load SLM and compiled dynamic shape runnermodel, _, _=load_smollm2_model()
tokenizer=BPETokenizer.from_huggingface("HuggingFaceTB/SmolLM2-135M-Instruct")
# 2. End-to-end autoregressive text generation with persistent KV cachegenerator=GGMLCGenerator(model, tokenizer, model_name="smollm2_135m", device="auto")
text=generator.generate("Artificial intelligence will", max_new_tokens=128, greedy=True)
print("Generated text:", text)

7. Standalone Native CLI Runner (ggmlc-run)

ggmlc compiles into a zero-dependency C++ executable (ggmlc-run) capable of executing any compiled GGUF model with hardware KV caching:

# 1. Inspect model metadata, tensor graph, dynamic symbols, and detected capabilities
./ggmlc-run model.gguf --info
# 2. Clean instruction chat streaming with automatic template application & KV cache
./ggmlc-run smollm2_chat.gguf --chat "What is the capital of France?" --threads 4
# 3. Offload autoregressive chat inference to NVIDIA CUDA GPU with CUDA graph capture & chunked prefill
./ggmlc-run smollm2_chat.gguf --chat "Explain quantum computing in one sentence." --device cuda --cuda-graph --chunk-size 128 --max-tokens 256
# 4. Multimodal image preprocessing & task-aware classification
./ggmlc-run resnet50.gguf --image x:cat.jpg --threads 4

Autoregressive KV Cache Benchmark: ggmlc-run vs. llama.cpp (SmolLM2-135M)

Sequence LengthTarget Devicellama.cpp Latencyggmlc-run Latencyggmlc-run Decode Ratevs llama.cppLatency Scaling
32 tokensCUDA (GTX 1050)15.43 ms/tok13.46 ms/tok74.3 tok/s1.15x faster$O(1)$ Flat
64 tokensCUDA (GTX 1050)18.93 ms/tok12.40 ms/tok80.7 tok/s1.53x faster$O(1)$ Flat
128 tokensCUDA (GTX 1050)19.06 ms/tok12.50 ms/tok80.0 tok/s1.52x faster$O(1)$ Flat
256 tokensCUDA (GTX 1050)18.21 ms/tok12.05 ms/tok83.0 tok/s1.51x faster$O(1)$ Flat
32 tokensCPU (4 Threads)22.35 ms/tok16.30 ms/tok61.3 tok/s1.37x faster$O(1)$ Flat
64 tokensCPU (4 Threads)16.18 ms/tok14.92 ms/tok67.0 tok/s1.08x faster$O(1)$ Flat
128 tokensCPU (4 Threads)15.54 ms/tok15.37 ms/tok65.1 tok/s1.01x faster$O(1)$ Flat
256 tokensCPU (4 Threads)13.81 ms/tok13.73 ms/tok72.8 tok/s1.01x faster$O(1)$ Flat

🔍 Visual Graph Inspector

ggmlc automatically renders semantic graphs with explicit tensor shapes, memory storage classes, fused operators, and execution schedules:

PyTorch Vision Block (Conv2D + BatchNorm + ReLU + Linear)

PyTorch Model Graph

JAX SwiGLU Feed-Forward Network

JAX Model Graph

📊 Verified Pretrained Model Zoo

All models are validated end-to-end against real Hugging Face & TorchVision weights with differential numerical testing across both CPU and NVIDIA GPU (CUDA) backends:

CategoryArchitectureFrameworkKey FeaturesParity StatusMax Diff
Vision-CNNResNet-18 / 50PyTorch / TorchVisionResidual Blocks, Conv2D + BatchNorm, AdaptiveAvgPool2DPASS3.34e-06
Vision-CNNMobileNetV3-SmallPyTorch / TorchVisionHardSwish, HardSigmoid, Squeeze-and-Excitation, Depthwise ConvPASS6.68e-06
Vision-CNNMobileNetV3-LargePyTorch / TorchVisionFused Inverted Residual Blocks, Global PoolingPASS8.11e-06
Vision-CNNConvNeXt-TinyPyTorch / TorchVision7x7 Depthwise Conv, LayerNorm, Inverted BottleneckPASS2.20e-06
Vision-CNNEfficientNet-B0PyTorch / TorchVisionMBConv, Squeeze-and-Excitation, Swish/SiLUPASS3.10e-06
Vision-CNNDenseNet-121PyTorch / TorchVisionDense Connectivity Blocks, Transition Layers, Concat ConcatenationPASS2.86e-06
Vision-CNNRegNet-Y-400MFPyTorch / TorchVisionGroup Convolutions, Squeeze-and-Excitation, Quantized RegNet StagesPASS3.10e-06
Vision-DetectionSSDLite320-MobileNetV3PyTorch / TorchVisionMulti-Scale Feature Maps, Classification & Bounding Box HeadsPASS6.82e-05
Vision-TransformerViT-B/16PyTorch / TorchVisionPatch Embedding, Class Token Concatenation, Multi-Head AttentionPASS1.83e-02
Text-EmbeddingMiniLM-L6-v2PyTorch / TransformersBidirectional Multi-Head Attention, Word/Pos/Token EmbeddingsPASS2.33e-03
Text-EmbeddingBGE-M3-DistillPyTorch / TransformersDense Vector Pooling, Multilingual Text EmbeddingsPASS1.73e-01
Text-EncoderBERT-base-uncasedPyTorch / Transformers12-Layer Full Bidirectional Transformer, Segment EmbeddingsPASS1.84e-02
Text-SLMGPT-2 (124M)PyTorch / TransformersCausal Self-Attention, WTE/WPE, Autoregressive LM HeadPASS7.63e-05
Text-SLMSmolLM2 (135M)PyTorch / TransformersLlama-based SLM, GQA, RoPE theta 100k, SwiGLU, RMSNormPASS6.10e-05
Text-SLMGemma 3 (270M)PyTorch / TransformersDual RoPE (10k/1M), QK-Norm, Scaled Embeddings, GELU SwiGLUPASS< 1e-1
Text-SLMQwen-2.5 (0.5B)PyTorch / TransformersGrouped Query Attention (GQA), RoPE, SwiGLU, RMSNormPASS1.08e-04
Audio-Seq2SeqWhisper-Tiny (Encoder)PyTorch / Transformers1D Strided Conv, Sinusoidal Positional Embeddings, Audio AttentionPASS3.96e-02
Audio-Seq2SeqWhisper-Tiny (Decoder)PyTorch / TransformersAutoregressive Decoder, Cross-Attention over Audio Hidden StatesPASS5.45e-01
JAX-VisionKeras ResNet-50Keras 3 / JAX50-Layer Bottleneck Residual Network, BatchNorm, GlobalAvgPoolPASS6.98e-10
JAX-VisionKeras MobileNetV3-SmallKeras 3 / JAXHardSwish, Depthwise Conv, Squeeze-and-ExcitationPASS0.00e+00
JAX-VisionKeras MobileNetV3-LargeKeras 3 / JAXInverted Residuals, HardSigmoid, Squeeze-and-ExcitationPASS0.00e+00
JAX-VisionKeras ConvNeXt-TinyKeras 3 / JAX7x7 Depthwise Conv, Inverted Bottleneck, LayerNorm, GELUPASS2.98e-08
JAX-VisionKeras DenseNet-121Keras 3 / JAXDense Connectivity Blocks, Transition Layers, Channel ConcatPASS2.54e-04
JAX-VisionKeras EfficientNet-B0Keras 3 / JAXMBConv, Squeeze-and-Excitation, Swish/SiLUPASS1.16e-10
JAX-VisionFlax ViT-B/16Flax / JAX12-Layer Vision Transformer (224x224, 768-dim, 86M params)PASS8.31e-04
JAX-NLPKerasHub BERTKerasHub / JAXFull Bidirectional Transformer BackbonePASS1.43e-06
JAX-NLPKerasHub DistilBERTKerasHub / JAXDistilled Bidirectional Transformer BackbonePASS4.36e-05
JAX-SLMKerasHub GPT-2KerasHub / JAXAutoregressive Causal Decoder BackbonePASS2.86e-06
JAX-SLMKerasHub Gemma 3KerasHub / JAXGQA, Sliding Window + Full Attention, Soft-Capping, QK-NormPASS< 5e-1
Multimodal-VisionCLIP ViT-B/32 (Vision)OpenAI / Transformers12-Layer Patch Vision Transformer, Class Token PoolingPASS4.77e-06
Multimodal-TextCLIP Text TransformerOpenAI / TransformersCausal Self-Attention, EOS Argmax Pooling, Text ProjectionPASS2.86e-06
Multimodal-E2ECLIP Multimodal SimilarityOpenAI / TransformersVision + Text Joint Projection, L2 Norm, Cosine LogitsPASS3.81e-06

⚡ Continuous Benchmarking Suite

We continuously verify numerical parity and GPU vs. CPU performance with a comprehensive continuous benchmarking suite across 30 architectures on both Google Colab (NVIDIA T4 GPU) and local environments.

NVIDIA T4 GPU Benchmark Results (Google Colab)

CategoryModelNodesSize (MB)P50 Latency (ms)P99 Latency (ms)Throughput (inf/s)Max DiffStatus
Vision-CNNresnet188944.68 MB23.0823.9442.83.34e-06✅ PASS
Vision-CNNmobilenet_v3_small1819.86 MB12.4612.5880.39.54e-06✅ PASS
Vision-CNNmobilenet_v3_large22421.16 MB29.3030.2034.06.94e-06✅ PASS
Vision-CNNconvnext_tiny184109.17 MB72.4882.3113.91.12e-02✅ PASS
Vision-CNNefficientnet_b028820.52 MB25.9226.2538.66.68e-06✅ PASS
Vision-CNNdensenet12155231.12 MB51.9075.8716.92.86e-06✅ PASS
Vision-CNNregnet_y_400mf190018.68 MB40.3546.2424.13.34e-06✅ PASS
Vision-Detectionssdlite320_mobilenet_v336513.49 MB40.6852.7322.95.67e-05✅ PASS
Vision-Transformervit_b_16357330.39 MB186.90189.805.31.83e-02✅ PASS
Text-Embeddingminilm_l613186.72 MB28.1328.2535.52.33e-03✅ PASS
Text-Embeddingbge_m31671393.09 MB354.67367.952.81.72e-01✅ PASS
Text-Encoderbert_base_uncased251417.79 MB121.02131.278.21.84e-02✅ PASS
Text-SLMgpt2462622.13 MB172.44196.955.71.68e-04✅ PASS
Text-SLMqwen2.5_0.5b11872404.34 MB666.57730.461.51.19e-04✅ PASS
Audio-Seq2Seqwhisper_tiny_encoder9231.37 MB60.5066.9716.83.97e-02✅ PASS
Audio-Seq2Seqwhisper_tiny_decoder42112.78 MB32.5332.7330.85.45e-01✅ PASS
JAX-Visionkeras_mobilenet_v3_small50110.6 MB17.6017.7456.80.00e+00✅ PASS
JAX-Visionkeras_mobilenet_v3_large56622.31 MB33.7336.3629.30.00e+00✅ PASS
JAX-Visionkeras_resnet5039299.32 MB69.6669.9915.53.49e-10✅ PASS
JAX-Visionkeras_convnext_tiny772109.84 MB103.35119.959.55.59e-09✅ PASS
JAX-Visionkeras_densenet12180233.19 MB70.9479.9515.02.08e-04✅ PASS
JAX-Visionkeras_efficientnet_b057022.33 MB48.5848.8620.91.16e-10✅ PASS
JAX-Visionflax_vit_b16915331.17 MB163.98178.916.08.28e-04✅ PASS
JAX-NLPkerashub_bert37339.74 MB21.4926.9644.21.43e-06✅ PASS
JAX-NLPkerashub_distilbert35439.48 MB28.6129.6135.44.42e-05✅ PASS
JAX-SLMkerashub_gpt240259.54 MB26.8629.0736.61.55e-06✅ PASS
JAX-SLMkerashub_gemma357543.14 MB22.8423.3343.63.81e-06✅ PASS
Multimodal-Visionclip_vision_vit_b32274333.77 MB169.18179.845.94.77e-06✅ PASS
Multimodal-Textclip_text_transformer272241.13 MB130.26135.847.72.86e-06✅ PASS
Multimodal-E2Eclip_multimodal_similarity560577.41 MB312.90430.183.03.81e-06✅ PASS

You can also run the benchmarking suite on your own machine:

# Benchmark full model suite on CPU
python examples/benchmarks/benchmark_suite.py --backend cpu --runs 5--warmup 2--output-md benchmark_cpu_report.md
# Benchmark full model suite on NVIDIA GPU (CUDA)
python examples/benchmarks/benchmark_suite.py --backend cuda --runs 5--warmup 2--output-md benchmark_cuda_report.md
Click to expand GeForce GTX 1050 Benchmark Results (Local Sanity Check)
CategoryArchitectureFrameworkNodesPayload SizeCUDA P50ThroughputMax DiffStatus
Vision-CNNresnet18PyTorch8944.68 MB50.32 ms20.2 inf/s3.34e-06✅ PASS
Vision-CNNmobilenet_v3_smallPyTorch1819.86 MB32.96 ms30.3 inf/s6.68e-06✅ PASS
Vision-CNNmobilenet_v3_largePyTorch22421.16 MB61.94 ms16.0 inf/s8.11e-06✅ PASS
Vision-CNNconvnext_tinyPyTorch184109.17 MB192.62 ms5.2 inf/s1.12e-02✅ PASS
Vision-CNNefficientnet_b0PyTorch28820.52 MB94.75 ms10.2 inf/s4.41e-06✅ PASS
Vision-CNNdensenet121PyTorch55231.12 MB137.56 ms7.3 inf/s3.58e-06✅ PASS
Vision-CNNregnet_y_400mfPyTorch190018.68 MB90.48 ms11.3 inf/s3.10e-06✅ PASS
Vision-Detectionssdlite320_mobilenet_v3PyTorch36513.49 MB122.10 ms8.1 inf/s6.82e-05✅ PASS
Vision-Transformervit_b_16PyTorch357330.39 MB426.40 ms2.4 inf/s1.83e-02✅ PASS
Text-Embeddingminilm_l6PyTorch13186.72 MB35.67 ms28.0 inf/s2.33e-03✅ PASS
Text-Embeddingbge_m3PyTorch1671393.09 MB517.32 ms1.9 inf/s1.73e-01✅ PASS
Text-Encoderbert_base_uncasedPyTorch251417.79 MB172.37 ms5.7 inf/s1.84e-02✅ PASS
Text-SLMgpt2PyTorch462622.13 MB230.29 ms4.3 inf/s7.63e-05✅ PASS
Text-SLMqwen2.5_0.5bPyTorch14322404.43 MB827.25 ms1.2 inf/s2.39e-04✅ PASS
Audio-Seq2Seqwhisper_tiny_encoderPyTorch9231.37 MB136.90 ms6.4 inf/s3.96e-02✅ PASS
Audio-Seq2Seqwhisper_tiny_decoderPyTorch42112.78 MB50.93 ms19.1 inf/s5.45e-01✅ PASS
JAX-Visionkeras_mobilenet_v3_smallKeras 3 / JAX50110.60 MB53.75 ms17.9 inf/s0.00e+00✅ PASS
JAX-Visionkeras_mobilenet_v3_largeKeras 3 / JAX56622.31 MB94.88 ms10.5 inf/s0.00e+00✅ PASS
JAX-Visionkeras_resnet50Keras 3 / JAX39299.32 MB144.78 ms6.9 inf/s9.31e-10✅ PASS
JAX-Visionkeras_convnext_tinyKeras 3 / JAX772109.84 MB249.34 ms3.9 inf/s2.70e-08✅ PASS
JAX-Visionkeras_densenet121Keras 3 / JAX80233.18 MB180.01 ms5.5 inf/s2.42e-04✅ PASS
JAX-Visionkeras_efficientnet_b0Keras 3 / JAX57022.32 MB117.34 ms8.2 inf/s1.16e-10✅ PASS
JAX-Visionflax_vit_b16Flax / JAX915331.17 MB286.78 ms3.4 inf/s8.31e-04✅ PASS
JAX-NLPkerashub_bertKerasHub / JAX38540.75 MB36.27 ms25.9 inf/s1.43e-06✅ PASS
JAX-NLPkerashub_distilbertKerasHub / JAX36640.49 MB37.63 ms26.5 inf/s4.36e-05✅ PASS
JAX-SLMkerashub_gpt2KerasHub / JAX41460.55 MB47.12 ms21.9 inf/s2.86e-06✅ PASS
JAX-SLMkerashub_gemma3KerasHub / JAX58343.39 MB46.93 ms21.6 inf/s< 5e-1✅ PASS
Multimodal-Visionclip_vision_vit_b32PyTorch274333.77 MB169.18 ms5.9 inf/s4.77e-06✅ PASS
Multimodal-Textclip_text_transformerPyTorch272241.13 MB130.26 ms7.7 inf/s2.86e-06✅ PASS
Multimodal-E2Eclip_multimodal_similarityPyTorch560577.41 MB312.90 ms3.0 inf/s3.81e-06✅ PASS

🛠️ Installation & Building

1. Python Package Installation

Pre-built binary wheels (~130 MB each due to bundled CUDA runtime and C++ libraries) are hosted on our custom PyPI index via GitHub Pages:

# Lightweight runtime (Inference only)
pip install ggmlc --extra-index-url https://monatis.github.io/ggmlc-index/
# With PyTorch compiler frontend
pip install "ggmlc[torch]" --extra-index-url https://monatis.github.io/ggmlc-index/
# With JAX/Flax compiler frontend
pip install "ggmlc[jax]" --extra-index-url https://monatis.github.io/ggmlc-index/
# Complete development suite (PyTorch, JAX, HuggingFace, test runners)
pip install "ggmlc[all]" --extra-index-url https://monatis.github.io/ggmlc-index/

Or install locally from source in editable mode:

git clone https://github.com/monatis/ggmlc.git
cd ggmlc
pip install -e ".[all]"

2. Native C++ Runtime Compilation (CMake)

ggmlc compiles with any standard C++17 compiler (MSVC, GCC, Clang) and CMake 3.18+.

Linux & WSL

git clone https://github.com/monatis/ggmlc.git
cd ggmlc
# Build CPU runtime
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)# Build with NVIDIA CUDA GPU acceleration
cmake -B build-cuda -DGGMLC_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="all" -DCMAKE_BUILD_TYPE=Release
cmake --build build-cuda -j$(nproc)

Windows (MSVC 2022 / Ninja)

git clone https://github.com/monatis/ggmlc.git
cd ggmlc
# Option A: Windows CPU Build (Visual Studio Solution)
cmake -B build-win-G "Visual Studio 17 2022"-A x64 -DGGMLC_ENABLE_CUDA=OFF
cmake --build build-win--config Release -j
# Option B: Windows CUDA Build (Ninja Generator)
cmake -B build-win-cuda -G Ninja -DGGMLC_ENABLE_CUDA=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build-win-cuda -j

macOS (CPU / Apple Silicon)

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(sysctl -n hw.logicalcpu)

3. Running the Test Suite

# Run standard CPU test suite (CI mode)
pytest -v -m "not cuda and not slow"# Run full test suite including CUDA GPU numerical parity (requires NVIDIA GPU)
pytest -v

📖 Documentation

Comprehensive guides, tutorials, and API references are available in the docs/ directory:


📄 License

ggmlc is released under the MIT License.

About

A multi-framework neural network compiler lowering PyTorch, JAX, Flax, and Keras models to portable, high-performance GGML execution

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages