Help me deploy Azure quantum service as a python program.

Alok GV 0 Reputation points
2024-05-31T05:57:46.3+00:00

Hey, I have been following the instructions provided in the link below.

https://learn.microsoft.com/en-in/azure/quantum/how-to-submit-jobs?pivots=ide-python&tabs=tabid-python

my python code :

import qsharp

import azure.quantum

workspace = azure.quantum.Workspace(

resource_id = "myActualId",

location = "location"

)

qsharp.init(project_root = '/myrootfolder')

qsharp.init(target_profile=qsharp.TargetProfile.Base)

MyProgram = qsharp.compile("Sample.RandomNBits(4)")

MyTarget = workspace.get_targets("rigetti.sim.qvm")

job = MyTarget.submit(MyProgram, "MyPythonJob", shots=10)

results = job.get_results()

print("\nResults: ", results)

My source.qs file:

namespace Sample {

operation Random() : Result {

use q = Qubit();

H(q);

let result = M(q);

Reset(q);

return result

}

operation RandomNBits(N: Int): Result[] {

mutable results = [];

for i in 0 .. N - 1 {

let r = Random();

set results += [r];

}

return results

}

}

I'm Getting the following error :

ll_str = get_interpreter().qir(entry_expr)

module.QSharpError: Qsc.Resolve.NotFound

× name error

╰─▶ RandomNBits not found

╭─[<entry>:1:1]

1 │ Sample.RandomNBits(4)

· ───────────

╰────

Qsc.TypeCk.AmbiguousTy

× type error

╰─▶ insufficient type information to infer type

╭─[<entry>:1:1]

1 │ Sample.RandomNBits(4)

· ─────────────────────

╰────

help: provide a type annotation Thanks for your help in advance ,

Azure Quantum
Azure Quantum
An Azure service that provides quantum computing and optimization solutions.
71 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 27,251 Reputation points
    2024-06-02T10:05:37.0466667+00:00

    Hello @Alok GV

    Thank you for reaching out to the Microsoft Q&A platform.

    There is a typo in the example for that article. If you have followed the steps as written and the python file is in the /src folder, you would need to set the project to qsharp.init(project_root = '../../myrootfolder'). Azure quntum product team is working to clarify the steps in that article and republish it.

    If I have answered your query, please click "Accept as answer" as a token of appreciation

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.