Skip to content

Make state vector copying explicit #3494

@95-martin-orion

Description

@95-martin-orion

The state_vector method in StateVectorTrialResult includes a copying of the state vector to resolve issue #3101:

return self._final_simulator_state.state_vector.copy()

This eliminates the issue of mutating the state vector, but can significantly increase runtime for large circuits without a clear indication of the root cause. We should force users to explicitly make a copy of the state if they need it, either by renaming the method to state_vector_copy or by removing it altogether and requiring users to copy the final_state_vector field.

Related: qsim issue 237

Metadata

Metadata

Labels

area/debuggingarea/performancearea/simulationcomplexity/lowintroduces/modifies 1-2 concepts, should take 1-2 days max for an advanced contributorkind/healthFor CI/testing/release process/refactoring/technical debt itemsskill-level/beginnerNo background required, self-contained issuetriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions