diff --git a/backend/oas/provider/openapi.yaml b/backend/oas/provider/openapi.yaml index 0ff29ee..40a3e78 100644 --- a/backend/oas/provider/openapi.yaml +++ b/backend/oas/provider/openapi.yaml @@ -305,94 +305,6 @@ paths: $ref: '#/components/schemas/error.BadRequest' example: detail: Bad request malformed input data - /results: - post: - summary: Submit a quantum job result - tags: - - results - description: Submit a quantum job result - operationId: postResult - security: [] - requestBody: - description: Result to be submitted - content: - application/json: - schema: - $ref: '#/components/schemas/results.ResultDef' - examples: - success sampling: - value: - jobId: 7af020f6-2e38-4d70-8cf0-4349650ea08c - status: SUCCESS - result: - '11': 4980 - '00': 5020 - reason: null - transpiledCode: OPENQASM 3;include "stdgates.inc";qubit[2] _all_qubits;let q = _all_qubits[0:1];h q[0];cx q[0], q[1]; - success estimation: - value: - jobId: 7af020f6-2e38-4d70-8cf0-4349650ea08c - status: SUCCESS - result: - - 1.5 - - 2.8 - reason: null - transpiledCode: OPENQASM 3;include "stdgates.inc";qubit[2] _all_qubits;let q = _all_qubits[0:1];h q[0];cx q[0], q[1]; - failure: - value: - jobId: 7af020f6-2e38-4d70-8cf0-4349650ea08c - status: FAILURE - result: null - reason: Invalid device parameter in request - transpiledCode: null - cancel: - value: - jobId: 7af020f6-2e38-4d70-8cf0-4349650ea08c - status: CANCELLED - result: null - reason: User cancelled - transpiledCode: null - responses: - '200': - description: Results submitted - content: - application/json: - schema: - $ref: '#/components/schemas/results.CreateResultResponse' - example: - message: Results submitted - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/error.BadRequest' - example: - detail: Bad request malformed input data - '404': - description: Not Found - content: - application/json: - schema: - $ref: '#/components/schemas/error.NotFoundError' - example: - detail: JobID not found - '409': - description: Result for jobId already exists - content: - application/json: - schema: - $ref: '#/components/schemas/error.ConflictError' - example: - detail: Result for jobId already exists - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '#/components/schemas/error.InternalServerError' - example: - detail: Internal server error components: schemas: devices.DeviceStatusUpdate: @@ -565,179 +477,9 @@ components: - failed - cancelled example: submitted - jobs.JobId: - type: string - format: uuid - example: 7af020f6-2e38-4d70-8cf0-4349650ea08c - jobs.SamplingAction: - type: object - properties: - name: - type: string - pattern: sampling - example: sampling - nShots: - type: integer - minimum: 1 - maximum: 10000000 - example: '1000' - required: - - name - - nShots - jobs.SingleOperator: - type: array - items: - anyOf: - - type: string - description: Pauli string - example: X 0 Y 1 Z 5 I 2 - - type: array - description: Real and imaginary components of complex coef value - items: - type: number - minItems: 2 - maxItems: 2 - example: - - 1.5 - - 2.8 - minItems: 2 - maxItems: 2 - jobs.Operator: - type: array - items: - $ref: '#/components/schemas/jobs.SingleOperator' - example: - - - X 0 X 1 - - - 1.5 - - 2.8 - - - Y 0 Z 1 - - - 1.2 - - -2.e-8 - jobs.EstimationAction: - type: object - properties: - name: - type: string - pattern: estimation - example: estimation - method: - type: string - enum: - - state_vector - - sampling - example: sampling - description: state_vector method valid only for 'simulator' devices - nShots: - type: integer - minimum: 1 - maximum: 10000000 - example: '1000' - description: Parameter valid only for sampling method - operator: - $ref: '#/components/schemas/jobs.Operator' - required: - - name - - method - - operator - jobs.Action: - type: object - oneOf: - - $ref: '#/components/schemas/jobs.SamplingAction' - - $ref: '#/components/schemas/jobs.EstimationAction' jobs.JobInfo: - type: object - properties: - jobId: - $ref: '#/components/schemas/jobs.JobId' - code: - type: string - example: OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q; - device: - type: string - example: Kawasaki - nQubits: - type: integer - example: null - nNodes: - description: Parameter valid only for 'simulator' devices - type: integer - example: 12 - action: - $ref: '#/components/schemas/jobs.Action' - qubitAllocation: - description: Parameter valid only for QPU devices - type: object - additionalProperties: - type: integer - example: - '0': 12 - '1': 16 - skipTranspilation: - type: boolean - example: false - seedTranspilation: - description: Parameter valid only if skipTranspilation is false - type: integer - example: 873 - seedSimulation: - description: Parameter valid only for 'simulator' devices - type: integer - example: 39058567 - roErrorMitigation: - description: Parameter valid only for QPU devices - type: string - enum: - - none - - pseudo_inverse - - least_square - example: pseudo_inverse - nPerNode: - description: Parameter valid only for simulator devices - type: integer - minimum: 1 - example: 5 - simulationOpt: - description: Parameter valid only for simulator devices - type: object - example: - optimizationMethod: light - optimizationBlockSize: 1 - optimizationSwapLevel: 1 - status: - $ref: '#/components/schemas/jobs.InternalJobStatus' - createdAt: - type: string - format: date-time - example: '2022-10-19T11:45:34+09:00' - required: - - jobId - - code - - device - - action - - skipTranspilation - - status - - createdAt - example: - jobId: 7af020f6-2e38-4d70-8cf0-4349650ea08c - code: OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q; - device: Kawasaki - nQubits: null - nNodes: 12 - action: - name: sampling - nShots: 1000 - qubitAllocation: null - skipTranspilation: false - seedTranspilation: 873 - seedSimulation: 39058567 - roErrorMitigation: null - nPerNode: 2 - simulationOpt: - optimizationMethod: light - optimizationBlockSize: 1 - optimizationSwapLevel: 1 - status: QUEUED_FETCHED - createdAt: '2022-10-19T11:45:34+09:00' + type: string + example: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2'', ''result'': {''00'': 5020, ''11'': 4980}, ''transpiledCode'': '''', ''reason'': ''''}' jobs.JobStatusUpdate: type: object properties: @@ -761,85 +503,13 @@ components: - QUEUED - CANCELLING example: QUEUED + jobs.JobId: + type: string + format: uuid + example: 7af020f6-2e38-4d70-8cf0-4349650ea08c jobs.UnfetchedJobsResponse: type: array items: oneOf: - $ref: '#/components/schemas/jobs.JobInfo' - $ref: '#/components/schemas/jobs.JobId' - results.ResultStatus: - type: string - enum: - - SUCCESS - - FAILURE - - CANCELLED - default: SUCCESS - example: SUCCESS - results.SamplingResult: - type: object - additionalProperties: - type: integer - minProperties: 2 - example: - '11': 4980 - '00': 5020 - results.EstimationResult: - type: array - items: - type: number - minItems: 2 - maxItems: 2 - example: - - 1.5 - - 2.8 - results.Result: - oneOf: - - type: 'null' - - $ref: '#/components/schemas/results.SamplingResult' - - $ref: '#/components/schemas/results.EstimationResult' - results.ResultDef: - type: object - properties: - jobId: - $ref: '#/components/schemas/jobs.JobId' - status: - $ref: '#/components/schemas/results.ResultStatus' - result: - $ref: '#/components/schemas/results.Result' - reason: - type: string - nullable: true - transpiledCode: - type: string - nullable: true - qubitAllocation: - description: Parameter valid only for QPU devices - type: object - additionalProperties: - type: integer - nullable: true - example: - '0': 0 - '1': 4 - required: - - jobId - - status - - result - - reason - - transpiledCode - results.CreateResultResponse: - type: object - properties: - message: - type: string - required: - - message - example: - message: Results submitted - error.ConflictError: - type: object - properties: - detail: - type: string - required: - - detail diff --git a/backend/oas/provider/paths/results.yaml b/backend/oas/provider/paths/results.yaml deleted file mode 100644 index 0c35be2..0000000 --- a/backend/oas/provider/paths/results.yaml +++ /dev/null @@ -1,97 +0,0 @@ -results: - post: - summary: Submit a quantum job result - tags: - - results - description: Submit a quantum job result - operationId: postResult - security: [] - requestBody: - description: "Result to be submitted" - content: - application/json: - schema: - $ref: "../schemas/results.yaml#/results.ResultDef" - examples: - success sampling: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "SUCCESS", - "result": - { - "00": 5020, - "11": 4980 - }, - "reason": null, - "transpiledCode": "OPENQASM 3;include \"stdgates.inc\";qubit[2] _all_qubits;let q = _all_qubits[0:1];h q[0];cx q[0], q[1];" - } - success estimation: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "SUCCESS", - "result": [1.5, 2.8], - "reason": null, - "transpiledCode": "OPENQASM 3;include \"stdgates.inc\";qubit[2] _all_qubits;let q = _all_qubits[0:1];h q[0];cx q[0], q[1];" - } - failure: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "FAILURE", - "result": null, - "reason": "Invalid device parameter in request", - "transpiledCode": null - } - cancel: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "CANCELLED", - "result": null, - "reason": "User cancelled", - "transpiledCode": null - } - - responses: - '200': - description: Results submitted - content: - application/json: - schema: - $ref: '../schemas/results.yaml#/results.CreateResultResponse' - example: - message: Results submitted - '400': - description: Bad Request - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.BadRequest' - example: - detail: Bad request malformed input data - '404': - description: Not Found - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.NotFoundError' - example: - detail: JobID not found - "409": - description: "Result for jobId already exists" - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.ConflictError' - example: - detail: Result for jobId already exists - '500': - description: Internal Server Error - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.InternalServerError' - example: - detail: Internal server error diff --git a/backend/oas/provider/root.yaml b/backend/oas/provider/root.yaml index 7b180ba..ce61a3f 100644 --- a/backend/oas/provider/root.yaml +++ b/backend/oas/provider/root.yaml @@ -21,5 +21,3 @@ paths: $ref: ./paths/jobs.yaml#/jobs.jobId /jobs/unfetched: $ref: ./paths/jobs.yaml#/jobs.unfetched - /results: - $ref: ./paths/results.yaml#/results diff --git a/backend/oas/provider/schemas/jobs.yaml b/backend/oas/provider/schemas/jobs.yaml index c87808b..d923e8c 100644 --- a/backend/oas/provider/schemas/jobs.yaml +++ b/backend/oas/provider/schemas/jobs.yaml @@ -8,163 +8,75 @@ jobs.InternalJobStatus: enum: ["submitted", "ready", "running", "success", "failed", "cancelled"] example: "submitted" -jobs.Action: - type: object - oneOf: - - $ref: "#/jobs.SamplingAction" - - $ref: "#/jobs.EstimationAction" +jobs.JobInfo: + type: string + example: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2', 'result': {'00': 5020, '11': 4980}, 'transpiledCode': '', 'reason': ''}" -jobs.SamplingAction: - type: object - properties: - name: - type: string - pattern: "sampling" - example: "sampling" - nShots: - type: integer - minimum: 1 - maximum: 1e7 - example: "1000" - required: [ - name, nShots - ] +jobs.TranspilerInfo: + type: string + example: "{'qubitAllocation': {'0': 12, '1': 16}, 'skipTranspilation': false, 'seedTranspilation': 873}" + +jobs.SimulatorInfo: + type: string + example: "{'nQubits': 5, 'nNodes': 12, 'nPerNode': 2, 'seedSimulation': 39058567, 'simulationOpt': {'optimizationMethod': 'light', 'optimizationBlockSize': 1, 'optimizationSwapLevel': 1}}" -jobs.EstimationAction: +jobs.MitigationInfo: + type: string + example: "{'roErrorMitigation': 'pseudo_inverse'}" + +jobs.JobDef: type: object properties: - name: + jobId: + $ref: "#/jobs.JobId" + description: + type: string + example: "Bell State Sampling" + note: type: string - pattern: "estimation" - example: "estimation" - method: + example: "Bell State Sampling Example" + device: type: string - enum: ["state_vector", "sampling"] - example: "sampling" - description: "state_vector method valid only for 'simulator' devices" + example: "Kawasaki" nShots: type: integer minimum: 1 maximum: 1e7 example: "1000" - description: "Parameter valid only for sampling method" - operator: - $ref: "#/jobs.Operator" - required: [ - name, method, operator - ] - -jobs.Operator: - type: array - items: - $ref: "#/jobs.SingleOperator" - example: - [ - ["X 0 X 1", [1.5, 2.8]], - ["Y 0 Z 1", [1.2, -2e-8]], - ] - -jobs.SingleOperator: - type: array - items: - anyOf: - - type: string - description: "Pauli string" - example: "X 0 Y 1 Z 5 I 2" - - type: array - description: "Real and imaginary components of complex coef value" - items: - type: number - minItems: 2 - maxItems: 2 - example: [1.5, 2.8] - minItems: 2 - maxItems: 2 - -jobs.JobInfo: - type: object - properties: - jobId: - $ref: "#/jobs.JobId" - code: {type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"} - device: {type: string, example: "Kawasaki"} - nQubits: - type: integer - example: null - nNodes: - description: "Parameter valid only for 'simulator' devices" - type: integer - example: 12 - action: - $ref: "#/jobs.Action" - qubitAllocation: - description: "Parameter valid only for QPU devices" - type: object - additionalProperties: - type: integer - example: - "0": 12 - "1": 16 - skipTranspilation: - type: boolean - example: false - seedTranspilation: - description: "Parameter valid only if skipTranspilation is false" - type: integer - example: 873 - seedSimulation: - description: "Parameter valid only for 'simulator' devices" - type: integer - example: 39058567 - roErrorMitigation: - description: "Parameter valid only for QPU devices" + jobType: type: string - enum: ["none", "pseudo_inverse", "least_square"] - example: "pseudo_inverse" - nPerNode: - description: "Parameter valid only for simulator devices" - type: integer - minimum: 1 - example: 5 - simulationOpt: - description: "Parameter valid only for simulator devices" - type: object - example: { - optimizationMethod: "light", - optimizationBlockSize: 1, - optimizationSwapLevel: 1 - } + example: "'sampling' or 'estimation', 'sse'" + jobInfo: + $ref: "#/jobs.JobInfo" + transpilerInfo: + $ref: "#/jobs.TranspilerInfo" + simulatorInfo: + $ref: "#/jobs.SimulatorInfo" + mitigationInfo: + $ref: "#/jobs.MitigationInfo" status: - $ref: "#/jobs.InternalJobStatus" + $ref: "#/jobs.JobStatus" createdAt: type: string format: date-time example: "2022-10-19T11:45:34+09:00" required: [ - jobId, code, device, action, skipTranspilation, status, createdAt + device, nShots, status, createdAt ] example: - jobId: 7af020f6-2e38-4d70-8cf0-4349650ea08c - code: OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q; - device: Kawasaki - nQubits: null - nNodes: 12 - action: - name: sampling - nShots: 1000 - qubitAllocation: null - skipTranspilation: false - seedTranspilation: 873 - seedSimulation: 39058567 - roErrorMitigation: null - nPerNode: 2 - simulationOpt: { - optimizationMethod: "light", - optimizationBlockSize: 1, - optimizationSwapLevel: 1 + { + jobId: "7af020f6-2e38-4d70-8cf0-4349650ea08c", + description: "Bell State Sampling", + note: "Bell State Sampling Example", + device: "Kawasaki", + nShots: 1000, + jobInfo: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2'}", + transpilerInfo: "{'qubitAllocation': {'0': 12, '1': 16}, 'skipTranspilation': false, 'seedTranspilation': 873}", + simulatorInfo: "{'nQubits': 5, 'nNodes': 12, 'nPerNode': 2, 'seedSimulation': 39058567, 'simulationOpt': {'optimizationMethod': 'light', 'optimizationBlockSize': 1, 'optimizationSwapLevel': 1}}", + mitigationInfo: "{'roErrorMitigation': 'pseudo_inverse'}", + status: "submitted", + createdAt: "2022-10-19T11:45:34+09:00" } - status: QUEUED_FETCHED - createdAt: "2022-10-19T11:45:34+09:00" jobs.JobStatusUpdate: type: object diff --git a/backend/oas/provider/schemas/results.yaml b/backend/oas/provider/schemas/results.yaml deleted file mode 100644 index b927a56..0000000 --- a/backend/oas/provider/schemas/results.yaml +++ /dev/null @@ -1,66 +0,0 @@ -results.ResultDef: - type: object - properties: - jobId: - $ref: "jobs.yaml#/jobs.JobId" - status: - $ref: "#/results.ResultStatus" - result: - $ref: "#/results.Result" - reason: - type: string - nullable: true - transpiledCode: - type: string - nullable: true - qubitAllocation: - description: "Parameter valid only for QPU devices" - type: object - additionalProperties: - type: integer - nullable: true - example: - "0": 0 - "1": 4 - required: [ - jobId, status, result, reason, transpiledCode - ] - -results.ResultStatus: - type: string - enum: ["SUCCESS", "FAILURE", "CANCELLED"] - default: "SUCCESS" - example: "SUCCESS" - -results.Result: - oneOf: - - type: "null" - - $ref: "#/results.SamplingResult" - - $ref: "#/results.EstimationResult" - -results.SamplingResult: - type: object - additionalProperties: - type: integer - minProperties: 2 - example: - "11": 4980 - "00": 5020 - -results.EstimationResult: - type: array - items: - type: number - minItems: 2 - maxItems: 2 - example: [1.5, 2.8] - - -results.CreateResultResponse: - type: object - properties: - message: - type: string - required: [message] - example: - message: Results submitted diff --git a/backend/oas/user/openapi.yaml b/backend/oas/user/openapi.yaml index fde5ebc..259a8b8 100644 --- a/backend/oas/user/openapi.yaml +++ b/backend/oas/user/openapi.yaml @@ -129,7 +129,7 @@ paths: note: Bell State Sampling Example device: Kawasaki nShots: 1000 - jobInfo: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2''}' + jobInfo: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2'', ''result'': {''00'': 5020, ''11'': 4980}, ''transpiledCode'': '''', ''reason'': ''''}' transpilerInfo: '' simulatorInfo: '{''nQubits'': 5, ''nNodes'': 12, ''nPerNode'': 2, ''seedSimulation'': 39058567, ''simulationOpt'': {''optimizationMethod'': ''light'', ''optimizationBlockSize'': 1, ''optimizationSwapLevel'': 1}}' mitigationInfo: '' @@ -142,7 +142,7 @@ paths: note: Bell State Sampling Example device: Kawasaki nShots: 1000 - jobInfo: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2''}' + jobInfo: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2'', ''result'': {''00'': 5020, ''11'': 4980}, ''transpiledCode'': '''', ''reason'': ''''}' transpilerInfo: '{''qubitAllocation'': {''0'': 12, ''1'': 16}, ''skipTranspilation'': false, ''seedTranspilation'': 873}' simulatorInfo: '' mitigationInfo: '{''roErrorMitigation'': ''pseudo_inverse''}' @@ -597,7 +597,7 @@ components: - detail jobs.JobInfo: type: string - example: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2''}' + example: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2'', ''result'': {''00'': 5020, ''11'': 4980}, ''transpiledCode'': '''', ''reason'': ''''}' jobs.JobId: type: string format: uuid @@ -640,6 +640,9 @@ components: minimum: 1 maximum: 10000000 example: '1000' + jobType: + type: string + example: '''sampling'' or ''estimation'', ''sse''' jobInfo: $ref: '#/components/schemas/jobs.JobInfo' transpilerInfo: @@ -665,7 +668,7 @@ components: note: Bell State Sampling Example device: Kawasaki nShots: 1000 - jobInfo: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2''}' + jobInfo: '{''code'': ''{type: string, example: "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;"}'', ''Operator'': ''X 0 Y 1 Z 5 I 2'', ''result'': {''00'': 5020, ''11'': 4980}, ''transpiledCode'': '''', ''reason'': ''''}' transpilerInfo: '{''qubitAllocation'': {''0'': 12, ''1'': 16}, ''skipTranspilation'': false, ''seedTranspilation'': 873}' simulatorInfo: '{''nQubits'': 5, ''nNodes'': 12, ''nPerNode'': 2, ''seedSimulation'': 39058567, ''simulationOpt'': {''optimizationMethod'': ''light'', ''optimizationBlockSize'': 1, ''optimizationSwapLevel'': 1}}' mitigationInfo: '{''roErrorMitigation'': ''pseudo_inverse''}' diff --git a/backend/oas/user/paths/jobs.yaml b/backend/oas/user/paths/jobs.yaml index b03111d..873f655 100644 --- a/backend/oas/user/paths/jobs.yaml +++ b/backend/oas/user/paths/jobs.yaml @@ -47,7 +47,7 @@ jobs: note: "Bell State Sampling Example", device: "Kawasaki", nShots: 1000, - jobInfo: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2'}", + jobInfo: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2', 'result': {'00': 5020, '11': 4980}, 'transpiledCode': '', 'reason': ''}", transpilerInfo: "", simulatorInfo: "{'nQubits': 5, 'nNodes': 12, 'nPerNode': 2, 'seedSimulation': 39058567, 'simulationOpt': {'optimizationMethod': 'light', 'optimizationBlockSize': 1, 'optimizationSwapLevel': 1}}", mitigationInfo: "", @@ -62,7 +62,7 @@ jobs: note: "Bell State Sampling Example", device: "Kawasaki", nShots: 1000, - jobInfo: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2'}", + jobInfo: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2', 'result': {'00': 5020, '11': 4980}, 'transpiledCode': '', 'reason': ''}", transpilerInfo: "{'qubitAllocation': {'0': 12, '1': 16}, 'skipTranspilation': false, 'seedTranspilation': 873}", simulatorInfo: "", mitigationInfo: "{'roErrorMitigation': 'pseudo_inverse'}", diff --git a/backend/oas/user/paths/results.yaml b/backend/oas/user/paths/results.yaml deleted file mode 100644 index 93fe94c..0000000 --- a/backend/oas/user/paths/results.yaml +++ /dev/null @@ -1,143 +0,0 @@ -results.sampling.jobId: - get: - tags: - - result - summary: "Get result of a sampling job" - description: "Gets a result of quantum job.

