Note
Work in Progress - Experimental
MojoSplat is an experimental port of Gaussian Splatting kernels to Mojo, exploring the potential performance and multi-vendor support of Mojo for GPU acceleration.
This project implements the three core kernels of 3D Gaussian Splatting:
- Projection: Transform 3D Gaussians to 2D image space
- Binning: Sort and assign Gaussians to screen tiles
- Rasterization: Render Gaussians to pixels with alpha blending
You can call the render function or any of the individual kernels directly from python (using pytorch). The mojo kernels will be compiled on the fly.
| Kernel | PyTorch | GSplat | Mojo | 
|---|---|---|---|
| Projection | ✅ | ✅ | ✅ | 
| Binning | ✅ | ✅ | ❌ (WIP) | 
| Rasterization | ❌* | ✅ | ✅ | 
*PyTorch rasterization falls back to GSplat implementation
Warning
- This is NOT production ready or even finished.
- Due to Mojo compiler limitations the compiler optimizes on tensor shapes. This causes some kernels to need to be recompiled if either the number of gaussians change or the view matrix changes.
- Performance is inferior to the GSplat CUDA version. Maybe some day we will be capable of surpassing it.
- Mojo is evolving very fast. Faster than I work on this (this is very much a side project). So thsi projects will likely not be up to date with latest Mojo all the time as each update requires a non insignificant amount of work. Particularly the Mojo interop with python/torch is a very novel thigns and the API is changing with every version.
For development or standalone usage, this project uses uv for dependency management:
# Clone the repository
git clone https://github.com/bertaveira/mojosplat.git
cd mojosplat
# Install dependencies and activate environment
uv syncpip install git+https://github.com/bertaveira/mojosplat.gitAdd to your pyproject.toml:
dependencies = [
    "mojosplat @ git+https://github.com/bertaveira/mojosplat.git",
    # ... your other dependencies
]Add to your requirements.txt:
git+https://github.com/bertaveira/mojosplat.git
dependencies:
  - pip
  - pip:
    - git+https://github.com/bertaveira/mojosplat.gituv run render_sample.pyimport torch
from mojosplat.render import render_gaussians
from mojosplat.projection import Camera
# Your 3D Gaussian data
means3d = torch.randn(1000, 3, device='cuda')
scales = torch.randn(1000, 3, device='cuda') 
quats = torch.randn(1000, 4, device='cuda')
opacities = torch.randn(1000, 1, device='cuda')
features = torch.randn(1000, 3, device='cuda')  # RGB colors
# Set up camera
camera = Camera(...)  # Configure your camera parameters
# Render with different backends
image_mojo = render_gaussians(means3d, scales, quats, opacities, features, camera, backend="mojo")
image_gsplat = render_gaussians(means3d, scales, quats, opacities, features, camera, backend="gsplat")  
image_torch = render_gaussians(means3d, scales, quats, opacities, features, camera, backend="torch")# Run all tests
uv run pytest
# Run specific kernel tests
uv run pytest tests/test_projection_mojo.py
uv run pytest tests/test_binning.py  
uv run pytest tests/test_rasterization.py
uv run pytest tests/test_render.py
# Run with verbose output
uv run pytest -v# Benchmark projection kernels
uv run python examples/benchmark_proj.py
# Benchmark full rendering pipeline  
uv run python examples/benchmark.pyBenchmarks coming soon - performance data will be added once comprehensive testing is complete.
Contributions are very welcome! This is an experimental project exploring the intersection of Mojo and high-performance graphics.
Areas where help is needed:
- Mojo Binning Kernel: Complete the binning implementation in Mojo
- PyTorch Rasterization: Native PyTorch rasterization kernel
- Performance Optimization: Analyse current implementation and improve existing Mojo kernels. For example, try to udnersdtand how the generated PTX compares with GSplat and how we can get closer or surpass its performance. Also measure the overhead of the python to mojo connection.
- Backwards pass: implement the mojo kernels for the backwards pass. This will allow the MojoSplat to be used in training the gaussian representation.
- Testing: More comprehensive test coverage
- Unscented Projection: Implmeent the Unscented projection from 3DGUT as an alternative to EWA
To contribute:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Submit a pull request
[License information to be added]
- GSplat for the reference implementation
- 3D Gaussian Splatting for the original method
- Modular for the Mojo language