Skip to content

Commit

Permalink
add qrms required by tests to project
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Aug 30, 2023
1 parent 68d35c1 commit 6a9317a
Show file tree
Hide file tree
Showing 22 changed files with 1,579 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/bpmn-q/test/tests/quantme/qrms/cutting/detector.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:quantme="https://github.com/UST-QuAntiL/QuantME-Quantum4BPMN" id="Definitions_1liu029" targetNamespace="http://bpmn.io/schema/bpmn" exporter="QuantME Modeler" exporterVersion="4.4.0">
<bpmn:process id="Process_0xzm0yb" isExecutable="true">
<quantme:CircuitCuttingSubprocess id="Task_0bpgwfl" cuttingMethod="qiskit" maxSubCircuitWidth="*" maxNumberOfCuts="*" maxNumSubCircuits="*" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0rzm0yb">
<bpmndi:BPMNShape id="QuantumHardwareSelectionSubprocess_05r5mhz_di" bpmnElement="Task_0fw4ne6">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
133 changes: 133 additions & 0 deletions components/bpmn-q/test/tests/quantme/qrms/cutting/replacement.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_00v8ddm" targetNamespace="http://bpmn.io/schema/bpmn" exporter="QuantME Modeler" exporterVersion="4.5.0-nightly.20221215">
<bpmn:process id="Process_0frghgx" isExecutable="true">
<bpmn:sequenceFlow id="SequenceFlow_1h1q60o" sourceRef="Task_14ryfsm" targetRef="Task_1ffvrj7" />
<bpmn:serviceTask id="Task_1ffvrj7" name="Combine Results" camunda:asyncAfter="true" camunda:exclusive="false">
<bpmn:incoming>SequenceFlow_1h1q60o</bpmn:incoming>
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="Accept">application/json</camunda:entry>
<camunda:entry key="Content-Type">application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="url">http://quokka-gateway:6474/quokka/circuit-cutting/combineResultsQuokka</camunda:inputParameter>
<camunda:inputParameter name="payload">
<camunda:script scriptFormat="groovy">import groovy.json.JsonBuilder
println("Combining circuits");
def counts = execution.getVariable("counts");
println("Counts: " + counts.toString());
def cuttingMetaData = execution.getVariable("cuttingMetaData");
println("CuttingMetaData: " + cuttingMetaData.toString());
def circuit = execution.getVariable("circuit")[0];

def request = [:];
request.put("circuit", circuit);
request.put("subcircuit_results", counts);
request.put("cuts", cuttingMetaData);
request.put("unnormalized_results", "True");
request.put("shot_scaling_factor", 1000);
request.put("circuit_format", "qiskit");
requeststring = new JsonBuilder(request).toPrettyString()
println(requeststring);
return requeststring;</camunda:script>
</camunda:inputParameter>
<camunda:outputParameter name="counts">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp);
println("Response with counts: " + resp.toString());
def result = [resp.get("result")];
println("Final result: " + result.toString());
return result;</camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
</bpmn:serviceTask>
<bpmn:serviceTask id="Task_14ryfsm" name="Cut Circuits" camunda:asyncAfter="true" camunda:exclusive="false">
<bpmn:outgoing>SequenceFlow_1h1q60o</bpmn:outgoing>
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="Accept">application/json</camunda:entry>
<camunda:entry key="Content-Type">application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="url">http://quokka-gateway:6474/quokka/circuit-cutting/cutCircuits</camunda:inputParameter>
<camunda:inputParameter name="payload">
<camunda:script scriptFormat="groovy">import groovy.json.JsonBuilder
println("Cutting circuits");
def circuit = execution.getVariable("circuit")[0];
def cuttingMethod = execution.getVariable("cuttingMethod");
def maxSubCircuitWidth = execution.getVariable("maxSubCircuitWidth");
if (maxSubCircuitWidth == null) {
maxSubCircuitWidth = 2;
}
maxSubCircuitWidth = maxSubCircuitWidth.toInteger();
def maxNumberOfCuts = execution.getVariable("maxNumberOfCuts");
if (maxNumberOfCuts == null) {
maxNumberOfCuts = 2;
}
maxNumberOfCuts = maxNumberOfCuts.toInteger();
def maxNumSubCircuits = execution.getVariable("maxNumSubCircuits");
if (maxNumSubCircuits == null) {
maxNumSubCircuits = 2;
}
maxNumSubCircuits = maxNumSubCircuits.toInteger();
println("Building request...");

