Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Créez et soumettez un exemple de tâche quantique OpenQASM 3.0
Vous pouvez utiliser le SDK Amazon Braket Python, Boto3 ou le pour envoyer des tâches quantiques OpenQASM 3.0 AWS CLI à un appareil Amazon Braket.
Dans cette section :
Exemple de programme OpenQASM 3.0
// ghz.qasm // Prepare a GHZ state OPENQASM 3; qubit[3] q; bit[3] c; h q[0]; cnot q[0], q[1]; cnot q[1], q[2]; c = measure q;
Utilisez le SDK Python pour créer des tâches quantiques OpenQASM 3.0
Vous pouvez utiliser le SDK Amazon Braket Python
with open("ghz.qasm", "r") as ghz: ghz_qasm_string = ghz.read() # Import the device module from braket.aws import AwsDevice # Choose the Rigetti device device = AwsDevice("arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-3") from braket.ir.openqasm import Program program = Program(source=ghz_qasm_string) my_task = device.run(program) # Specify an optional s3 bucket location and number of shots s3_location = ("amzn-s3-demo-bucket", "openqasm-tasks") my_task = device.run( program, s3_location, shots=100, )
Utilisez Boto3 pour créer des tâches quantiques OpenQASM 3.0
Vous pouvez également utiliser le SDK AWS Python pour Braket (Boto3)
import boto3 import json my_bucket = "amzn-s3-demo-bucket" s3_prefix = "openqasm-tasks" with open("ghz.qasm") as f: source = f.read() action = { "braketSchemaHeader": { "name": "braket.ir.openqasm.program", "version": "1" }, "source": source } device_parameters = {} device_arn = "arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-3" shots = 100 braket_client = boto3.client('braket', region_name='us-west-1') rsp = braket_client.create_quantum_task( action=json.dumps( action ), deviceParameters=json.dumps( device_parameters ), deviceArn=device_arn, shots=shots, outputS3Bucket=my_bucket, outputS3KeyPrefix=s3_prefix, )
Utilisez le AWS CLI pour créer des tâches OpenQASM 3.0
La AWS Command Line Interface (CLI)
aws braket create-quantum-task \ --region "us-west-1" \ --device-arn "arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-3" \ --shots 100 \ --output-s3-bucket "amzn-s3-demo-bucket" \ --output-s3-key-prefix "openqasm-tasks" \ --action '{ "braketSchemaHeader": { "name": "braket.ir.openqasm.program", "version": "1" }, "source": $(cat ghz.qasm) }'