Any finished quantum job must generate a result. The result contains either simulation result (for successfully completed jobs) or reason why simulation outcome is not provided (for unsuccessful and cancelled jobs)

Operation is valid only for COMPLETED, FAILED and CANCELLED jobs" - operationId: getSamplingResult - security: - - BearerAuth: [] - parameters: - - in: path - name: jobId - required: true - description: "Job identifier" - schema: {type: string} - responses: - "200": - description: "Return quantum job result" - content: - application/json: - schema: - $ref: "../schemas/results.yaml#/results.SamplingResultDef" - examples: - success sampling: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "SUCCESS", - "result": - { - "00": 5020, - "11": 4980 - }, - "transpiledCode": "OPENQASM 3;include \"stdgates.inc\";qubit[2] _all_qubits;let q = _all_qubits[0:1];h q[0];cx q[0], q[1];" - } - failure: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "FAILURE", - "reason": "Invalid device parameter in request" - } - cancel: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "CANCELLED", - "reason": "User cancelled" - } - "400": - description: Bad Request - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.BadRequest' - example: - detail: Bad request malformed input data - "401": - description: Unauthorized - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.UnauthorizedError' - example: - detail: Unauthorized - '404': - description: Not Found - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.NotFoundError' - example: - detail: job not found - -results.estimation.jobId: - get: - tags: - - result - summary: "Get result of estimation job" - description: "Gets a result of quantum job.

