Skip to content

Conversation

@BradLarson
Copy link
Collaborator

We are beginning a transition from enqueue_function to enqueue_function_checked, on path to eventually replacing the original enqueue_function with a new typechecked version. However, there are some compiler issues that need to be resolved before the new enqueue_function is ready, so in the meantime we are doing a stepwise migration to enqueue_function_checked to gain the benefits of typechecking on GPU functions.

enqueue_function_checked requires some code modifications, so this begins that process across the puzzles. Not all puzzles are updated, because some require a bit more manual care to transition over.

Copy link
Collaborator

@ehsanmok ehsanmok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Brad! Appreciating the changes. One comment on the layout tensor pattern.

alias dtype = DType.float32
alias layout = Layout.row_major(HEIGHT, WIDTH)

fn kernel[dtype: DType, layout: Layout](tensor: LayoutTensor[mut=True, dtype, layout]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change isn't required afaik and the existing pattern is more succinct than using the explicit MutableAnyOrigin. Wdyt?

alias layout = Layout.row_major(HEIGHT, WIDTH)

fn kernel[dtype: DType, layout: Layout](tensor: LayoutTensor[mut=True, dtype, layout]):
fn kernel[dtype: DType, layout: Layout](tensor: LayoutTensor[dtype, layout, MutableAnyOrigin]):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn kernel[dtype: DType, layout: Layout](tensor: LayoutTensor[dtype, layout, MutableAnyOrigin]):
fn kernel[dtype: DType, layout: Layout](tensor: LayoutTensor[dtype, layout, MutAnyOrigin]):

Here and elsewhere due to rename from @NathanSWard today

Copy link
Collaborator

@ehsanmok ehsanmok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedagogically please use the mut=True pattern as the use of origin adds more cognitive load.

@dunnoconnor dunnoconnor self-requested a review November 7, 2025 20:45
Copy link
Collaborator

@dunnoconnor dunnoconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. These changes are consistent with warning messages and with the 25.7 Nightly Library changes: https://docs.modular.com/mojo/changelog/#25-7-library-changes

Copy link
Collaborator

@dunnoconnor dunnoconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is consistent with guidance in the changelog https://docs.modular.com/mojo/changelog/#25-7-library-changes

@BradLarson BradLarson dismissed ehsanmok’s stale review November 7, 2025 21:37

We will improve upon the ergonomics in a follow-on, but we need to merge this to make progress towards getting the repository to build on the upcoming nightly.

@BradLarson BradLarson merged commit 03640d1 into modular:main Nov 7, 2025
2 checks passed
@BradLarson BradLarson deleted the enqueue_function_checked_part1 branch November 7, 2025 21:39
@ehsanmok
Copy link
Collaborator

ehsanmok commented Nov 7, 2025

The nightly release is no longer tied to the puzzles. Please fix the origin issue I raised earlier as a fast follow.

@BradLarson
Copy link
Collaborator Author

Checked with the team, and it unfortunately appears that simply specifying mut=True will not work with enqueue_function_checked. The typechecking provided by enqueue_function_checked requires all parameters to be fully bound, including the origin. This requires you then to specify either MutAnyOrigin (which then implies mut=True) or ImmutAnyOrigin (mut=False).

There may be a different way we can approach this, but unfortunately at present a simple mut=True marking won't suffice.

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

Successfully merging this pull request may close these issues.

4 participants