OU blog

Personal Blogs

It's Jonathan's photo in a toga

Your ML Code is Lying to You (And How to Fix It)

Visible to anyone in the world

Why "move fast and break things" doesn’t work for machine learning—and how Axiom.jl can save your sanity (and your models).

Introduction

You’ve just spent 12 hours training a PyTorch model. It crashes. The error? A shape mismatch buried deep in your architecture. You fix it, rerun, and—surprise!—NaNs everywhere. Sound familiar?

Most ML frameworks let you fail. They let you ship models with silent bugs, unchecked edge cases, and zero guarantees about behavior. In finance, healthcare, or even gambling systems, this isn’t just annoying—it’s dangerous.

I built Axiom.jl because I’m tired of this. Axiom.jl catches bugs at compile time, not in production. It’s not just a tool; it’s a rejection of the "debug later" culture that plagues ML.

And no, you don’t need to rewrite everything in Julia. You can verify your Python models today.


Section 1: The Problem with Python’s ML Stack

1. Silent Failures Are the Norm

Python’s dynamic nature is a liability when precision matters. Example:

python
Copy
# PyTorch: This compiles. It also crashes. model = nn.Sequential( nn.Conv2d(3, 64, 3), # Output: (batch, 64, 222, 222) nn.Linear(64, 10) # ERROR: Expected (batch, 64), got (batch, 64, 222, 222) )

Result: Runtime crash after hours of training.

2. NaNs and Edge Cases Slip Through

  • How many times has your loss exploded to NaN?
  • How often do you assume your softmax outputs sum to 1 (but don’t check)?
  • When was the last time you proved your model handles adversarial inputs?

Python’s answer: "Just add more tests!" Axiom.jl’s answer: "Let’s catch that at compile time."


Section 2: Axiom.jl—Verification, Not Just Validation

What Axiom.jl Does

  1. Compile-time shape checking:

    julia
    Copy
    @axiom MyModel begin input :: Tensor{Float32, (224, 224, 3)} output = input |> Conv(64, (3,3)) |> Dense(10) # ERROR: Shape mismatch end

    No runtime surprises.

  2. Formal guarantees:

    julia
    Copy
    @ensure sum(output) ≈ 1.0 # Runtime assertion @prove ∀x. sum(softmax(x)) == 1.0 # Mathematical proof

    Your model doesn’t just seem correct—it is correct.

  3. PyTorch interop:

    julia
    Copy
    model = from_pytorch("resnet50.pth") # Load your existing model @ensure no_nans(model) # Add one verification rule

    No rewrite needed.

Why This Matters

  • For researchers: Stop wasting time debugging.
  • For industries: Meet regulatory standards (e.g., FDA, ISO 26262).
  • For educators: Teach students correctness, not just accuracy.

Section 3: "But I Use Python!"

Axiom Lite: Verification Without Rewriting

julia
Copy
@axiom_lite MyPyTorchModel begin model = from_pytorch("resnet50.pth") @ensure no_nans(model) # Start small end

One line of code. Instant safety net.

Section 4: This Isn’t About Julia vs. Python

People who know me will know I loathe Python with a passion. But this not about that - it is a recognition of the weakness inherent in ML design and practice, and it’s about raising the bar for all ML tools. Python’s ecosystem can = and  (obviously, I think) should - adopt these practices so we can raise the game, whichever side you are playing on..

Call to action:

  • Try Axiom.jl on your next model.
  • Demand verification from your tools.
  • Join the movement for correctness-first ML.

Closing: What You Can Do Today

  1. Star Axiom.jl on GitHub.
  2. Try the @axiom_lite macro on your PyTorch models.
  3. Share this post with your team (especially if they’re still debugging NaNs at 2 AM).

Question for readers:

  • How much time have you lost to silent ML bugs?
  • Would you use a tool that caught them at compile time?

Comment below—or better yet, contribute to Axiom.jl.

Permalink
Share post