Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile_to_hardware mangles sequences #172

Open
matthewware opened this issue Jul 25, 2018 · 3 comments
Open

compile_to_hardware mangles sequences #172

matthewware opened this issue Jul 25, 2018 · 3 comments

Comments

@matthewware
Copy link
Collaborator

Is there any danger in doing a deep copy of seqs before we get here:

QGL/QGL/Compiler.py

Lines 327 to 331 in 446ff4f

# all sequences should start with a WAIT for synchronization
for seq in seqs:
if not isinstance(seq[0], ControlFlow.Wait):
logger.debug("Adding a WAIT - first sequence element was %s", seq[0])
seq.insert(0, ControlFlow.Wait())

This mangles the seqs and even makes lines like

tomo_block = state_tomo([X(q1)], (q1,))
cals = create_cal_seqs((q1,), numRepeats=4)
seqs = tomo_block + cals

axis_descriptor = [{
    'name': 'segment num',
    'unit': None,
    'points': list(range(0,len(tomo_block))),
    'partition': 1
}]
axis_descriptor.append(cal_descriptor((q1,), 4))

metafile = compile_to_hardware(seqs, 'Tomo/Tomo', axis_descriptor=axis_descriptor, 
                               extra_meta = {'sequences':tomo_block})

crash hard since the metadata construction is happening after this initial loop. This seems to work for me with minor changes to QGL's Pulse object:

compiler_seqs = copy.deepcopy(seqs)
metafile = compile_to_hardware(compiler_seqs, 'Tomo/Tomo', axis_descriptor=axis_descriptor, 
                               extra_meta = {'sequences':str(tomo_block)})

Assuming we're not doing something like GST (a case we can work around) is there any reason not to do this? Seems this would be an issue anytime you needed seqs or adata about them after you'd run compile_to_hardware

@matthewware
Copy link
Collaborator Author

I basically just added a copy and deepcopy method

@dieris
Copy link
Collaborator

dieris commented Jul 25, 2018

I think we can indeed copy the sequence (but do we need to define copy methods for lower layers? Note that tests are not passing now). This question was also brought up in #150

Note however that for this application, the sequence is already saved in Tomo-code.json before the WAIT is added

save_code(seqs, fileName + suffix)

@matthewware
Copy link
Collaborator Author

In my experience you need to have a __deepcopy__ method defined for all the objects to be deep copied. Here Pulse is the base object. The code above doesn't work without a deepcopy method. I guess I'm fine with not copying and loading the sequences from json as long as we document that process and put up some examples. My one concern is it starts to make creating axis descriptors comically obtuse. @grahamrow I think it's the extra meta data Auspex needs down the line that causes issues here. Do you have strong opinions on save-v-load?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants