- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
I would like to be able to implement gates randomly, requiring random choices of qubit indices. However it does not look like you can pass indices to a quantum-kernel defined function in a similar way to passing parameters such as rotation angles. For example the following piece of code causes problems
qbit Q[N];
int variable_qubit_index;
quantum_kernel void Random_H(){
H(Q[variable_qubit_index]);
}
The error message is:
Validating and processing quantum kernels...
ERROR: Quantum SDK - ValidateAndConditionQBBPass says: Unresolved qubit arguments stuck around in 'Random_H()'.
LLVM ERROR: Cannot process further. Exiting...
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks,
I'll add that it is possible to write a quantum kernel in a templated way.
For instance, you could have
template <int m> quantum_kernel void Random_H() {
H(q[m]);
}
However, when you call it you'll still need the switch statement on the random number to call the templated function since template parameters must be known at compile time.
switch(rand_num) {
case 0:
Random_H<0>();
break;
case 1:
Random_H<1>();
break;
...
}
A more scalable way would be to write code that generates a cpp file that does this switch statement, which would help with larger number of qubits.
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
The 'Unresolved qubit arguments . . . ' is telling you that the compiler can't fully determine which variable of qbit type that gate will run on.
The Intel(R) Quantum SDK requires that the instructions that will run on the quantum hardware be fully unambiguously formed at compile time. This means that the compiler must be able to figure out which variable of qbit type each gate will act on. Some consequences of this requirement are obvious, e.g. that the parameter of a top-level quantum_kernel (i.e. one that is directly called from main() ) can't have a qbit type parameter. Or in other words, you can't use runtime data to decide which qbit one quantum_kernel will act on. Instead you can use runtime data to decide which quantum_kernel (with a fully determinable qbit-gate set) the Quantum Runtime will select to run.
More concretely: you can't choose the array accessor value with a random draw, but you can make a random draw force a decision between H(Q[0]) or H(Q[1]).
In general, it is possible to use parametrized arguments of qbit type with quantum_kernel functions, but the logic calling them, i.e. some code in the quantum_kernels above them, should establish values for those parameters.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
I successfully implemented random gates as you described. However this was done for a small number (3) qubits, in which different indices correspond to a different quantum kernel. Scaling this up for a larger number of qubits is very awkward. For example I define
quantum_kernel void CNOT01()
{
CNOT(Q[0],Q[1]);
}
and so on for CNOT02, CNOT10, CNOT12, CNOT20, H0, H1,H2
and then inside main generate random integers which are mapped to different quantum-kernels via a switch statement.
I did not find a way to write this such that one can easily change the number of qubits.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks,
I'll add that it is possible to write a quantum kernel in a templated way.
For instance, you could have
template <int m> quantum_kernel void Random_H() {
H(q[m]);
}
However, when you call it you'll still need the switch statement on the random number to call the templated function since template parameters must be known at compile time.
switch(rand_num) {
case 0:
Random_H<0>();
break;
case 1:
Random_H<1>();
break;
...
}
A more scalable way would be to write code that generates a cpp file that does this switch statement, which would help with larger number of qubits.

- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable