Skip to content

Introduce new Executor primitive incorporating samplomatic semantics#78

Draft
delapuente wants to merge 23 commits into
Qiskit:masterfrom
delapuente:patch-1
Draft

Introduce new Executor primitive incorporating samplomatic semantics#78
delapuente wants to merge 23 commits into
Qiskit:masterfrom
delapuente:patch-1

Conversation

@delapuente
Copy link
Copy Markdown

@delapuente delapuente commented Aug 14, 2025

This RFC proposes the introduction of a new Executor primitive into Qiskit as a vendor-agnostic substrate for execution. The Executor provides three core components—Executor, ExecutorProgram, and ExecutorResult—that capture the relationship between a programming model engine, its semantics, and its results.

The immediate motivation is to make randomization semantics for error mitigation explicit and first-class in Qiskit. Today, such workflows are implicit and opaque; this RFC standardizes how users express their intent through annotations and portable representations. This enables reproducibility, fine-grained control, and composability, while letting providers implement and optimize their own expansion engines.

This RFC does not introduce a specific engine such as IBM’s Samplomatic into Qiskit. Instead, it defines the substrate and user-intent representation, leaving execution engines to providers. Follow-up RFCs may propose additional semantics, a reference Executor, or reimplementations of existing primitives (e.g., Sampler and Estimator) atop this foundation.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 14, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Member

@garrison garrison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread 0023-low-level-sampler.md Outdated
Comment thread 0023-low-level-sampler.md Outdated
Comment thread 0023-low-level-sampler.md Outdated
Comment thread 0023-low-level-sampler.md Outdated
offers two such primitives: the Sampler and the Estimator. The Estimator
leverages advanced error mitigation techniques to enhance the quality of
results from noisy quantum computers. On a noiseless quantum computer, the
Estimator could instead be constructed atop the Sampler, simplifying its role.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of the Estimator extends beyond just mitigating noise. It also adds a layer abstraction around the concept of estimating observables, allowing implementors of Estimator interfaces to offer different methods for observable estimation (e.g. classical shadows) while preserving a common interface.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will include this as part of the explanation of the Estimator purpose.

Comment thread 0023-low-level-sampler.md Outdated
Comment thread 0023-low-level-sampler.md Outdated
Comment on lines +21 to +22
inefficient, but this can be optimized using a "samplex" — a domain-specific
language (DSL) program describing the way of producing these variations. The
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of a "samplex" as a DSL is odd. It feels more like a data structure than a DSL to me. Is this RFC going to include a section on sampling graphs?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always compared the sampling graph as data transformation steps but I may be missing insight that would translate in a more natural explanation of the sampling process. I'll investigate about it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The system of decorating boxes with twirling annotations feels like a DSL. The samplex is a graphical representation of circuit transformations.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I made the language and the control flow graph the same but that's a non-trivial leap and separating those concepts would make it more clear. Let me work on the rewording.

Comment thread 0023-low-level-sampler.md Outdated
Comment thread 0023-low-level-sampler.md Outdated
Copy link
Copy Markdown
Contributor

@blakejohnson blakejohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This RFC seems to introduce 3 concepts:

  1. Sampling graphs (samplex)
  2. Executor primitive
  3. QuantumProgram data structure

However, (2) and (3) aren't described at all beyond their appearance in the example. (1) gets the most motivating text, but the RFC doesn't actually say enough about what it is beyond something that produces circuit variations.

In short, this looks rather incomplete at this stage.

Co-authored-by: Blake Johnson <blakejohnson04@gmail.com>
Comment thread 0023-low-level-sampler.md Outdated
Comment on lines +20 to +21
variations. Transmitting these variations across cloud environments is
inefficient, but this can be optimized using a "samplex" — a domain-specific
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this summary doesn't really capture the problem we are trying to solve. It reads as if the problem was this data transfer being inefficient. But we already solved that problem with Qiskit Runtime - i.e. by generating all the parameters on the server side. The problem is really that the existing Qiskit Runtime solution does not offer the transparency and flexibility users want.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rationale to justify this way is as follows:

If we would not have the data bandwidth problem, we could give the user a bare sampling primitive, and let them do the sampling of the noise model, and the parameter linkage on the client side. Instead, we offer a way of describing the sampling process so we transmit a "compact" summary of the process.

However, I agree with you when saying Samplomatic, and the samplex, do not solve the bandwidth problem: any other sampling graph would accomplish the same. Samplomatic offers a sound framework for sampling, and the fact that is open source accounts for the transparency we were looking for. Do you think this goes more in the direction of your expectation?