Any finished quantum job must generate a result. The result contains either simulation result (for successfully completed jobs) or reason why simulation outcome is not provided (for unsuccessful and cancelled jobs)

Operation is valid only for COMPLETED, FAILED and CANCELLED jobs" - operationId: getEstimationResult - security: - - BearerAuth: [] - parameters: - - in: path - name: jobId - required: true - description: "Job identifier" - schema: {type: string} - responses: - "200": - description: "Return quantum job result" - content: - application/json: - schema: - $ref: "../schemas/results.yaml#/results.EstimationResultDef" - examples: - success estimation: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "SUCCESS", - "result": [1.5, 2.8], - "transpiledCode": "OPENQASM 3;include \"stdgates.inc\";qubit[2] _all_qubits;let q = _all_qubits[0:1];h q[0];cx q[0], q[1];" - } - failure: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "FAILURE", - "reason": "Invalid device parameter in request" - } - cancel: - value: - { - "jobId": "7af020f6-2e38-4d70-8cf0-4349650ea08c", - "status": "CANCELLED", - "reason": "User cancelled" - } - "400": - description: Bad Request - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.BadRequest' - example: - detail: Bad request malformed input data - "401": - description: Unauthorized - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.UnauthorizedError' - example: - detail: Unauthorized - '404': - description: Not Found - content: - application/json: - schema: - $ref: '../schemas/error.yaml#/error.NotFoundError' - example: - detail: job not found diff --git a/backend/oas/user/schemas/jobs.yaml b/backend/oas/user/schemas/jobs.yaml index 609e6d9..3150ee1 100644 --- a/backend/oas/user/schemas/jobs.yaml +++ b/backend/oas/user/schemas/jobs.yaml @@ -31,7 +31,7 @@ jobs.JobStatus: jobs.JobInfo: type: string - example: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2'}" + example: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2', 'result': {'00': 5020, '11': 4980}, 'transpiledCode': '', 'reason': ''}" jobs.TranspilerInfo: type: string @@ -64,6 +64,9 @@ jobs.JobDef: minimum: 1 maximum: 1e7 example: "1000" + jobType: + type: string + example: "'sampling' or 'estimation', 'sse'" jobInfo: $ref: "#/jobs.JobInfo" transpilerInfo: @@ -88,7 +91,7 @@ jobs.JobDef: note: "Bell State Sampling Example", device: "Kawasaki", nShots: 1000, - jobInfo: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2'}", + jobInfo: "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2', 'result': {'00': 5020, '11': 4980}, 'transpiledCode': '', 'reason': ''}", transpilerInfo: "{'qubitAllocation': {'0': 12, '1': 16}, 'skipTranspilation': false, 'seedTranspilation': 873}", simulatorInfo: "{'nQubits': 5, 'nNodes': 12, 'nPerNode': 2, 'seedSimulation': 39058567, 'simulationOpt': {'optimizationMethod': 'light', 'optimizationBlockSize': 1, 'optimizationSwapLevel': 1}}", mitigationInfo: "{'roErrorMitigation': 'pseudo_inverse'}", diff --git a/backend/oas/user/schemas/results.yaml b/backend/oas/user/schemas/results.yaml deleted file mode 100644 index d47672e..0000000 --- a/backend/oas/user/schemas/results.yaml +++ /dev/null @@ -1,73 +0,0 @@ -results.SamplingResultDef: - type: object - properties: - jobId: - $ref: "jobs.yaml#/jobs.JobId" - status: - $ref: "#/results.ResultStatus" - result: - description: "Provided only for successful results" - type: object - additionalProperties: - type: integer - minProperties: 2 - example: - "11": 4980 - "00": 5020 - reason: - description: "Provided only for unsuccessful (failed, cancelled) results" - type: string - transpiledCode: - description: "Provided only for jobs with transpilation (jobs created with skipTranspilation=False), if traspilation was successfull" - type: string - qubitAllocation: - description: "Parameter valid only for QPU devices" - type: object - additionalProperties: - type: integer - example: - "0": 0 - "1": 4 - required: [ - jobId, status - ] - -results.ResultStatus: - type: string - enum: ["SUCCESS", "FAILURE", "CANCELLED"] - default: "SUCCESS" - example: "SUCCESS" - - -results.EstimationResultDef: - type: object - properties: - jobId: - $ref: "jobs.yaml#/jobs.JobId" - status: - $ref: "#/results.ResultStatus" - result: - description: "Real and imaginary components of complex estimation result value
Provided only for successful results" - type: array - items: - type: number - minItems: 1 - maxItems: 2 - example: [1.5, 2.8] - reason: - description: "Provided only for unsuccessful (failed, cancelled) results" - type: string - transpiledCode: - description: "Provided only for jobs with transpilation (jobs created with skipTranspilation=False), if traspilation was successfull" - type: string - qubitAllocation: - description: "Parameter valid only for QPU devices" - type: object - additionalProperties: - type: integer - example: - "0": 0 - "1": 4 - required: [ - jobId, status - ] diff --git a/backend/oqtopus_cloud/provider/schemas/__init__.py b/backend/oqtopus_cloud/provider/schemas/__init__.py index 1ac8cc9..1c41958 100644 --- a/backend/oqtopus_cloud/provider/schemas/__init__.py +++ b/backend/oqtopus_cloud/provider/schemas/__init__.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T06:40:46+00:00 +# timestamp: 2024-10-10T00:36:24+00:00 # version: 0.25.9 from __future__ import annotations diff --git a/backend/oqtopus_cloud/provider/schemas/devices.py b/backend/oqtopus_cloud/provider/schemas/devices.py index 28c4b4d..cba0bd8 100644 --- a/backend/oqtopus_cloud/provider/schemas/devices.py +++ b/backend/oqtopus_cloud/provider/schemas/devices.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T06:40:46+00:00 +# timestamp: 2024-10-10T00:36:24+00:00 # version: 0.25.9 from __future__ import annotations diff --git a/backend/oqtopus_cloud/provider/schemas/error.py b/backend/oqtopus_cloud/provider/schemas/error.py index 0702565..ff64804 100644 --- a/backend/oqtopus_cloud/provider/schemas/error.py +++ b/backend/oqtopus_cloud/provider/schemas/error.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T06:40:46+00:00 +# timestamp: 2024-10-10T00:36:24+00:00 # version: 0.25.9 from __future__ import annotations @@ -18,7 +18,3 @@ class NotFoundError(BaseModel): class InternalServerError(BaseModel): detail: str - - -class ConflictError(BaseModel): - detail: str diff --git a/backend/oqtopus_cloud/provider/schemas/jobs.py b/backend/oqtopus_cloud/provider/schemas/jobs.py index d99ba4f..15bf638 100644 --- a/backend/oqtopus_cloud/provider/schemas/jobs.py +++ b/backend/oqtopus_cloud/provider/schemas/jobs.py @@ -1,14 +1,14 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T06:40:46+00:00 +# timestamp: 2024-10-10T00:36:24+00:00 # version: 0.25.9 from __future__ import annotations -from typing import Annotated, Any, Literal, Optional, Union +from typing import Annotated, Literal, Union from uuid import UUID -from pydantic import AwareDatetime, BaseModel, Field, RootModel +from pydantic import BaseModel, Field, RootModel class InternalJobStatus( @@ -22,113 +22,15 @@ class InternalJobStatus( ] -class JobId(RootModel[UUID]): - root: Annotated[UUID, Field(examples=["7af020f6-2e38-4d70-8cf0-4349650ea08c"])] - - -class SamplingAction(BaseModel): - name: Annotated[str, Field(examples=["sampling"], pattern="sampling")] - nShots: Annotated[int, Field(examples=["1000"], ge=1, le=10000000)] - - -class SingleOperator(RootModel[list[float]]): +class JobInfo(RootModel[str]): root: Annotated[ - list[float], Field(examples=[[1.5, 2.8]], max_length=2, min_length=2) - ] - """ - Real and imaginary components of complex coef value - """ - - -class SingleOperatorModel(RootModel[list[Union[str, SingleOperator]]]): - root: Annotated[list[Union[str, SingleOperator]], Field(max_length=2, min_length=2)] - - -class Operator(RootModel[list[SingleOperatorModel]]): - root: Annotated[ - list[SingleOperatorModel], - Field(examples=[[["X 0 X 1", [1.5, 2.8]], ["Y 0 Z 1", [1.2, -2e-08]]]]), - ] - - -class EstimationAction(BaseModel): - name: Annotated[str, Field(examples=["estimation"], pattern="estimation")] - method: Annotated[Literal["state_vector", "sampling"], Field(examples=["sampling"])] - """ - state_vector method valid only for 'simulator' devices - """ - nShots: Annotated[Optional[int], Field(None, examples=["1000"], ge=1, le=10000000)] - """ - Parameter valid only for sampling method - """ - operator: Operator - - -class Action(RootModel[Union[SamplingAction, EstimationAction]]): - root: Union[SamplingAction, EstimationAction] - - -class JobInfo(BaseModel): - jobId: JobId - code: Annotated[ str, Field( examples=[ - "OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;" + "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2', 'result': {'00': 5020, '11': 4980}, 'transpiledCode': '', 'reason': ''}" ] ), ] - device: Annotated[str, Field(examples=["Kawasaki"])] - nQubits: Annotated[Optional[int], Field(None, examples=[None])] - nNodes: Annotated[Optional[int], Field(None, examples=[12])] - """ - Parameter valid only for 'simulator' devices - """ - action: Action - qubitAllocation: Annotated[ - Optional[dict[str, int]], Field(None, examples=[{"0": 12, "1": 16}]) - ] - """ - Parameter valid only for QPU devices - """ - skipTranspilation: Annotated[bool, Field(examples=[False])] - seedTranspilation: Annotated[Optional[int], Field(None, examples=[873])] - """ - Parameter valid only if skipTranspilation is false - """ - seedSimulation: Annotated[Optional[int], Field(None, examples=[39058567])] - """ - Parameter valid only for 'simulator' devices - """ - roErrorMitigation: Annotated[ - Optional[Literal["none", "pseudo_inverse", "least_square"]], - Field(None, examples=["pseudo_inverse"]), - ] - """ - Parameter valid only for QPU devices - """ - nPerNode: Annotated[Optional[int], Field(None, examples=[5], ge=1)] - """ - Parameter valid only for simulator devices - """ - simulationOpt: Annotated[ - Optional[dict[str, Any]], - Field( - None, - examples=[ - { - "optimizationMethod": "light", - "optimizationBlockSize": 1, - "optimizationSwapLevel": 1, - } - ], - ), - ] - """ - Parameter valid only for simulator devices - """ - status: InternalJobStatus - createdAt: Annotated[AwareDatetime, Field(examples=["2022-10-19T11:45:34+09:00"])] class JobStatusUpdate(BaseModel): @@ -143,5 +45,9 @@ class InternalFetchableJobStatus(RootModel[Literal["QUEUED", "CANCELLING"]]): root: Annotated[Literal["QUEUED", "CANCELLING"], Field(examples=["QUEUED"])] +class JobId(RootModel[UUID]): + root: Annotated[UUID, Field(examples=["7af020f6-2e38-4d70-8cf0-4349650ea08c"])] + + class UnfetchedJobsResponse(RootModel[list[Union[JobInfo, JobId]]]): root: list[Union[JobInfo, JobId]] diff --git a/backend/oqtopus_cloud/user/schemas/__init__.py b/backend/oqtopus_cloud/user/schemas/__init__.py index 2d76a0e..499ce1b 100644 --- a/backend/oqtopus_cloud/user/schemas/__init__.py +++ b/backend/oqtopus_cloud/user/schemas/__init__.py @@ -1,4 +1,4 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T08:20:49+00:00 +# timestamp: 2024-10-10T00:36:17+00:00 # version: 0.25.9 diff --git a/backend/oqtopus_cloud/user/schemas/devices.py b/backend/oqtopus_cloud/user/schemas/devices.py index 5722c34..c3fa8c6 100644 --- a/backend/oqtopus_cloud/user/schemas/devices.py +++ b/backend/oqtopus_cloud/user/schemas/devices.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T08:20:49+00:00 +# timestamp: 2024-10-10T00:36:17+00:00 # version: 0.25.9 from __future__ import annotations diff --git a/backend/oqtopus_cloud/user/schemas/error.py b/backend/oqtopus_cloud/user/schemas/error.py index 2e672e5..6907fa4 100644 --- a/backend/oqtopus_cloud/user/schemas/error.py +++ b/backend/oqtopus_cloud/user/schemas/error.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T08:20:49+00:00 +# timestamp: 2024-10-10T00:36:17+00:00 # version: 0.25.9 from __future__ import annotations diff --git a/backend/oqtopus_cloud/user/schemas/jobs.py b/backend/oqtopus_cloud/user/schemas/jobs.py index ea6b821..8762bef 100644 --- a/backend/oqtopus_cloud/user/schemas/jobs.py +++ b/backend/oqtopus_cloud/user/schemas/jobs.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T08:20:49+00:00 +# timestamp: 2024-10-10T00:36:17+00:00 # version: 0.25.9 from __future__ import annotations @@ -16,7 +16,7 @@ class JobInfo(RootModel[str]): str, Field( examples=[ - "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2'}" + "{'code': '{type: string, example: \"OPENQASM 3; qubit[2] q; bit[2] c; h q[0]; cnot q[0], q[1]; c = measure q;\"}', 'Operator': 'X 0 Y 1 Z 5 I 2', 'result': {'00': 5020, '11': 4980}, 'transpiledCode': '', 'reason': ''}" ] ), ] @@ -71,6 +71,9 @@ class JobDef(BaseModel): ] device: Annotated[str, Field(examples=["Kawasaki"])] nShots: Annotated[int, Field(examples=["1000"], ge=1, le=10000000)] + jobType: Annotated[ + Optional[str], Field(None, examples=["'sampling' or 'estimation', 'sse'"]) + ] jobInfo: Optional[JobInfo] = None transpilerInfo: Optional[TranspilerInfo] = None simulatorInfo: Optional[SimulatorInfo] = None diff --git a/backend/oqtopus_cloud/user/schemas/success.py b/backend/oqtopus_cloud/user/schemas/success.py index 21789a1..f4253fb 100644 --- a/backend/oqtopus_cloud/user/schemas/success.py +++ b/backend/oqtopus_cloud/user/schemas/success.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2024-10-09T08:20:49+00:00 +# timestamp: 2024-10-10T00:36:17+00:00 # version: 0.25.9 from __future__ import annotations