• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 10393187711
90%
main: 88%

Build:
Build:
LAST BUILD BRANCH: unitary-synthesis
DEFAULT BRANCH: main
Ran 14 Aug 2024 07:01PM UTC
Jobs 1
Files 855
Run time 3min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

14 Aug 2024 05:46PM UTC coverage: 89.934% (-0.01%) from 89.944%
10393187711

push

github

web-flow
Allow immutable borrow to access `QuantumCircuit.parameters` (#12918) (#12958)

* Allow immutable borrow to access `QuantumCircuit.parameters`

`QuantumCircuit.parameters` is logically a read-only operation on
`QuantumCircuit`.  For efficiency in multiple calls to
`assign_parameters`, we actually cache the sort order of the internal
`ParameterTable` on access.  This is purely a caching effect, and should
not leak out to users.

The previous implementation took a Rust-space mutable borrow out in
order to (potentially) mutate the cache.  This caused problems if
multiple Python threads attempted to call `assign_parameters`
simultaneously; it was possible for one thread to give up the GIL during
its initial call to `CircuitData::copy` (so an immutable borrow was
still live), allowing another thread to continue on to the getter
`CircuitData::get_parameters`, which required a mutable borrow, which
failed due to the paused thread in `copy`.

This moves the cache into a `RefCell`, allowing the parameter getters to
take an immutable borrow as the receiver.  We now write the cache out
only if we *can* take the mutable borrow out necessary.  This can mean
that other threads will have to repeat the work of re-sorting the
parameters, because their borrows were blocking the saving of the cache,
but this will not cause failures.

The methods on `ParameterTable` that invalidate the cache all require a
mutable borrow on the table itself.  This makes it impossible for an
immutable borrow to exist simultaneously on the cache, so these methods
should always succeed to acquire the cache lock to invalidate it.

* Use `RefCell::get_mut` where possible

In several cases, the previous code was using the runtime-checked
`RefCell::borrow_mut` in locations that can be statically proven to be
safe to take the mutable reference.  Using the correct function for this
makes the logic clearer (as well as technically removing a small amount
of runtime overhead).

* Use `OnceCell` inste... (continued)

50 of 53 new or added lines in 2 files covered. (94.34%)

11 existing lines in 3 files now uncovered.

66731 of 74200 relevant lines covered (89.93%)

231238.17 hits per line

Jobs
ID Job ID Ran Files Coverage
1 10393187711.1 14 Aug 2024 07:01PM UTC 0
89.93
GitHub Action Run
Source Files on build 10393187711
Detailed source file information is not available for this build.
  • Back to Repo
  • eff654f9 on github
  • Prev Build on gh-readonly-queue/stable/1.2/pr-12954-75e29d77bb5734c9f6fdc8f310b9a98a2cd54167 (#10387257200)
  • Next Build on stable/1.2 (#10410092388)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc