@@ -540,20 +540,19 @@ def random_clifford(
540540
541541 backend = _check_backend (backend )
542542 backend .set_seed (seed )
543+ dtype = backend .uint8 if nqubits <= 255 else backend .int16
543544
544545 hadamards , permutations = backend .qinfo ._sample_from_quantum_mallows_distribution (
545546 nqubits
546547 )
547- hadamards = backend .cast (hadamards , dtype = backend . uint8 )
548- permutations = backend .cast (permutations , dtype = backend . uint8 )
548+ hadamards = backend .cast (hadamards , dtype = dtype )
549+ permutations = backend .cast (permutations , dtype = dtype )
549550
550- gamma = backend .diag (backend .random_integers (2 , size = nqubits , dtype = backend . uint8 ))
551+ gamma = backend .diag (backend .random_integers (2 , size = nqubits , dtype = dtype ))
551552
552- gamma_prime = backend .diag (
553- backend .random_integers (2 , size = nqubits , dtype = backend .uint8 )
554- )
553+ gamma_prime = backend .diag (backend .random_integers (2 , size = nqubits , dtype = dtype ))
555554
556- delta = backend .identity (nqubits , dtype = backend . uint8 )
555+ delta = backend .identity (nqubits , dtype = dtype )
557556 delta_prime = backend .cast (delta , dtype = delta .dtype , copy = True )
558557
559558 backend .qinfo ._fill_tril (gamma , symmetric = True )
@@ -568,7 +567,7 @@ def random_clifford(
568567 block_inverse_threshold = 50
569568
570569 # Compute stabilizer table
571- zero = backend .zeros ((nqubits , nqubits ), dtype = backend . uint8 )
570+ zero = backend .zeros ((nqubits , nqubits ), dtype = dtype )
572571 prod1 = (gamma @ delta ) % 2
573572 prod2 = (gamma_prime @ delta_prime ) % 2
574573 inv1 = backend .qinfo ._inverse_tril (delta , block_inverse_threshold ).T
0 commit comments