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

UserWarning: routing_method is not a recognized runtime option when using execute #7200

Closed
nonhermitian opened this issue Oct 31, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@nonhermitian
Copy link
Contributor

Information

  • Qiskit Terra version: 0.18.3
  • Python version:
  • Operating system:
  • Provider 0.16.0

What is the current behavior?

Calling

execute(qc, backend, optimization_level=3, routing_method='sabre', layout_method='sabre')

raises:

/Users/paul/mambaforge/envs/qiskit/lib/python3.9/site-packages/qiskit/execute_function.py:399: UserWarning: routing_method is not a recognized runtime option and may be ignored by the backend.

However, doing

transpile(qc, backend, optimization_level=3, routing_method='sabre', layout_method='sabre')

gives no such error.

Steps to reproduce the problem

What is the expected behavior?

Suggested solutions

@jakelishman
Copy link
Member

At the time the transpile/execute interface was made (#2166), execute was meant to understand all of transpile and assemble's kwargs, but over time it's lost a lot of them.

Kwargs in transpile but missing from execute:

  • approximation_degree
  • callback
  • dt
  • instruction_durations
  • layout_method
  • output_name
  • routing_method
  • timing_constraints
  • translation_method
  • unitary_synthesis_method

Kwargs in assemble but not execute:

  • meas_lo_freq
  • parametric_pulses
  • qubit_lo_freq

meas_lo_freq and qubit_lo_freq are actually gathered, they're just called default_{meas,qubit}_los respectively in the list. Perhaps we should add both for now, and deprecate one form (in either assemble or execute) in favour of moving to a common name? @taalexander: this question looks like your domain, given #6167.

execute also collects the memory_slots keyword by name, and passes it to assemble by name, even though assemble doesn't directly recognise it. I don't know enough about how the backends work to know if there's a reason we can't collect it in **run_config, though.

@ajavadia: is it your intention that the execute interface should still interpret all of transpile's (and assemble's?) keyword arguments? With the current interface split, it does seem like we should be supporting them all, though now that the argument list is much longer, it does feel slightly worrying that we're going to start having clashing names pretty soon. That's especially likely if we collect all the "unknown" arguments to pass on to the backends.

@nonhermitian
Copy link
Contributor Author

execute is kind of going out of favor, and is replaced by transpile and backend.run(), and probably the "sampler" runtime going forward. However, the warning is confusing, and it is not clear whether or not the setting is actually applied to the transpilation.

@jakelishman
Copy link
Member

Yeah, I'd be in favour of splitting things up to make it clearer as well. At the moment, routing_method (nor any of the other parameters I mentioned) doesn't get passed through to transpile - if you want to use them, you have to manually call it.

@mtreinish
Copy link
Member

Right, at a certain point we realized that bundling all the arguments for compilation and running into a single function didn't make sense and would result in an ridiculously long function signature and stopped adding explicit kwargs for every field in transpile() (and assemble() too, although this had more to do with making qobj explicitly about the ibm provider). execute() is useful as an abstraction for users that don't care about how a circuit gets compiled and just want to run a given circuit on a backend and have it work without caring about all the steps to get from an abstract virtual circuit to a result. I'd argue at the point you care about routing methods you've gone past this use case and do care about the transpilation details. We really need to improve the documentation on execute() to make these expectations clear and also clean up the code to make it a much thinner wrapper than it is and deprecate and remove all the qobj and backend overriding options specifc kwargs from the signature (basically all of these: https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/execute_function.py#L42-L44, https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/execute_function.py#L49-L65, and https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/execute_function.py#L71 )

As for the specific warning message you're seeing emitted, when BackendV1 was added and we had an explicit options field for each backend we made the default passthrough **run_opts work by setting a backend's options (since execute() is about running circuits and for backwards compatibility with BaseBackend and assemble() which used to add any extra kwargs to the global configuration in the qobj generated). So since routing_method isn't a listed kwarg on execute() the function doesn't know it should pass that to transpile() and is trying to do the equivalent of:

transpile(optimization_level=3)
backend.run(routing_method='sabre', layout_method='sabre')

and the warning message is coming from execute() knowing that routing_method is not a valid run time option for backend and it's letting you know that it will probably be ignored by the backend because of this. In the medium term I think this won't be an issue for you in the next release because after #7036 merges I'm planning to switch optimization_level 3 to use sabre by default, but more generally I'm not sure what the best path forward here is besides documentation improvements for the function.

mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Nov 1, 2021
This commit switches the default routing and layout method for
optimization level 3 to use SabreSwap and Sabre layout passes. The
quality of results is typically better with sabre than the default
stochastic swap and dense layout we're using now. For optimization
level 3 where we try to produce the best quality result and runtime
is of secondary concern using sabre makes the most sense (especially
after Qiskit#7036 which improves the runtime performance). Also for
optimization level 3 currently sabre is typically faster because we
increase the number of trials for stochastic swap (which is generally
significantly faster) which slows it down as it's doing more work.
This should improve the quality and speed of the results in general
when running with optimization level 3. In the future we can do more
work to improve the runtime performance of the sabre passes and
hopefully make it fast enough to use for all the optimization levels
which have more constraints on the run time performance than level 3.

Related to Qiskit#7112 and Qiskit#7200
mergify bot added a commit that referenced this issue Nov 20, 2021
* Switch default routing/layout method to sabre for opt level 3

This commit switches the default routing and layout method for
optimization level 3 to use SabreSwap and Sabre layout passes. The
quality of results is typically better with sabre than the default
stochastic swap and dense layout we're using now. For optimization
level 3 where we try to produce the best quality result and runtime
is of secondary concern using sabre makes the most sense (especially
after #7036 which improves the runtime performance). Also for
optimization level 3 currently sabre is typically faster because we
increase the number of trials for stochastic swap (which is generally
significantly faster) which slows it down as it's doing more work.
This should improve the quality and speed of the results in general
when running with optimization level 3. In the future we can do more
work to improve the runtime performance of the sabre passes and
hopefully make it fast enough to use for all the optimization levels
which have more constraints on the run time performance than level 3.

Related to #7112 and #7200

* Clarify punctuation in release note

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@nonhermitian
Copy link
Contributor Author

This is no longer an issue now that execute is gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants