Update configurations to perform serialization/deserialization scalings before initializing class #4728
Conversation
There was a problem hiding this comment.
I'm not sure how this was working previously?
There was a problem hiding this comment.
Apparently this conversion was happening in the provider. It seems like this update will be required for the dumping of files. Its possible I could do this conversion in the mock backend loader @mtreinish ?
There was a problem hiding this comment.
I'm not sure I fully follow how this gets used. But yeah we can probably port whatever we need into the fake provider class. We'll probably add a method to the base class to extract the json loading bit and PulseDefaults object creation for all the pulse backends. Right now they just all have lines like:
to do this. If we need to add more common code we should do that in a single place instead of multiple
mtreinish
left a comment
There was a problem hiding this comment.
This LGTM, the only thing I'm not really sure about is changing the types from the __int__ constructor I feel that is potentially a breaking change because in past releases if you did PulseBackendConfiguration(..., dt=x_in_secs)` it would now behave differently than it did in prior releases.
Also, in the past we've tried to make construction from from_dict(input) is roughly equivalent to __init__(**input) (with the exception of nested objects with to_dict/from_dict)so that regardless of how you create the objects the input is roughtly the same.
|
I'm fine moving it back. My rational was that this decouples the Python representation from the serialized representation. Thumbs up this if you want to switch back. |
Yeah I agree with the idea as a general statement, but I think it's potentially going to break things because it changes the input format for the constructor. So if we want to do this we should come up with a deprecation and migration plan |
|
I'll revert 😄 |
IBM Quantum has added 3 new backends recently: Bogota, Montreal, and Toronto. This commit creates new fake backends FakeBogota, FakeMontreal, and FakeToronto from snapshots of the real devices.
603d33c to
9d7c6e5
Compare
|
Reverted and rebased on #4733 |
…ackend-defaults-bug
mtreinish
left a comment
There was a problem hiding this comment.
LGTM, one inline question but probably not a blocker. I was thinking it might be good to add a test for this, probably just adding some asserts to https://github.com/Qiskit/qiskit-terra/blob/master/test/python/providers/test_fake_backends.py#L78 or something to make sure we get these right moving forward.
| if self.qubit_lo_range: | ||
| out_dict['qubit_lo_range'] = [ | ||
| [min_range * 1e-9, max_range * 1e-9] for | ||
| (min_range, max_range) in self.qubit_lo_range] | ||
|
|
||
| if self.meas_lo_range: | ||
| out_dict['meas_lo_range'] = [ | ||
| [min_range * 1e-9, max_range * 1e-9] for | ||
| (min_range, max_range) in self.meas_lo_range] | ||
|
|
||
| if self.rep_times: | ||
| out_dict['rep_times'] = [_rt * 1e6 for _rt in self.rep_times] |
There was a problem hiding this comment.
How does this interact with the equivalent lines in QasmBackendConfiguration? I assume we just end up running this conversion twice and overwriting what's in out_dict with this from super().
There was a problem hiding this comment.
These are fields are only for pulse backends. They aren't in the QasmBackendConfiguration.
There was a problem hiding this comment.
Ignore my previous comment. Apparently they are in the QASM backend. However, they should interact as you said so it shouldn't be an issue.
There was a problem hiding this comment.
I guess the follow on question here then is whether we need this duplicated, but it doesn't hurt anything and we can always clean it up in a follow up PR later.
mtreinish
left a comment
There was a problem hiding this comment.
LGTM, thanks for adding some tests. Hopefully this means we won't have issues with the units in the fake backend snapshots moving forward.
| if self.qubit_lo_range: | ||
| out_dict['qubit_lo_range'] = [ | ||
| [min_range * 1e-9, max_range * 1e-9] for | ||
| (min_range, max_range) in self.qubit_lo_range] | ||
|
|
||
| if self.meas_lo_range: | ||
| out_dict['meas_lo_range'] = [ | ||
| [min_range * 1e-9, max_range * 1e-9] for | ||
| (min_range, max_range) in self.meas_lo_range] | ||
|
|
||
| if self.rep_times: | ||
| out_dict['rep_times'] = [_rt * 1e6 for _rt in self.rep_times] |
There was a problem hiding this comment.
I guess the follow on question here then is whether we need this duplicated, but it doesn't hurt anything and we can always clean it up in a follow up PR later.
In Qiskit#4728 how we handle the difference between the object units and the serialization format. However the snapshot update didn't actually save the correct values in the json and this is causing issues for tutorials that rely on this. This commit updates the backend snapshots for backends by rerunning the update script to correct this issue.
In #4728 how we handle the difference between the object units and the serialization format. However the snapshot update didn't actually save the correct values in the json and this is causing issues for tutorials that rely on this. This commit updates the backend snapshots for backends by rerunning the update script to correct this issue.
In #4728 how we handle the difference between the object units and the serialization format. However the snapshot update didn't actually save the correct values in the json and this is causing issues for tutorials that rely on this. This commit updates the backend snapshots for backends by rerunning the update script to correct this issue. (cherry picked from commit 0f7673e)
In #4728 how we handle the difference between the object units and the serialization format. However the snapshot update didn't actually save the correct values in the json and this is causing issues for tutorials that rely on this. This commit updates the backend snapshots for backends by rerunning the update script to correct this issue. (cherry picked from commit 0f7673e) Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
In Qiskit#4728 how we handle the difference between the object units and the serialization format. However the snapshot update didn't actually save the correct values in the json and this is causing issues for tutorials that rely on this. This commit updates the backend snapshots for backends by rerunning the update script to correct this issue.
* Update the qobj schema to support pulse gate calibrations. * Fixup qobj classes: add docstrings, call out to super * Move pulse library to top level. Fill in more details in qasm_qobj.py * Fix mistake in schema: the pulse_library definition already contains the 'array' requirement * Move pulse library to top level in qasm_qobj.py as well * Add GateCalibration to qobj/__init__.py * Fixup some implementation errors: gates contains a list of dict items, which needed to be fixed in both the schema and the py files * Put gate calibrations into calibrations.gates to leave room for adding other metadata in the future. Make a qobj.common file to allow qobj.qasm to use features of qobj.pulse * Add an example json * Schema version should be referenced not hardcoded a second time * Pretty print example file * Check if calibrations is present when doing to from dict * Fixup qobj test * Update the qobj schema to support pulse gate calibrations. * Fixup qobj classes: add docstrings, call out to super * Move pulse library to top level. Fill in more details in qasm_qobj.py * Fix mistake in schema: the pulse_library definition already contains the 'array' requirement * Move pulse library to top level in qasm_qobj.py as well * Add GateCalibration to qobj/__init__.py * Fixup some implementation errors: gates contains a list of dict items, which needed to be fixed in both the schema and the py files * Put gate calibrations into calibrations.gates to leave room for adding other metadata in the future. Make a qobj.common file to allow qobj.qasm to use features of qobj.pulse * Add an example json * Schema version should be referenced not hardcoded a second time * Pretty print example file * Update backend snapshots with new conf or defs (#4897) In #4728 how we handle the difference between the object units and the serialization format. However the snapshot update didn't actually save the correct values in the json and this is causing issues for tutorials that rely on this. This commit updates the backend snapshots for backends by rerunning the update script to correct this issue. * One reference to get_sample_pulse is raising deprecation warnings from the assembler (#4903) * Check if calibrations is present when doing to from dict * Fixup qobj test * Add qobj.config.calibrations for common cals * style * Move recent qasm qobj changes to the new qobj.common file * Update schema with qobj level and experiment level calibrations * Add schema test * Apply suggestions from code review Co-authored-by: SooluThomas <soolu.elto@gmail.com> * Fix encoding for validation of new pulse library field in qasm qobj. Add qobj test Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: SooluThomas <soolu.elto@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…gs before initializing class (Qiskit/qiskit#4728) * Add fake backends for Bogota, Montreal, and Toronto IBM Quantum has added 3 new backends recently: Bogota, Montreal, and Toronto. This commit creates new fake backends FakeBogota, FakeMontreal, and FakeToronto from snapshots of the real devices. * Refactor QobjConfiguration transformations to happen in to_dict and from_dict * Refactor PulseDefaults transformations to happen in to_dict and from_dict * Remove conversions from update fake backends scripts. * Update mock backends. Added ibmq_toronto and ibmq_montreal. * fix bug in the parametric pulse code. * Undo from_dict/init changes. * Do conversion of complex number better. * Update mock backend files. * Linting. * Add conversion tests. Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
This fixes a bug in the mock backend data. All mock backends were updated as well. Additionally a bug was found in parametric pulse.
Details and comments