Skip to content

Fix duplicate overload type resolution - #914

Open
ZzEeKkAa wants to merge 2 commits into
NVIDIA:mainfrom
ZzEeKkAa:yhavrylko/fix/duplicate_type_resolution
Open

Fix duplicate overload type resolution#914
ZzEeKkAa wants to merge 2 commits into
NVIDIA:mainfrom
ZzEeKkAa:yhavrylko/fix/duplicate_type_resolution

Conversation

@ZzEeKkAa

@ZzEeKkAa ZzEeKkAa commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fix duplicate overload type resolution

Summary

@overload / @overload_method implementation functions are re-executed once per
distinct compiler-Flags context in which a call is resolved. Because the overload
body is where user code does its (sometimes very expensive) work, this doubles that
work for every overload that is resolved both during an enclosing kernel's type
inference and during a device-function compile.

This MR memoizes the overload-function result on the typing context + argument
types only
— the inputs the overload actually depends on — so the body runs at
most once per distinct signature, while leaving the existing flag-sensitive
_impl_cache untouched.

Root cause

_OverloadFunctionTemplate._get_impl keys its implementation cache on the active
flags:

flags = targetconfig.ConfigStack.top_or_none()
cache_key = self.context, tuple(args), tuple(kws.items()), flags

@copy-pr-bot

copy-pr-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ZzEeKkAa
ZzEeKkAa requested a review from atmnp July 9, 2026 23:42
@ZzEeKkAa

ZzEeKkAa commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@ZzEeKkAa
ZzEeKkAa requested a review from gmarkall July 9, 2026 23:43
@ZzEeKkAa
ZzEeKkAa marked this pull request as ready for review July 9, 2026 23:43
@copy-pr-bot

copy-pr-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

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.

1 participant