Skip to content

[Feature] Add S gate to QuMat - #1540

Open
tingyu-patrick wants to merge 2 commits into
apache:mainfrom
tingyu-patrick:apply-s-gate
Open

tingyu-patrick wants to merge 2 commits into
apache:mainfrom
tingyu-patrick:apply-s-gate

Conversation

@tingyu-patrick

Copy link
Copy Markdown

Related Issues

Part of #1511

Changes

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Test
  • CI/CD pipeline
  • Other

Why

QuMat currently has no S gate (phase of π/2), which is common in textbook circuits and standard transpilation targets. Users have to drop down to the underlying SDK to use it. This PR adds the S gate as one of the gates tracked in #1511 (one gate per PR, as requested there).

How

  • Added QuMat.apply_s_gate in qumat/qumat.py, following the pattern of apply_t_gate.
  • Implemented it in all three backends: Qiskit, Cirq and Amazon Braket.
  • Added tests in testing/qumat/test_single_qubit_gates.py that run on all backends: basis-state preservation, S² = Z, S⁴ = I (each H-sandwiched so the phase becomes measurable), and a sign check (H-S-T-T-H ends in |1⟩, which would fail if the gate were S† instead of S).
  • Added an S-Gate section and an Updates entry to docs/qumat/basic-gates.md.

All tests in testing/qumat/ pass locally on all backends, and ruff passes. The ty and Rust pre-commit hooks could not run in my Windows environment (uv and cargo were not found by the hooks), so I am relying on CI for those.

AI assistance: I used Claude to help draft the tests and docs. I reviewed and ran all of it and can explain every change.

Checklist

  • Added or updated unit tests for all changes
  • Added or updated documentation for all changes

@tingyu-patrick

Copy link
Copy Markdown
Author

Hi @400Ping , sorry to bother you. When you have some free time, could you please take a look at this PR? Any feedback would be greatly appreciated!

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