Skip to content

【代码贡献】新增 Parameter-Shift 变分量子梯度模块 - #87

Open
tokenjunkielabs wants to merge 16 commits into
OriginQ:developfrom
woahwhattheheck:zz-cindermosaic/origin-cup-parameter-shift-20260920
Open

tokenjunkielabs wants to merge 16 commits into
OriginQ:developfrom
woahwhattheheck:zz-cindermosaic/origin-cup-parameter-shift-20260920

Conversation

@tokenjunkielabs

@tokenjunkielabs tokenjunkielabs commented Sep 20, 2026

Copy link
Copy Markdown

关联 #13(2026 本源杯开源创新赛道|代码贡献)。

概要

新增 pyqpanda_alg/ParameterShift,为变分量子算法提供后端无关的解析参数移位梯度层,避免把梯度逻辑绑死到单一本地模拟器。

主要内容

  • 通用双本征值生成元参数移位规则;RX/RY/RZ 默认规则为 1/2[f(θ+π/2)-f(θ-π/2)],并支持不同 spectral gap;
  • build_shift_schedule 将所有移位参数点显式化,便于 CPUQVM、QCloud 或真实 QPU 做批量提交;
  • ParameterShiftSchedule.reconstruct 可从远端返回结果重建完整 Jacobian,并为冻结参数保留零行;
  • 同时提供标量 gradient、向量/tensor Jacobian 与 VJP 接口;
  • evaluate_shift_batch 支持一次远端调用执行整批移位点;
  • 参数、规则、索引、返回 shape 与有限值均做 fail-fast 校验;
  • 新增公开包导出、使用文档、纯函数示例与聚焦回归源。

该设计把“生成要执行的量子任务”和“从结果重建梯度”拆开,使同一 API 可用于本地模拟和远程硬件工作流。

Exact owner head: 632b4abfdef3872607db08186643dd576abf1d90.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants