Skip to content

Generate QLT IR for all bloq examples - #1926

Open
mpharrigan wants to merge 1 commit into
quantumlib:mainfrom
mpharrigan:2026-07/qltaavm
Open

Generate QLT IR for all bloq examples#1926
mpharrigan wants to merge 1 commit into
quantumlib:mainfrom
mpharrigan:2026-07/qltaavm

Conversation

@mpharrigan

Copy link
Copy Markdown
Collaborator

Build an on-disk library of verified Qualtran-L1 (.qlt) files from bloqs.
Given a (bloq, name) pair and a root directory, build_library_entry runs the
full L1 pipeline for that bloq:

  1. Compiles it to a .qlt file (qualtran.l1.dump_l1).
  2. Loads that .qlt file back into bloqs (qualtran.l1.load_module).
  3. Executes the root bloq through the
    StandardQualtranArchitectureAgnosticVirtualMachine.

This is the basic infrastructure. Future PRs will investigate and/or fix the failure cases.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces tools and libraries to build and verify an on-disk library of Qualtran-L1 (.qlt) files from BloqExamples, including a new driver script, shell script, and core build logic. Feedback on the changes highlights three critical issues: first, the use of Unix-only signal APIs (setitimer and SIGALRM) in _library.py will cause crashes on Windows and in multi-threaded environments; second, the newly added __str__ methods on both Join and Split bloqs reference a non-existent num_bits attribute on QDType instead of num_qubits, which will raise an AttributeError when called.

Comment thread qualtran/l1/_library.py
Comment on lines +157 to +159
if not seconds or seconds <= 0:
yield
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The signal.setitimer and signal.SIGALRM APIs are Unix-only and will raise an AttributeError on Windows. Additionally, signal.signal can only be called from the main thread; calling it from a background thread (e.g., in a multi-threaded test runner or worker pool) will raise a ValueError. To prevent hard crashes in these environments, we should check for the presence of these APIs and ensure we are running on the main thread before attempting to set a timeout.

    import threading
    if (
        not seconds
        or seconds <= 0
        or not hasattr(signal, 'SIGALRM')
        or not hasattr(signal, 'setitimer')
        or threading.current_thread() is not threading.main_thread()
    ):
        yield
        return

Comment thread qualtran/bloqs/bookkeeping/join.py
Comment thread qualtran/bloqs/bookkeeping/split.py
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

Successfully merging this pull request may close these issues.

1 participant