Quandela / Perceval

An open source framework for programming photonic quantum computers
https://perceval.quandela.net
Other
133 stars 63 forks source link

Fix of heralds display (issue 207) #405

Closed burlemarxiste closed 3 weeks ago

burlemarxiste commented 1 month ago

This is a separate branch for this fix.

https://github.com/Quandela/Perceval/issues/207

ericbrts commented 4 weeks ago

Hello @burlemarxiste , I've created an integration branch for UnitaryHACK 2024 contributions. I've just merged your Barrier PR. It seems it created conflicts. Could you please solve them before I review this PR?

I'm assigning the bounty to you right now.

burlemarxiste commented 4 weeks ago

Sure! I will look into this tomorrow!

ericbrts commented 3 weeks ago

Thanks, testing and reviewing it right now!

burlemarxiste commented 3 weeks ago

I'm a bit lost with the branches at this moment. How should I proceed to continue making changes related to this issue, but with the barrier implementation included to it?

Can I merge the barriers code accepted in Quandela:release/unitary-hack-2024 and update this pull request?

ericbrts commented 3 weeks ago

You fix_heralds branch seems to be the correct source branch to work on. I'm messing with destination branches, because I want to enable the automated test workflow (which I failed to do). In the end, your synchronized with main + your Barrier branch, so working on fix_heralds is the way to go.

I'll merge it in an intermediate branch (right now, named "release/unitary-hack-2024") so that I can control to which scope we add these unitary hack contributions.

burlemarxiste commented 3 weeks ago

Is it okay if I merge the latest version of my barrier branch into this? It would be easier to regenerate the figure for the test that fails. I might also add a few more tests (circuits with recursive True or False).

ericbrts commented 3 weeks ago

The Barrier code I merged on Friday is already in your fix_heralds branch (or do you have newer code for Barriers?). I made you split your work into 3 different PR for easier reviews. Now we're reconstructing your work brick by brick. When you merged fix_heralds from the unitary-hack-2024 branch, you retrieved your work about Barriers: image

burlemarxiste commented 3 weeks ago

Thank you for confirming! I have made the changes you suggested to check for null object width, updated the image, and fixed the problem with the missing background color (it was a line that disappeared when I merged with the barrier branch).

burlemarxiste commented 3 weeks ago

I have found an issue with my implementation: collect_herald_info should collect information with the same level of flattening as the diagram to be drawn.

Can you confirm that this is how the diagram should look when recursive=False?

Screenshot 2024-06-10 at 17 13 01
ericbrts commented 3 weeks ago

Yes you can add a recursion_level parameter with a default value meaning max recursion level (like 0 ? -1 ?)

The picture for the non-recursive display is totally fine.

burlemarxiste commented 3 weeks ago

Thanks for confirming that the image is correct.

I just understood something that answered my initial confusion about the recursive argument: there are only 2 possible recursion levels. The reason is that when a Processor is added to a Processor, they are composed (no nesting between them); and iterating on a circuit always goes to the deepest level.

So there are only two possible levels, and there is no needed for an extra argument. I just need to collect the herald info at the component level when recursive=False, and circuit element level when recursive=True. (Processors are composed, but circuits can remain nested with the argument merge=False).

This latest commit should fix it.

ericbrts commented 3 weeks ago

Thanks @burlemarxiste , I'm reviewing / testing again now. Do you wish to add other things to your PR, or can I merge once I approve it?

burlemarxiste commented 3 weeks ago

I'll leave it as is for the Heralds display bug fix, but when investigating on nesting levels, I have found an unrelated display issue (present before I did any change, not affected by my changes). Should I file an issue for it?

ericbrts commented 3 weeks ago

Yes please, file as many issues as you wish!