本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
示例:将量子任务提交给 QPU
Amazon Braket 允许您在设备上运行量子电路。QPU以下示例说明如何将量子任务提交给 Rigetti 或者 IonQ 设备。
选择 Rigetti Ankaa-2 设备,然后查看相关的连接图
# import the QPU module from braket.aws import AwsDevice # choose the Rigetti device device = AwsDevice("arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2") # take a look at the device connectivity graph device.properties.dict()['paradigm']['connectivity']
{'fullyConnected': False, 'connectivityGraph': {'0': ['1', '7'], '1': ['0', '2', '8'], '2': ['1', '3', '9'], '3': ['2', '4', '10'], '4': ['3', '5', '11'], '5': ['4', '6', '12'], '6': ['5', '13'], '7': ['0', '8', '14'], '8': ['1', '7', '9', '15'], '9': ['2', '8', '10', '16'], '10': ['3', '9', '11', '17'], '11': ['4', '10', '12', '18'], '12': ['5', '11', '13', '19'], '13': ['6', '12', '20'], '14': ['7', '15', '21'], '15': ['8', '14', '22'], '16': ['9', '17', '23'], '17': ['10', '16', '18', '24'], '18': ['11', '17', '19', '25'], '19': ['12', '18', '20', '26'], '20': ['13', '19', '27'], '21': ['14', '22', '28'], '22': ['15', '21', '23', '29'], '23': ['16', '22', '24', '30'], '24': ['17', '23', '25', '31'], '25': ['18', '24', '26', '32'], '26': ['19', '25', '33'], '27': ['20', '34'], '28': ['21', '29', '35'], '29': ['22', '28', '30', '36'], '30': ['23', '29', '31', '37'], '31': ['24', '30', '32', '38'], '32': ['25', '31', '33', '39'], '33': ['26', '32', '34', '40'], '34': ['27', '33', '41'], '35': ['28', '36', '42'], '36': ['29', '35', '37', '43'], '37': ['30', '36', '38', '44'], '38': ['31', '37', '39', '45'], '39': ['32', '38', '40', '46'], '40': ['33', '39', '41', '47'], '41': ['34', '40', '48'], '42': ['35', '43', '49'], '43': ['36', '42', '44', '50'], '44': ['37', '43', '45', '51'], '45': ['38', '44', '46', '52'], '46': ['39', '45', '47', '53'], '47': ['40', '46', '48', '54'], '48': ['41', '47', '55'], '49': ['42', '56'], '50': ['43', '51', '57'], '51': ['44', '50', '52', '58'], '52': ['45', '51', '53', '59'], '53': ['46', '52', '54'], '54': ['47', '53', '55', '61'], '55': ['48', '54', '62'], '56': ['49', '57', '63'], '57': ['50', '56', '58', '64'], '58': ['51', '57', '59', '65'], '59': ['52', '58', '60', '66'], '60': ['59'], '61': ['54', '62', '68'], '62': ['55', '61', '69'], '63': ['56', '64', '70'], '64': ['57', '63', '65', '71'], '65': ['58', '64', '66', '72'], '66': ['59', '65', '67'], '67': ['66', '68'], '68': ['61', '67', '69', '75'], '69': ['62', '68', '76'], '70': ['63', '71', '77'], '71': ['64', '70', '72', '78'], '72': ['65', '71', '73', '79'], '73': ['72', '80'], '75': ['68', '76', '82'], '76': ['69', '75', '83'], '77': ['70', '78'], '78': ['71', '77', '79'], '79': ['72', '78', '80'], '80': ['73', '79', '81'], '81': ['80', '82'], '82': ['75', '81', '83'], '83': ['76', '82']}}
前面的字典connectivityGraph
列出了每个量子比特的相邻量子比特 Rigetti 设备。
选择 IonQ Aria-1 设备
对于 IonQ Aria-1 device,connectivityGraph
为空,如以下示例所示,因为该设备提供all-to-all连接。因此,connectivityGraph
不需要详细说明。
# or choose the IonQ Aria-1 device device = AwsDevice("arn:aws:braket:us-east-1::device/qpu/ionq/Aria-1") # take a look at the device connectivity graph device.properties.dict()['paradigm']['connectivity']
{'fullyConnected': True, 'connectivityGraph': {}}
如以下示例所示,您可以选择调整 shots (默认值=1000)、poll_timeout_seconds
(默认值 = 432000 = 5 天)、poll_interval_seconds
(默认值 = 1)以及存储结果的 S3 存储桶的位置 (s3_location
)(如果您选择指定默认存储桶以外的位置)。
my_task = device.run(circ, s3_location = 'amazon-braket-my-folder', shots=100, poll_timeout_seconds = 100, poll_interval_seconds = 10)
这些区域有:IonQ 以及 Rigetti 设备会自动将提供的电路编译到各自的原生门集中,然后映射摘要 qubit 物理指数 qubits 在相应的QPU。
注意
QPU设备的容量有限。达到容量后,等待时间可能会更长。
Amazon Braket 可以在特定的可用性窗口内运行QPU量子任务,但您仍然可以随时(全天候)提交量子任务,因为所有相应的数据和元数据都可靠地存储在相应的 S3 存储桶中。如下一节所示,您可以使用AwsQuantumTask
和唯一的量子任务 ID 恢复量子任务。