-
Notifications
You must be signed in to change notification settings - Fork 969
MAHOUT-681 :Implement T-gate (π/8 gate) across all backends #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAHOUT-681 :Implement T-gate (π/8 gate) across all backends #693
Conversation
- Add apply_t_gate() method to QuMat class with validation - Implement T-gate support in Qiskit, Cirq, and Amazon Braket backends - Restore T-gate documentation in basic_gates.md to match implementation Fixes apache#681
|
cc @guan404ming @rawkintrevo is it correct what r ur opinions on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements the T-gate (π/8 gate) across all quantum computing backends (Qiskit, Cirq, Amazon Braket) to resolve an inconsistency where the documentation claimed T-gate support existed but no implementation was present in the codebase. The T-gate is essential for universal quantum computation when combined with Hadamard and CNOT gates.
Key Changes
- Added
apply_t_gate()method to the main QuMat API class with comprehensive docstring - Implemented backend-specific T-gate functions for Qiskit, Cirq, and Amazon Braket
- Updated documentation to reflect that T-gate is now fully implemented (removed "New Addition" label)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| qumat/qumat.py | Added apply_t_gate method to QuMat class with validation and backend delegation |
| qumat/qiskit_backend.py | Implemented T-gate using Qiskit's native t() method |
| qumat/cirq_backend.py | Implemented T-gate using Cirq's T gate on LineQubit |
| qumat/amazon_braket_backend.py | Implemented T-gate using Amazon Braket's t() method |
| docs/basic_gates.md | Removed "(New Addition)" label from T-Gate section header |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
qumat/qumat.py
Outdated
| Applies a π/4 phase shift to the qubit. Essential for universal | ||
| quantum computation when combined with Hadamard and CNOT gates. |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring incorrectly states "Applies a π/4 phase shift" but the T-gate actually applies a π/4 phase to the |1⟩ state, not a π/4 phase shift to the overall state. More accurately, the T-gate can be described as applying a relative phase of π/4 or introducing a phase of e^(iπ/4) = e^(i45°) to the |1⟩ state. The phase shift terminology is potentially misleading.
| Applies a π/4 phase shift to the qubit. Essential for universal | |
| quantum computation when combined with Hadamard and CNOT gates. | |
| Applies a relative phase of π/4 (i.e., multiplies the |1⟩ state by e^(iπ/4)). | |
| Essential for universal quantum computation when combined with Hadamard and CNOT gates. |
| def apply_t_gate(self, qubit_index): | ||
| """Apply a T-gate (π/8 gate) to the specified qubit. | ||
| Applies a π/4 phase shift to the qubit. Essential for universal | ||
| quantum computation when combined with Hadamard and CNOT gates. | ||
| :param qubit_index: Index of the qubit. | ||
| :type qubit_index: int | ||
| :raises RuntimeError: If the circuit has not been initialized. | ||
| """ | ||
| self._ensure_circuit_initialized() | ||
| self._validate_qubit_index(qubit_index) | ||
| self.backend_module.apply_t_gate(self.circuit, qubit_index) |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added apply_t_gate method lacks test coverage. The test file testing/test_single_qubit_gates.py has comprehensive test classes for all other single-qubit gates (TestPauliXGate, TestPauliYGate, TestPauliZGate, TestHadamardGate, TestNOTGate, TestUGate), but no TestTGate class exists. Consider adding a test class similar to the existing ones that verifies:
- T-gate state transitions (e.g., T|0⟩ = |0⟩, T|1⟩ applies phase)
- T-gate phase accumulation (T^8 = I)
- Cross-backend consistency
- Combination with Hadamard to verify phase effect
|
cc @guan404ming |
guan404ming
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Need to resolve the pre-commit error. |
issues resolved |
|
@guan404ming do you want to take another look? |
Purpose of PR
Implements the T-gate (π/8 gate) across all backends to resolve the discrepancy where the documentation claimed T-gate support was "Added" but no implementation existed in the codebase.
Related Issues or PRs
Changes Made
Breaking Changes
Checklist