qiskit-advocate/qamp-fall-22

Fix issue "Template optimization fails to recognize simpler circuit"

Closed this issue ยท 6 comments

Description

See Qiskit/qiskit#6974.

Template optimization is an important circuit compilation method which detects gate patterns in a circuit and replaces them with simpler patterns. There is a major issue with the current implementation in Qiskit Terra which causes the template optimization to fail to replace known patterns in certain instances. The task for this project is to research how to fix this issue and implement the fix.

Deliverables

Fix Qiskit/qiskit#6974.

Mentors details

  • Mentor 1
    • Name: Kevin Sung
    • GitHub ID: kevinsung
    • What they do: Qiskit Researcher

Number of mentees

1

Type of mentees

  • Mentee 1
    • Required: Knowledge of Qiskit
      • item 1
    • Nice to have: Experience contributing to Qiskit, experience with quantum circuit compilation
      • item 1
  • Mentee 2
    • Required:
      • item 1
    • Nice to have:
      • item 1

@kevinsung @GemmaDawson I will do my best in this project ;)

Please add your Checkpoint 1 presentation materials.

Checkpoint 1 presentation for project #32

Fix Template Optimization.pdf

Checkpoint 2

We have found and fixed the bug of our issue loosely. The main strategy we used is adding function "_attempt_bind" from "template_substitution.py" at step where "forward_matching.py" compairs gate of the circuit and template are same or not. This figure shows our code :
image

Example 3 of the file attached below shows that our new code resolve bug from Qiskit/qiskit-terra/issues/6974:
32_Fix_Qiskit_qiskit-terra_6974.pdf. The file is little bit messy, because I didn't erase lot of "print()" I used to debug. I need to use them again when I optimize the code ;).

The next step we are going to do is optimize the code, learn how to use git and github, and finally contribute to the issue.

I cite detail information about package and function I mentioned above :

  1. forward_matching.py : Template matching in the forward direction, it takes an initial match, a configuration of qubit and both circuit and template as inputs. The result is a list of match between the template and the circuit.
  2. template_substitution.py : Template matching substitution, given a list of maximal matches it substitutes them in circuit and creates a new optimized dag version of the circuit.
  3. _attempt_bind : Copies the template and attempts to bind any parameters, i.e. attempts to solve for a valid parameter assignment. template_sublist and circuit_sublist match up to the assignment of the parameters.

Final Checkpoint

Every works we have done has been written at checkpoint1&2. We have already fixed the issue, but didn't optimized yet. All the future works will be uploaded at github and communicate at #6974 Template optimization fails to recognize simpler circuit

Congratulations on completing all the requirements for QAMP Fall 2022!! ๐ŸŒŸ๐ŸŒŸ๐ŸŒŸ