Skip to content

Conversation

@philip-paul-mueller
Copy link
Contributor

@philip-paul-mueller philip-paul-mueller commented Nov 10, 2025

Makes gt_split_access_nodes() deterministic by processing it in the order of AccessNodes.
However, this means that the name of the data must be predictable and stable.


ToDo

@philip-paul-mueller
Copy link
Contributor Author

Performance seems to be okay:

bench_blueline_stencil_compute

@philip-paul-mueller philip-paul-mueller marked this pull request as ready for review November 11, 2025 12:02
Copy link
Contributor

@edopao edopao left a comment

Choose a reason for hiding this comment

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

LGTM, only some minor comments/questions.

)

# Since the transformation only applies to single use data, the order in which the
# states are processed is irrelevant. Furthermore, the fragments generated through
Copy link
Contributor

@edopao edopao Jan 15, 2026

Choose a reason for hiding this comment

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

"Furthermore, the fragments generated..." I don't see how this is relevant. Are you considering the case in which gt_split_access_nodes() is called multiple times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the justification why scanning the state once is enough.
Because you could argue that you should examine the result of the split (which generates more AccessNodes) should be examined as well.
And we would thus need an interative procedure.
However, I am not fully sure now if this might be needed.
I will update the comment to make this more clear.

# NOTE: Turning them into a string is the best solution is probably the only way
# to achieve some stability. The only downside is that the order now depends
# on the specialization level that is used, i.e. to we have numbers or symbols.
split_description = sorted(split_description, key=lambda split: str(split))
Copy link
Contributor

Choose a reason for hiding this comment

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

split_description is a Sequence, so it is already sorted. As alternative, we could ensure the deterministic order in the place where the sequence is created.

Copy link
Contributor Author

@philip-paul-mueller philip-paul-mueller Jan 16, 2026

Choose a reason for hiding this comment

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

I do not fully understand your comment, are you saying that sorting is not needed, because it is a sequence?
According to the Python glossary a Sequence extends an Iterable by an efficient __getitem__() function, which essentially give sense to the concept of "first", "second", etc. element.
This means that they have some (fixed but ultimately random) order but to be stable you need a specific order.

Copy link
Contributor

Choose a reason for hiding this comment

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

On the second thought, I agree with sorting this sequence here. My motivation is that this function should in theory implement some logic for the order, but we rely on alphabetical order for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree this is what the Note should express, that this is the only way I found that gives you something stable.
Because, you can have comparable things such as symPyVariable1 and symPyVariable2.

Comment on lines +343 to +348
# Bring the split description in a deterministic order.
# NOTE: See note in `split_node()` why the sorting is done in this way.
# NOTE: The main benefit of bringing `split_description` into a deterministic
# order is that the output of this function is deterministic as well. I am
# not sure if there is any benefit beside that.
split_description = sorted(split_description, key=lambda split: str(split))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see my other reply.

Copy link
Contributor

@edopao edopao left a comment

Choose a reason for hiding this comment

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

LGTM

@philip-paul-mueller
Copy link
Contributor Author

I have rerun the experiments again, because it was some time ago.

bench_blueline_stencil_compute

It look like there is some degradation in the last stencil, but it is probably only a fluctuation.
Furthermore, I only run the experiment with the change once, because of the problems on the system.
So I think we should go ahead and merge it.

@philip-paul-mueller philip-paul-mueller merged commit ed71f11 into GridTools:main Jan 16, 2026
23 checks passed
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.

2 participants