# Learning MAX Graph API Through Working Examples

**URL:** <https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606>\
**Category:** Community Showcase\
**Created:** [January 16, 2026, 9:05am UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606 "2026-01-16T09:05:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjboothaus](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mjboothaus](https://forum.modular.com/u/mjboothaus)\
**Post date:** [January 16, 2026, 9:05am UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/1 "2026-01-16T09:05:21Z")

</div>

# Learning MAX Graph API Through Working Examples

**Sharing my learning journey** : Six progressive examples from `relu(x * 2 + 1)` to production transformers

**Repository:** [GitHub - DataBooth/max-learning: Learn MAX Graph API through 6 progressive examples (element-wise → transformers). Working code, minimal examples, benchmarks, and tests. An ongoing learning journey shared.](https://github.com/DataBooth/max-learning)  
**Version:** 0.3.0

**Key Features:**

- Minimal examples highlighting pure MAX Graph API without abstractions
- DistilBERT achieving 5.58x speedup vs PyTorch on M1 CPU
- First reported MAX Graph inference on Apple Silicon GPU (element-wise ops)
- 49 comprehensive tests with correctness validation
- Complete benchmarking framework with MAX vs PyTorch comparisons
- MLP regression and CNN MNIST implementations

**Perfect for:** Anyone wanting to learn MAX Graph API through working code, building from basics to transformers.

**Ready for community feedback!** All tests passing, all examples working.

MIT Licence | Sponsored by [DataBooth](https://www.databooth.com.au)

---

<div class="post-metadata">

**Author:** ![clattner](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/clattner/32/201_2.png) [@clattner](https://forum.modular.com/u/clattner)\
**Post date:** [January 17, 2026, 11:35pm UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/2 "2026-01-17T23:35:09Z")

</div>

This is really amazing, thank you for breaking this down to be so easily digestible!

---

<div class="post-metadata">

**Author:** ![mjboothaus](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mjboothaus](https://forum.modular.com/u/mjboothaus)\
**Post date:** [January 18, 2026, 3:39am UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/3 "2026-01-18T03:39:51Z")

</div>

Thank you! Really appreciate the encouragement again.

One small piece of feedback from building these examples: while learning, I struggled with the **InferenceSession** terminology in the tutorial’s simple addition example. The term “inference” has strong ML model connotations (to me at least - likely others?) so it took a while to realise MAX uses it more broadly to mean “graph execution” (which makes sense, aligning with TensorRT, ONNX Runtime, etc.).

I submitted a docs feedback suggesting a one-sentence clarification where InferenceSession is first introduced. Though if MAX aims to position itself as a general computational framework beyond just ML inference (which from your talks it does) names like GraphSession or ExecutionSession might communicate that more clearly. Just a thought—completely understand if alignment with existing inference engine conventions (TensorRT, etc.) is more valuable.

_My full list of possible names: ComputeSession, ExecutionSession, GraphEngine, GraphExecutor, GraphRuntime, GraphSession, or RuntimeSession. 🙂_

Thanks again for the positive response to the repo! 🔥

---

<div class="post-metadata">

**Author:** ![BradLarson](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/bradlarson/32/62_2.png) [@BradLarson](https://forum.modular.com/u/BradLarson)\
**Post date:** [January 20, 2026, 2:20pm UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/4 "2026-01-20T14:20:47Z")

</div>

As an update, the latest MAX nightly contains a fallback path for matrix multiplication on Apple silicon GPUs, so `ops.matmul` now compiles and runs on those GPUs. There are significant performance optimizations to be made in matmul on that architecture, but at least it’ll work. Therefore, your linear layer example now builds using the latest nightly.

One caveat is that `max.driver.Tensor` has been renamed to `max.driver.Buffer`, so you’ll need to make that change in your code.

As a recommendation: you may want to lock the specific MAX version used in your projects within your pixi.toml to make sure they continue to build as breaking API changes come in. You can then move that version up and modernize your code manually as you are ready to use new versions. In this case, I think changing the line in your pixi.toml to read

```auto
modular = "==26.1.0.dev2026012005"

```

would lock to this morning’s nightly release.

---

<div class="post-metadata">

**Author:** ![trojan\_x](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/trojan_x/32/902_2.png) [@trojan\_x](https://forum.modular.com/u/trojan_x)\
**Post date:** [January 20, 2026, 6:35pm UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/5 "2026-01-20T18:35:03Z")

</div>

Hi Brad Larson,Dude the core Mathematical operation for Matrix multiplication (ops.matmul as you phrase) in Apple GPUs requires high level optimization. If the Tensor is now buffer as it’s phrased Max.driver.tensor to max.driver.buffer. Logically and intellectually I’ll be interested in understanding the importance of that significant shift in either compatibility or performance.

---

<div class="post-metadata">

**Author:** ![trojan\_x](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/trojan_x/32/902_2.png) [@trojan\_x](https://forum.modular.com/u/trojan_x)\
**Post date:** [January 20, 2026, 6:36pm UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/6 "2026-01-20T18:36:51Z")

</div>

And also have interest on why the the Code will Freeze if I don’t use pixi.toml as you stated.

---

<div class="post-metadata">

**Author:** ![mjboothaus](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mjboothaus](https://forum.modular.com/u/mjboothaus)\
**Post date:** [January 21, 2026, 9:54pm UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/7 "2026-01-21T21:54:12Z")

</div>

Thanks for the feedback and pointers 🙂 i’ll try and get to them today

---

<div class="post-metadata">

**Author:** ![mjboothaus](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mjboothaus](https://forum.modular.com/u/mjboothaus)\
**Post date:** [January 26, 2026, 4:09am UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/8 "2026-01-26T04:09:09Z")

</div>

Thanks for the info and suggestion I think this is now done and I added a script to update to latest nightly and re-test with rollback if tests fail.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [July 25, 2026, 4:09am UTC](https://forum.modular.com/t/learning-max-graph-api-through-working-examples/2606/9 "2026-07-25T04:09:56Z")

</div>

Closed on July 25, 2026, 4:09am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
