範例:將量子任務提交至 QPU - Amazon Braket

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

範例:將量子任務提交至 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列出 中每個 qubit 的鄰近 qubit Rigetti 裝置。

選擇 IonQ Aria-1 裝置

對於 IonQ Aria-1 裝置為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 可以在特定可用時段內執行量子任務,但您仍然可以隨時提交量子任務 (24/7),因為所有對應的資料和中繼資料都可靠地存放在適當的 S3 儲存貯體中。如下一節所示,您可以使用 AwsQuantumTask和唯一的量子任務 ID 來復原量子任務。