Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs][Examples]@unroll examples inconsistent, throws an error #2940

Closed
DWSimmons opened this issue Jun 3, 2024 · 4 comments
Closed

[Docs][Examples]@unroll examples inconsistent, throws an error #2940

DWSimmons opened this issue Jun 3, 2024 · 4 comments

Comments

@DWSimmons
Copy link

@unroll(tile_y)

from the github mojo examples throws an error:

/mnt/p/mojo_scratch/github_test.mojo:165:20: error: unsupported decorator on 'for' statement
            @unroll(tile_y)
             ~~~~~~^~~~~~~~
mojo: error: failed to parse the provided Mojo source module

This line is present in the Playground and executes with no errors L131

This line is not present on https://docs.modular.com/mojo/notebooks/Matmul#vectorizing-the-inner-most-loop
and instead has unroll_factor in the vectorize call

                # Vectorize by nelts and unroll by tile_x/nelts
                # Here unroll factor is 4
                alias unroll_factor = tile_x // nelts
                vectorize[dot, nelts, size=tile_x, unroll_factor=unroll_factor]()

which throws no errors and compiles (if the code snippets are copy-pasted together).

https://docs.modular.com/mojo/changelog#v241-2024-02-29

(base) darin@DESKTOP-09A56TM:/mnt/p/mojo_scratch$ modular -v
modular 0.8.0 (39a426b5)
(base) darin@DESKTOP-09A56TM:/mnt/p/mojo_scratch$ mojo -v
mojo 2024.5.3112 (e60dc71f)
(base) darin@DESKTOP-09A56TM:/mnt/p/mojo_scratch$ uname -a
Linux DESKTOP-09A56TM 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Not sure where the exact problem is as the LSP says no to github raw but Playground says yes; but also, the notebook walk through works. I'm under the impression from the manual that the @unroll should work because it's declaring that the for loop after it should be unrolled (tile_y) times. I'm under the impression that I would have to declare it in the execution but it doesn't compile so I can't declare. Chicken and the egg.

Expectation: Examples copied from github would all pass compile.

Proposed solution: ???

@DWSimmons DWSimmons changed the title @unroll and @vectorize docs inconsistent, throws an error @unroll examples inconsistent, throws an error Jun 3, 2024
@DWSimmons DWSimmons changed the title @unroll examples inconsistent, throws an error [Docs][Examples]@unroll examples inconsistent, throws an error Jun 3, 2024
@soraros
Copy link
Contributor

soraros commented Jun 4, 2024

Are you using Mojo nightly? We moved away from the unroll decorator in favour of @parameter in the latest build.

@DWSimmons
Copy link
Author

I am which would explain the error and the difference with the blog and unroll factor. The reason I tagged it with [Docs][Examples] is simply to note that the examples ought to be updated e.g. the people following Prakash's new "Getting Started" video would immediately run into a compile problem.

@ematejska
Copy link
Collaborator

Yes, the official documentation (on https://docs.modular.com/mojo/) is following against the latest release corresponding to the main branch, not the nightly builds. The nightly branch on github does have examples that work with the nightly though.

Keeping this bug for the issues of blogs/videos getting outdated. Maybe the compatible version has to be noted.

@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2024
@hogepodge
Copy link
Collaborator

Thanks for raising this @DWSimmons. Our goal is go keep the examples up to date as much as we can, and we're working on some new structures to help that happen. There are instances where the docs will be out of sync (for example, with nightlies), and we may not be able to completely reconcile that. Blog posts are a good example, we have to strike a balance between talking about new features and maintaining the old posts. We may not be able to get to everything, which is why we've built the new devrel-extras repository. That gives us a place to mark known compatibility, and go back and update examples when we have the opportunity to.

We have some other changes to our content that are coming soon but that I can't say much more about that will make it easier to keep the examples up to date. So we hear you loud and clear on this, and are working towards solutions to this exact problem that are scalable and maintainable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants