Skip to content

Add type annotations around boxtree.fmm - #125

Merged
inducer merged 8 commits into
inducer:mainfrom
alexfikl:type-fmm
Aug 5, 2026
Merged

Add type annotations around boxtree.fmm#125
inducer merged 8 commits into
inducer:mainfrom
alexfikl:type-fmm

Conversation

@alexfikl

@alexfikl alexfikl commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

This adds a bunch of type annotations around the ExpansionWranglerInterface.

Comment thread boxtree/fmm.py
Comment thread boxtree/fmm.py
Comment thread boxtree/fmm.py
global_tgt_idx_all_ranks=None):
src_weight_vecs: Sequence[Array], *,
global_src_idx_all_ranks: Sequence[Array] | None = None,
global_tgt_idx_all_ranks: Sequence[Array] | None = None) -> Array | None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

drive_fmm can return None in the distributed case (in workers).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I agree, but that's clearly cumbersome, typing-wise. Can we make it so that we recognize the distributed-worker case via the type system?

@alexfikl alexfikl Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure that will work very well. The distributed stuff works by inserting a mixin into an existing wrangler (from what I can tell?), so it's not easy for the type system to check that..

I added an overload in https://github.com/inducer/boxtree/compare/88c4d64fc59db123db07642b40aade35d89b63a5..8347612c329f3a6cbb67d95b3b133451992165b3 that should work? Not sure how to test it without also typing the distributed parts and some tests though 🤷 at least pyright doesn't seem too upset about it..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also, the overload checks "is DistributedMixin and indices is None", which I'm not super sure is true on the worker side, but we can probably enforce it (?).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I added an overload

That's totally good enough, thanks!

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Also, the overload checks "is DistributedMixin and indices is None", which I'm not super sure is true on the worker side, but we can probably enforce it (?).

Type checker is happy, tests pass---happy to snooze this until it becomes relevant.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for fleshing this out!

Comment thread boxtree/rotation_classes.py
Comment thread boxtree/translation_classes.py
Comment thread boxtree/pyfmmlib_integration.py
Comment thread boxtree/pyfmmlib_integration.py
Comment thread boxtree/pyfmmlib_integration.py
@alexfikl
alexfikl marked this pull request as ready for review August 1, 2026 11:22

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! Just one minor thing regarding dist-mem and None.

Comment thread boxtree/fmm.py
@inducer
inducer enabled auto-merge (rebase) August 5, 2026 11:55
@inducer

inducer commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Thank you!

@inducer
inducer merged commit d57e168 into inducer:main Aug 5, 2026
8 checks passed
@alexfikl
alexfikl deleted the type-fmm branch August 7, 2026 11:41
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