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

interface to execute(), transpile() and assemble() #2166

Merged
merged 14 commits into from
Apr 26, 2019

Conversation

ajavadia
Copy link
Member

@ajavadia ajavadia commented Apr 22, 2019

Summary

This is a refactoring of qiskit.compiler to define the user interfaces and the internal method interfaces.

There are 3 main user-facing functions: transpile(), assemble(), and execute().
All 3 can handle both circuits and pulse schedules. All have an expansive set of arguments, which are overloaded heavily in certain cases for convenience (e.g. an initial_layout can be passed as a dict, or list, or Layout object).

A parsing stage separates this from the internal methods and data-structures.

Internally we have well-defined methods (e.g. transpile_circuit() takes a QuantumCircuit and a TranspileConfig. The TranspileConfig has a model defined whereby it only allows initial_layout to be of type Layout, etc. etc.)

Details

  • Deprecates and moves the transpile() function from the qiskit.transpiler namespace to the qiskit.compiler namespace, which is where all transpilation, scheduling and assembling functions will reside.

  • transpile() (and therefore execute()) functions now accept a list for all kwargs, similar to how they accept a list of circuits. This is so each circuit's transpilation can be configured independently, yet all run together. (Fixes Initial_layout success should not depend on QuantumRegister name #1945, Fixes transpile should be imported in * #2178, Fixes execute ignores basis_gates argument #2190. Closes need function to get TranspileConfig for a backend #1953 by making it moot.)

  • Internally, Qiskit parses and creates a TranspileConfig from these, and then selects an appropriate PassManager based on that TranspileConfig (Closes need function to get TranspileConfig for a backend #1953 by making it moot).

  • Extensive documentation for the transpile() , assemble and execute() functions.

  • Several modes of input are now supported to the assemble_circuits() function, including via individual kwargs (e.g. shots), or from a RunConfig. Refer to documentation for more details.

  • execute() is now a thin wrapper (3 lines) around transpile(), assemble(), backend.run()

  • seed_mapper is deprecated --> use seed_transpiler

  • seed is deprecated --> use seed_simulator

Follow-ups

I have made TODO comments for these:

  • The TranspileConfig and RunConfig models have to be formalized based on Marshmallow. I did this in but I reverted it due to a few bugs.

  • The optimization_level field of transpile_config has to be tied to choosing a pass manager. I'll do this next.

  • The transpile_circuit function is a bit awkward now as it accepts a tuple of (circuit, transpile_config). This was so that it could be parallelized. In general we should make the parallel_map function be able to handle multi-variable parallelizations (essentially like a zip).

1ucian0
1ucian0 previously approved these changes Apr 22, 2019
Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

I'm not fully sure about the changes in the API, but I dont want to block here since it looks good from the code perspective.

@1ucian0 1ucian0 dismissed their stale review April 23, 2019 19:42

@ajavadia is still working on this

@ajavadia ajavadia force-pushed the transpile-interface branch 2 times, most recently from ed2e0ae to 2434413 Compare April 25, 2019 07:19
@ajavadia ajavadia changed the title interface to transpile() and assemble_circuits() interface to execute(), transpile() and assemble() Apr 25, 2019
@jaygambetta jaygambetta merged commit 65fd9d7 into Qiskit:master Apr 26, 2019
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* update transpile docstring

* parse transpile options from kwarg or transpile_config or backend

* refactor transpiler for better encapsulation

* adapt execute and assembler

* adapt tools.compiler and circuits_to_qobj and some tests

* fix last test: KeyError not TranspilerError

* rebase and clean up

* add assemble() to support both circuit and pulse assembling

* define TranspileConfig and RunConfig models

* revert the TranspileConfig/RunConfig models for now

* cleanup assembler, pass run_config to assemble_circuits and assemble_schedules

* remove assembler checks and warnings

* bring back pass_manager arg in transpile for parallizability

* move transpiler test to test.python.compiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API affects user-facing API change
Projects
None yet
4 participants