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

Pulse backend configuration #2216

Merged

Conversation

taalexander
Copy link
Contributor

Summary

This PR adds a pulse backend configuration (as well as a qasm backend configuration). BackendConfiguration is now a factory method that decides on whether to initialize a QASMBackendConfiguration or BackendConfiguration based on the value of the field open_pulse.

Closes #2116.

Details and comments

In particular, I would like an opinion on the implementation of from_dict in BackendConfiguration the main advantage of this approach is it does not break any existing code.

@taalexander taalexander added the API affects user-facing API change label Apr 28, 2019
@taalexander taalexander added this to the 0.8 milestone Apr 28, 2019
@taalexander taalexander added this to To do in Pulse via automation Apr 28, 2019
@@ -69,6 +97,37 @@ class BackendConfigurationSchema(BaseSchema):
tags = List(String())


class QASMBackendConfigurationSchema(BackendConfigurationSchema):
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename the QASMFoo classes to QasmFoo (ie. QasmBackendConfigurationSchema), for consistency with the naming we use in the Qobj models (QasmQobj, etc)?

Complex, Float, Dict, InstructionParameter)
from qiskit.validation.validate import PatternProperties

# pylint: disable=invalid-name,bad-super-call
Copy link
Member

@diego-plan9 diego-plan9 Apr 30, 2019

Choose a reason for hiding this comment

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

Can you move the invalid-name to inside the specific classes or lines that need it? bad-super-call is also likely to go away with the from_dict changes.

memory = Boolean(required=True)
max_shots = Integer(required=True, validate=Range(min=1))

# Optional properties.
open_pulse = Boolean()
Copy link
Member

Choose a reason for hiding this comment

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

If both subclasses define open_pulse as required (and actually it is required and provided by the backends), can you leave it as required?

self.memory = memory
self.max_shots = max_shots

super().__init__(**kwargs)

@classmethod
def from_dict(cls, dict_):
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the customized from_dict methods?

I think I see the intent, but the main advantage (not breaking existing code) should already be achieved by the subclassing, if done correctly (as in, if existing code instantiates a generic BackendConfiguration for a qasm backend in the same way as before, it would not break or actually change - specially if the change for open_pulse not required is reverted; and for pulse backends we have the chance of modifying them as they have not been published in a stable release yet). Removing from_dict would help keeping the models as just containers - I think we are better off not moving functionality into them: even if is a relatively small change from the line counts point of view, it has some implications at the arquitectural level that I'd rather avoid.

In turn, this probably means adjusting the individual backends for using the specific subclasses - can you include the changes for basicaer in this PR, and open an issue in the qiskit-ibmq-provider repo for handling those in that provider?

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
Copy link
Member

Choose a reason for hiding this comment

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

With the suggested change regarding from_dict, these tests might be rendered obsolete - instead, can you tune python.test_schemas.TestSchemaExamples#test_examples_are_valid so it uses the specific subclasses (should be a matter of updating obj_map and explicitly including backend_configuration_openpulse_example.json, as it is excluded by the if ad the end of the method)?

memory (bool): backend supports memory.
max_shots (int): maximum number of shots supported.
"""

def __init__(self, backend_name, backend_version, n_qubits, basis_gates,
gates, local, simulator, conditional, open_pulse, memory,
Copy link
Member

@diego-plan9 diego-plan9 Apr 30, 2019

Choose a reason for hiding this comment

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

Can you revert this line (and the docstring, plus line 125)?

@taalexander taalexander merged commit a82a774 into Qiskit:master Apr 30, 2019
Pulse automation moved this from To do to Done Apr 30, 2019
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Add pulse backend configuration.

* Add QASM and Pulse backend configuration objects.

* Added QASMBackendConfiguration and PulseBackendConfiguration with factory method from_dict.

* add tests for qasm/pulse backend configuration.

* linting.

* Parameter update

* Cleanup provider models and rename.

* linting

* Linting

* Make QASM -> Qasm

* remove invalid name

* Update open_pulse field to required.

* Remove from_dict hackery.

* Update tests.

* linting.

* linting.

* linting and required variable.

* readd comment.
@1ucian0 1ucian0 added the mod: pulse Related to the Pulse module label Jan 15, 2021
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 mod: pulse Related to the Pulse module
Projects
No open projects
Pulse
  
Done
Development

Successfully merging this pull request may close these issues.

BackendConfiguration for Pulse
5 participants