You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(parser): reject calls between Modules resolving different topology hierarchies #131
Two Modules that resolve different topology hierarchies must not be able to call
each other. Today nothing stops that at construction; analysis rejects it
later, and schedule relies on the same late check.
ifcallee_owner.effective_topologies() !=caller_owner.effective_topologies():
raiseAnalysisError(
f"{caller_owner.name!r} calls {callee_owner.name!r}, which resolves a "f"different topology hierarchy ...; one kernel invocation runs one "f"hierarchy -- declare none on the child and inherit"
)
Type inference does not and should not catch it: visitors.py_call_function
checks arity and each argument's shape/dtype against the callee's parameters.
Two Modules with different hierarchies can match on every one of those. Module
ownership and topology declaration are program structure, not types.
Why it belongs earlier
The check is a precondition of measurement, not of typing. Every analysis number
carries a per-unit denominator read off the topology:
If the caller declares cta=132 and the callee cta=64, a "unit" means two
different things on the two sides, and no single denominator is right. The same
holds for schedule, which lays work out against one hierarchy.
So the program is not merely unanalysable -- it does not describe one kernel
invocation at all. That is a property of how it was written, which is what the
parser is for.
What this costs today
validate_call_context is reached through check_program, which has three
callers: analysis/api.py, schedule/api.py, and cli/analyze.py. Each pays
for a call-graph walk to re-establish something the program's own construction
could have settled once. An author also learns about it only when they ask for
an analysis, not when they write the call.
Note on wording
The current message reads as "you wrote this wrong". If nested launches with
their own hierarchy are ever modelled, the same shape becomes legal and the
check turns into a boundary to record rather than an edge to refuse. Worth
keeping in mind when choosing where the parser states it.
Activity