QGL icon indicating copy to clipboard operation
QGL copied to clipboard

immutable cached Waveforms and APS2 instructions

Open caryan opened this issue 8 years ago • 0 comments

Compiling longish sequences spends ~10% of them time creating APS2 instructions and converting them to 8 byte machine code and another 5% of the time creating Compiler.Waveform, most of which is in hash_shape. It also uses a non-trivial amount of memory. It seems both of these could be solved with conversion to immutable named tuples and caching.

from QGL import *

import psutil
process = psutil.Process(os.getpid())
print("Memory usage: {} MB".format(process.memory_info().rss // (1 << 20)))

q = QubitFactory("q1")
pulseLib = [Cliffords.AC(q, cliffNum) for cliffNum in range(24)]
# over write AC Id to have finite length
pulseLib[0] = Id(q, 2e-8)

def create_seqs(file):
    seqs = []
    with open(file, 'r') as FID:
        lines = FID.readlines()

    for line in lines:
        seq = [pulseLib[int(pulseNum)] for pulseNum in line.split(',')]
        seq.append(MEAS(q))
        seqs.append(seq)

    seqs += create_cal_seqs((q,), 500)

    return seqs

file = "sequence_numbers.csv"
seqs = create_seqs(file)
filenames = compile_to_hardware(seqs, "test/test" )
print("Memory usage: {} MB".format(process.memory_info().rss // (1 << 20)))
Compiled 4505 sequences.
Memory usage: 659 MB

%%timeit
seqs = create_seqs(file)
filenames = compile_to_hardware(seqs, "test/test" )
Compiled 4505 sequences.
Compiled 4505 sequences.
Compiled 4505 sequences.
Compiled 4505 sequences.
1 loop, best of 3: 57.9 s per loop

%load_ext snakeviz
%%snakeviz
seqs = create_seqs(file)
compile_to_hardware(seqs, "test/test" )

sequence_numbers.csv.zip

caryan avatar Aug 26 '16 02:08 caryan