Skip to content

Shot-based functions on MPSCircuit #184

Discussion options

You must be logged in to vote

Currently MPSCircuit does not count with shot-based functions such as sample and sample_expectation

try MPSCircuit.measure(), sample API is built as a wrapper for measure API which is lacking in MPSCircuit class for now.

Demo usage:

K = tc.set_backend("tensorflow")
n = 10
c = tc.MPSCircuit(n)
c.set_split_rules({"max_singular_values": 8})
c.h(range(10))

@K.jit
def sample(status):
    return c.measure(*range(n), status=status)[0]
 
r = [] 
for _ in range(20):
    r.append(sample(K.implicit_randu([n])))
    
K.stack(r)

Replies: 2 comments 15 replies

Comment options

You must be logged in to vote
6 replies
@refraction-ray
Comment options

@EmilianoG-byte
Comment options

@refraction-ray
Comment options

@EmilianoG-byte
Comment options

@refraction-ray
Comment options

Answer selected by EmilianoG-byte
Comment options

You must be logged in to vote
9 replies
@refraction-ray
Comment options

@refraction-ray
Comment options

@EmilianoG-byte
Comment options

@refraction-ray
Comment options

@refraction-ray
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants