forked from quantumlib/Cirq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace AbstractEngineProcessorShim (quantumlib#4842)
We were using `AbstractEngineProcessorShim` pending quantumlib#4644 and friends. Those PRs have landed. For data hygiene as part of the workflow tools, we need to record what processor was used. This PR introduces an abstract `ProcessorRecord` interface and three implementations for mapping (processor_id, whether it's a simulator, what sort of noise) tuples to an AbstractProcessor instance for doing the work. - Remove `AbstractEngineProcessorShim` - Add dataclasses for data hygene - Now we can have proper serialization tests for anything that saves a `QuantumRuntimeConfiguration`, hence the new json files - We don't need to shim over `cirq.read_json` in tests that make use of `AbstractEngineProcessorShim` any more - Side effect: the new engine-processor-backed instances mean we have to use "real" qubits in the tests, so there are some knock-on test changes. cc @dstrain115 @MichaelBroughton
- Loading branch information
1 parent
a5b3a5a
commit c4122ef
Showing
22 changed files
with
539 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
cirq-google/cirq_google/json_test_data/cirq.google.EngineProcessorRecord.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"cirq_type": "cirq.google.EngineProcessorRecord", | ||
"processor_id": "rainbow" | ||
} |
1 change: 1 addition & 0 deletions
1
cirq-google/cirq_google/json_test_data/cirq.google.EngineProcessorRecord.repr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cirq_google.EngineProcessorRecord(processor_id='rainbow') |
130 changes: 130 additions & 0 deletions
130
cirq-google/cirq_google/json_test_data/cirq.google.ExecutableGroupResult.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ | ||
"cirq_type": "cirq.google.ExecutableGroupResult", | ||
"runtime_configuration": { | ||
"cirq_type": "cirq.google.QuantumRuntimeConfiguration", | ||
"processor_record": { | ||
"cirq_type": "cirq.google.SimulatedProcessorRecord", | ||
"processor_id": "rainbow", | ||
"noise_strength": 0 | ||
}, | ||
"run_id": "unit-test", | ||
"random_seed": null, | ||
"qubit_placer": { | ||
"cirq_type": "cirq.google.NaiveQubitPlacer" | ||
} | ||
}, | ||
"shared_runtime_info": { | ||
"cirq_type": "cirq.google.SharedRuntimeInfo", | ||
"run_id": "my run" | ||
}, | ||
"executable_results": [ | ||
{ | ||
"cirq_type": "cirq.google.ExecutableResult", | ||
"spec": { | ||
"cirq_type": "cirq.google.KeyValueExecutableSpec", | ||
"executable_family": "cirq_google.algo_benchmarks.example", | ||
"key_value_pairs": [ | ||
[ | ||
"name", | ||
"test-spec-0" | ||
] | ||
] | ||
}, | ||
"runtime_info": { | ||
"cirq_type": "cirq.google.RuntimeInfo", | ||
"execution_index": 0, | ||
"qubit_placement": null | ||
}, | ||
"raw_data": { | ||
"cirq_type": "ResultDict", | ||
"params": { | ||
"cirq_type": "ParamResolver", | ||
"param_dict": [] | ||
}, | ||
"measurements": { | ||
"z": { | ||
"packed_digits": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", | ||
"binary": true, | ||
"dtype": "float64", | ||
"shape": [ | ||
1000, | ||
4 | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"cirq_type": "cirq.google.ExecutableResult", | ||
"spec": { | ||
"cirq_type": "cirq.google.KeyValueExecutableSpec", | ||
"executable_family": "cirq_google.algo_benchmarks.example", | ||
"key_value_pairs": [ | ||
[ | ||
"name", | ||
"test-spec-1" | ||
] | ||
] | ||
}, | ||
"runtime_info": { | ||
"cirq_type": "cirq.google.RuntimeInfo", | ||
"execution_index": 1, | ||
"qubit_placement": null | ||
}, | ||
"raw_data": { | ||
"cirq_type": "ResultDict", | ||
"params": { | ||
"cirq_type": "ParamResolver", | ||
"param_dict": [] | ||
}, | ||
"measurements": { | ||
"z": { | ||
"packed_digits": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", | ||
"binary": true, | ||
"dtype": "float64", | ||
"shape": [ | ||
1000, | ||
4 | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"cirq_type": "cirq.google.ExecutableResult", | ||
"spec": { | ||
"cirq_type": "cirq.google.KeyValueExecutableSpec", | ||
"executable_family": "cirq_google.algo_benchmarks.example", | ||
"key_value_pairs": [ | ||
[ | ||
"name", | ||
"test-spec-2" | ||
] | ||
] | ||
}, | ||
"runtime_info": { | ||
"cirq_type": "cirq.google.RuntimeInfo", | ||
"execution_index": 2, | ||
"qubit_placement": null | ||
}, | ||
"raw_data": { | ||
"cirq_type": "ResultDict", | ||
"params": { | ||
"cirq_type": "ParamResolver", | ||
"param_dict": [] | ||
}, | ||
"measurements": { | ||
"z": { | ||
"packed_digits": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", | ||
"binary": true, | ||
"dtype": "float64", | ||
"shape": [ | ||
1000, | ||
4 | ||
] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
cirq-google/cirq_google/json_test_data/cirq.google.ExecutableGroupResult.repr
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
cirq-google/cirq_google/json_test_data/cirq.google.ExecutableResult.repr
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
cirq-google/cirq_google/json_test_data/cirq.google.QuantumRuntimeConfiguration.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"cirq_type": "cirq.google.QuantumRuntimeConfiguration", | ||
"processor_record": { | ||
"cirq_type": "cirq.google.SimulatedProcessorRecord", | ||
"processor_id": "rainbow", | ||
"noise_strength": 0 | ||
}, | ||
"run_id": "unit-test", | ||
"random_seed": null, | ||
"qubit_placer": { | ||
"cirq_type": "cirq.google.NaiveQubitPlacer" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
cirq-google/cirq_google/json_test_data/cirq.google.QuantumRuntimeConfiguration.repr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cirq_google.QuantumRuntimeConfiguration(processor_record=cirq_google.SimulatedProcessorRecord(processor_id='rainbow', noise_strength=0), run_id='unit-test', random_seed=None, qubit_placer=cirq_google.NaiveQubitPlacer()) |
5 changes: 5 additions & 0 deletions
5
cirq-google/cirq_google/json_test_data/cirq.google.SimulatedProcessorRecord.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cirq_type": "cirq.google.SimulatedProcessorRecord", | ||
"processor_id": "rainbow", | ||
"noise_strength": 0.001 | ||
} |
1 change: 1 addition & 0 deletions
1
cirq-google/cirq_google/json_test_data/cirq.google.SimulatedProcessorRecord.repr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cirq_google.SimulatedProcessorRecord(processor_id='rainbow', noise_strength=0.001) |
5 changes: 5 additions & 0 deletions
5
...oogle/cirq_google/json_test_data/cirq.google.SimulatedProcessorWithLocalDeviceRecord.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cirq_type": "cirq.google.SimulatedProcessorWithLocalDeviceRecord", | ||
"processor_id": "rainbow", | ||
"noise_strength": 0.001 | ||
} |
1 change: 1 addition & 0 deletions
1
...oogle/cirq_google/json_test_data/cirq.google.SimulatedProcessorWithLocalDeviceRecord.repr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cirq_google.SimulatedProcessorWithLocalDeviceRecord(processor_id='rainbow', noise_strength=0.001) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
cirq-google/cirq_google/workflow/_abstract_engine_processor_shim.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.