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

Serializable Qobj + Pass cpp/projectq simulator tests #397

Merged
merged 4 commits into from
Apr 16, 2018

Conversation

ajavadia
Copy link
Member

@ajavadia ajavadia commented Apr 15, 2018

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 thebackend field was a Backend 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Member

@atilag atilag left a 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,
Copy link
Member

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() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, thanks!

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']
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep. removed.

@atilag
Copy link
Member

atilag commented Apr 15, 2018

I'm dreaming with the day QObj is an actual class and not a dictionary :)

@jaygambetta
Copy link
Member

jaygambetta commented Apr 15, 2018

@atilag will be soon.

@ajavadia ajavadia changed the title Serializable Qobj + Pass cpp/projectq simulator tests WIP: Serializable Qobj + Pass cpp/projectq simulator tests Apr 16, 2018
@@ -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.')
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 also remove the

         Raises:
             QISKitError: if preformatted==True but no backend is specified.

bit from the docstring, for consistency?

Copy link
Member

@diego-plan9 diego-plan9 left a 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!

@ajavadia ajavadia changed the title WIP: Serializable Qobj + Pass cpp/projectq simulator tests Serializable Qobj + Pass cpp/projectq simulator tests Apr 16, 2018
@ajavadia ajavadia merged commit 3f6c023 into Qiskit:master Apr 16, 2018
ajavadia added a commit to ajavadia/qiskit that referenced this pull request Apr 29, 2018
Serializable Qobj + Pass cpp/projectq simulator tests
@ajavadia ajavadia deleted the fix/qobj-format branch July 21, 2018 00:12
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
Serializable Qobj + Pass cpp/projectq simulator tests
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