def request = [:];
request.put("circuit", circuit);
request.put("method", "automatic");
request.put("max_subcircuit_width", maxSubCircuitWidth);
request.put("max_cuts", maxNumberOfCuts);
request.put("max_num_subcircuits", maxNumSubCircuits);
request.put("circuit_format", "qiskit");
requeststring = new JsonBuilder(request).toPrettyString()
println(requeststring);
return requeststring;</camunda:script>
</camunda:inputParameter>
<camunda:outputParameter name="cuttingMetaData">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp)
println("Response with cuttingMetaData: " + resp.toString());
return resp;</camunda:script>
</camunda:outputParameter>
<camunda:outputParameter name="subCircuits">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp)
println("Response with subCircuits: " + resp.toString());
def result = [:];
result.put("subCircuits", resp.get("individual_subcircuits"));
println("Final result: " + result.toString());
return result;</camunda:script>
</camunda:outputParameter>

</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0frghgx">
<bpmndi:BPMNEdge id="SequenceFlow_1h1q60o_di" bpmnElement="SequenceFlow_1h1q60o">
<di:waypoint x="260" y="120" />
<di:waypoint x="320" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_05zk3jf_di" bpmnElement="Task_1ffvrj7">
<dc:Bounds x="320" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_0338onn_di" bpmnElement="Task_14ryfsm">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:quantme="https://github.com/UST-QuAntiL/QuantME-Quantum4BPMN" id="Definitions_1roy9h8" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.3.0-nightly.20200911">
<bpmn:process id="Process_03e1olx" isExecutable="true">
<quantme:quantumCircuitExecutionTask id="Task_0z5udr0" provider="ibm" qpu="*" shots="*" programmingLanguage="openqasm" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03e1olx">
<bpmndi:BPMNShape id="QuantumCircuitExecutionTask_02ujkz1_di" bpmnElement="Task_0z5udr0">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0b7il2s" targetNamespace="http://bpmn.io/schema/bpmn" exporter="QuantME Modeler" exporterVersion="4.5.0-nightly.20220628">
<bpmn:process id="Process_03tgi13" isExecutable="true">
<bpmn:serviceTask id="ServiceTask_1d6l6i7" name="Execute Circuit" camunda:asyncAfter="true" camunda:exclusive="false">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="Accept">application/json</camunda:entry>
<camunda:entry key="Content-Type">application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="url">http://quokka-gateway:6474/quokka/circuit-execution/execution-service</camunda:inputParameter>
<camunda:inputParameter name="payload">
<camunda:script scriptFormat="groovy">
import groovy.json.JsonBuilder
def qpu = execution.getVariable("qpu");
def circuit = execution.getVariable("circuit");
def token = execution.getVariable("token");
def gammas = execution.getVariable("gammas");
def betas = execution.getVariable("betas");
def optimizedParameters = execution.getVariable("optimizedParameters");
def credentials = [:];
credentials.put("token", token);
credentials.put("hub", "ibm-q");
credentials.put("group", "open")
credentials.put("project", "main");
credentials.put("url", "https://auth.quantum-computing.ibm.com/api");
def request = [:];
request.put("qpu", qpu);
request.put("credentials", credentials)
request.put("shots", 2000);
request.put("circuit", circuit);
request.put("circuit_format", "openqasm");
request.put("provider", "ibm");

