feat: GridSynth#165
Conversation
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>
There was a problem hiding this comment.
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 newqcir gridsynthCLI command, wired throughsrc/cmd/qcir_cmd.cpp. - Adds a CMake module
cmake/cppgridsynth.cmakethat builds the vendored library (linking GMP/MPFR only into it), plus end-to-end.dof/.logtests 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.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The following checks are failing:
There seem to be two issues:
CMake stops here: 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
The linter shows formatting changes are required in: Suggested fix: clang-format -i src/qcir/gridsynth/gridsynth_pass.cppThen commit and push the updated workflow/file so the CI can rerun. suggestions are AI-generated. |
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>
Check List
make test?make test-docker?make lintbefore submission?Added
Changed
Fixed
Removed