amazon-braket / amazon-braket/amazon-braket-default-simulator-python

Custom gate with transcendental function produces AttributeError

Open
#387 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
74
Forks
34
Avg merge
2d 18h
Merged PRs (30d)
3

Description

**Describe the bug**

Transcendental functions for user defined gates appear to not work, despite that arithmetic does, and that for normal gates these functions work fine. Gate formal parameters may need to be stored as `SymbolLiteral(Symbols(name))`.

**To reproduce**

```python
from braket.devices import LocalSimulator
from braket.ir.openqasm import Program

oq3 = """
OPENQASM 3.0;
input float theta;
bit[1] b;
qubit[1] q;
gate my_gate(arg) r {
rx(sin(arg)) r;
}
my_gate(theta) q[0];
b[0] = measure q[0];
"""

sim = LocalSimulator()
prog = Program(source=oq3, inputs={"theta": 0.5})
result = sim.run(prog, shots=10).result()
```

**Expected behavior**
Works generally, just fails for user-defined gates.

**Screenshots or logs**
If applicable, add screenshots or logs to help explain your problem.

**System information**
A description of your system. Please provide:
- **Amazon Braket Python SDK version**: 1.123.0.post0
- **Amazon Braket Python Schemas version**: 1.29.1
- **Amazon Braket Python Default Simulator version**: 1.39.5
- **Python version**:

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.