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

Evidence operator #271

Merged
merged 31 commits into from
Oct 9, 2024
Merged

Evidence operator #271

merged 31 commits into from
Oct 9, 2024

Conversation

loreloc
Copy link
Member

@loreloc loreloc commented Sep 23, 2024

Implemented evidence symbolic operator and added support for it in the Torch compiler.

List of major changes in this PR:

  • Previously, we had that integrating a circuit yields a circuit with the same scope, but this should not be the case. For instance, if I integrate Y in a circuit computing c(X,Y), I should receive a circuit over X only. To fix this problem, I have made the LogPartitionLayer (computing the log partition function of an input layer) to have an empty scope instead.
  • The symbolic evidence operator is implemented by encapsulating an input layer in a symbolic EvidenceLayer whose constant parameters consists of an assignment to the variables the input layer is defined on. Similarly, to the LogPartitionLayer, this EvidenceLayer has empty scope.
  • Furthermore, previously we had that the scope was a property of each symbolic layer. However, since the connections are stored in the circuit, the circuit itself now stores a mapping between layers and their scope, which is pre-computed up to initialization. Given a symbolic circuit, the scope of a layer can be retrieved with the method layer_scope(.).
  • Added the implementation of the product of circuits and sub-circuits over disjoint (i.e., non-overlapping) scopes. However, it only works when layers of the same size and over non-overlapping scopes are being multiplied.

Closes #268 .

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 78.00270% with 163 lines in your changes missing coverage. Please review.

Project coverage is 70.16%. Comparing base (e5f1b5c) to head (f9bdb0f).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
cirkit/symbolic/parameters.py 82.55% 25 Missing and 1 partial ⚠️
cirkit/symbolic/layers.py 74.15% 15 Missing and 8 partials ⚠️
cirkit/backend/torch/layers/input.py 70.66% 18 Missing and 4 partials ⚠️
cirkit/symbolic/circuit.py 71.79% 22 Missing ⚠️
cirkit/symbolic/functional.py 79.36% 7 Missing and 6 partials ⚠️
cirkit/backend/torch/graph/modules.py 67.64% 8 Missing and 3 partials ⚠️
cirkit/backend/torch/parameters/nodes.py 86.56% 9 Missing ⚠️
cirkit/symbolic/operators.py 57.14% 9 Missing ⚠️
cirkit/pipeline.py 11.11% 8 Missing ⚠️
cirkit/symbolic/dtypes.py 55.55% 2 Missing and 2 partials ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #271      +/-   ##
==========================================
+ Coverage   68.95%   70.16%   +1.20%     
==========================================
  Files          45       45              
  Lines        4986     5238     +252     
  Branches      547      578      +31     
==========================================
+ Hits         3438     3675     +237     
+ Misses       1348     1346       -2     
- Partials      200      217      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@loreloc loreloc added the enhancement New feature or request label Sep 23, 2024
@loreloc loreloc self-assigned this Sep 23, 2024
@loreloc loreloc merged commit 0232014 into main Oct 9, 2024
3 of 4 checks passed
@loreloc loreloc deleted the evidence-operator branch October 9, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement symbolic evidence operator
1 participant