How buddy-compiler/buddy-mlir works
BUDDY MLIR combines a DSL-to-DSA compiler with packaged model inference. The documented workflow builds a model from a spec (optionally importing local HuggingFace weights), then runs its .rax artifact through buddy-cli. The compiler graph preserves Python frontend/lowering and MLIR dialect/conversion stages; the runtime graph covers manifest-based model loading, model-specific inference, and text, audio, and vision-language use cases. Some subsystem links are documented only at a high level; unsampled implementation details are not inferred as specific calls.
Main entry points: buddy-cli.cpp Inference CLI · build_model.py Model codegen · Llama31TTRunner.cpp Llama runner · frontend.py Python frontend
Components 21
Compiler frontend
- Python frontend
frontend/Python/frontend.py - Frontend generator
frontend/FrontendGen/lib/Parser.cpp - TTIR operations
frontend/Python/ops/ttir_llm.py - Graph transforms
frontend/Python/graph/transform
MLIR optimization
- MLIR dialects
midend/lib/Dialect - Conversion passes
midend/lib/Conversion - LLVM export
midend/lib/Target/LLVMIR/ConvertBuddyToLLVMIR.cpp
Model packaging
- Model codegen
tools/buddy-codegen/build_model.py - Model import
tools/buddy-codegen/import_model.py - RAX model artifact
Inference runtime
- Inference CLI
tools/buddy-cli/buddy-cli.cpp - Manifest resolver
runtime/include/buddy/runtime/core/ModelManifest.h - Inference runner
runtime/include/buddy/runtime/core/InferenceRunner.h - Text generation
runtime/llm/TextGeneration.cpp - Token sampler
runtime/include/buddy/runtime/llm/Sampler.h
Model capabilities
- Llama runner
models/llama31_tt/Llama31TTRunner.cpp - BGE-M3 embeddings
models/bge_m3/BgeM3EmbeddingModel.cpp - Whisper transcription
models/whisper/WhisperRuntime.cpp - Qwen3-VL vision
models/qwen3_vl/Qwen3VLRuntime.cpp
Other components
- Model developer
- Inference result
Connections 20
- Model developer → Model codegen: builds model
README.md - Model codegen → Model import: imports weights
- Model codegen → Python frontend: lowers model
- Python frontend → Graph transforms: transforms graph
- TTIR operations → Graph transforms: provides operations
- Frontend generator → MLIR dialects: generates definitions
- MLIR dialects → Conversion passes: supports conversion
- Conversion passes → LLVM export: lowers to LLVM
- Model codegen → RAX model artifact: produces RAX
README.md - Model developer → Inference CLI: runs model
README.md - Inference CLI → RAX model artifact: loads artifact
tools/buddy-cli/buddy-cli.cpp - Inference CLI → Manifest resolver: resolves manifest
tools/buddy-cli/buddy-cli.cpp - Inference CLI → Inference runner: invokes runner
tools/buddy-cli/buddy-cli.cpp - Inference runner → Text generation: generates text
- Llama runner → Token sampler: uses sampler
models/llama31_tt/Llama31TTRunner.cpp - Llama runner → Manifest resolver: reads manifest
models/llama31_tt/Llama31TTRunner.cpp - Text generation → Inference result: returns text
- Inference CLI → Whisper transcription: supports audio
README.md - Inference CLI → Qwen3-VL vision: supports images
README.md - BGE-M3 embeddings → Inference result: returns embeddings