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

Introduce Symbolic circuit #155

Merged
merged 10 commits into from
Dec 5, 2023
Merged

Introduce Symbolic circuit #155

merged 10 commits into from
Dec 5, 2023

Conversation

IrwinChay
Copy link
Collaborator

Basically following what we discussed in week 8,

specifically, using re-param for placeholder (uninitialized) parameters

Also stored all the information (layer_cls and efamily_cls) so the tensorized circuit could be directly converted into tensorized form, no additional input needed

CP layers and sum layer (previously called mixing layer) not implemented yet

"Building symbolic circuit from RG" will be implemented in another file, writing now

@IrwinChay IrwinChay requested a review from lkct November 30, 2023 11:27
@IrwinChay
Copy link
Collaborator Author

Alternative: use a "sum product node" class to store the CP and Tucker placeholder parameters? instead of storing everything in the sum node class?

@lkct
Copy link
Member

lkct commented Nov 30, 2023

As just discussed: (to keep a note here)

"Building symbolic circuit from RG" will be implemented in another file, writing now

Better include it in this PR, which also requires some changes to the __init__ interface.

Alternative: use a "sum product layer" class to store the CP and Tucker placeholder parameters? instead of storing everything in the sum layer class?

It's better to split sum and prod in symbolic layers. Fusing them into SumProductLayer with einsum is just a computational trick but not the semantics of circuit.

Also some nomenclature renamings mentioned in discussion.

@IrwinChay
Copy link
Collaborator Author

Update:

renamed from node to layer, num_input_units into num_units, product layer type

Added CP parameter construction

Added symbolic circuit class, construction from Region Graph, compatibility test,

re-arranged folder structure to /new/symbolic

Copy link
Member

@lkct lkct left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For linting, just ignore for the moment. Will be looked after during future refactoring.

Regarding SymbolicCircuit:

  1. from_region_graph should directly become __init__ because SC can only be constructed from RG. We don't need add_layer and add_edge publicly.
  2. Just save a copy of RG, and the structural properties can be directly retrieved from the RG. NO need to repeat code and recalculate.

@IrwinChay
Copy link
Collaborator Author

IrwinChay commented Dec 5, 2023

For linting, just ignore for the moment. Will be looked after during future refactoring.

Regarding SymbolicCircuit:

  1. from_region_graph should directly become __init__ because SC can only be constructed from RG. We don't need add_layer and add_edge publicly.
  2. Just save a copy of RG, and the structural properties can be directly retrieved from the RG. NO need to repeat code and recalculate.

Update:

moved from_region_graph to __init__

removed smooth and decomposability tests, which are copies of that in RG

retained is_compatible, will move it to new/RG

Copy link
Member

@lkct lkct left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have questions about the motivation of some code.
But I think it's OK to merge and I'll fix those along with linting.


"""
self._layers: Set[SymbolicLayer] = set()
self._region_graph = region_graph
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's mark self.region_graph public.
and where are the properties? I expect something like self.is_smooth=region_graph.is_smooth

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, will require new/RG

tail.outputs.add(head)
head.inputs.add(tail)

def __from_region_graph(self, **circuit_params) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using this function but not merging into __init__?
also do we really need __func instead of _func?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

legacy issues, fixed

@lkct lkct self-requested a review December 5, 2023 16:41
Copy link
Member

@lkct lkct left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lkct lkct merged commit 601baf0 into main Dec 5, 2023
@lkct lkct deleted the symbolic_circuit branch December 5, 2023 16:53
@lkct lkct added the enhancement New feature or request label Dec 5, 2023
@lkct lkct changed the title Step -1 of Symbolic Product Introduce Symbolic circuit Feb 15, 2024
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.

2 participants