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

Pulse compression increases recursion depth of the schedule #4774

Closed
nkanazawa1989 opened this issue Jul 22, 2020 · 1 comment
Closed

Pulse compression increases recursion depth of the schedule #4774

nkanazawa1989 opened this issue Jul 22, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@nkanazawa1989
Copy link
Contributor

nkanazawa1989 commented Jul 22, 2020

Information

  • Qiskit Terra version: master
  • Python version: 3.7
  • Operating system:

What is the current behavior?

The pulse compress may increase the recursion depth of input schedule and crash the pulse assembler.

Steps to reproduce the problem

Prepare very long schedule

from qiskit.ignis.verification import randomized_benchmarking_seq
import numpy as np
from qiskit.test.mock import FakeAlmaden
from qiskit.pulse import transforms

rb_circs, xdata = randomized_benchmarking_seq(length_vector=[350], nseeds=1, rb_pattern=[[0]])
transpiled_rb_circs = qiskit.transpile(rb_circs[0], backend=FakeAlmaden(), optimization_level=0)
rb_scheds = qiskit.schedule(transpiled_rb_circs, backend=FakeAlmaden())

rb_scheds.instructions

transformed_sched = transforms.compress_pulses([rb_scheds])
transformed_sched[0].instructions # this causes an error
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-99-d345b17804b7> in <module>
     11 
     12 transformed_sched = transforms.compress_pulses([rb_scheds])
---> 13 transformed_sched[0].instructions

~/qiskit/qiskit-terra/qiskit/pulse/schedule.py in instructions(self)
    126                     sorted(chan.name for chan in inst.channels))
    127 
--> 128         return tuple(sorted(self._instructions(), key=key))
    129 
    130     def ch_duration(self, *channels: List[Channel]) -> int:

~/qiskit/qiskit-terra/qiskit/pulse/schedule.py in _instructions(self, time)
    174         """
    175         for insert_time, child_sched in self._children:
--> 176             yield from child_sched._instructions(time + insert_time)
    177 
    178     def union(self,

... last 1 frames repeated, from the frame below ...

~/qiskit/qiskit-terra/qiskit/pulse/schedule.py in _instructions(self, time)
    174         """
    175         for insert_time, child_sched in self._children:
--> 176             yield from child_sched._instructions(time + insert_time)
    177 
    178     def union(self,

RecursionError: maximum recursion depth exceeded while calling a Python object

Note that rb_scheds.instructions does work.
If we use two qubits for RB, the assembler crashes at almost the half clifford length ~ 150.
This is a realistic setup and should be supported.
Perhaps QV is also affected.

What is the expected behavior?

Transform module should convert the schedule so that transformed schedule has the almost constant recursion depth.

Suggested solutions

I'm not familiar with the logic of transform. @taalexander

@nkanazawa1989 nkanazawa1989 added the bug Something isn't working label Jul 22, 2020
@taalexander
Copy link
Contributor

Instead of using << and |= please trying using sched. insert(inst, inplace=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants