Skip to content

feat: GridSynth#165

Open
LonerDavid wants to merge 11 commits into
DVLab-NTU:mainfrom
LonerDavid:feat/gridsynth
Open

feat: GridSynth#165
LonerDavid wants to merge 11 commits into
DVLab-NTU:mainfrom
LonerDavid:feat/gridsynth

Conversation

@LonerDavid

@LonerDavid LonerDavid commented May 27, 2026

Copy link
Copy Markdown

Check List

  1. Does your submission pass tests by running make test?
  2. If you have specified a [no ci] tag, does your submission also pass tests by running make test-docker?
  3. Have you linted your code locally with make lint before submission?

Added

  • New qcir gridsynth --epsilon command to decompose single-qubit RZ gates into Clifford+T sequences using the GridSynth algorithm
  • Vendored cppgridsynth library under vendor/cppgridsynth/ with GMP/MPFR dependencies isolated to its own static library target
  • GridSynthAdapter and GridSynthPass for integrating cppgridsynth into the qcir pipeline (src/qcir/gridsynth/)
  • DOF test cases for gridsynth RZ decomposition and equivalence checking (tests/qcir/gridsynth/)

Changed

  • HeaderFilterRegex in .clang-tidy restricted to src/ to prevent thousands of lint warnings from Homebrew GMP/MPFR system headers
  • GMP/MPFR includes on the cppgridsynth target marked as SYSTEM PRIVATE to suppress external header warnings

Fixed

  • Skip W gates produced by GridSynth to avoid incorrect circuit output

Removed

  • N/A

LonerDavid and others added 4 commits May 25, 2026 03:42
Add qcir gridsynth --epsilon to decompose single-qubit RZ gates into
Clifford+T via vendored cppgridsynth. GMP/MPFR are isolated to the
GridSynth static library; qsyn core numerics are unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Limit HeaderFilterRegex to src/ so make lint does not report thousands
of warnings from Homebrew gmp/gmpxx/mpfr. Mark GMP/MPFR includes as
SYSTEM PRIVATE on the cppgridsynth target.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@LonerDavid LonerDavid changed the title Feat/gridsynth feat: GridSynth May 27, 2026
@LonerDavid LonerDavid marked this pull request as ready for review May 29, 2026 16:16
Copilot AI review requested due to automatic review settings May 29, 2026 16:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Vendors a new C++ port of the GridSynth algorithm (cppgridsynth) and wires it into qsyn as a new qcir gridsynth command that decomposes single-qubit RZ gates into Clifford+T sequences. The vendored library uses GMP/MPFR for arbitrary-precision arithmetic and is built as an isolated static library so those dependencies don't leak into the rest of qsyn.

Changes:

  • Adds the full vendor/cppgridsynth/ tree (headers, sources, README/LICENSE) implementing the ring algebra, ODGP/TDGP/upright reduction, Diophantine solver, normal-form, and top-level pipeline.
  • Adds src/qcir/gridsynth/ adapter + pass and a new qcir gridsynth CLI command, wired through src/cmd/qcir_cmd.cpp.
  • Adds a CMake module cmake/cppgridsynth.cmake that builds the vendored library (linking GMP/MPFR only into it), plus end-to-end .dof/.log tests for the new command.

Reviewed changes

Copilot reviewed 11 out of 53 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vendor/cppgridsynth/src/.cpp, include/cppgridsynth/.hpp Vendored C++ port of pygridsynth: rings, region/grid ops, ODGP/TDGP, upright, Diophantine, normal form, top-level pipeline.
vendor/cppgridsynth/{README,LICENSE,UPSTREAM,.gitignore} Vendored library docs and metadata.
vendor/README.md Lists cppgridsynth as a vendored, optional-build dependency.
src/qcir/gridsynth/gridsynth_adapter.{hpp,cpp} Thin bridge translating qsyn requests to cppgridsynth and converting back to a plain gate list (keeps GMP/MPFR headers out of qsyn core).
src/qcir/gridsynth/gridsynth_pass.{hpp,cpp} Iterates a QCir, replaces each RZGate with the synthesized Clifford+T sequence.
src/cmd/qcir/gridsynth.cpp, src/cmd/qcir_cmd.cpp Registers the new qcir gridsynth subcommand and its arguments.
cmake/cppgridsynth.cmake, CMakeLists.txt New CMake module that builds cppgridsynth as a static lib, finds GMP/MPFR, and excludes the adapter from libqsyn.
tests/qcir/gridsynth/{dof,ref}/* New end-to-end tests covering gridsynth and verifying equivalence vs. the original Rz at several angles.
.clang-tidy Restricts HeaderFilterRegex so vendor/system headers (GMP/MPFR) aren't linted.
.gitignore Whitelists tests/**/ref/*.log so the new reference logs are tracked.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/qcir/gridsynth/gridsynth_pass.cpp Outdated
@LonerDavid LonerDavid requested a review from Copilot May 29, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 53 changed files in this pull request and generated 2 comments.

Comment thread src/qcir/gridsynth/gridsynth_pass.cpp
Comment thread cmake/cppgridsynth.cmake
LonerDavid and others added 2 commits May 30, 2026 00:58
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Ferayer

Ferayer commented May 30, 2026

Copy link
Copy Markdown
Collaborator

The following checks are failing:

  • gcc test (Ubuntu) / build-and-test
  • llvm-clang test (Ubuntu) / build-and-test
  • Lint / Run linters

There seem to be two issues:

  1. Ubuntu build-and-test fails because GMP/MPFR are missing

CMake stops here:

GridSynth requires GMP and MPFR, but they were not found.

Suggested fix: add the required packages to the Ubuntu GitHub Actions dependency install step:

sudo apt-get update
sudo apt-get install -y libgmp-dev libmpfr-dev

libgmp-dev and libmpfr-dev provide the GMP/MPFR headers and libraries required by GridSynth.

  1. Lint fails because clang-format is needed

The linter shows formatting changes are required in:

src/qcir/gridsynth/gridsynth_pass.cpp

Suggested fix:

clang-format -i src/qcir/gridsynth/gridsynth_pass.cpp

Then commit and push the updated workflow/file so the CI can rerun.

suggestions are AI-generated.

LonerDavid and others added 4 commits May 31, 2026 14:19
Run sudo apt install -y libgmp-dev libmpfr-dev pkg-config without
prior notices; keep CMake configure quiet on success.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

3 participants