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

bugfix gflow visualization #107

Merged
merged 10 commits into from
Dec 19, 2023
Merged

bugfix gflow visualization #107

merged 10 commits into from
Dec 19, 2023

Conversation

d1ssk
Copy link
Contributor

@d1ssk d1ssk commented Dec 15, 2023

Before submitting, please check the following:

  • Make sure you have tests for the new code and that test passes (run tox)
  • format added code by black -l 120 <filename>
  • If applicable, add a line to the [unreleased] part of CHANGELOG.md, following keep-a-changelog.

Then, please fill in below:

Context (if applicable):
Singular matrix error occured with visualisation tool when drawing graph with gflow. (#97 )

Description of the change:
The direct cause of the error was in the get_figsize() method, which returned 0 height for pattern without input_nodes. Fixed that part and modified some detailed drawing methods for better gflow visualization.

Related issue:
#97

also see that checks (github actions) pass.
If lint check keeps failing, try installing black==22.8.0 as behavior seems to vary across versions.

@d1ssk d1ssk linked an issue Dec 15, 2023 that may be closed by this pull request
@d1ssk
Copy link
Contributor Author

d1ssk commented Dec 15, 2023

As a example, these are visualizations of QNN pattern after Pauli measurements. The first one was generated by pattern.draw_graph() and the second one by pattern.draw_graph(node_distance=(1.2, 1.6)) to broaden node distances for better visualization.
スクリーンショット 2023-12-15 21 18 12
スクリーンショット 2023-12-15 21 18 03

Copy link
Contributor

@shinich1 shinich1 left a comment

Choose a reason for hiding this comment

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

@d1ssk looks good! please see my changes and if you are happy about them, please squash and merge.

@shinich1
Copy link
Contributor

@d1ssk if you have time - can you add type hints to visualization.py? I think it's time to start adding them part by part..

README.md Outdated Show resolved Hide resolved
@d1ssk
Copy link
Contributor Author

d1ssk commented Dec 19, 2023

It seems that python<=3.8 and python>=3.9 have different ways of adding type hints. (Either include the typing module or use the built-in type hints class). Currently, graphix requirements are >=3.8,<3.12, so we need to decide which one we should use and make it consistent across the library. This time, I'm merging this PR without adding them.

@d1ssk d1ssk merged commit 19d4e0e into master Dec 19, 2023
12 checks passed
@d1ssk d1ssk deleted the 97-bug-visualizing-with-gflow branch December 19, 2023 13:10
@pafloxy
Copy link

pafloxy commented Jan 24, 2024

I am not sure if this is the right place to ask this, but sometimes(or maybe always) there are edges with double arrows are showinf up in the plots which I am not sure how to interpret :/. Like if there are the elements from the correction-set then the arrows should have single heads no ?


For example
image

here is a pettern where the correction sets are as follows :
[{2: {1}, 3: {0, 1}, 4: {1, 3}}]

all vertices measured in XY, {0,1} are the outputs and {4,2} the inputs


Can you point out wht am I doing wrong ?

I instantiated graphix.vizualisation.GraphVisualizer on the adjacenecy matrix
[[0, 0, 1, 1, 0],
[0, 0, 1, 0, 0],
[1, 1, 0, 0, 1],
[1, 0, 0, 0, 1],
[0, 0, 1, 1, 0]]
i,e
image

and the information about the input an the outputs. and used classmethod visualize_w_gflow() to generate the plot.

@d1ssk
Copy link
Contributor Author

d1ssk commented Jan 25, 2024

@pafloxy I have investigated this issue and found a basic logic error in the visualization method that had not been revealed until now. I will commit the change to fix this in PR #113. Thank you for pointing it out!

@pafloxy
Copy link

pafloxy commented Jan 25, 2024

Ahn okay. glad to be of help ;). But can you maybe hint me at the problem ? So that I can bypass it somehow for my own tasks for a while before you fix it in the mentioned PR.

@d1ssk
Copy link
Contributor Author

d1ssk commented Jan 25, 2024

Sure. The problem had lain in the section where the edges to be drawn are collected, lines 547 and 548 of visualization.py. You can bypass this by modifying this part according to the latest commit in PR #113.

@shinich1 shinich1 mentioned this pull request Jan 28, 2024
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

Successfully merging this pull request may close these issues.

[Bug]: visualizing with gflow
4 participants