Comment thread 0023-low-level-sampler.md Outdated
Comment on lines +30 to +31
Users and researchers seek finer control over these techniques to improve the
reliability of quantum computations, especially on noisy quantum hardware.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence reads a bit odd to me. I think it'd help to provide concrete examples - e.g. people want to experiment combining different EM methods (like PEA + PEC), or they want to apply different scale to different parts of their circuits to reduce cost.

Copy link
Copy Markdown
Author

@delapuente delapuente Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a very good idea, would you mind suggesting the changes, please?

Comment thread 0023-low-level-sampler.md Outdated
Comment on lines +37 to +38
transmitting thousands or millions of circuit variations. By shifting variation
generation to the backend through a portable DSL, researchers can run advanced
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we are not shifting this. Variation generation is already done on the server side, at least for Qiskit Runtime. Performance is not the problem we are trying to solve. It's just something we need to consider when solving the real problem.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. When I review the previous argument, I will update this as well.

Comment thread 0023-low-level-sampler.md Outdated
Comment on lines +41 to +43
Today, Qiskit users can already run large-scale error mitigation experiments,
but the process is **implicit** — it is difficult to explain and difficult to
compose, and users have no direct control over how circuit variations are
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a Qiskit Runtime problem, not a Qiskit problem. Mitiq, for example, does their error mitigation on the client side. But then that solution hits the performance issue you described. So samplex is really a solution to address both transparency/flexibility + performance concerns.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. I will rephrase in terms of a vendor-agnostic challenge and see how Qiskit can help in mitigating that challenge.

Comment thread 0023-low-level-sampler.md Outdated
# Prepare circuit for executing
template, samplex = samplex.build()

with Session(backend=backend) as session:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session is a Qiskit Runtime only concept, so it's a bit odd to show up in this example. I believe the reason is to ensure there is no long gap between learning and mitigation... but how would other vendors that don't support Session solve this issue?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope of this RFC does not include solving the drifting issue. However, I wanted to highlight some mechanism is needed if wanting to keep learning, and sampling close.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree solving this issue is out of the scope. But it's probably worth mentioning this is a potential issue introduced by this new interface.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now addressed in its own section.

Comment thread 0023-low-level-sampler.md Outdated
Comment on lines +86 to +89
# The proposal wants to acknowledge the transtionary reality in which the
# primitives continue being the entry point for operating the quantum computer
# and this is a low level interface for advanced usage.
from qiskit.primitives.implementation import QuantumProgram, Executor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean? The title of the RFC says "low level Sampler", so is this Executor a replacement of Sampler? Yet here it seems to imply the primitives (sampler and estimator) are not going away ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Executor is the low level sampler. When I started the RFC branch, I called it that way, and then Ian came with the Executor name.

Yet here it seems to imply the primitives (sampler and estimator) are not going away ?

Yes, they are not going away. The fact the Executor is in an implementation package is my attempt to mitigate your concern regarding primitives going away. It was my understanding we don't want them to go away but to expose a "low-level interface".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Executor is the low level sampler.

Perhaps the word sampler is overloaded here. If I understand you correctly, Executor is not an implementation of the sampler primitive - i.e. it does not implement the Sampler interface defined in Qiskit. It is, however, a program that does sampling, hence it's a lower level "sampler".

If this is correct, I'd still avoid calling it a low level sampler. Otherwise people might be confused thinking it's an implementation of the existing sampler interface.

Comment thread 0023-low-level-sampler.md Outdated
Comment thread 0023-low-level-sampler.md Outdated
@delapuente delapuente changed the title Introduce low level sampler (a.k.a. Executor) primitive incorporating samplomatic semantics Introduce new Executor primitive incorporating samplomatic semantics Aug 19, 2025
Comment thread 0023-executor-primitive.md Outdated
Comment on lines +15 to +20
The Estimator leverages advanced error mitigation techniques to enhance the quality
of results from noisy quantum computers. On a noiseless quantum computer, the
Estimator could instead be constructed atop the Sampler, simplifying its role.
However, given current noise levels, robust error mitigation is essential,
requiring executing thousands or even millions of circuit variations to implement
certain mitigation protocols. Transmitting these variations across cloud environments
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should distinguish between the estimator abstraction, which says nothing about mitigation, and our IBM hardware implementation---the primitives service---that has options to enable it.

Comment thread 0023-executor-primitive.md Outdated
# The proposal wants to acknowledge the transtionary reality in which the
# primitives continue being the entry point for operating the quantum computer
# and this is a low level interface for advanced usage.
from qiskit.primitives.implementation import QuantumProgram, Executor
Copy link
Copy Markdown
Contributor

@ihincks ihincks Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that the Executor in this snippet will need to come from qiskit-ibm-runtime instead: it needs to do things like POST to our service.

Instead, base class like BaseExecutor would like in the SDK proper.

