Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Qiskit job result missing attributes cause wrong exception when job fails in VQE

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

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
azure, python

调研方向

从 azure/quantum/qiskit/job.py 中 issue 提及的 result_dict 构造部分开始,并将其输出与 Qiskit Result 的预期进行比较。复现 VQE job 失败的场景,然后验证生成的错误信息可以通过预期的结果属性获取,同时不影响成功的 job。

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

描述

If running the VQE sample and it fails to run on a quantum_instance (for instance, if Quantinuum is out of credits), then instead of printing the error code and message, it prints that an attribute "status" could not be found.

image

It looks like this is throwing from when it tries to read result.status from run_circuits.py.

Looking at the latest definition of Result object in qiskit, it looks like for the error_data message to be shown, we should encode the error_data into status field as well.

This is where we encode job result into Qiskit result as part of azure-quantum: https://github.com/microsoft/qdk-python/blob/944fac0ee64e962b65b73f29635a2c65abf332d7/azure-quantum/azure/quantum/qiskit/job.py#L93

Current:

result_dict = {
            "results" : [results],
            "job_id" : self._azure_job.details.id,
            "backend_name" : self._backend.name(),
            "backend_version" : self._backend.version,
            "qobj_id" : self._azure_job.details.name,
            "success" : success,
            "error_data" : None if self._azure_job.details.error_data is None else self._azure_job.details.error_data.as_dict()
}

Proposed change:

error_msg = None if self._azure_job.details.error_data is None else self._azure_job.details.error_data.as_dict()
result_dict = {
            "results" : [results],
            "job_id" : self._azure_job.details.id,
            "backend_name" : self._backend.name(),
            "backend_version" : self._backend.version,
            "qobj_id" : self._azure_job.details.name,
            "success" : success,
            "error_data" : error_msg,
            "status": error_msg,
}

We may optionally want to add the other missing attributes on Qiskit result that are currently not populated, such as date, header, in case they also cause errors down the road.
主要语言
Python
星标
160
派生
113
平均合并
6 天 23 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

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

microsoft/azure-quantum-python 的其他 Issue

查看 microsoft/azure-quantum-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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