Comments (7)
This is due to numerical error in the argument of acos in yzy_to_zyz. For example, math.sin(math.pi/2) * math.cos(math.pi/4) / math.sin(math.pi/4) = 1.0000000000000002 > 1. One solution is to round the argument.
from qiskit-terra.
One option is to round, but that might add errors after several computations. I suggest to move to symbolic computation instead of flouting point math to avoid this issue:
> import sympy
> sympy.sin(sympy.pi/2) * sympy.cos(sympy.pi/4) / sympy.sin(sympy.pi/4)
< 1
Comments?
from qiskit-terra.
I think @awcross1 was giving an example where it fails, but it general the inputs are not symbolic they are floats.
from qiskit-terra.
The particular case in yzy_to_zyz
, can be solved symbolically. There are several other points in the mapper where math is used, that can be easily be replaced with sympy.
I'm not sure what you mean. In situations where user code has floats, that error is introduced by the user and we can represent exactly that error without adding more, using Decimal in the parser.
My point is, when possible, we should operate with symbols to avoid adding error.
from qiskit-terra.
Thanks Luciano, I think it is worth investigating using symbols.
from qiskit-terra.
Here is a self-contained test case from @dcmckayibm that triggers the error
from qiskit import QuantumProgram
import numpy as np
coupling_map_test = {0:[0]}
qp = QuantumProgram()
qr = qp.create_quantum_register('q', 1)
cr = qp.create_classical_register('c', 1)
qc = qp.create_circuit('qc1', qregisters=[qr], cregisters=[cr])
qc.u2(np.pi/2, 0, qr[0])
qc.u3(np.pi/2, np.pi/2, 0.0, qr[0])
qp.compile('qc1', coupling_map=coupling_map_test)
from qiskit-terra.
Closing the issue, as it was fixed by #151 - thanks Luciano!
from qiskit-terra.
Related Issues (20)
- Bring back exact probabilities for SamplerV2. HOT 1
- Organize the synthesis library of multi-controlled gates HOT 3
- OpenQASM 3 dumper misses type annotation at loop variable
- `qasm2.dumps` fails to export `Initialize` and `PrepareState` with array inputs HOT 1
- Transpile error when transpile the circuit HOT 2
- several `SparsePauliOp` methods ignore `self.paulis.phase` HOT 3
- `QuantumCircuit.assign_parameters` of Qiskit 1.2.0 rc1 raises an error with `dict_values` while Qiskit 1.1 works HOT 1
- `qasm3.Exporter` raises an obscure error on invalid basis-gate name HOT 5
- Stop storing default `unit="dt"` in rust space extra attributes by default
- Importing BackendV2 results in a deprecation warning of `qiskit.providers.models`
- Python 3.13 support HOT 6
- Port `TwoQubitControlledUDecomposer` to rust
- Transpiler Failure HOT 7
- Poor image quality while saving circuit image using qc.draw(output = 'latex'). HOT 4
- Add builtin interner index for empty qubits or clbits HOT 1
- Optimisation failure HOT 1
- Normalize on `py_foo()` and `foo()` function name pattern in `accelerate` crate HOT 3
- Overflow error: Seed Transpiler Validation HOT 4
- Cannot schedule circuits using AerSimulator and QasmSimulator HOT 5
- add samplerv2 support for qiskit/algorithms/state_fidelities/compute_uncompute.py HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qiskit-terra.