Job operations are not parallelizable
还没有人认领这个 Issue。
评估
调研方向
首先使用 exec_job 运行报告中的 multiprocessing.Pool 示例,然后跟踪 SimulatedBifurcationMachine 使用的 solver.submit() 和 job.get_results() 入口点。比较两个 worker 的时间戳,并确定提交或结果检索在哪里变成串行。完成的标准是,独立的 job 可以在没有观察到的数分钟延迟的情况下同时提交和处理。
由索引模型根据 Issue 内容生成。
描述
I'm trying to submit and process results of multiple jobs in parallel but I'm noticing that, in many cases, jobs are submitted sequentially.
import datetime
import imp
from multiprocessing import Pool
from azure.quantum import Workspace
from azure.quantum.optimization import Problem, ProblemType, Term
from azure.quantum.target.toshiba import SimulatedBifurcationMachine
import logging
def create_problem():
problem = Problem('Test_Problem', problem_type=ProblemType.pubo)
problem.add_terms([
Term(c=1, indices=[]),
Term(c=2, indices=[1, 2]),
Term(c=-3, indices=[1, 2]),
Term(c=1, indices=[0, 2])
])
return problem
def exec_job(no):
workspace = Workspace (
resource_id = "<workspace-id>",
location= "<location>"
)
problem = create_problem()
solver = SimulatedBifurcationMachine(workspace, loops=0, timeout=10)
print(str(datetime.datetime.utcnow()), "\t[%d] solver.submit() start" % no)
job = solver.submit(problem)
print(str(datetime.datetime.utcnow()), "\t[%d] job.id=%s" % (no, str(job.id)))
print(str(datetime.datetime.utcnow()), "\t[%d] job.get_results() start" % no)
result = job.get_results()
print(str(datetime.datetime.utcnow()), "\t[%d] job.details=%s" % (no, str(job.details)))
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
njobs = 2
with Pool(processes=njobs) as pool:
pool.map(func=exec_job, iterable=range(njobs))
For the above, output is:
2022-04-21 18:40:23.466530 [0] solver.submit() start
2022-04-21 18:40:23.542727 [1] solver.submit() start
2022-04-21 18:40:28.752803 [1] job.id=810bc3bb-c1a2-11ec-baa1-b831b575aea6
2022-04-21 18:40:28.752803 [1] job.get_results() start
..........2022-04-21 18:40:52.826348 [1] job.details={..........}
2022-04-21 18:44:19.108243 [0] job.id=81018a8e-c1a2-11ec-adf4-b831b575aea6
2022-04-21 18:44:19.109211 [0] job.get_results() start
..........2022-04-21 18:44:42.799796 [0] job.details={..............}
You can see that job 1 was submitted and awaited while job 0 hasn't been submitted at the same time and was done 4 mins after the first job.
- 主要语言
- Python
- 星标
- 160
- 派生
- 113
- 平均合并
- 6 天 23 小时
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/azure-quantum-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 38/100
-
Export types 未关闭
难度 2/5 1-3 小时 新手友好度 55/100
-
难度 4/5 3-5 天 新手友好度 38/100
microsoft/azure-quantum-python#650 · 1 条评论 ·
-
azure-quantum
难度 2/5 1-3 小时 新手友好度 20/100
查看 microsoft/azure-quantum-python 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 70/100
huggingface/Repo2RLEnv#163 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
难度 2/5 1-3 小时 新手友好度 70/100
NousResearch/hermes-agent#121143 ·