I'm also wondering how this might all fit in with BackendV3, @ElePT , @jakelishman , @mtreinish : we might consider not having an Executor at all and reverting to something more like backend.run(). In this case we might need to have different semantics for sessions/batches than we have today.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that the Executor will need to come from qiskit-ibm-runtime instead: it needs to do things like POST to our service.

They need to, same as sampler and estimator.

I'm also wondering how this might all fit in with BackendV3, @ElePT , @jakelishman , @mtreinish : we might consider not having an Executor at all and reverting to something more like backend.run(). In this case we might need to have different semantics for sessions/batches than we have today.

I think this requires understanding how this proposal affects the "primitives model" of execution we currently have. Will this replace the primitives? complement the primitives? I don't know how we could reasonably justify reverting to backend.run() if the sampler and estimator primitives continue existing...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not incompatible, in a timeline. Let's introduce the Executor first, then figure out if this way of operating could establish a new compute model. This idea is explored in Future extensions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm going to try to imitate the RFC for the Estimator in which the imports are not displayed, and elaborate on the concepts, then we can think of a strategy for adding this to Qiskit.

Comment thread 0023-executor-primitive.md Outdated

## Future Extensions

The introduction of a low‑level sampler is only the first step. The long‑term
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The introduction of a low‑level sampler is only the first step. The long‑term
The introduction of a low‑level sampler (called an executor) is only the first step. The long‑term

Comment thread 0023-executor-primitive.md Outdated
Comment thread 0023-executor-primitive.md Outdated
Comment thread 0023-executor-primitive.md Outdated
Vendors like IBM have identified that users desire capabilities for precise
noise learning, twirling, and expectation value calculations.

This proposal will enable Qiskit users to perform large-scale, backend-optimized
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to be precise... this would be Qiskit IBM Runtime users. But I think it's ok to use the broader sense of Qiskit here.

Copy link
Copy Markdown
Author

@delapuente delapuente Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important. For landing in Qiskit, the new primitive needs to be of utility for vendor-agnostic users. I'd say we need an abstraction for the samplex. Even if it is pure definition. Once the correct abstractions are out there, I can think of other providers implementing different ways of creating samplex-like objects for their specific implementations. Don't you think?

Comment thread 0023-executor-primitive.md Outdated
# The proposal wants to acknowledge the transtionary reality in which the
# primitives continue being the entry point for operating the quantum computer
# and this is a low level interface for advanced usage.
from qiskit.primitives.implementation import QuantumProgram, Executor
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that the Executor will need to come from qiskit-ibm-runtime instead: it needs to do things like POST to our service.

They need to, same as sampler and estimator.

I'm also wondering how this might all fit in with BackendV3, @ElePT , @jakelishman , @mtreinish : we might consider not having an Executor at all and reverting to something more like backend.run(). In this case we might need to have different semantics for sessions/batches than we have today.

I think this requires understanding how this proposal affects the "primitives model" of execution we currently have. Will this replace the primitives? complement the primitives? I don't know how we could reasonably justify reverting to backend.run() if the sampler and estimator primitives continue existing...

delapuente and others added 3 commits August 22, 2025 14:23
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Refactor the description of the samplex DSL for clarity and consistency. Improve the explanation of its role in error mitigation and its benefits for users and developers.
Delve into the key concepts of the Executor primitive, and its relation with samplex annotation and the samplex data structure.
Clarify the reasoning behind the decision to avoid saving user-generated samplex in the client and emphasize the importance of local generation for inspectability and debuggability.
@1ucian0 1ucian0 added the RFC proposal New RFC is proposed label Sep 8, 2025
Reframe to balance focus on the Executor primitive as a programming model, and introducing randomization semantics in Qiskit.
Refine the demo and detailed design of the RFC.
Comment thread 0023-executor-primitive.md Outdated
Comment thread 0023-executor-primitive.md Outdated
Comment on lines +267 to +273
An alternative to introducing the **samplex** DAG is to generate all circuit
variations entirely on the client side and transmit them to the backend for
execution. This approach offers maximum flexibility and complete control over
how variations are produced, since the backend would simply execute the
provided circuits without influencing their structure. Users could implement
any custom error mitigation workflow they wish, with no restrictions imposed by
backend capabilities or vendor‑specific optimizations.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is be another, more efficient alternative to "[generating] all circuit
variations entirely on the client side," which is to simply generate templates and parameters. However, a benefit of the samplex is that it allows generating parameters "on the fly:" vendors can set up their stack in such a way that their QPU can execute a set of parameters while a new set of parameters is being generated by the samplex. This can significantly speed up execution, with respect to both alternatives

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not realize passing the samplex enabled lazy generation. Thank you.

delapuente and others added 2 commits September 23, 2025 10:14
Co-authored-by: Samuele Ferracin <sam.ferracin@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFC proposal New RFC is proposed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants