# mojoBLAS (v0.1.0) A pure Mojo implementation of BLAS routines

**URL:** <https://forum.modular.com/t/mojoblas-v0-1-0-a-pure-mojo-implementation-of-blas-routines/2992>\
**Category:** Community Showcase\
**Created:** [April 22, 2026, 5:42pm UTC](https://forum.modular.com/t/mojoblas-v0-1-0-a-pure-mojo-implementation-of-blas-routines/2992 "2026-04-22T17:42:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Photon](https://avatars.discourse-cdn.com/v4/letter/p/b5a626/32.png) [@Photon](https://forum.modular.com/u/Photon)\
**Post date:** [April 22, 2026, 5:42pm UTC](https://forum.modular.com/t/mojoblas-v0-1-0-a-pure-mojo-implementation-of-blas-routines/2992/1 "2026-04-22T17:42:54Z")

</div>

**[mojoBLAS](https://github.com/shivasankarka/mojoBLAS)**: A pure Mojo implementation of BLAS routines. (yes, peak naming creativity 😉)

I started this while working on numerical backends for [NuMojo](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo) and ended up going down the rabbit hole of implementing the full BLAS routines in Mojo. This will later be embedded into my existing work on [SciJo](https://github.com/mojomath/SciJo).

### Current coverage

- **Level 1:** 12 routines
- **Level 2:** 16 routines
- **Level 3:** 6 routines

### What’s included

- Pure Mojo kernels: no external BLAS dependencies in the core implementation.
- Generic support for real data types via `DType`
  - Traditional `s/d` prefixes are removed since Mojo handles this generically

- Test coverage across all levels
  - Results validated against OpenBLAS

- Benchmark scripts comparing performance with system OpenBLAS

### What’s not included (yet)

- Optimized routines
  - Level 2 and Level 3 currently use naive implementations (this is reflected in benchmarks xD)
  - Some of Level 1 routines include SIMD vectorisation.

- Complex number support
  - Still exploring the best way to represent and handle complex types generically in Mojo.

Check out the benchmark plots [here](https://github.com/shivasankarka/mojoBLAS/tree/main/benchmarks). There’s plenty of room for optimization, from low hanging improvements to more hardcore tuning. Contributions are very welcome!!! If you are interesting in going down the optimisations rabbit hole, I’ll be happy to take PRs. Also, I’m not super confident in my benchmarking abilities, so if that’s your thing, feel free to take a crack at it 🙂

Happy computing!

Repo: [GitHub - shivasankarka/mojoBLAS: Implementation of BLAS routines in pure Mojo 🔥 · GitHub](https://github.com/shivasankarka/mojoBLAS)  
Reference: [https://www.netlib.org/blas/](https://www.netlib.org/blas/)

---

<div class="post-metadata">

**Author:** ![ephemer](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@ephemer](https://forum.modular.com/u/ephemer)\
**Post date:** [April 26, 2026, 6:11pm UTC](https://forum.modular.com/t/mojoblas-v0-1-0-a-pure-mojo-implementation-of-blas-routines/2992/2 "2026-04-26T18:11:33Z")

</div>

Cool stuff, love the direction. There was one Level 2 and one Level 3 routine which seemed to be an order of magnitude faster than Accelerate. Is that a bug or how is that possible do you think?

---

<div class="post-metadata">

**Author:** ![Photon](https://avatars.discourse-cdn.com/v4/letter/p/b5a626/32.png) [@Photon](https://forum.modular.com/u/Photon)\
**Post date:** [April 27, 2026, 5:21am UTC](https://forum.modular.com/t/mojoblas-v0-1-0-a-pure-mojo-implementation-of-blas-routines/2992/3 "2026-04-27T05:21:31Z")

</div>

Thanks! Great catch!

The initial benchmark results were a bit misleading due to few subtle bugs in the benchmarking setup, not the algorithms themselves. I have been trying to improve the performance, which led me to find these bugs in benchmarking.

- I had added `keep()` inside the closure function, which somehow caused the compiler to optimize it all away, resulting in inflated values.
- I wasn’t filling up the relevant buffers in the correct manner (in mojo, openblas and accelerate). This led to some weird jumps in performance in openblas and mojo (GPT5.3 found this).

After fixing these bugs, I was able to get a reliable (Assuming I didn’t make any other mistakes lol) benchmark code working, which is what I using right now to benchmark the performance as I try to improve these routines.

I have updated the plots in the main branch! The current results make much more sense and seem consistent. Mojo performs good enough given level 2 and 3 are naive algorithms without any optimisation (in main branch). I will drop an update once I improve performance on level 2 algorithms.
