Migration Guide: PyTorch to MIND

Side-by-side examples showing how PyTorch patterns map to MIND. Every comparison highlights what MIND catches at compile time that PyTorch only finds at runtime. Examples follow the MIND v1.0 specification surface; anything marked roadmap is not yet in the shipped compiler.

Tensor Creation

PyTorch
import torch

x = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
w = torch.randn(2, 3)
b = torch.zeros(3)

In MIND, tensor shapes are compile-time types. A shape mismatch is a compile error, not a runtime crash.

Shape Safety

PyTorch
# PyTorch: crashes at RUNTIME
x = torch.randn(32, 784)
w = torch.randn(256, 784)  # Wrong shape!
y = x @ w  # RuntimeError: mat1 and mat2 shapes
           # cannot be multiplied (32x784 and 256x784)

Static shape mismatches are caught at compile time, before the model ever runs.

Autodiff

PyTorch
# Runtime autograd tape
x = torch.randn(32, 784, requires_grad=True)
y = model(x)
loss = criterion(y, target)
loss.backward()  # Builds + walks tape at runtime
optimizer.step()

MIND's @grad compiles gradients at build time. The optimizer sees the full graph and fuses ops.

Linear Layer

PyTorch
import torch.nn as nn

class MLP(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(784, 256)
        self.fc2 = nn.Linear(256, 10)

    def forward(self, x):
        x = torch.relu(self.fc1(x))
        return self.fc2(x)

Explicit parameter tensors instead of opaque Module objects. Every shape is visible and verified.

Model Export

PyTorch
# Multiple export paths, each with quirks
torch.onnx.export(model, dummy_input, "model.onnx")
traced = torch.jit.trace(model, dummy_input)
traced.save("model.pt")
# TensorRT, CoreML need separate conversion

The open-source compiler targets CPU today. GPU, Metal, and ONNX targets are on the roadmap — GPU execution ships in the commercial mind-runtime.

CPU: shippedGPU: commercial mind-runtime (roadmap)Metal: roadmapONNX: roadmap

What maps, what doesn't

FeatureMaps?Notes
Tensor operations (matmul, conv2d, etc.)YesCore ops covered
Shape-checked tensorsYesCompile-time (vs runtime)
Autograd / autodiffYesCompile-time @grad
Custom CUDA kernelsNoRoadmap (commercial mind-runtime)
Distributed training (DDP)NoRoadmap
Model servingNoRoadmap
Dynamic computation graphsNoMIND is static-graph
Eager execution / REPLNoCompiled, not interpreted
Python ecosystem (pandas, sklearn)NoMIND has its own stdlib
Pre-trained model zoo (HuggingFace)NoRequires reimplementation

Estimated migration effort

Model ComplexityEffortMIND LOC
Simple model (linear, MLP)1-2 hours50-100 lines
Medium model (CNN, RNN)2-4 hours100-300 lines
Complex model (Transformer)4-8 hours300-600 lines
Full training pipeline1-2 days500-1000 lines

Need help migrating?

Our pilot program includes hands-on migration support. We'll help you port your first model and verify compliance artifacts.

Start a pilot