requeststring = new JsonBuilder(request).toPrettyString()
println(requeststring);
return requeststring;</camunda:script>
</camunda:inputParameter>
<camunda:outputParameter name="counts">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp);
println(resp);
counts_array= [];
for (el in resp){
println(el);
counts_array.push(el.get('counts'));
}
println(counts_array);
counts_array;</camunda:script>
</camunda:outputParameter>
<camunda:outputParameter name="measQubits">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp);
println(resp);
meas_qubits_array = [];
for (el in resp){
meas_qubits_array.push(el.get('meas_qubits'));
}
println(meas_qubits_array);
return meas_qubits_array;</camunda:script>
</camunda:outputParameter>
<camunda:outputParameter name="circuitDepthTranspiled">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp)
println(resp);
transpiled_circuit_depth_array = [];
for (el in resp){
println(el);
transpiled_circuit_depth_array.push(el.get('transpiled_circuit_depth'));
}
println(transpiled_circuit_depth_array);
return transpiled_circuit_depth_array;</camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03tgi13">
<bpmndi:BPMNShape id="ServiceTask_1d6l6i7_di" bpmnElement="ServiceTask_1d6l6i7">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:quantme="https://github.com/UST-QuAntiL/QuantME-Quantum4BPMN" id="Definitions_1roy9h8" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.3.0-nightly.20200911">
<bpmn:process id="Process_03e1olx" isExecutable="true">
<quantme:quantumCircuitExecutionTask id="Task_0z5udr0" provider="ibm" qpu="*" shots="*" programmingLanguage="qiskit" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03e1olx">
<bpmndi:BPMNShape id="QuantumCircuitExecutionTask_02ujkz1_di" bpmnElement="Task_0z5udr0">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_0b7il2s" targetNamespace="http://bpmn.io/schema/bpmn" exporter="QuantME Modeler" exporterVersion="4.5.0-nightly.20220628">
<bpmn:process id="Process_03tgi13" isExecutable="true">
<bpmn:serviceTask id="ServiceTask_1d6l6i7" name="Execute Circuit" camunda:asyncAfter="true" camunda:exclusive="false">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="Accept">application/json</camunda:entry>
<camunda:entry key="Content-Type">application/json</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="url">http://quokka-gateway:6474/quokka/circuit-execution/execution-service</camunda:inputParameter>
<camunda:inputParameter name="payload">
<camunda:script scriptFormat="groovy">
import groovy.json.JsonBuilder
def qpu = execution.getVariable("qpu");
def circuit = execution.getVariable("circuit");
def token = execution.getVariable("token");
def gammas = execution.getVariable("gammas");
def betas = execution.getVariable("betas");
def optimizedParameters = execution.getVariable("optimizedParameters");
def subCircuits = execution.getVariable("subCircuits");
if (subCircuits != null) {
println("Subcircuits: " + subCircuits.toString());
circuit = subCircuits.get("subCircuits");
println("Circuits after adding subcircuits: " + circuit.toString());
}
def credentials = [:];
credentials.put("token", token);
credentials.put("hub", "ibm-q");
credentials.put("group", "open")
credentials.put("project", "main");
credentials.put("url", "https://auth.quantum-computing.ibm.com/api");
def request = [:];
request.put("qpu", qpu);
request.put("credentials", credentials)
request.put("shots", 2000);
request.put("circuit", circuit);
request.put("circuit_format", "qiskit");
request.put("provider", "ibm");
if (optimizedParameters == null){

if (betas instanceof String) {
println("Parsing betas...");
betas = betas.drop(1).take(betas.length()-2).split(",");
execution.setVariable("betas", betas);
}

if (gammas instanceof String) {
println("Parsing gammas...");
gammas = gammas.drop(1).take(gammas.length()-2).split(",");
execution.setVariable("gammas", gammas);
}

optimizedParameters = betas + gammas;
} else {
param_array=[];
println(optimizedParameters);
optimizedParameters=optimizedParameters.drop(1).take(optimizedParameters.length()-2);
println(optimizedParameters);
optimizedParameters= optimizedParameters.replaceAll("\\s","").split(",");
println(optimizedParameters);
optimizedParameters.each{ param->
param_array.push(param.toDouble());}
optimizedParameters=param_array;
}
request.put("parameters", optimizedParameters);
requeststring = new JsonBuilder(request).toPrettyString()
println(requeststring);
return requeststring;</camunda:script>
</camunda:inputParameter>
<camunda:outputParameter name="counts">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp);
println(resp);
counts_array= [];
for (el in resp){
println(el);
counts_array.push(el.get('counts'));
}
println(counts_array);
counts_array;</camunda:script>
</camunda:outputParameter>
<camunda:outputParameter name="measQubits">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp);
println(resp);
meas_qubits_array = [];
for (el in resp){
meas_qubits_array.push(el.get('meas_qubits'));
}
println(meas_qubits_array);
return meas_qubits_array;</camunda:script>
</camunda:outputParameter>
<camunda:outputParameter name="circuitDepthTranspiled">
<camunda:script scriptFormat="groovy">def resp = connector.getVariable("response");
resp = new groovy.json.JsonSlurperClassic().parseText(resp)
println(resp);
transpiled_circuit_depth_array = [];
for (el in resp){
println(el);
transpiled_circuit_depth_array.push(el.get('transpiled_circuit_depth'));
}
println(transpiled_circuit_depth_array);
return transpiled_circuit_depth_array;</camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_03tgi13">
<bpmndi:BPMNShape id="ServiceTask_1d6l6i7_di" bpmnElement="ServiceTask_1d6l6i7">
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Loading

0 comments on commit 6a9317a

Please sign in to comment.