# Importing functions from max.nn

**URL:** <https://forum.modular.com/t/importing-functions-from-max-nn/1945>\
**Category:** MAX\
**Created:** [July 11, 2025, 3:25am UTC](https://forum.modular.com/t/importing-functions-from-max-nn/1945 "2025-07-11T03:25:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![avb03](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@avb03](https://forum.modular.com/u/avb03)\
**Post date:** [July 11, 2025, 3:25am UTC](https://forum.modular.com/t/importing-functions-from-max-nn/1945/1 "2025-07-11T03:25:45Z")

</div>

I am referencing some of the library functions under the max/nn directory on the modular github.

For example I am trying to import:

```auto
from nn.mha import _naive_attention_with_transpose, mha_gpu_naive
from nn.mha_mask import CausalMask, MaterializedMask

```

as one of the benchmark scripts does. I was able to get this script running with this import a couple weeks ago, but I had to reinstall the pixi shell with modular today and am getting these errors:

```auto
mojo: error: failed to parse the provided Mojo source module

```

wherever I try to import from nn. How can I import these functions?

---

<div class="post-metadata">

**Author:** ![Ehsan](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/ehsan/32/142_2.png) [@Ehsan](https://forum.modular.com/u/Ehsan)\
**Post date:** [July 11, 2025, 5:40am UTC](https://forum.modular.com/t/importing-functions-from-max-nn/1945/2 "2025-07-11T05:40:00Z")

</div>

For those Mojo modules, are you following [this guide](https://forum.modular.com/t/importing-max-kernels-from-source/1942/2) to build and import? I don’t think pixi can work with that as is.

---

<div class="post-metadata">

**Author:** ![avb03](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@avb03](https://forum.modular.com/u/avb03)\
**Post date:** [July 12, 2025, 3:45am UTC](https://forum.modular.com/t/importing-functions-from-max-nn/1945/3 "2025-07-12T03:45:58Z")

</div>

Thanks for the prompt reply. I get this error when trying to follow the steps outlined in that post. When running `./bazelw build //max/kernels/src/nn`, I get this error:

```auto
//mojo/stdlib/stdlib:stdlib building mojo package failed: (Exit 1): mojo failed: error executing MojoPackage command (from target //mojo/stdlib/stdlib:stdlib) external/rules_mojo++mojo+mojo_toolchain_linux_x86_64/bin/mojo package '-strip-file-prefix=.' -o bazel-out/k8-fastbuild/bin/mojo/stdlib/stdlib/stdlib.mojopkg mojo/stdlib/stdlib

```

---

<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:** [January 8, 2026, 3:46am UTC](https://forum.modular.com/t/importing-functions-from-max-nn/1945/4 "2026-01-08T03:46:41Z")

</div>

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