Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate circuit counters for parallel traversals/queries #64

Closed
RenatoGeh opened this issue Mar 18, 2021 · 3 comments
Closed

Separate circuit counters for parallel traversals/queries #64

RenatoGeh opened this issue Mar 18, 2021 · 3 comments

Comments

@RenatoGeh
Copy link
Contributor

Hi,

Currently Juice stores a unique counter for each node to mark them as visited during a traversal. As a consequence, traversing the same circuit (for perhaps different queries) in parallel is not allowed.

Could we optionally let the user supply a counter map instead so we can run several threads traversing the same circuit at the same time? If so, what would be the most Juice-idiomatic? Here's an example proposal out of the top of my head, where query is some query function (like log_likelihood_per_instance or isdeterministic).

c = ... # some circuit
V = Dict{ProbCircuit, UInt32}()
query(c, args; counter = V)

Thanks

@guyvdbroeck
Copy link
Member

guyvdbroeck commented Mar 18, 2021

It makes sense to provide a function that is given the node, an integer k, increments the counter by k, and returns the previous value of the counter. The default implementation can use the counter field in the node struct -- this will always be fastest --, but one can also use a Dict as in your example or a field in the struct pointed at by the node's data field.

@khosravipasha
Copy link
Contributor

Yeah I think this could be very useful. Also, at the same time we can probably provide a more robust reset counter, Tractables/LogicCircuits.jl#64.

Another option might be an option to deep copy the same circuit for each thread, uses more memory but probably better for speed. Then user can decide between the tradeoffs.

@guyvdbroeck
Copy link
Member

I changed the traversal infrastructure in Tractables/LogicCircuits.jl@00177e3 so that it is now safe to traverse the circuit in parallel: each traversal uses its own Dict.

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

No branches or pull requests

3 participants