Skip to content

Commit

Permalink
fix for runtime pattern combination
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Jul 31, 2024
1 parent 5170ed2 commit f8df392
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export async function startPatternReplacementProcess(xml) {
);
console.log(`Time taken for step C: ${Date.now() - startTime}ms`);
containedPatterns = getPatterns(rootElement, elementRegistry);
console.log(containedPatterns);

console.log("Begin of step E:");
startTime = Date.now();
Expand Down Expand Up @@ -294,6 +295,8 @@ export async function startPatternReplacementProcess(xml) {
replacementSuccess = true;
}
replacementSuccess = true;
optimizationCandidates = await findOptimizationCandidates(modeler);
console.log("optimization candidates: ", optimizationCandidates)
}
if (replacementConstruct.task.$type === constants.PRE_DEPLOYED_EXECUTION) {
console.log("Replace pre-deployed execution");
Expand Down Expand Up @@ -361,6 +364,8 @@ export async function startPatternReplacementProcess(xml) {
patterns.push(pattern);
replacementSuccess = true;
}
optimizationCandidates = await findOptimizationCandidates(modeler);
console.log("optimization candidates: ", optimizationCandidates);
}
if (replacementConstruct.task.$type === constants.PRIORITIZED_EXECUTION) {
console.log("Replace prioritized execution");
Expand Down Expand Up @@ -413,9 +418,12 @@ export async function startPatternReplacementProcess(xml) {
}
if (!foundOptimizationCandidate) {
const pattern = elementRegistry.get(replacementConstruct.task.id);
console.log("no optimization candidate found", pattern);
patterns.push(pattern);
replacementSuccess = true;
}
optimizationCandidates = await findOptimizationCandidates(modeler);
console.log("optimization candidates: ", optimizationCandidates);
}

if (!replacementSuccess) {
Expand All @@ -438,7 +446,24 @@ export async function startPatternReplacementProcess(xml) {

elementsToDelete = patterns.concat(allFlow);
console.log(elementsToDelete);
modeling.removeElements(elementsToDelete);

// remove duplicate patterns from elementsToDelete
let elementsToDeleteNoDuplicates = [];
for (let i = 0; i < elementsToDelete.length; i++){
let contains = false;
for (let j = 0; j < elementsToDeleteNoDuplicates.length; j++){
if (elementsToDeleteNoDuplicates[j].id === elementsToDelete[i].id ) {
contains = true;
}
}
if (!contains && elementsToDelete[i].parent !== null){
elementsToDeleteNoDuplicates.push(elementsToDelete[i]);
}
}

console.log("remove elements: ");
console.log(elementsToDeleteNoDuplicates);
modeling.removeElements(elementsToDeleteNoDuplicates);
console.log(`Time taken for step F: ${Date.now() - startTime}ms`);

// layout diagram after successful transformation
Expand Down Expand Up @@ -545,7 +570,7 @@ export function attachPatternsToSuitableTasks(
);
}
});

console.log(children);
children.forEach((id) => {
attachPatternsToSuitableConstruct(
elementRegistry.get(id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export async function rewriteWorkflow(
}

// update the graphical visualization in the modeler
await refreshModeler(modeler);
// TODO: might destroy manual runtime rewrite
// await refreshModeler(modeler);
return { result: "success" };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function getQiskitRuntimeProgramDeploymentModel(
);
for (let i = 0; i < quantumCircuitExecutionTasks.length; i++) {
if (
quantumCircuitExecutionTasks[i].provider.toUpperCase().includes("IBM")
!quantumCircuitExecutionTasks[i].provider.toUpperCase().includes("IBM")
) {
console.log(
"Found QuantumCircuitExecutionTask with provider different than IBM: ",
Expand Down

0 comments on commit f8df392

Please sign in to comment.