-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Serializable Qobj + Pass cpp/projectq simulator tests #397
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!.. just found a little mistake.
@@ -61,7 +61,7 @@ def setUp(self): | |||
} | |||
]} | |||
self.q_job = QuantumJob(self.qobj, | |||
backend='local_sympy_qasm_simulator', | |||
backend=SympyQasmSimulator, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you meant: SympyQasmSimulator()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, thanks!
qiskit/_quantumjob.py
Outdated
self.qobj = self._create_qobj(circuits, circuit_config, backend, | ||
seed, resources, shots, do_compile) | ||
self.backend = self.qobj['config']['backend'] | ||
self.backend_name = self.qobj['config']['backend_name'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.backend_name
is not being used elsewhere, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. removed.
I'm dreaming with the day QObj is an actual class and not a dictionary :) |
@atilag will be soon. |
@@ -82,12 +80,9 @@ def __init__(self, circuits, backend=None, | |||
# circuits is actually a qobj...validate (not ideal but convenient) | |||
self.qobj = circuits | |||
else: | |||
if not backend: | |||
raise QISKitError('backend needs to be specified if ' | |||
'preformatted==True.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also remove the
Raises:
QISKitError: if preformatted==True but no backend is specified.
bit from the docstring, for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks for cleaning up after the herculean merge of the previous two PRs!
For context, the change was made in order to decouple and be able to work directly with instances, even at the quantumjob level, and during the merge I was relying on travis plus local tests - which seem to be not skipped and passing but indeed are a bit brittle. Some sugar was added also during the last PR for being able to transparently go back to a backend name eventually (mostly as a helper for tackling serialization in a single place), but I'm glad we are able to at least have something more robust in place while waiting for solving it fully during the qobj introduction. TL;DR: thanks!
Serializable Qobj + Pass cpp/projectq simulator tests
Serializable Qobj + Pass cpp/projectq simulator tests
I realized that the previous PR (#376) merge broke our c++ simulator and Project Q simulators. It was because our c++ simulator tests were flawed (they were actually using the Python backend!), and the ProjectQ simulator was not installed on Travis.
The problem was with the Qobj dictionary created. The value for the
backend
field was aBackend
instance, but this is not valid JSON and those simulators that expect and decode JSON will throw errors. I made this point to the backend string, but included a copy of the instance in the QuantumJob wrapper. Going forward, this will be part of the Qobj object.Description
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: