You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Slightly optimize ParameterVector construction (Qiskit#10403)
This commit optimizes the construction code for the ParameterVector and
ParameterVectorElement classes. The construction of these objects was
primarily dominated by the UUID construction time. This is because each
element in the vector was calling uuid4() to generate a random unique
identifier for each Parameter element. However, we don't need a truly
random identifier as we just need to avoid collisions with identically
named elements. So instead of calling uuid4() n times this commit opts
to call uuid4() once and then just use an index offset of that value.
This is slightly faster because we don't need to need run the full
uuid4 algorithm each time and instead just wrap an integer in uuid
object. While this does slightly increase the change of a collision
between identically named ParameterVectors, in practice it should still
be sufficiently rare. At the same time the classes are slotted to speed
up attribute access and shrink the memory footprint of using these
objects.
The geometric mean of the runtime of creating 10x 2424000 element
ParamterVector objects goes from 15.702722168587812 to 13.738723886030732
sec with this commit. While not a huge improvement it is a consistent
incremental gain that doesn't require any data model changes. To make
the classes significantly faster we'll likely need to change the data
model for Paramter, ParameterVector, etc to facilitate faster creation.
0 commit comments