Skip to content

DynamiqsBackend failing with ZMQError #26

@yhteoh

Description

@yhteoh
  • I'm submitting a ...

    • bug report
    • feature request
  • What is the current behavior?
    DynamiqsBackend fails with ZMQError: Too many open files

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
    Run the Dynamiqs backend on the following AtomicCircuit:

import numpy as np
from oqd_core.interface.atomic import (
    AtomicCircuit,
    Beam,
    Ion,
    Level,
    ParallelProtocol,  # noqa: F401
    Phonon,
    Pulse,
    SequentialProtocol,  # noqa: F401
    System,
    Transition,
)

downstate = Level(
    principal=6,
    spin=1 / 2,
    orbital=0,
    nuclear=1 / 2,
    spin_orbital=1 / 2,
    spin_orbital_nuclear=0,
    spin_orbital_nuclear_magnetization=0,
    energy=2 * np.pi * 0,
    label="q0",
)
upstate = Level(
    principal=6,
    spin=1 / 2,
    orbital=0,
    nuclear=1 / 2,
    spin_orbital=1 / 2,
    spin_orbital_nuclear=1,
    spin_orbital_nuclear_magnetization=0,
    energy=2 * np.pi * 12.643e9,
    label="q1",
)
estate = Level(
    principal=6,
    spin=1 / 2,
    orbital=1,
    nuclear=1 / 2,
    spin_orbital=1 / 2,
    spin_orbital_nuclear=1,
    spin_orbital_nuclear_magnetization=-1,
    energy=2 * np.pi * 811.29e12,
    label="e0",
)
estate2 = Level(
    principal=6,
    spin=1 / 2,
    orbital=1,
    nuclear=1 / 2,
    spin_orbital=1 / 2,
    spin_orbital_nuclear=1,
    spin_orbital_nuclear_magnetization=1,
    energy=2 * np.pi * 911.14e12,
    label="e1",
)

transitions = [
    Transition(
        level1=downstate, level2=upstate, einsteinA=1, multipole="M1", label="q0->q1"
    ),
    Transition(
        level1=downstate, level2=estate, einsteinA=1, multipole="E1", label="q0->e0"
    ),
    Transition(
        level1=downstate, level2=estate2, einsteinA=1, multipole="E1", label="q0->e1"
    ),
    Transition(
        level1=upstate, level2=estate, einsteinA=1, multipole="E1", label="q1->e0"
    ),
    Transition(
        level1=upstate, level2=estate2, einsteinA=1, multipole="E1", label="q1->e1"
    ),
]

Yb171 = Ion(
    mass=171,
    charge=1,
    position=[0, 0, 0],
    levels=[downstate, upstate, estate, estate2],
    transitions=transitions,
)

COM_x = Phonon(energy=2 * np.pi * 1e6, eigenvector=[1, 0, 0])

system = System(
    ions=[
        Yb171,
    ],
    modes=[
        COM_x,
    ],
)

beam = Beam(
    transition=transitions[0],
    rabi=2 * np.pi * 1e6,
    detuning=0,
    phase=0,
    polarization=[0, 1, 0],
    wavevector=[1, 0, 0],
    target=0,
)


protocol = SequentialProtocol(
    sequence=[
        Pulse(beam=beam, duration=1e-6),
    ]
)

circuit = AtomicCircuit(system=system, protocol=protocol)
  • What is the expected behavior?
    DynamiqsBackend should work without error

  • What is the motivation / use case for changing the behavior?
    Nil

  • Please tell us about your environment:

    • Version: 0.1.0dev
    • Platform: Windows 10
    • Subsystem: x64
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Traceback (most recent call last):
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\ipykernel\iostream.py", line 142, in _event_pipe
    event_pipe = self._local.event_pipe
                 ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_thread._local' object has no attribute 'event_pipe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\jax\_src\callback.py", line 95, in pure_callback_impl
    return tree_util.tree_map(np.asarray, callback(*args))
                                          ~~~~~~~~^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\jax\_src\callback.py", line 72, in __call__
    return tree_util.tree_leaves(self.callback_func(*args, **kwargs))
                                 ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\diffrax\_progress_meter.py", line 297, in _step
    step_bar(bar, np.array(_progress).reshape(()))
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\diffrax\_progress_meter.py", line 213, in _step_bar
    bar.refresh()
    ~~~~~~~~~~~^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\tqdm\std.py", line 1347, in refresh
    self.display()
    ~~~~~~~~~~~~^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\tqdm\std.py", line 1495, in display
    self.sp(self.__str__() if msg is None else msg)
    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\tqdm\std.py", line 459, in print_status
    fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\tqdm\std.py", line 452, in fp_write
    fp.write(str(s))
    ~~~~~~~~^^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\tqdm\utils.py", line 196, in inner
    return func(*args, **kwargs)
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\ipykernel\iostream.py", line 694, in write
    self._schedule_flush()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\ipykernel\iostream.py", line 590, in _schedule_flush
    self.pub_thread.schedule(_schedule_in_thread)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\ipykernel\iostream.py", line 267, in schedule
    self._event_pipe.send(b"")
    ^^^^^^^^^^^^^^^^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\ipykernel\iostream.py", line 146, in _event_pipe
    event_pipe = ctx.socket(zmq.PUSH)
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\zmq\sugar\context.py", line 354, in socket
    socket_class(  # set PYTHONTRACEMALLOC=2 to get the calling frame
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self, socket_type, **kwargs
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "d:\work\Projects\TrICal\.venv\Lib\site-packages\zmq\sugar\socket.py", line 159, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        ctx_or_socket,
        ^^^^^^^^^^^^^^
    ...<2 lines>...
        copy_threshold=copy_threshold,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "_zmq.py", line 690, in zmq.backend.cython._zmq.Socket.__init__
zmq.error.ZMQError: Too many open files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions