question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adds a fake session to primitives

See original GitHub issue

What should we add?

The base classes, reference implementations, and backend implementations of primitives do not take a session while qiskit-ibm-runtime version of primitives takes session to reduce latency. Here is a sample code of runtime estimator with session.

        with Session(service=service, backend="ibmq_qasm_simulator") as session:
            estimator = Estimator(session=session)
            theta1 = [0, 1, 1, 2, 3, 5]
            # calculate [ <psi1(theta1)|H1|psi1(theta1)> ]
            psi1_H1 = estimator.run(circuits=[psi1], observables=[H1], parameter_values=[theta1])
            print(psi1_H1.result())

If users implement algorithms with the base class or reference impl of primitives, the code cannot take advantage of session when they replace the primitives with the runtime version. If users implement algorithms with runtime primitives, they need to adjust the code to test their implementation using the reference impl. So, it would be useful to introduce a fake session and extend the base classes of primitives to take the fake session as an argument.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jakelishmancommented, Nov 16, 2022

the rest of the primitive usage is (should be) fully consistent and through the defined API.

I should be clearer on this point: I mean that all the running of circuits on primitives is a defined part of the API, and so this code should look the same no matter what Estimator is used, but the actual constructor of an Estimator isn’t part of the interface, so it’s totally normal for it to look a bit different between implementations.

If there is meant to be a single defined construction method, then this needs formalising into an API that everyone can implement. For the Backend path, such a factory class is (approximately) Provider, as an example. I personally don’t see a need for a unified construction interface here (I think they generally don’t reduce any complexity, they just move it to the construction of a different object), but I’m not the best person to design the UX of these interfaces.

1reaction
t-imamichicommented, Nov 16, 2022

Thank you for your comment, Jake. I ask @adekusar-drl to describe the details of this request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

what is the best way to mock window.sessionStorage in jest
You probably do not even need a mock. Just use window.sessionStorage as usual and write your condition based on window.sessionStorage.getItem(..
Read more >
Chapter 3. Hello Spark: primitives, components, FXG and ...
In this workshop session, we'll start work with the primitives that are the basic building block classes used by Spark components. (When I...
Read more >
Is it possible to fake session variables? - PHP - SitePoint Forums
I was just wondering if malicious users are able to fake session variables? When a user logs on, I assign a session var...
Read more >
Communication Primitives in Deep Learning Frameworks
Using TensorFlow API you would add “while not succeeded:” loops like these on operations such as session creation and run commands that catch ......
Read more >
R Internals
Primitive. 2.1 Special primitives; 2.2 Special internals; 2.3 Prototypes for primitives; 2.4 Adding a primitive. 3 Internationalization in the R sources.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found