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

BasisTranslator to only bind substitutions for parameterized gates. #4636

Merged
merged 3 commits into from
Jul 8, 2020

Conversation

kdk
Copy link
Member

@kdk kdk commented Jul 1, 2020

When replacing source gates with their target implementations, the
BasisTranslator pass had been assigning parameters for every gate
replacement which is expensive (as it requires a deepcopy of the
target DAG) and in most cases unnecessary (unless the source gate
has parameters which need to be bound).

This commit checks that the source gate needs parameter assignment,
and uses the target implementation directly if not. (The round-trip
to circuit for cases where parameter assignment will be addressed in
a later PR.)

Resolves #4632 .

Summary

Details and comments

When replacing source gates with their target implementations, the
BasisTranslator pass had been assigning parameters for every gate
replacement which is expensive (as it requires a deepcopy of the
target DAG) and in most cases unnecessary (unless the source gate
has parameters which need to be bound).

This commit checks that the source gate needs parameter assignment,
and uses the target implementation directly if not. (The round-trip
to circuit for cases where parameter assignment will be addressed in
a later PR.)

Resolves Qiskit#4632 .
@kdk kdk requested a review from a team as a code owner July 1, 2020 15:53
@kdk kdk added the performance label Jul 1, 2020
@kdk kdk added this to the 0.15 milestone Jul 1, 2020
@mergify mergify bot merged commit f0f9c04 into Qiskit:master Jul 8, 2020
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
…iskit#4636)

When replacing source gates with their target implementations, the
BasisTranslator pass had been assigning parameters for every gate
replacement which is expensive (as it requires a deepcopy of the
target DAG) and in most cases unnecessary (unless the source gate
has parameters which need to be bound).

This commit checks that the source gate needs parameter assignment,
and uses the target implementation directly if not. (The round-trip
to circuit for cases where parameter assignment will be addressed in
a later PR.)

Resolves Qiskit#4632 .

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Matthew Treinish <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BasisTranslator causes transpiler performance regression
3 participants