Skip to content

Commit

Permalink
initial commit for advanced nisq analyzer selection
Browse files Browse the repository at this point in the history
  • Loading branch information
salmma committed Jul 11, 2024
1 parent a0d3cae commit 75fd156
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 141 deletions.
26 changes: 4 additions & 22 deletions generated/api-nisq/models/analysis-result-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,11 @@
import { ImplementationDto } from './implementation-dto';
import { Links } from './links';
export type AnalysisResultDto = {
id?: string;
provider?: string;
qpu?: string;
compiler?: string;
analyzedDepth?: number;
analyzedWidth?: number;
analyzedTotalNumberOfOperations?: number;
analyzedNumberOfSingleQubitGates?: number;
analyzedNumberOfMultiQubitGates?: number;
analyzedNumberOfMeasurementOperations?: number;
analyzedMultiQubitGateDepth?: number;
numberOfQubits?: number;
t1?: number;
t2?: number;
avgReadoutError?: number;
avgSingleQubitGateError?: number;
avgMultiQubitGateError?: number;
avgSingleQubitGateTime?: number;
avgMultiQubitGateTime?: number;
maxGateTime?: number;
simulator?: boolean;
time?: string;
implementation?: ImplementationDto;
id?: string;
inputParameters?: {};
originalCircuitResultId?: string;
qpuSelectionJobId?: string;
correlationId?: string;
_links?: Links;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
export type ExecuteAnalysisResultRequestDto = {
refreshToken?: string;
tokens?: {};
correlationId?: string;
};
1 change: 1 addition & 0 deletions generated/api-nisq/models/execution-result-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export type ExecutionResultDto = {
result?: string;
shots?: number;
histogramIntersectionValue?: number;
resultLocation?: string;
_links?: Links;
};
1 change: 0 additions & 1 deletion generated/api-nisq/models/implementation-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type ImplementationDto = {
implementedAlgorithm?: string;
algorithmName?: string;
language?: string;
selectionRule?: string;
sdk?: string;
fileLocation?: string;
inputParameters?: ParameterListDto;
Expand Down
11 changes: 11 additions & 0 deletions generated/api-nisq/models/selection-request-dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
/* tslint:disable */
export type SelectionRequestDto = {
parameters?: {};
allowedProviders?: Array<string>;
compilers?: Array<string>;
preciseResultsPreference?: boolean;
shortWaitingTimesPreference?: boolean;
queueImportanceRatio?: number;
maxNumberOfCompiledCircuits?: number;
predictionAlgorithm?: string;
metaOptimizer?: string;
tokens?: {};
algorithmId?: string;
refreshToken?: string;
mcdaMethodName?: string;
mcdaWeightLearningMethod?: string;
};
69 changes: 2 additions & 67 deletions generated/api-nisq/services/analysis-result.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { AnalysisJobDto } from '../models/analysis-job-dto';
import { AnalysisJobListDto } from '../models/analysis-job-list-dto';
import { AnalysisResultDto } from '../models/analysis-result-dto';
import { AnalysisResultListDto } from '../models/analysis-result-list-dto';
import { ExecuteAnalysisResultRequestDto } from '../models/execute-analysis-result-request-dto';
import { ExecutionResultDto } from '../models/execution-result-dto';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -99,7 +97,7 @@ export class AnalysisResultService extends BaseService {
static readonly GetAnalysisJobsPath = '/analysis-results/jobs';

/**
* Retrieve all compiler analysis jobs
* Retrieve all analysis jobs
*
* This method provides access to the full `HttpResponse`, allowing access to response headers.
* To access only the response body, use `getAnalysisJobs()` instead.
Expand Down Expand Up @@ -132,7 +130,7 @@ export class AnalysisResultService extends BaseService {
}

/**
* Retrieve all compiler analysis jobs
* Retrieve all analysis jobs
*
* This method provides access to only to the response body.
* To access the full response (for headers, for example), `getAnalysisJobs$Response()` instead.
Expand Down Expand Up @@ -326,67 +324,4 @@ export class AnalysisResultService extends BaseService {
)
);
}

/**
* Path part for operation executeAnalysisResult
*/
static readonly ExecuteAnalysisResultPath =
'/analysis-results/{resId}/execute';

/**
* Execute an analysis configuration
*
* This method provides access to the full `HttpResponse`, allowing access to response headers.
* To access only the response body, use `executeAnalysisResult()` instead.
*
* This method sends `application/json` and handles request body of type `application/json`.
*/
executeAnalysisResult$Response(params: {
resId: string;
body?: ExecuteAnalysisResultRequestDto;
}): Observable<StrictHttpResponse<ExecutionResultDto>> {
const rb = new RequestBuilder(
this.rootUrl,
AnalysisResultService.ExecuteAnalysisResultPath,
'post'
);
if (params) {
rb.path('resId', params.resId, {});

rb.body(params.body, 'application/json');
}
return this.http
.request(
rb.build({
responseType: 'json',
accept: 'application/hal+json',
})
)
.pipe(
filter((r: any) => r instanceof HttpResponse),
map((r: HttpResponse<any>) => {
return r as StrictHttpResponse<ExecutionResultDto>;
})
);
}

/**
* Execute an analysis configuration
*
* This method provides access to only to the response body.
* To access the full response (for headers, for example), `executeAnalysisResult$Response()` instead.
*
* This method sends `application/json` and handles request body of type `application/json`.
*/
executeAnalysisResult(params: {
resId: string;
body?: ExecuteAnalysisResultRequestDto;
}): Observable<ExecutionResultDto> {
return this.executeAnalysisResult$Response(params).pipe(
map(
(r: StrictHttpResponse<ExecutionResultDto>) =>
r.body as ExecutionResultDto
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h2>Required information for the NISQ Analyzer</h2>
</button>
</div>
</div>

</div>
<div class="col-lg-6 col-md-12">
<app-select-input
Expand Down Expand Up @@ -112,7 +112,8 @@ <h4>Input Parameters</h4>
[choices]="[
{ value: 'Integer', label: 'Integer' },
{ value: 'Float', label: 'Float' },
{ value: 'String', label: 'String' }
{ value: 'String', label: 'String' },
{ value: 'FloatArray', label: 'FloatArray' }
]"
(onChange)="param.type = $event"
>
Expand All @@ -132,20 +133,6 @@ <h4>Input Parameters</h4>
</mat-card>
</div>
</div>
<div class="header-container" *qcAtlasUiShowOnFeature="UiFeatures.NISQ_ANALYZER">
<h4>Prolog Rules</h4>
</div>
<mat-card class="m-4" *qcAtlasUiShowOnFeature="UiFeatures.NISQ_ANALYZER">
<div class="row">
<div class="col-12">
<app-prolog-input
name="Selection Rule (in PROLOG)"
[(ngModel)]="nisqImpl.selectionRule"
(onSaveChanges)="saveImplementation()"
></app-prolog-input>
</div>
</div>
</mat-card>
</div>

<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import { ApiConfiguration } from 'api-atlas/api-configuration';
import { ExecutionEnvironmentsService } from 'generated/api-atlas/services/execution-environments.service';
import { ChangePageGuard } from '../../../services/deactivation-guard';
import { parsePrologRule, PrologRule } from '../../../util/MinimalPrologParser';
import { Option } from '../../generics/property-input/select-input.component';
import { UiFeatures } from '../../../directives/qc-atlas-ui-repository-configuration.service';
import { PlanqkPlatformService } from '../../../services/planqk-platform.service';
Expand All @@ -40,10 +39,6 @@ export class ImplSelectionCriteriaComponent implements OnInit, OnChanges {
oldNisqImpl: NisqImplementationDto;
nisqImpl: NisqImplementationDto;

paramPrologRules: {
selectionRule: PrologRule;
};

selection = new SelectionModel<number>(true);
sdks$: Observable<Option[]>;
languages: Option[] = [
Expand Down Expand Up @@ -90,9 +85,6 @@ export class ImplSelectionCriteriaComponent implements OnInit, OnChanges {
if (!this.nisqImpl) {
return;
}
this.paramPrologRules = {
selectionRule: parsePrologRule(this.nisqImpl.selectionRule),
};
}

addOne(): void {
Expand Down Expand Up @@ -254,7 +246,6 @@ export class ImplSelectionCriteriaComponent implements OnInit, OnChanges {
body = {
name: this.impl.name,
implementedAlgorithm: this.algo.id,
selectionRule: '',
sdk: this.impl.technology,
language: this.impl.version,
fileLocation:
Expand Down Expand Up @@ -326,7 +317,6 @@ export class ImplSelectionCriteriaComponent implements OnInit, OnChanges {
body = {
name: this.impl.name,
implementedAlgorithm: this.algo.id,
selectionRule: '',
// TODO
sdk: 'Qiskit',
language: 'OpenQASM',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
ibmqEnabled = true;
ionqEnabled = false;
awsEnabled = false;
shortWaitingTimeEnabled = false;
stableExecutionResultsEnabled = false;
shortWaitingTimeEnabled = true;
stableExecutionResultsEnabled = true;
predictionAlgorithmInDialog = 'extra_trees_regressor';
metaOptimizerInDialog = 'ada_boost_regressor';
metaOptimizerInDialog = 'none';
advancedSettingsOpen: boolean;
queueImportanceRatioDialog = 0;
maxNumberOfCompiledCircuitsDialog = 5;
maxNumberOfCompiledCircuitsDialog = 6;
disableDefiningMaximumNumberOfCircuits = false;

constructor(
Expand Down Expand Up @@ -147,10 +147,10 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
}
this.setCompilerOptions(this.selectedVendors);
this.predictionAlgorithm.setValue('extra_trees_regressor');
this.metaOptimizer.setValue('ada_boost_regressor');
this.maxNumberOfCompiledCircuits.setValue(5);
this.stableExecutionResults.setValue(false);
this.shortWaitingTime.setValue(false);
this.metaOptimizer.setValue('none');
this.maxNumberOfCompiledCircuits.setValue(6);
this.stableExecutionResults.setValue(true);
this.shortWaitingTime.setValue(true);

this.dialogRef.beforeClosed().subscribe(() => {
this.data.vendors = this.selectedVendors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ImplementationDto as NISQImplementationDto,
AnalysisJobDto,
ExecuteAnalysisResultRequestDto,
QpuSelectionResultDto,
} from 'api-nisq/models';
import { AnalysisResultService } from 'api-nisq/services/analysis-result.service';
import { ImplementationService } from 'api-nisq/services/implementation.service';
Expand Down Expand Up @@ -80,31 +81,32 @@ export class NisqAnalyzerComponent implements OnInit {
'execution',
];
analyzerResults: AnalysisResultDto[] = [];
allQpuSelectionResults: QpuSelectionResultDto[] = [];
jobColumns = ['inputParameters', 'time', 'ready'];
analyzerJobs$: Observable<AnalysisJobDto[]>;
sort$ = new BehaviorSubject<string[] | undefined>(undefined);
analyzerJob: AnalysisJobDto;
jobReady = false;
expandedElement: AnalysisResultDto | null;
expandedElement: QpuSelectionResultDto | null;
pollingAnalysisJobData: Subscription;
queueLengths = new Map<string, number>();
executionResultsAvailable = new Map<string, boolean>();
loadingResults = new Map<string, boolean>();
groupedResultsMap = new Map<
NISQImplementationDto,
MatTableDataSource<AnalysisResultDto>
MatTableDataSource<QpuSelectionResultDto>
>();
qpuDataIsUpToDate = new Map<AnalysisResultDto, boolean>();
qpuDataIsUpToDate = new Map<QpuSelectionResultDto, boolean>();
qpuCounter = 0;
qpuCheckFinished = false;

// 3) Execution
resultBackendColumns = ['backendName', 'width', 'depth'];
executedAnalyseResult: AnalysisResultDto;
executedQpuSelectionResult: QpuSelectionResultDto;
expandedElementExecResult: ExecutionResultDto | null;
results?: ExecutionResultDto = undefined;
expandedElementMap: Map<AnalysisResultDto, ExecutionResultDto> = new Map<
AnalysisResultDto,
expandedElementMap: Map<QpuSelectionResultDto, ExecutionResultDto> = new Map<
QpuSelectionResultDto,
ExecutionResultDto
>();
executeAnalysisResultRequestDto: ExecuteAnalysisResultRequestDto = {
Expand All @@ -113,11 +115,9 @@ export class NisqAnalyzerComponent implements OnInit {
};

constructor(
private executionEnvironmentsService: ExecutionEnvironmentsService,
private analysisResultService: AnalysisResultService,
private nisqAnalyzerService: NisqAnalyzerService,
private utilService: UtilService,
private formBuilder: FormBuilder,
private http: HttpClient,
private implementationService: ImplementationService,
private sdkService: SdksService,
Expand Down Expand Up @@ -322,7 +322,7 @@ export class NisqAnalyzerComponent implements OnInit {
this.groupedResultsMap = resultMap;
}

checkIfQpuDataIsOutdated(analysisResult: AnalysisResultDto): void {
checkIfQpuDataIsOutdated(analysisResult: QpuSelectionResultDto): void {
let provider = null;
this.qprovService.getProviders().subscribe((providers) => {
for (const providerDto of providers._embedded.providerDtoes) {
Expand Down Expand Up @@ -365,7 +365,7 @@ export class NisqAnalyzerComponent implements OnInit {
});
}

execute(analysisResult: AnalysisResultDto): void {
execute(analysisResult: QpuSelectionResultDto): void {
let token = ' ';
this.utilService
.createDialog(ImplementationTokenDialogComponent, {
Expand All @@ -375,7 +375,7 @@ export class NisqAnalyzerComponent implements OnInit {
.subscribe((dialogResult) => {
this.loadingResults[analysisResult.id] = true;
this.results = undefined;
this.executedAnalyseResult = analysisResult;
this.executedQpuSelectionResult = analysisResult;
if (dialogResult.token) {
token = dialogResult.token;
}
Expand Down Expand Up @@ -422,7 +422,7 @@ export class NisqAnalyzerComponent implements OnInit {
});
}

hasExecutionResult(analysisResult: AnalysisResultDto): void {
hasExecutionResult(analysisResult: QpuSelectionResultDto): void {
this.analysisResultService
.getAnalysisResult({ resId: analysisResult.id })
.subscribe((result) => {
Expand All @@ -433,7 +433,7 @@ export class NisqAnalyzerComponent implements OnInit {
});
}

showExecutionResult(analysisResult: AnalysisResultDto): void {
showExecutionResult(analysisResult: QpuSelectionResultDto): void {
if (this.expandedElementMap.has(analysisResult)) {
this.expandedElementMap.delete(analysisResult);
this.expandedElement = undefined;
Expand All @@ -460,7 +460,7 @@ export class NisqAnalyzerComponent implements OnInit {
return result;
}

showBackendQueueSize(analysisResult: AnalysisResultDto): void {
showBackendQueueSize(analysisResult: QpuSelectionResultDto): void {
this.nisqAnalyzerService
.getIBMQBackendState(analysisResult.qpu)
.subscribe((data) => {
Expand Down
Loading

0 comments on commit 75fd156

Please sign in to comment.