A modern domain-specific language for machine learning that compiles to PyTorch
Project description
Write focused model architecture in .aur. Ship readable PyTorch.
Aurane is a compiler-oriented machine learning DSL with parsing, semantic checks, type/shape inference, IR lowering, optimization, profiling, visualization, and a polished CLI workflow.
Why Aurane
Aurane keeps model authoring compact without hiding the generated code. It is designed for developers who want high-signal model definitions, fast feedback from analysis tools, and clean Python output that still feels familiar to PyTorch users.
flowchart LR
A[".aur source"] --> B["Parser"]
B --> C["Semantic + Type Checks"]
C --> D["Optimizer"]
D --> E["IR Lowering"]
E --> F["PyTorch Generator"]
F --> G["Readable Python"]
Quick Look
use torch
experiment SimpleExample:
seed = 42
device = "cpu"
model TinyNet:
input_shape = (3, 32, 32)
def forward(x):
x -> conv2d(16, kernel=3).relu
-> maxpool(2)
-> flatten()
-> dense(64).relu
-> dense(10)
Compile it:
aurane compile examples/simple.aur tiny_net.py --validate --format
Generated shape:
class TinyNet(nn.Module):
def __init__(self):
super().__init__()
self.conv2d1 = nn.Conv2d(3, 16, 3, stride=1, padding=0)
self.dense1 = nn.Linear(3600, 64)
self.dense2 = nn.Linear(64, 10)
def forward(self, x):
x = F.relu(self.conv2d1(x))
x = F.max_pool2d(x, 2)
x = torch.flatten(x, 1)
x = F.relu(self.dense1(x))
x = self.dense2(x)
return x
Install
git clone https://github.com/desenyon/aurane.git
cd aurane
# Compiler and CLI
pip install -e .
# Full ML extras
pip install -e ".[all]"
# Developer tools
pip install -e ".[dev]"
Requirements:
- Python 3.10+
- Rich for the CLI experience
- PyTorch 2.0+ for running generated ML programs
CLI Surface
| Command | Purpose | Example |
|---|---|---|
compile |
Generate Python from .aur |
aurane compile model.aur model.py --validate --format |
check |
Run semantic and type/shape checks | aurane check model.aur --semantic --types --json |
inspect |
Browse AST and model stats | aurane inspect model.aur --verbose --stats --export ast.json |
visualize |
Render architecture graphs | aurane visualize model.aur --format mermaid |
profile |
Estimate params, FLOPs, memory | aurane profile model.aur --detailed |
ir |
Dump lowered intermediate representation | aurane ir model.aur --format json |
watch |
Recompile on change | aurane watch model.aur model.py --analyze |
lint |
Find and fix simple source issues | aurane lint model.aur --auto-fix |
format |
Normalize Aurane source style | aurane format examples/ --check |
Release 2.0 Highlights
- Graph-aware parser: supports sequential chains and explicit graph-style forward definitions without confusing kwargs for assignments.
- Backend registry: code generation now routes through a backend layer instead of hard-coding one path.
- IR tooling: lower models into a structured intermediate representation with
aurane ir. - First-class checks: semantic analysis and type/shape validation are exposed through
aurane check. - Safer CLI exits:
python -m aurane.clinow preserves command return codes. - Stable cache keys: cached compilation output includes backend/options/schema information to avoid stale generated code.
- Better visualization: Mermaid and DOT output preserve labels, shapes, and parameter counts.
- Release-grade examples: the bundled CNN, ResNet, Transformer, GAN, and simple examples compile, check, and syntax-validate.
Language Features
| Area | Supported |
|---|---|
| Models | model, input_shape, sequential forward chains, graph forward blocks |
| Layers | conv2d, dense, linear, flatten, maxpool, avgpool, dropout, batch_norm, batchnorm, reshape, embedding, multihead_attention, layer_norm, positional_encoding |
| Activations | relu, gelu, sigmoid, tanh, softmax, leaky_relu, residual |
| Analysis | semantic issues, type/shape inference, parameter counts, FLOPs estimates |
| Output | idiomatic PyTorch modules and training scaffolds |
Examples
The examples/ directory includes:
simple.aur- compact CNN startermnist.aur- MNIST training pipelineresnet.aur- deeper convolutional classifiertransformer.aur- language-model style architecturegan.aur- generator/discriminator pair
Run the full example smoke path:
for file in examples/*.aur; do
aurane check "$file" --semantic --types
aurane compile "$file" "/tmp/$(basename "$file" .aur).py" --quiet
done
Project Map
aurane/
parser.py # .aur source to AST
semantic_analyzer.py # DSL-level diagnostics
type_checker.py # tensor shape/type checks
optimizer.py # AST optimization passes
ir.py # intermediate representation
backends/ # backend registry and torch backend
codegen_torch.py # PyTorch source generation
profiler.py # params/FLOPs/memory estimates
visualizer.py # rich, Mermaid, and DOT architecture output
cli/ # command-line interface
Development
uv run --extra dev black --check aurane tests
uv run --extra dev mypy aurane
uv run --extra dev pytest -q
uv build
Release smoke:
for file in examples/*.aur; do
out="/tmp/aurane-$(basename "$file" .aur).py"
uv run aurane compile "$file" "$out" --quiet
uv run aurane check "$file" --semantic --types --json >/tmp/aurane-check.json
done
Documentation
License
Aurane is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aurane-2.0.0.tar.gz.
File metadata
- Download URL: aurane-2.0.0.tar.gz
- Upload date:
- Size: 68.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4190ea394e2fea6ffe8134ae1d8a99080b5a77c9ac7262fb69a99c639a29c54
|
|
| MD5 |
4990fdf7ff076f465f5fef1fd51a5eea
|
|
| BLAKE2b-256 |
07d9399d5a247b265c113cbeba16707068603e22e2673bc002febeef68782f33
|
Provenance
The following attestation bundles were made for aurane-2.0.0.tar.gz:
Publisher:
publish.yml on desenyon/aurane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aurane-2.0.0.tar.gz -
Subject digest:
e4190ea394e2fea6ffe8134ae1d8a99080b5a77c9ac7262fb69a99c639a29c54 - Sigstore transparency entry: 1644832749
- Sigstore integration time:
-
Permalink:
desenyon/aurane@18266f01f934f5f679956adc611fe1e04378f7a1 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/desenyon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18266f01f934f5f679956adc611fe1e04378f7a1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aurane-2.0.0-py3-none-any.whl.
File metadata
- Download URL: aurane-2.0.0-py3-none-any.whl
- Upload date:
- Size: 63.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
722efa062ba60dc505ab6d4554025523348a54293dd3e1351af277ca88c40263
|
|
| MD5 |
0ac187802129d40e2c795b87e8448836
|
|
| BLAKE2b-256 |
292880c3a5611c3f3c7e552524d8ee20ef285a23328afd46122379cd19d5eaff
|
Provenance
The following attestation bundles were made for aurane-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on desenyon/aurane
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aurane-2.0.0-py3-none-any.whl -
Subject digest:
722efa062ba60dc505ab6d4554025523348a54293dd3e1351af277ca88c40263 - Sigstore transparency entry: 1644832860
- Sigstore integration time:
-
Permalink:
desenyon/aurane@18266f01f934f5f679956adc611fe1e04378f7a1 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/desenyon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@18266f01f934f5f679956adc611fe1e04378f7a1 -
Trigger Event:
push
-
Statement type: