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
The design of this library emphasizes composing many different model transformations (effect handlers) like condition and do to generate a single expanded program representing a causal quantity of interest, but the syntax for applying a deeply nested sequence of handlers in Pyro is awkward and easy to mess up. The ITE query from the SLC example illustrates this:
Coming up with general machinery for safely composing handlers or other program transformations is out of scope, certainly for first release.
Fortunately, to handle cases like the above it seems more straightforward to define a higher-order effect handler Query for composing our causal query transformations like do and MultiWorldCounterfactual as well as a few important ones built into Pyro such as condition and plate:
The following sketch of an implementation is almost sufficient to address the SLC example (except the final pyro.deterministic statement computing the ITE, discussed in #80, and the added argument data):
Should Query be able to consume other Query instances as arguments?
Should Query be nestable inside models? If not, how should we detect and prevent this?
Which upstream Pyro handlers could be allowed as arguments to Query without overly complicating its semantics? For example, what about reparam and block?
It also suggests a number of possible extensions or refinements:
Could we reorganize or augment the type hierarchy of Query-compatible query handlers so that there is a common base type that can be subclassed by users?
Could we extend the interface above to allow deferring large arguments like data as in the original example's queried_model?
This discussion was converted from issue #82 on May 31, 2023 22:33.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The design of this library emphasizes composing many different model transformations (effect handlers) like
condition
anddo
to generate a single expanded program representing a causal quantity of interest, but the syntax for applying a deeply nested sequence of handlers in Pyro is awkward and easy to mess up. The ITE query from the SLC example illustrates this:Coming up with general machinery for safely composing handlers or other program transformations is out of scope, certainly for first release.
Fortunately, to handle cases like the above it seems more straightforward to define a higher-order effect handler
Query
for composing our causal query transformations likedo
andMultiWorldCounterfactual
as well as a few important ones built into Pyro such ascondition
andplate
:The following sketch of an implementation is almost sufficient to address the SLC example (except the final
pyro.deterministic
statement computing the ITE, discussed in #80, and the added argumentdata
):This design raises several interesting questions:
Query
be able to consume otherQuery
instances as arguments?Query
be nestable inside models? If not, how should we detect and prevent this?Query
without overly complicating its semantics? For example, what aboutreparam
andblock
?It also suggests a number of possible extensions or refinements:
Query
-compatible query handlers so that there is a common base type that can be subclassed by users?data
as in the original example'squeried_model
?Query
be atorch.nn.Module
orpyro.nn.PyroModule
for parameter and name compatibility, as part of Make Pyro more compatible with PyTorch idioms #44 and Add a "modern Pyro" programming tutorial #45 ?Query
as a place to address Specify algebraic relationships between transformations #30 by allowing it to fuse and canonically order query operations?Query
in a way that enables model-agnostic specification of query templates like the ITE?Query
-compatible interface to theselect_world
operation proposed in Computing causal quantities across worlds is too clunky #80?Beta Was this translation helpful? Give feedback.
All reactions