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

Improving docstrings in final qubit mapping, w/ {logical: physical} #1563

Merged

Conversation

GuillermoAbadLopez
Copy link
Contributor

@GuillermoAbadLopez GuillermoAbadLopez commented Jan 23, 2025

PR addressing Issue: #1562

  • Changes incorrect CircuitMap.final_layout() docstring from physical-logical to logical-physical
  • Changes all logical-physical by {logical: physical}, for showing more explicitly which are the keys/values

Extra for reviewers:

  • Please check the first change from above is correct, since I didn't went too deeply to check it. Instead I assumed it has to be that way based on the contradiction there was, and checking the next method names it calls 👍

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.

…eys and value statement. And reversed logica-physical in the `Circuitmap.final_layout()`
Copy link
Member

@alecandido alecandido left a comment

Choose a reason for hiding this comment

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

Nothing to amend, we can merge.


General comment, beyond this PR

Just notice that the logical and physical adjectives were also a poor choice, since most often they are just intermediate steps, so it's just a way of handling a permutation.

In principle, we could return just a permutation as a sequence of permuted indices.
However, the common output of each step is a transformed circuit, which may be remodeled including a permutation, or boil down to just that. But it may even contain no permutation at all, and just operate on the gates (as in the case of the Unroller).

So, I would discourage any further focus on permutations. Including the current final_layout, which is only sometimes present, and leading to patterns like the following

for transpiler_pass in self.passes:
if isinstance(transpiler_pass, Optimizer):
transpiler_pass.connectivity = self.connectivity
circuit = transpiler_pass(circuit)
elif isinstance(transpiler_pass, Placer):
transpiler_pass.connectivity = self.connectivity
final_layout = transpiler_pass(circuit)
elif isinstance(transpiler_pass, Router):
transpiler_pass.connectivity = self.connectivity
circuit, final_layout = transpiler_pass(circuit)
elif isinstance(transpiler_pass, Unroller):
circuit = transpiler_pass(circuit)
else:
raise_error(
TranspilerPipelineError,
f"Unrecognised transpiler pass: {transpiler_pass}",
)
return circuit, final_layout

Just relying the Circuit.wire_names will embed the optional permutation in the resulting Circuit.

@scarrazza scarrazza added the run-workflow Forces github workflow execution label Jan 23, 2025
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.68%. Comparing base (d32efb8) to head (6145cc9).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1563   +/-   ##
=======================================
  Coverage   99.68%   99.68%           
=======================================
  Files          76       76           
  Lines       11280    11280           
=======================================
  Hits        11244    11244           
  Misses         36       36           
Flag Coverage Δ
unittests 99.68% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@GuillermoAbadLopez
Copy link
Contributor Author

GuillermoAbadLopez commented Jan 24, 2025

PR itself:

Nothing to amend, we can merge.

Cool to hear 🙌


Beyond the PR:

Just notice that the logical and physical adjectives were also a poor choice, since most often they are just intermediate steps, so it's just a way of handling a permutation.

Yes, and qiskit has changed all these names several times not too long ago, so I would say the industry hasn't yet settled on anything, and it can be tricky to keep up with what each permutation represents for each different SDK.. 😅

In principle, we could return just a permutation as a sequence of permuted indices.

Precisely!

So, I would discourage any further focus on permutations. Including the current final_layout, which is only sometimes present, and leading to patterns like the following
[source_code]
Just relying the Circuit.wire_names will embed the optional permutation in the resulting Circuit.

That makes sense, I'll try it, thanks!

@renatomello renatomello added this pull request to the merge queue Jan 25, 2025
Merged via the queue into qiboteam:master with commit cbcee14 Jan 25, 2025
17 checks passed
@renatomello renatomello added this to the Qibo 0.2.16 milestone Jan 25, 2025
@GuillermoAbadLopez GuillermoAbadLopez deleted the docstring_qubit_mapping branch January 25, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-workflow Forces github workflow execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvements to final logical-physical qubit mapping, documentation
5 participants