1.3K Star 2K Fork 3.6K

GVPMindSpore / mindquantum

 / 详情

[CT][MS][mindquantum]Simulator,sim.get_expectation_with_grad,hams的类型校验写成valueerror

DONE
Bug-Report
创建于  
2021-12-11 17:13
name about labels
Bug Report Use this template for reporting a bug kind/bug

Environment

  • Hardware Environment(Ascend/GPU/CPU):

Uncomment only one /device <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/device ascend
/device gpu
/device cpu

  • Software Environment:
    -- MindSpore version (source or binary):
    -- Python version (e.g., Python 3.7.5):
    -- OS platform and distribution (e.g., Linux Ubuntu 16.04):
    -- GCC/Compiler version (if compiled from source):

Related testcase

Steps to reproduce the issue

import numpy as np
from mindquantum import Simulator, Hamiltonian
from mindquantum import Circuit
from mindquantum.core.operators import QubitOperator
circ = Circuit().ry('a', 0)
ham = Hamiltonian(QubitOperator('Z0'))
sim = Simulator('projectq', 1)
grad_ops = sim.get_expectation_with_grad((1,1), circ)
grad_ops(np.array([1.0]))

Describe the current behavior

Simulator,sim.get_expectation_with_grad,hams的类型校验写成valueerror

Describe the expected behavior

改成typeerror

Related log / screenshot

[INFO] PARALLEL(39224,7f54ad687740,python):2021-12-11-17:24:59.090.189 [mindspore/ccsrc/frontend/parallel/costmodel_context.cc:30] GetInstance] Create costmodel_context
[INFO] CORE(39224,7f54ad687740,python):2021-12-11-17:24:59.098.421 [mindspore/core/utils/ms_context.h:236] set_param<std::__cxx11::basic_string >] ms set context device target:CPU
[INFO] CORE(39224,7f54ad687740,python):2021-12-11-17:24:59.183.773 [mindspore/core/utils/ms_context.cc:120] set_backend_policy] ms set context backend policy:ms
Traceback (most recent call last):
File "test.py", line 8, in
grad_ops = sim.get_expectation_with_grad((1,1), circ)
File "/root/miniconda3/envs/wys/lib/python3.7/site-packages/mindquantum/simulator/simulator.py", line 475, in get_expectation_with_grad
raise ValueError(f"hams requires a Hamiltonian or a list of Hamiltonian, but get {type(hams)}")
ValueError: hams requires a Hamiltonian or a list of Hamiltonian, but get <class 'tuple'>
[INFO] PIPELINE(39224,7f54ad687740,python):2021-12-11-17:24:59.913.648 [mindspore/ccsrc/pipeline/jit/init.cc:323] opera

Special notes for this issue

评论 (4)

mu_rong_meng 创建了Bug-Report
mu_rong_meng 添加了
 
kind/bug
标签
mu_rong_meng 添加了device/cpu(已删除)标签
展开全部操作日志

parallel_worker 也是,报错信息还不对 parallel_worker need a integer, but get

校验都不对,自己排查

donghufeng 任务状态TODO 修改为VALIDATION
donghufeng 添加协作者donghufeng
donghufeng 负责人donghufeng 修改为mu_rong_meng
donghufeng 取消协作者donghufeng
donghufeng 里程碑B-MBA 修改为B-ComponentTest

输入图片说明
报错信息写的是circuit_left, 但是文档写的是circ_left

mu_rong_meng 任务状态VALIDATION 修改为DONE
mu_rong_meng 移除了device/cpu(已删除)标签

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(1)
Python
1
https://gitee.com/mindspore/mindquantum.git
git@gitee.com:mindspore/mindquantum.git
mindspore
mindquantum
mindquantum

搜索帮助

344bd9b3 5694891 D2dac590 5694891