Commit 16c8088
authored
If a circuit has a global phase containing a `ParameterVectorElement`,
the resulting `SymbolExpr` will transitively contain a `Py<PyAny>`
pointing back to the `ParameterVector` object. When adding to the
global phase, a name/symbol-map clone occurs, which requires us to be
attached to the Python interpreter. Since `RemoveIdentityEquivalent`
manually detaches from the Python interpreter, we may attempt to
increment the refcount without being attached.
This patch is intended to be minimal for backport to 2.4; there are
several more invasive changes we could make (and largely _should_ make)
to make `ParameterExpression` safer and more performant, and in general
it is becoming clear we still have a lot of work to do to be able to
remove the `py-clone` feature use of PyO3 and let the compiler catch
these mistakes for us.
1 parent c2477ab commit 16c8088
3 files changed
Lines changed: 35 additions & 2 deletions
File tree
- crates/transpiler/src/passes
- releasenotes/notes
- test/python/transpiler
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
245 | 256 | | |
246 | 257 | | |
247 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
248 | 262 | | |
249 | 263 | | |
250 | 264 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
216 | 226 | | |
217 | 227 | | |
218 | 228 | | |
| |||
0 commit comments