0
$\begingroup$

enter image description here

Here [+1] represents X gate for qutrit. How the Counter value is coming to 5? which is the measurement outcome(q0q1q2->102). Even for (q0q1q2->101) also counter value is 5. In total, for this 3 qutrits composite system, we have access to 27 levels (0,1,_ _ _ 26) but the counter value is not exceeding more than 7(q0q1q2->222).

Can someone suggest how to get true levels in Cirq for qudits after measurement? as well as what does counter value represent?

$\endgroup$

1 Answer 1

0
$\begingroup$

The histogram function has a default value for the fold_func parameter that calculates the integer value for the binary big endian number got from measurement results assuming qubits, not qudits. Thus:

  1. I guess one could argue that it's a bug that it doesn't fail for non-bool values (you can open an issue for that to save time for future qudit users) and instead returns the "binary value" of the array, e.g. [1,0,2] -> [1,0,1] -> 5 is the reason you're getting 5, and why for 3 bits it never goes above 7=2^3-1.

  2. You can create your own function instead for d=3 case and pass it like this for example:

def big_endian_dits_to_int(dits, dim: int) -> int:   
    result = 0
    for e in dits:        
        result *= dim
        result += e
    return result

samples.histogram(key='out',fold_func=lambda v: big_endian_dits_to_int(v, 3))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.