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

Compiler Redo #1856

Merged
merged 30 commits into from
Mar 11, 2019
Merged

Compiler Redo #1856

merged 30 commits into from
Mar 11, 2019

Conversation

jaygambetta
Copy link
Member

@jaygambetta jaygambetta commented Feb 24, 2019

Fixes #978
Fixes #1716

Deprecated execute, compile and circuits_to_qobj and replaced with execute_circuits, transpire and assemble_circuits.

edit (Ali): execute() remains and wraps execute_circuits(), to limit changes.

assemble_circuits takes a list of circuits and makes a qobj. It uses a run_config to make it and supports an additional qobj_header for additional header input. See below and allows #1716 to work. The name change is because it is not a conversion like implied with circuits_to_qobj

transpile takes a list of circuits and a transpile_config to make a new set of circuits (this is why it does not replace compile and is different to the old transpile). This is the ugly code at the moment but we need to rework the transpiler to make it cleaner.

execute_circuits takes a list of circuits, a backend, a run_config, a transpile_config and a qobj_header to simplify running the circuits on a backend.

The deprecated functions are made to call the new functions.

For example for #1716

from qiskit.qobj import QobjHeader
qobj_header = QobjHeader(description = 'paul is so cool')

job_sim = execute_circuits(circuits, backend, qobj_header=qobj_header)

Then to get the description use

job_sim.qobj().header.description

or

job_sim.result().header.description

@nonhermitianI know you wanted job.description but I wonder if this is ok as the search function can call this.

concerns

@ajavadiaI do like having objects but in a wrapper, I wonder if for the user of run_circuits a list long inputs is prefered so for the wrapper user they don't have to make the objects (transpile_config, user_qobj_header, and run_config) to run the circuits.

Todo

[ ] clean up the transpile code (synthesis part).
[x] need to give examples
[x] need to make some more test
[ ] give some optional values to transpile_config could not do this with the backend getting hacked into it.

Follow up PR1

I would be to replace qobj_to_circuits with a function that returns the circuits and the run_config, and a user_qobj_header.

I imagine it is something like

[circuits, run_config, user_qobj_header] = disassemble_qobj(qobj)

follow up PR2

A function to simplify getting the options for the compiler.

[run_config, transpile_config] = default_compiler_configs(backend)

follow up PR3

A function to simplify updating a qobj_runconfig

new_qobj = update_qobj_runconfig(qobj, run_config)

follow up PR4

decide on how to address #1714.

@t-imamichi
Copy link
Member

Great. It fixes #883 too.

qiskit/compiler/synthesizer.py Outdated Show resolved Hide resolved
qiskit/compiler/synthesizer.py Outdated Show resolved Hide resolved
qiskit/compiler/assembler.py Outdated Show resolved Hide resolved
qiskit/compiler/assembler.py Outdated Show resolved Hide resolved
qiskit/compiler/transpile_config.py Outdated Show resolved Hide resolved
qiskit/converters/circuits_to_qobj.py Outdated Show resolved Hide resolved
qiskit/runner_wrapper.py Outdated Show resolved Hide resolved
qiskit/runner_wrapper.py Outdated Show resolved Hide resolved
qiskit/runner_wrapper.py Outdated Show resolved Hide resolved
qiskit/runner_wrapper.py Outdated Show resolved Hide resolved
@1ucian0
Copy link
Member

1ucian0 commented Mar 1, 2019

I'm moving this discussion to an issue and adding https://github.com/Qiskit/qiskit-terra/wiki/Terra-high-level-workflow-API.

@1ucian0 1ucian0 closed this Mar 1, 2019
@ajavadia
Copy link
Member

ajavadia commented Mar 1, 2019

why close this? this already does most of the things, so we can pull request into this branch with any possible changes.

qiskit/compiler/assembler.py Outdated Show resolved Hide resolved
qiskit/compiler/assembler.py Show resolved Hide resolved
qiskit/compiler/transpile.py Outdated Show resolved Hide resolved
qiskit/compiler/transpile_config.py Outdated Show resolved Hide resolved
qiskit/converters/circuits_to_qobj.py Show resolved Hide resolved
qiskit/converters/circuits_to_qobj.py Show resolved Hide resolved
qiskit/execute_wrapper.py Outdated Show resolved Hide resolved
qiskit/tools/compiler.py Outdated Show resolved Hide resolved
qiskit/tools/compiler.py Outdated Show resolved Hide resolved
qiskit/__init__.py Outdated Show resolved Hide resolved
@ajavadia
Copy link
Member

I'm merging this and will follow up with a clean up of transpile so that TranspileConfig doesn't take a backend.

@ajavadia ajavadia merged commit 89ceb19 into Qiskit:master Mar 11, 2019
@jaygambetta jaygambetta deleted the compiler branch April 16, 2019 21:48
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Compiler redo

* Compiler redo

* More changes

* Linting

* Linting

* Update qiskit/compiler/synthesizer.py

Co-Authored-By: jaygambetta <[email protected]>

* Update qiskit/compiler/assembler.py

Co-Authored-By: jaygambetta <[email protected]>

* Update qiskit/compiler/assembler.py

Co-Authored-By: jaygambetta <[email protected]>

* Update qiskit/runner_wrapper.py

Co-Authored-By: jaygambetta <[email protected]>

* Renaming for ali

* Cleaning up

* Listing. And doc

* Making compile work with pass manager.

* Style fixes

* Moving around

* Limiting and passing

* naming

* Doctoring

* rename assemble() to assemble_circuits(), update warning messages

* add a changelog

* add qobj_header as an arg to execute() as well

* move schema to models folder like other qiskit components

* add tests for assembler

* qiskit.compiler.transpile -> qiskit.compiler.transpiler

* update teleport example

* update rippleadd example

* fix misleading try-except statements in the examples

* update level 1 example to be transpile then assemble

* bring run_config arg to second position in assemble_circuits()

* remove compile from tests and a bunch of pylint ignores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants