Skip to content

Commit

Permalink
Restore cirq_google.api.v2 protos deleted in 6442 (#6746)
Browse files Browse the repository at this point in the history
Restore proto files that are still used by internal code.
This reverts small part of #6442.
  • Loading branch information
pavoljuhas authored Sep 27, 2024
1 parent 3a87b33 commit ce1d903
Show file tree
Hide file tree
Showing 6 changed files with 573 additions and 0 deletions.
58 changes: 58 additions & 0 deletions cirq-google/cirq_google/api/v2/batch.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
syntax = "proto3";

import "cirq_google/api/v2/program.proto";
import "cirq_google/api/v2/result.proto";
import "cirq_google/api/v2/run_context.proto";

package cirq.google.api.v2;

option java_package = "com.google.cirq.google.api.v2";
option java_outer_classname = "BatchProto";
option java_multiple_files = true;

// A Batch of multiple circuits that should be run together
// as one QuantumProgram within Quantum Engine.
//
// Note: Batching is done on a best-effort basis.
// Circuits will be be bundled together, but the size
// of the total batch and different hardware constraints may
// cause the programs to be executed separately on the hardware.
message BatchProgram {

// The circuits that should be bundled together as one program
repeated Program programs = 1;
}

// A batch of contexts for running a bundled batch of programs
// To be used in conjunction with BatchProgram
message BatchRunContext {

// Run contexts for each program in the BatchProgram
// Each RunContext should map directly to a Program in the corresponding
// BatchProgram.
//
// This message must have one RunContext for each Program in the
// BatchProgram, and the order of the RunContext messages should
// match the order of the Programs in the BatchProgram.
repeated RunContext run_contexts = 1;
}


// The result returned from running a BatchProgram/BatchRunContext
message BatchResult {

// Results returned from executing a BatchProgram/BatchRunContext pair.
//
// After a BatchProgram and BatchRunContext is successfully run in
// Quantum Engine, the expected result if successful will be a BatchResult.
//
// Each Result in this message will directly correspond to a Program/
// RunContext pair in the request. There will be one Result in this message
// for each corresponding pair in the request and the order of the Results
// will match the order of the Programs from the request.
//
// In case of partial results, an empty (default) Result object will be
// populated for programs that were not able to be run correctly.
repeated Result results = 1;
}

33 changes: 33 additions & 0 deletions cirq-google/cirq_google/api/v2/batch_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions cirq-google/cirq_google/api/v2/batch_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions cirq-google/cirq_google/api/v2/calibration.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
syntax = "proto3";

import "cirq_google/api/v2/metrics.proto";
import "cirq_google/api/v2/program.proto";

package cirq.google.api.v2;

option java_package = "com.google.cirq.google.api.v2";
option java_outer_classname = "FocusedCalibrationProto";
option java_multiple_files = true;

// This message represents a request to execute a custom calibration routine.
//
message FocusedCalibration {
// The layers field represents each invocation of a calibration
// procedure.
//
// For instance, each (unique) moment of a circuit could be
// calibrated using parallel_xeb. In this case,
// each moment would have its own CalibrationLayer.
//
// Some calibrations, such as a readout calibration,
// will only have one layer.
repeated CalibrationLayer layers = 1;
}

// Each CalibrationLayer represents one invocation
// of a calibration procedure.
message CalibrationLayer {
// The type of the calibration procedure to execute.
// The value of this field must be in one of the acceptable
// values found in the cirq enum TBD.
// TODO(dstrain): Point to the cirq enum once it exists.
string calibration_type = 1;

// A circuit that identifies the layer or circuit to optimize
// if the calibration requires this. For many calibrations,
// this will be a single moment representing the layer to
// optimize for.
Program layer = 2;

// Arguments that can be specified to the calibration procedure,
// such as the number of layers, which angles to optimize, etc
map<string, Arg> args = 3;
}

// The results returned by a FocusedCalibration request.
message FocusedCalibrationResult {

// The results of each CalibrationLayer request.
// There will be one CalibrationLayerResults message for each
// CalibrationLayer in the request, and the results will
// correspond to the order of the requests.
repeated CalibrationLayerResult results = 1;
}

// Response codes for Calibration requests
enum CalibrationLayerCode {

// Zero is a default value and means the value was unknown or unset.
CALIBRATION_RESULT_UNSPECIFIED = 0;

// Successful run of the calibration.
SUCCESS = 1;

// Miscellaenous errors not covered by the below conditions.
ERROR_OTHER = 2;

// The parameters given to the calibration were not valid.
// For instance, multiple moments were given to a type of calibration
// that expects a single moment.
ERROR_INVALID_PARAMETERS = 3;

// The calibration took too long and was aborted.
ERROR_TIMEOUT = 4;

// The calibration failed for internal reasons. For instance,
// suitable device parameters could not be acheived or dependencies
// needed by the calibration did not exist.
ERROR_CALIBRATION_FAILED = 5;
}


message CalibrationLayerResult {
// Whether the calibration procedure was a success or failure.
CalibrationLayerCode code = 1;

// On non-successful results, contains additional information
// about the details of the error.
string error_message = 2;

// A token identifying the calibration result.
// If a token exists in the response, it can be used to tag
// focused circuits that use parameters
// derived from this calibration.
// If no token exists, then the calibration was purely diagnostic.
string token = 3;

// Results, such as gate fidelities, gate angles, etc
// would be returned in a similar format to calibration metrics.
// This allows the return result to be easily extensible.
MetricsSnapshot metrics = 4;

// Timestamp of when the calibration is valid until, specified as
// milliseconds since the Unix epoch time.
uint64 valid_until_ms = 5;
}
40 changes: 40 additions & 0 deletions cirq-google/cirq_google/api/v2/calibration_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ce1d903

Please sign in to comment.