Skip to content

Bcast object wrappers, attempt 2 #310

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

Merged
merged 2 commits into from
Apr 2, 2025
Merged

Bcast object wrappers, attempt 2 #310

merged 2 commits into from
Apr 2, 2025

Conversation

inducer
Copy link
Owner

@inducer inducer commented Mar 31, 2025

Second attempt at #280, much simpler technically.

I'm mostly seeking early feedback on this. It still needs, at least:

  • Documentation
  • Tests
  • Fixed types

This could help fill the hole that's left by the plan to make implicit broadcasting of data class containers across actx array types illegal. See inducer/grudge#377 for an example use, specifically shortcuts.py. (Note that I've updated the grudge PR to use this.)

Copy link
Collaborator

@majosm majosm left a comment

Choose a reason for hiding this comment

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

Noticed one thing. Otherwise, I'm on board. 👍

@majosm
Copy link
Collaborator

majosm commented Mar 31, 2025

One other thing that just occurred to me: do we need to add some unpacking for the case where the broadcastee is itself a container? (For example, adding a cv of scalars to a cv of elems x dofs data. Should there be some code that recurses into the broadcastee and produces a cv of Bcast*s or something like that?)

@inducer
Copy link
Owner Author

inducer commented Mar 31, 2025

One other thing that just occurred to me: do we need to add some unpacking for the case where the broadcastee is itself a container? (For example, adding a cv of scalars to a cv of elems x dofs data. Should there be some code that recurses into the broadcastee and produces a cv of Bcast*s or something like that?)

That's a fair question. I think I would prefer to wait for a specific use case and keep it simple until that point. One happy fact about this approach is that we can introduce additional Bcast* objects with distinct behavior when needed.

@inducer inducer force-pushed the bcast-obj-attempt-2 branch from 62672f6 to 720e1ec Compare March 31, 2025 19:17
@inducer
Copy link
Owner Author

inducer commented Mar 31, 2025

FYI @majosm: Also added you as co-author. I used your initial code from #307 after all. 🙂 Forgot about that initially.

Copy link
Collaborator

@alexfikl alexfikl left a comment

Choose a reason for hiding this comment

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

Looks good to me too! Worth adding the simple non-recursive Bcast version too?

@inducer inducer force-pushed the bcast-obj-attempt-2 branch from 720e1ec to 0d4a555 Compare April 2, 2025 18:24
@inducer
Copy link
Owner Author

inducer commented Apr 2, 2025

Worth adding the simple non-recursive Bcast version too?

I'm not in favor. I brought over the tests from #280, replaced all the Bcast objects with the one introduced here, and that did the trick. So I'm not super sold we need anything else. The cost differential between the recursing and not ought to be a few isinstance checks---I think that's fairly minor in the grand scheme of things.

@inducer inducer marked this pull request as ready for review April 2, 2025 18:26
Co-authored-by: Matt Smith <[email protected]>
@inducer inducer force-pushed the bcast-obj-attempt-2 branch from 0d4a555 to fa488f1 Compare April 2, 2025 18:32
@inducer inducer enabled auto-merge (rebase) April 2, 2025 18:32
@inducer
Copy link
Owner Author

inducer commented Apr 2, 2025

Thanks all for your help with this!

@inducer inducer merged commit 3cb5ef4 into main Apr 2, 2025
12 checks passed
@inducer inducer deleted the bcast-obj-attempt-2 branch April 2, 2025 18:44
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.

3 participants