# Question on LayoutTenson mut parameter

**URL:** <https://forum.modular.com/t/question-on-layouttenson-mut-parameter/2438>\
**Category:** Mojo\
**Tags:** gpu\_puzzle\
**Created:** [November 9, 2025, 5:54pm UTC](https://forum.modular.com/t/question-on-layouttenson-mut-parameter/2438 "2025-11-09T17:54:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonl2219](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@antonl2219](https://forum.modular.com/u/antonl2219)\
**Post date:** [November 9, 2025, 5:54pm UTC](https://forum.modular.com/t/question-on-layouttenson-mut-parameter/2438/1 "2025-11-09T17:54:26Z")

</div>

Hello,

I’m confused about the way `mut` parameter works in LayoutTensor.

For example in gpu puzzle 16 ( and others) the out\_tensor is declared in main with mut=False but in the parameter list of the kernel functions mut=True for output argument and False for input, as I naively expect. I would have expected the compiler to flag this error as output changes type.

What do I miss? Could someone explain to to me?

Kind regards,

Lucian

> <https://github.com/modular/mojo-gpu-puzzles/blob/main/solutions/p16/p16.mojo#L259>

---

<div class="post-metadata">

**Author:** ![nate](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/nate/32/740_2.png) [@nate](https://forum.modular.com/u/nate)\
**Post date:** [November 9, 2025, 6:55pm UTC](https://forum.modular.com/t/question-on-layouttenson-mut-parameter/2438/2 "2025-11-09T18:55:37Z")

</div>

Hi @antonl2219 ! 👋

Thank you for bringing this up and pointing this out. So you are correct, in puzzle 16 it _should_ be marked with `mut=True` as we “mutate” the contents of the tensor inside the kernel.

The reason this is not currently caught by the compiler is two-fold:

1. A bug in `LayoutTensor` and its underlying type `UnsafePointer`. Theoretically, this _should_ fail to compile (as you pointed out) but we need to do some bug fixing on our handling of mutabilities for `LayoutTensor` and `UnsafePointer`.
2. The `enqueue_function` call does not do any type-checking currently, but this is being worked on as we move over to use `enqueue_function_checked` instead.

If you want to, you could open a pull request on the gpu-puzzles repository and fix this issue for problem #16 (and others you might have found).

These mutability issues will be fixed in a future version of Mojo (hopefully 26.1 🤞)

Let us know if you have any follow up questions or concerns 🙂

---

<div class="post-metadata">

**Author:** ![antonl2219](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@antonl2219](https://forum.modular.com/u/antonl2219)\
**Post date:** [November 9, 2025, 10:20pm UTC](https://forum.modular.com/t/question-on-layouttenson-mut-parameter/2438/3 "2025-11-09T22:20:29Z")

</div>

Hi,

Thanks for the clear explanation.

I was concern that I don’t graps the Mojo’s ownership model.

Lucian

---

<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:** [November 10, 2025, 5:07pm UTC](https://forum.modular.com/t/question-on-layouttenson-mut-parameter/2438/4 "2025-11-10T17:07:05Z")

</div>

I’ve [put up a pull request](https://github.com/modular/mojo-gpu-puzzles/pull/137) to migrate puzzles 13-16 to `enqueue_function_checked`and in the process fixing these issues with mutability. Thanks for pointing it out, we’ll also try to fix other places in the puzzles where this may have occurred.

---

<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:** [November 17, 2025, 5:07pm UTC](https://forum.modular.com/t/question-on-layouttenson-mut-parameter/2438/5 "2025-11-17T17:07:57Z")

</div>

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