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
It's Jonathan's photo in a toga

It would appear...

Visible to anyone in the world
Edited by Jonathan Jewell, Saturday 21 November 2015 at 20:26

...that no-one is actually viewing this, which is disappointing, albeit what I have to say is unlikely to be crazy exciting!

Still, to give an idea of the kinds of things that associate lecturers do in their spare time.

Today I woke up early. I lay around in bed think about all kinds of things that would make the day productive and, after about 30 minutes of pondering, decided that I would push for today to be mostly focused in three areas:

1) Marking assignments (although these only came in yesterday, I feel that it is time now to start moving things along at a pace).

2) Forum development (including answering fears my students have about their grades and preparing for an online tutorial tomorrow...urg, a Sunday!).

3) Learning to program. Okay, okay, don't worry, I CAN program (so as not to lose all my credibility with my computing students!) What I want to do is learn a new programming language, specifically Erlang (Erikson Language).

Maybe, actually, the big lesson of today is really going to be learning about personal limitations, resource constraints and the importance of prioritisation. All the lessons I should have learned through 19 years of study!

FOLLOW UP: I've ditched Erlang, I'm no longer interested in that. My new language is the AMAZING 'Julia' which hopefully I will one day blog more about.
Permalink
Share post

This blog might contain posts that are only visible to logged-in users, or where only logged-in users can comment. If you have an account on the system, please log in for full access.

Total visits to this blog: 45894