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

🐛 Increased tolerance to avoid undetected degeneracy and added forbidden BDL types in wire detection #685

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

Drewniok
Copy link
Collaborator

@Drewniok Drewniok commented Mar 3, 2025

Description

This PR increases the tolerance used in groundstate_from_simulation_results to extract the ground states from simulation results. Previously, it failed to detect the degeneracy of the ground state in some cases, leading to "weird" operational domains. This should now be fixed.

Example:
This operational domain should be empty, which is only the case if the degeneracy of the ground state is correctly detected. As said, this should be fixed now.
perturber_distance_encoded_two_bdl_wire

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have added a changelog entry.
  • I have created/adjusted the Python bindings for any new or updated functionality.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

@Drewniok Drewniok added the bug Something isn't working label Mar 3, 2025
@Drewniok Drewniok self-assigned this Mar 3, 2025
@Drewniok Drewniok changed the title 🐛 Increased tolerance to avoid undetected degeneracy. 🐛 Increased tolerance to avoid undetected degeneracy Mar 3, 2025
@Drewniok Drewniok requested a review from marcelwa March 3, 2025 17:34
@marcelwa
Copy link
Collaborator

marcelwa commented Mar 3, 2025

Thanks for the fix! 🙏

Slightly off-topic, but thinking about the function, I wonder if we should refactor it into a member of sidb_simulation_result called groundstate for more intuitive usability. What do you think, @Drewniok and @wlambooy?

Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 97.05882% with 4 lines in your changes missing coverage. Please review.

Project coverage is 98.36%. Comparing base (15b53ec) to head (8691e3c).

Files with missing lines Patch % Lines
...on/algorithms/simulation/sidb/detect_bdl_wires.hpp 84.61% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #685   +/-   ##
=======================================
  Coverage   98.36%   98.36%           
=======================================
  Files         254      253    -1     
  Lines       41399    41484   +85     
  Branches     1878     1883    +5     
=======================================
+ Hits        40722    40806   +84     
- Misses        677      678    +1     
Files with missing lines Coverage Δ
...on/algorithms/simulation/sidb/defect_influence.hpp 96.51% <100.00%> (ø)
...ion/algorithms/simulation/sidb/is_ground_state.hpp 100.00% <100.00%> (ø)
...tion/algorithms/simulation/sidb/is_operational.hpp 92.02% <100.00%> (-0.03%) ⬇️
...orithms/simulation/sidb/sidb_simulation_result.hpp 100.00% <100.00%> (ø)
...est/algorithms/simulation/sidb/clustercomplete.cpp 99.68% <100.00%> (ø)
...lation/sidb/exhaustive_ground_state_simulation.cpp 100.00% <100.00%> (ø)
.../algorithms/simulation/sidb/operational_domain.cpp 100.00% <100.00%> (ø)
test/algorithms/simulation/sidb/quickexact.cpp 100.00% <ø> (ø)
test/algorithms/simulation/sidb/quicksim.cpp 100.00% <100.00%> (ø)
...orithms/simulation/sidb/sidb_simulation_result.cpp 100.00% <100.00%> (ø)
... and 2 more

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15b53ec...8691e3c. Read the comment docs.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented Mar 3, 2025

clang-tidy review says "All clean, LGTM! 👍"

@Drewniok
Copy link
Collaborator Author

Drewniok commented Mar 3, 2025

Thanks for the fix! 🙏

Slightly off-topic, but thinking about the function, I wonder if we should refactor it into a member of sidb_simulation_result called groundstate for more intuitive usability. What do you think, @Drewniok and @wlambooy?

That's a great idea! I like it!

Copy link
Contributor

github-actions bot commented Mar 4, 2025

clang-tidy review says "All clean, LGTM! 👍"

@Drewniok Drewniok changed the title 🐛 Increased tolerance to avoid undetected degeneracy 🐛 Increased tolerance to avoid undetected degeneracy and add forbidden BDL types in wire detection Mar 4, 2025
@Drewniok Drewniok changed the title 🐛 Increased tolerance to avoid undetected degeneracy and add forbidden BDL types in wire detection 🐛 Increased tolerance to avoid undetected degeneracy and added forbidden BDL types in wire detection Mar 4, 2025
Copy link
Contributor

github-actions bot commented Mar 4, 2025

clang-tidy review says "All clean, LGTM! 👍"

@wlambooy
Copy link
Collaborator

wlambooy commented Mar 4, 2025

Thanks for the fix! 🙏

Slightly off-topic, but thinking about the function, I wonder if we should refactor it into a member of sidb_simulation_result called groundstate for more intuitive usability. What do you think, @Drewniok and @wlambooy?

I think that is an excellent idea! Since there is always the possibility of getting degenerate groundstates, we should respect that in the function name, i.e.: groundstates.

@marcelwa
Copy link
Collaborator

marcelwa commented Mar 4, 2025

Thanks for the fix! 🙏

Slightly off-topic, but thinking about the function, I wonder if we should refactor it into a member of sidb_simulation_result called groundstate for more intuitive usability. What do you think, @Drewniok and @wlambooy?

I think that is an excellent idea! Since there is always the possibility of getting degenerate groundstates, we should respect that in the function name, i.e.: groundstates.

Good call! Would it make sense then to parameterize the function to allow degeneracy or not? Or have two separate functions for that? I'm also okay with having a single one simply called groundstates. I'm merely asking for your preference since you're going to use the API the most.

@Drewniok
Copy link
Collaborator Author

Drewniok commented Mar 5, 2025

Thanks for the fix! 🙏
Slightly off-topic, but thinking about the function, I wonder if we should refactor it into a member of sidb_simulation_result called groundstate for more intuitive usability. What do you think, @Drewniok and @wlambooy?

I think that is an excellent idea! Since there is always the possibility of getting degenerate groundstates, we should respect that in the function name, i.e.: groundstates.

Good call! Would it make sense then to parameterize the function to allow degeneracy or not? Or have two separate functions for that? I'm also okay with having a single one simply called groundstates. I'm merely asking for your preference since you're going to use the API the most.

Personally, I do not see a reason for parameterizing it.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Signed-off-by: GitHub Actions <[email protected]>
Comment on lines 604 to 606
[[nodiscard]] std::vector<bdl_wire<Lyt>>
filter_wires_by_type(const typename technology<Lyt>::cell_type& type) const noexcept
filter_wires_by_type(const typename technology<Lyt>::cell_type& type,
const typename technology<Lyt>::cell_type forbidden_type) const noexcept
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe I'm missing something here. If you filter wires by a certain type, why do you need to specify another type that is prohibited? Wouldn't any type != type be automatically prohibited by definition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I understand that this is not great and confusing. Thanks for bringing this up!
I think we should solve this differently and use a different name for the input. The idea is that forbidden_type can be used to remove BDL pairs of the given type from the wire. This is needed in the specific case of a BDL wire with input and output BDL pairs (typically the BDL wires of our gates have either input or output BDL wires and not both).

Copy link
Collaborator

Choose a reason for hiding this comment

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

The fact that this seems necessary hints at a design flaw somewhere. Maybe calling the filter function twice to remove all the dots you want gone wouldn't be so bad.

Copy link
Collaborator Author

@Drewniok Drewniok Mar 12, 2025

Choose a reason for hiding this comment

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

hmm, what do you think about the new version.

@Drewniok Drewniok requested a review from marcelwa March 13, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants