-
Notifications
You must be signed in to change notification settings - Fork 10
Optimizing the number of qubits
You can also use the QuantumMDMWithRiemannianPipeline pipeline :
QuantumMDMWithRiemannianPipeline(
convex_metric="mean", quantum=True
)
Which is an equivalent of the pipeline below:
make_pipeline(
XdawnCovariances(nfilter=1, estimator="scm", xdawn_estimator="lwf"),
Whitening(dim_red={"n_components": 2}),
MDM(metric={"mean": "convex", "distance": "euclid"})
)
The pipeline does:
- XDawn is a method for pre-processing the input data to covariances matrices that is designed to improve the signal to signal + noise ratio
- Whitening for unsupervised dimension reduction (similar to PCA, but for SPD matrices)
In order for the pipeline to be executed on real quantum computer we need to optimize the number of used qubits.
The number of qubits depends on 2 factors:
- the size of the matrices being processed
- the encoding of the matrices which is required for the QAOA
The size of the square matrix in the pipeline is:
- 4 x 4 (
nfilter * 4
) after XdawnCovariances because 1 filter x 4 = size of 4 for the matrix - 2 x 2 after Whitening (because
n_components
is 2) The number of components has to be lower than the number of columns or rows of the covariance matrices.
When QAOA is selected as an optimizer (quantum simulation or real quantum),
the optimizer also applies an additional modification to the size of the matrix.
The size of the matrix then depends on the upper_bound
parameter passed to the NaiveQAOAOptimizer
optimizer.
To find the resulting matrix size, you have to:
- Convert the
upper_bound
to binary. By defaultupper_bound
is 7, that is, 111. - Then you take the number of digits (111 = 3 digits).
- You multiply the number of elements in the matrix after Whitening by the number of digits:
total_number_elements = elements_after_whitening * digits
So here:
total_number_elements = 2 x 2 x 3 = 12
The table below gives some of the possible combinations.
Important you may want to check the total number of elements before running on true quantum backend. The number of qubit in the quantum backend has to match or be greater than the number of elements.
xdawn filter | size of covariance matrix | whitening components | size after whitening | upper_bound | binary representation | nb qubit by element | nb total element |
---|---|---|---|---|---|---|---|
1 | 4x4 | 2 | 2x2 | 1 | 10 | 2 | 8 |
2 | 10 | 2 | 8 | ||||
7 | 111 | 3 | 12 | ||||
4 | 4x4 | 1 | 1 | 1 | 32 | ||
2 | 10 | 2 | 64 | ||||
7 | 111 | 3 | 96 |