Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Switch graph accumulator to use new support calculator #1013

Closed

Conversation

ericlippert
Copy link
Contributor

Summary:
We need to know the support -- the set of possible values of a stochastic expression -- to handle compiling models of the form

x = some_rv(some_finite_rv())

where some_finite_rv has small, finite support. It needs to be small and finite because we're going to actually call some_rv with each possible value.

For our purposes we define small as <= 1000. (We should add a mechanism to tweak this parameter later.)

Previously we had each node compute its own support, but (1) this is not a concern of the node, and (2) we need extra mechanisms to also compute approximate support size, and (3) the implementation was recursive, which crashes if the model has a path that exceeds python's recursion limit.

We now have a module using the same nonrecurisve, mutation-aware algorithm that the type checker uses. In this diff I switch over the graph accumulator to use the new mechanism. In the next diff I will delete the now-unused support instance methods.

Reviewed By: wtaha

Differential Revision: D30738627

Summary:
We need to know the support -- the set of possible values of a stochastic expression -- to handle compiling models of the form

    x = some_rv(some_finite_rv())

where some_finite_rv has small, finite support. It needs to be small and finite because we're going to actually call some_rv with each possible value.

For our purposes we define small as <= 1000.  (We should add a mechanism to tweak this parameter later.)

Previously we had each node compute its own support, but (1) this is not a concern of the node, and (2) we need extra mechanisms to also compute approximate support size, and (3) the implementation was recursive, which crashes if the model has a path that exceeds python's recursion limit.

We now have a module using the same nonrecurisve, mutation-aware algorithm that the type checker uses. In this diff I switch over the graph accumulator to use the new mechanism.  In the next diff I will delete the now-unused support instance methods.

Reviewed By: wtaha

Differential Revision: D30738627

fbshipit-source-id: b56a254c6b6f88a5ee93cc8738584923704783a8
@facebook-github-bot
Copy link
Collaborator

This pull request was exported from Phabricator. Differential Revision: D30738627

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 23, 2021
@facebook-github-bot
Copy link
Collaborator

This pull request has been merged in 83d69c4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants