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

Check for gate parameter #12439

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

Conversation

MozammilQ
Copy link
Contributor

@MozammilQ MozammilQ commented May 18, 2024

Summary

This PR aims to fix an issue withTarget.has_calibration() and Target.get_calibration() when passed with parameterized gates didn't work as expected.

Refer to issues for more information.
#11658
#11657

Details and comments

To be precise, Target.has_calibration() didn't check if the calibration if present is present for a particular gate with a particular parameter,
and,
Target.get_calibration() didn't get the calibration for the gate if present is present for a particular gate with a particular parameter, when passed as a parameter as args, the method tried to bind this args with a parameter in the schedule, which was not the intention of this particular args.

So, the signature of Target.has_calibration includes a new argument operation_params which has to be passed with the parameter of the Gate if the Gate is parameterized.

Similarly, the signature of Target.get_calibration also includes a new argument operation_params which has to be passed with the parameter of the Gate if the Gate is parameterized. In the case of args argument in this function, it should be passed with the values to be bound with the parameter of the schedule which has been attached to this particular gate as its calibration.

fixes #11658
fixes #11657

@MozammilQ MozammilQ requested a review from a team as a code owner May 18, 2024 01:41
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label May 18, 2024
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core
  • @nkanazawa1989

@coveralls
Copy link

Pull Request Test Coverage Report for Build 9136334258

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 2 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.006%) to 89.607%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 92.62%
Totals Coverage Status
Change from base Build 9134495129: 0.006%
Covered Lines: 62302
Relevant Lines: 69528

💛 - Coveralls

@@ -95,4 +95,4 @@ def get_calibration(self, node_op: CircuitInst, qubits: List) -> Union[Schedule,
Raises:
TranspilerError: When node is parameterized and calibration is raw schedule object.
"""
return self.target.get_calibration(node_op.name, tuple(qubits), *node_op.params)
return self.target.get_calibration(node_op.name, tuple(qubits), None, *node_op.params)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reviewer's comment anticipated! :)
I am not super satisfied with putting None here.
Here, the parameter node_op.params has the actual list of float parameters to bind with the Gate's parameters stored in the target which is a parameter(variable). That is why I had to put None just to keep the function's behavior similar to its previous version.

)

def test_get_calibration_for_oper_with_param_pulse_with_param(self):
args = {0.23, 0.123, 0.2}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Considering theta maps to amp, sigma, and, beta. The emphasis here is just to prove that multiple *args could be successfully bind if equal number of parameter(variable) present in the actual Schedule

@MozammilQ MozammilQ changed the title [WIP] Check for gate parameter Check for gate parameter May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: No status
3 participants