Avoid statevector copy in `qsim.simulate(qc, initial_state=sv)`

未关闭
#617 12 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
34/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp, python
领域
api, performance

调研方向

The copy happens in init_state() in pybind_interface/pybind_main.cpp, near the line the issue links (around line 695-701), when simulate is given an initial_state. Read how that state is passed into the simulator and whether the simulator can reference the caller's buffer without taking ownership. Done means the initial state is no longer copied on this path, and the existing Python tests for initial_state still pass. The thread has been unanswered for about three years, so confirm the approach with maintainers first.

由索引模型根据 Issue 内容生成。

描述

a: c++ a: performance a: python contributors welcome no QC knowledge needed

I have a use case where I am simulating my circuit piece by piece so using the ability to pass an initial state to qsim is very handy.
However I have noticed this makes a copy of the initial_state here:

Is there a way to avoid the expensive copy?
If there is a little patch that can be applied (I assume couple of lines in void init_state() should do it) I would be happy to apply it locally and re-build qsim.

Thanks!

主要语言
C++
星标
702
派生
219
平均合并
1 天 2 小时
30 天内合并 PR
8

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

quantumlib/qsim 的其他 Issue

查看 quantumlib/qsim 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。