Skip to content

Don't default particle_id_type in get_kernel_info#114

Merged
inducer merged 2 commits intomainfrom
no-gki-default
Mar 10, 2026
Merged

Don't default particle_id_type in get_kernel_info#114
inducer merged 2 commits intomainfrom
no-gki-default

Conversation

@inducer
Copy link
Copy Markdown
Owner

@inducer inducer commented Mar 10, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 10, 2026 17:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the internal defaulting of particle_id_dtype in FMMTraversalBuilder.get_kernel_info and makes callers pass an explicit dtype, aligning kernel compilation settings with the tree’s declared particle_id_dtype.

Changes:

  • Make particle_id_dtype a required argument to get_kernel_info and remove the None -> int32 fallback.
  • Update traversal generation to pass tree.particle_id_dtype directly instead of using getattr(..., None).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 2010 to 2013
knl_info = self.get_kernel_info(
dimensions=tree.dimensions,
particle_id_dtype=getattr(tree, "particle_id_dtype", None),
particle_id_dtype=tree.particle_id_dtype,
box_id_dtype=tree.box_id_dtype,
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

__call__ now unconditionally accesses tree.particle_id_dtype. TreeOfBoxes does not define this attribute (see boxtree/tree.py), and there is an existing test that calls FMMTraversalBuilder(actx)(actx, tob). This change will raise AttributeError for TreeOfBoxes and break traversal generation for box-only trees. Consider restoring a fallback here (e.g. derive a dtype from tree.box_id_dtype or a fixed int dtype for box-only trees), or ensure TreeOfBoxes provides a particle_id_dtype attribute so traversal kernels can be built consistently.

Copilot uses AI. Check for mistakes.
Comment on lines 1749 to 1762
def get_kernel_info(self, *,
dimensions: int,
particle_id_dtype: np.dtype[np.integer[Any]] | None,
particle_id_dtype: np.dtype[np.integer[Any]],
box_id_dtype: np.dtype[np.integer[Any]],
coord_dtype: np.dtype[np.floating[Any]],
box_level_dtype: np.dtype[np.integer[Any]],
max_levels: int,
sources_are_targets: bool,
sources_have_extent: bool,
targets_have_extent: bool,
extent_norm: ExtentNorm | None,
source_boxes_has_mask: bool,
source_parent_boxes_has_mask: bool,
debug: bool = False) -> _KernelInfo:
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

get_kernel_info previously accepted particle_id_dtype=None and selected a default. With the parameter now required and the defaulting logic removed, callers that intentionally relied on the previous behavior (notably traversal generation for TreeOfBoxes, which historically had no particle_id_dtype) will fail unless they supply a dtype. If the goal is to avoid defaulting inside get_kernel_info, consider moving the default selection to the caller (or making it explicit via a required particle_id_dtype attribute on all supported tree types) to preserve existing functionality.

Copilot uses AI. Check for mistakes.
@inducer inducer enabled auto-merge (rebase) March 10, 2026 18:36
@inducer inducer merged commit 3c220d5 into main Mar 10, 2026
8 checks passed
@inducer inducer deleted the no-gki-default branch March 10, 2026 19:12
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