Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
356 commits
Select commit Hold shift + click to select a range
838aad5
changes from review
beckykd Feb 23, 2026
05794d2
There is no precedence section!
beckykd Feb 24, 2026
7cceeda
Merge branch 'main' into bd-new-toc
beckykd Feb 24, 2026
e8f53a7
links should have the full path
beckykd Feb 24, 2026
d11b950
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Feb 24, 2026
5a9020e
Move stuff around
beckykd Feb 24, 2026
72957ee
Apply suggestions from code review
beckykd Feb 24, 2026
1a0fce3
merge conflicts
beckykd Feb 24, 2026
2a32a94
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Feb 26, 2026
745a26c
links
beckykd Feb 26, 2026
d07207e
squeaky clean
beckykd Feb 26, 2026
51dcbfc
Marry pubs and broadcasting topics
beckykd Feb 26, 2026
23d6da9
Update _toc.json
beckykd Feb 26, 2026
daae80d
Clean up the options overview
beckykd Feb 26, 2026
dfe2005
fix twisties
beckykd Feb 27, 2026
3339461
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Feb 27, 2026
ff86adb
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Feb 27, 2026
2963cf5
untangle toc
beckykd Feb 27, 2026
085d209
AC comments
beckykd Feb 27, 2026
b282918
title mismatch
beckykd Mar 2, 2026
460a27c
Capitalization
beckykd Mar 2, 2026
2a3d781
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Mar 2, 2026
4b68a9c
links
beckykd Mar 2, 2026
feb7505
Something fun
beckykd Mar 2, 2026
e565670
typo
beckykd Mar 2, 2026
b915ddb
Add PEA example
beckykd Mar 3, 2026
dd5f006
links
beckykd Mar 3, 2026
5a0d8c3
yarghhh
beckykd Mar 4, 2026
41e909f
remove unused images
beckykd Mar 5, 2026
6675bd4
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Mar 6, 2026
9bdfbe3
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Mar 23, 2026
ca41e55
Pull in all updates, make copies of files previously modified
beckykd Mar 23, 2026
7a97913
put modified filkes in a different folder
beckykd Mar 23, 2026
aaa4c78
updates from previous work
beckykd Mar 24, 2026
88064be
Use full link path
beckykd Mar 24, 2026
ed28c49
Move periods outside links
beckykd Mar 24, 2026
d6893e8
Fix TOC
beckykd Mar 24, 2026
f3e8b90
fix links
beckykd Mar 24, 2026
64529b3
links
beckykd Mar 24, 2026
7942159
remove file
beckykd Mar 24, 2026
eb393e9
broken link
beckykd Mar 24, 2026
8e49e8f
link
beckykd Mar 24, 2026
8ceec65
replace pubs-broadcasting with primitives-input-output
beckykd Mar 25, 2026
1578621
linx
beckykd Mar 25, 2026
05786cb
edits
beckykd Mar 25, 2026
bd9f3bb
link
beckykd Mar 26, 2026
db6e971
fix the bot
beckykd Mar 26, 2026
800bbf2
fix
beckykd Mar 26, 2026
35bc9ae
Merge branch 'main' into bd-new-toc
beckykd Mar 26, 2026
87a1a9b
edits
beckykd Mar 27, 2026
14f6a34
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Mar 27, 2026
b532dd0
Merge branch 'main' into bd-new-toc
beckykd Mar 27, 2026
e4e74fe
no executor in qiskit
beckykd Mar 30, 2026
e5e656e
clean up input output topics
beckykd Mar 30, 2026
4dc0136
squeaky clean!
beckykd Mar 30, 2026
932f805
fix notebook tester
beckykd Mar 31, 2026
50a4f24
Apply suggestions from code review
beckykd Mar 31, 2026
46f0be9
change to notebook for testing
beckykd Mar 31, 2026
bd23a6d
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Mar 31, 2026
2acb0ec
review comments
beckykd Mar 31, 2026
0ff98e1
review comments
beckykd Apr 6, 2026
031a6aa
finish updates from reviews
beckykd Apr 6, 2026
2e61549
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 6, 2026
5144be3
execution modes
beckykd Apr 6, 2026
1f04c79
unused
beckykd Apr 6, 2026
8469233
title mismatches
beckykd Apr 7, 2026
dfc664d
Fix code
beckykd Apr 7, 2026
ff65393
spelling
beckykd Apr 7, 2026
c7c974e
Merge branch 'main' into bd-new-toc
abbycross Apr 7, 2026
7dce5d9
./fix
abbycross Apr 7, 2026
4fae164
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 7, 2026
0eed48f
tox e fix
beckykd Apr 7, 2026
ccab48d
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 7, 2026
448ff1a
fix notebook code LIKE A BOSS
beckykd Apr 7, 2026
81fdff2
merge
beckykd Apr 8, 2026
83668e1
Squeaky clean!
beckykd Apr 8, 2026
df3152a
update executor options info
beckykd Apr 8, 2026
b82ab34
links
beckykd Apr 8, 2026
b864abb
update notebook so it runs
beckykd Apr 8, 2026
5519fdf
Squeaky clean - again?
beckykd Apr 8, 2026
212ce10
last readthrough
beckykd Apr 8, 2026
b06d448
typo
abbycross Apr 8, 2026
7c0a419
squeaky clean again
beckykd Apr 9, 2026
6da51a1
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 9, 2026
c638a97
Make sure sampler-examples notebook runs on a test device.
beckykd Apr 9, 2026
b8bde93
move more to test system
beckykd Apr 9, 2026
0426af7
more notebooks can be simulated
beckykd Apr 9, 2026
8e239a3
Apply suggestions from code review
beckykd Apr 9, 2026
d8aaaa9
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 9, 2026
450119f
broadcasting topic needs pseudocode
beckykd Apr 10, 2026
e32c7aa
take out i/o
beckykd Apr 10, 2026
bccf5a1
maybe cards
beckykd Apr 13, 2026
cb28e20
move backend out of Runtime
beckykd Apr 13, 2026
ccc2994
no links in cards
beckykd Apr 13, 2026
7da5730
quick shortening
beckykd Apr 13, 2026
c469abe
change cards
beckykd Apr 13, 2026
207aad2
Merge branch 'main' into bd-new-toc
beckykd Apr 13, 2026
94048bd
cards
beckykd Apr 13, 2026
43afce3
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 13, 2026
3e76e18
comments
beckykd Apr 13, 2026
166c242
comments
beckykd Apr 14, 2026
ce28ed3
links
beckykd Apr 14, 2026
a169b0f
tox e fix
beckykd Apr 14, 2026
8c784f7
execution-spans
beckykd Apr 14, 2026
eb59897
execution spans
beckykd Apr 14, 2026
b2b879e
typo
beckykd Apr 14, 2026
d0c052a
tox e fix
beckykd Apr 14, 2026
a8088dd
edits
beckykd Apr 14, 2026
e502ccd
fix notebook
beckykd Apr 14, 2026
2622697
fix execution span example
beckykd Apr 14, 2026
711f878
squeaky
beckykd Apr 14, 2026
c4d90db
edits
beckykd Apr 14, 2026
8f41abf
Update docs/guides/get-started-with-estimator.ipynb
beckykd Apr 15, 2026
00e8738
Update docs/guides/qiskit-runtime-primitives.mdx
beckykd Apr 15, 2026
c6b4684
Just one more little change
beckykd Apr 15, 2026
0b9fd4e
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 15, 2026
925a7d9
change examples to use batch
beckykd Apr 15, 2026
5a26684
links
beckykd Apr 15, 2026
1c4335a
title mismatch
beckykd Apr 15, 2026
360f84a
I'm losing my mind
beckykd Apr 15, 2026
f1e1759
spelling
beckykd Apr 15, 2026
e72f790
spell
beckykd Apr 15, 2026
289dd5b
squeaky clean
beckykd Apr 16, 2026
91b6830
code fix
beckykd Apr 16, 2026
0e5e85d
squeaky
beckykd Apr 16, 2026
b8de0d4
edits
beckykd Apr 16, 2026
97666e8
only one table
beckykd Apr 16, 2026
6a36568
edits
beckykd Apr 16, 2026
95c23a7
squeaky
beckykd Apr 16, 2026
029778c
add one more link
beckykd Apr 16, 2026
c1b9bec
Add example
beckykd Apr 16, 2026
7d261b0
fix titles
beckykd Apr 16, 2026
a429c98
Fix metadata
beckykd Apr 16, 2026
ea6c3a8
run again
beckykd Apr 17, 2026
df582d3
rerun notebook
beckykd Apr 17, 2026
ad52710
delete unused imates
beckykd Apr 17, 2026
e4449af
Update get-started-with-executor.ipynb
beckykd Apr 17, 2026
5f3c95e
update example
beckykd Apr 17, 2026
4b6c5cc
don't need to import numpy
beckykd Apr 17, 2026
f5f1e45
squeaky clean
beckykd Apr 17, 2026
1022f5c
Merge branch 'main' into bd-new-toc
abbycross Apr 17, 2026
1674a2b
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 17, 2026
8194a9e
tox -e fix
abbycross Apr 17, 2026
79991f9
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
abbycross Apr 17, 2026
4824906
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 17, 2026
b9a614b
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 20, 2026
94c5ca1
Apply suggestions from code review
beckykd Apr 21, 2026
bb93560
Apply suggestions from code review
beckykd Apr 21, 2026
b9c9bda
Review changes
beckykd Apr 21, 2026
30cc721
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 21, 2026
2be0be6
Apply suggestions from code review
beckykd Apr 21, 2026
188777b
Apply suggestions from code review
beckykd Apr 21, 2026
f35e115
Revamp get started
beckykd Apr 21, 2026
43c9011
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 21, 2026
1008b86
Apply suggestions from code review
beckykd Apr 21, 2026
3bb9ea8
Comments from Sam
beckykd Apr 21, 2026
cedf9fb
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 21, 2026
dbf74dd
squeaky
beckykd Apr 22, 2026
9c03fbe
circuit transpilation settings submits jobs
beckykd Apr 22, 2026
1ced9dd
Update docs/guides/executor-input-output.mdx
beckykd Apr 22, 2026
7799ec0
Update docs/guides/executor-input-output.mdx
beckykd Apr 22, 2026
31846be
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 23, 2026
9c06842
get rid of executor
beckykd Apr 23, 2026
310d1ca
fix links
beckykd Apr 23, 2026
f2a6d91
links
beckykd Apr 23, 2026
83ceafe
update all the files
beckykd Apr 23, 2026
c6a5578
fix link
beckykd Apr 23, 2026
4399f2d
remove executor images
beckykd Apr 23, 2026
741efbb
ignore title mismatches
beckykd Apr 23, 2026
a277513
update setup files
beckykd Apr 23, 2026
176b2b3
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 23, 2026
4a9b51b
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 23, 2026
237d70d
Update qiskit_bot.yaml
beckykd Apr 23, 2026
f7f6290
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 23, 2026
9814670
remove unwanted file
beckykd Apr 23, 2026
033096b
duplicate entry
beckykd Apr 23, 2026
fca12f3
Merge branch 'bd-new-toc' of https://github.com/Qiskit/documentation …
beckykd Apr 23, 2026
2ff6a6d
add owner
beckykd Apr 23, 2026
5dc436e
Apply suggestions from code review
beckykd Apr 23, 2026
dd2eb41
remove duplicated code
beckykd Apr 23, 2026
62baf4d
run notebook
beckykd Apr 28, 2026
ce3fe14
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 28, 2026
65adba5
unused
beckykd Apr 28, 2026
ce0ca45
fix bot
beckykd Apr 28, 2026
95d84aa
update notebook testing
beckykd Apr 28, 2026
1c99ec3
Apply suggestions from code review
beckykd Apr 28, 2026
df2a478
executor is new
beckykd Apr 28, 2026
118fd5a
Merge branch 'bd-just-executor' of https://github.com/Qiskit/document…
beckykd Apr 28, 2026
3bdb988
change to notebook and run
beckykd Apr 29, 2026
e7179bb
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd Apr 29, 2026
963bd6e
tox e fix
beckykd Apr 29, 2026
e8a3b03
clarify more
beckykd Apr 29, 2026
1c4b578
get the Get started topic running
beckykd Apr 29, 2026
2d7e95e
link formatting
beckykd Apr 29, 2026
6648396
Merge branch 'main' into bd-just-executor
beckykd Apr 30, 2026
21b91c6
add "template circuit"
beckykd Apr 30, 2026
17c2577
Merge branch 'main' into bd-just-executor
beckykd Apr 30, 2026
213f77f
review comments
beckykd Apr 30, 2026
f894a08
Merge branch 'bd-just-executor' of https://github.com/Qiskit/document…
beckykd Apr 30, 2026
c86aa68
spelling
beckykd Apr 30, 2026
77d98ea
Fix spelling?
beckykd Apr 30, 2026
dae066a
fix qiskit bot
beckykd Apr 30, 2026
6a561a6
clean
beckykd May 1, 2026
a86d61c
Samplex inputs
beckykd May 1, 2026
651d82e
rerun to fix
beckykd May 1, 2026
c46e8b8
clean
beckykd May 1, 2026
99f7db7
./fix
abbycross May 1, 2026
0b20914
review comments
beckykd May 1, 2026
3cfe8fe
Add install instruction
beckykd May 4, 2026
aae106f
spelling
beckykd May 4, 2026
056d876
run tox
beckykd May 4, 2026
671c919
Merge branch 'main' into bd-just-executor
abbycross May 4, 2026
f892298
./fix
abbycross May 4, 2026
9f1b46d
combine the two remove-cell blocks
abbycross May 4, 2026
7ec7593
address 5061
beckykd May 4, 2026
ba5f2c6
rerun notebook
beckykd May 4, 2026
7554fcb
tox e fix
beckykd May 4, 2026
2ea4ed3
Update docs/guides/error-mitigation-and-suppression-techniques.ipynb
beckykd May 4, 2026
cfeb205
Update docs/guides/get-started-with-executor.ipynb
beckykd May 5, 2026
8aa161d
Update docs/guides/executor-input-output.ipynb
beckykd May 5, 2026
f054c50
Update docs/guides/executor-input-output.ipynb
beckykd May 5, 2026
d8ec628
Update docs/guides/executor-input-output.ipynb
beckykd May 5, 2026
5de0775
review comments
beckykd May 5, 2026
d652260
Merge branch 'bd-just-executor' of https://github.com/Qiskit/document…
beckykd May 5, 2026
a49336c
two parameter values
beckykd May 5, 2026
fc555fb
show samplomatic version
beckykd May 5, 2026
c67ddbf
import samplomatic as part of the code
beckykd May 5, 2026
4a59660
make purty
beckykd May 5, 2026
c767891
add samplomatic install where needed
beckykd May 5, 2026
e6cbc58
don't explicitly import samplomatic
beckykd May 5, 2026
24b89aa
Update docs/guides/get-started-with-executor.ipynb
beckykd May 5, 2026
97bb635
Update docs/guides/executor-options.ipynb
beckykd May 5, 2026
15ab18e
Update docs/guides/executor-input-output.ipynb
beckykd May 5, 2026
d1e2ec3
Merge branch 'main' into bd-just-executor
abbycross May 6, 2026
23e1e76
tox e fix
beckykd May 6, 2026
f7de8fd
Merge branch 'main' of https://github.com/Qiskit/documentation into b…
beckykd May 7, 2026
0bc7b48
merge conflicts
beckykd May 7, 2026
5f7d8c4
fix example
beckykd May 7, 2026
fe44dfc
rerun examples file
beckykd May 7, 2026
2c4f929
unused images
beckykd May 7, 2026
b0d667a
jessie udpates
beckykd May 7, 2026
54bcaf3
tox
beckykd May 7, 2026
16bb882
tox
beckykd May 7, 2026
3b66f25
Merge branch 'main' into bd-just-executor
abbycross May 7, 2026
6008c71
./fix
abbycross May 7, 2026
4d341d3
Update docs/guides/executor-broadcasting.mdx
beckykd May 8, 2026
55aeed3
final countdown
beckykd May 8, 2026
d72cd4c
Merge branch 'bd-just-executor' of https://github.com/Qiskit/document…
beckykd May 8, 2026
c2aaa5a
Merge branch 'main' into bd-just-executor
abbycross May 8, 2026
11741e8
Update save-jobs.ipynb
abbycross May 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions docs/guides/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,7 @@
{
"title": "Introduction to primitives",
"url": "/docs/guides/qiskit-runtime-primitives"
},
{
"title": "Directed execution model (beta)",
"url": "/docs/guides/directed-execution-model"
},
{
}, {
"title": "Introduction to options",
"url": "/docs/guides/runtime-options-overview"
},
Expand Down Expand Up @@ -560,6 +555,32 @@
}
]
},
{
"title": "Executor",
"isNew": true,
"isNewDate": "2026-05-15",
"children": [
{
"title": "Get started",
"url": "/docs/guides/get-started-with-executor"
},
{
"title": "Inputs and outputs",
"url": "/docs/guides/executor-input-output"
},
{
"title": "Broadcasting",
"url": "/docs/guides/executor-broadcasting"
},
{
"title": "Options",
"url": "/docs/guides/executor-options"
},
{
"title": "Examples",
"url": "/docs/guides/executor-examples"
} ]
},
{
"title": "Manage noise",
"children": [
Expand All @@ -577,6 +598,10 @@
}
]
},
{
"title": "Directed execution model (beta)",
"url": "/docs/guides/directed-execution-model"
},
{
"title": "Debug Qiskit Runtime jobs",
"url": "/docs/guides/debug-qiskit-runtime-jobs"
Expand Down
337 changes: 337 additions & 0 deletions docs/guides/executor-broadcasting.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
---
title: Executor broadcasting
description: How the Executor handles array inputs and outputs using broadcasting semantics

---
{/* cspell:ignore broadcastable */}

# Executor broadcasting

The data provided to the Executor primitive can be arranged in a variety of shapes to provide flexibility in a workload through broadcasting. This guide explains how the Executor handles array inputs and outputs using broadcasting semantics. Understanding these concepts will help you efficiently sweep over parameter values, combine
multiple configurations, and interpret the shape of returned data.

<Admonition type="note">
The examples in this topic cannot be run on their own. They assume you have defined appropriate circuits, used the Samplomatic pass manager to add boxes and annotations, and used the Samplomatic `build` method to get a template circuit and samplex for each code block, as necessary.
</Admonition>

<span id="quickstart"></span>
## Quickstart example

This example demonstrates the core idea. It creates a parametric circuit and and five different parameter configurations. The executor runs all five configurations and returns data organized by configuration, with one result per classical register in each quantum program item.

The rest of this guide refers back to this example to explain how this works and how to build more complex sweeps, including Samplomatic-based randomization and inputs.

```python
import numpy as np
from qiskit.circuit import Parameter, QuantumCircuit
from qiskit_ibm_runtime import QiskitRuntimeService, Executor
from qiskit_ibm_runtime.quantum_program import QuantumProgram
from qiskit.transpiler import generate_preset_pass_manager

# A circuit with 2 parameters
# This circuit is used throughout the rest of this guide.
circuit = QuantumCircuit(4)
circuit.rx(Parameter("a"), 0)
circuit.rx(Parameter("b"), 1)
circuit.h(2)
circuit.cx(2, 3)
circuit.measure_all()

# 5 different parameter configurations (shape: 5 configurations × 2 parameters)
parameter_values = np.linspace(0, np.pi, 10).reshape(5, 2)

# Initialize the service and choose a backend
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)

# Transpile to ISA circuit
preset_pass_manager = generate_preset_pass_manager(
backend=backend,
optimization_level=3,
)
isa_circuit = preset_pass_manager.run(circuit)

# This program is used throughout the rest of this guide.
program = QuantumProgram(shots=1024)
program.append_circuit_item(isa_circuit, circuit_arguments=parameter_values)

# initialize an Executor with default options
executor = Executor(mode=backend)

# Run and get results
result = executor.run(program).result()

# result is a list with one entry per program item
# result[0] is a dict mapping classical register names to data arrays
# Output bool arrays have shape (5, 1024, 4)
# 5 = number of parameter configurations
# 1024 = number of shots
# 4 = bits in the classical register
result[0]["meas"]
```

## Intrinsic and extrinsic axes

Broadcasting only applies to _extrinsic_ axes. The intrinsic axes are always preserved as specified.

- **Intrinsic axes** (rightmost): Determined by the data type. For example, if your circuit
has three parameters, then parameter values require three numbers, giving an intrinsic shape
of `(3,)`.

- **Extrinsic axes** (leftmost): Your sweep dimensions. These define how many configurations you
want to run.

| Input type | Intrinsic shape | Example full shape |
|----------------------------------------|---------------|---------------------------------------------------|
| Parameter values (n parameters) | (n,) | (5, 3) for five configurations and three parameters |
| Scalar inputs (for example, noise scale) | () | (4,) for four configurations |
| Observables (if applicable) | varies | Depends on observable type |

### Example

Consider a circuit with two parameters that you want to sweep over a 4x3 grid of configurations, varying parameter values and a noise scale factor:
Comment thread
beckykd marked this conversation as resolved.

```python
import numpy as np

# Parameter values: 4 configurations along axis 0, intrinsic shape (2,)
# Full shape: (4, 1, 2) - the "1" allows broadcasting with noise_scale
parameter_values = np.array([
[[0.1, 0.2]],
[[0.3, 0.4]],
[[0.5, 0.6]],
[[0.7, 0.8]],
]) # shape (4, 1, 2)

# Noise scale: 3 configurations, intrinsic shape () (scalar)
# Full shape: (3,)
noise_scale = np.array([0.8, 1.0, 1.2]) # shape (3,)

# Extrinsic shapes: (4, 1) and (3,) → broadcast to (4, 3)
# Result: 12 total configurations in a 4×3 grid
program.append_samplex_item(
template_circuit,
samplex=samplex,
samplex_arguments={
"parameter_values": parameter_values,
"noise_scales.mod_ref1": noise_scale,
},
)
```

The shapes are as follows:

| Input | Full shape | Extrinsic shape | Intrinsic shape |
|------------------|----------|---------------|---------------|
| `parameter_values` | (4, 1, 2) | (4, 1) | (2,) |
| `noise_scale` | (3,) | (3,) | () |
| Broadcast | None | (4, 3) | None |

## Output array shapes

Output arrays follow the same extrinsic/intrinsic pattern:

- **Extrinsic shape:** Matches the broadcast shape of all inputs
- **Intrinsic shape:** Determined by the output type

The most common output is bitstring data from measurements, which is
formatted as an array of boolean values:

| Output type | Intrinsic shape | Description |
|-----------------------|----------------------|--------------------------------|
| Classical register data | (num_shots, creg_size) | Bitstring data from measurements |

### Example

If you provide inputs with extrinsic shapes `(4, 1)` and `(3,)`, the broadcast extrinsic
shape is `(4, 3)`. The following code uses a circuit with 1024 shots and a 4-bit classical register (as defined in the [Quickstart](#quickstart) example):

```python
# Input extrinsic shapes: (4, 1) and (3,) → (4, 3)
# Output for classical register "meas":
# extrinsic: (4, 3)
# intrinsic: (1024, 4) - shots × bits
# full shape: (4, 3, 1024, 4)

result = executor.run(program).result()
meas_data = result[0]["meas"] # result[0] for first program item
print(meas_data.shape) # (4, 3, 1024, 4)

# Access a specific configuration
config_2_1 = meas_data[2, 1, :, :] # shape (1024, 4)
```
<Admonition type="note">
Each configuration runs the full shot count specified in the quantum program. Shots are **not** divided among configurations. For example, if you request 1024 shots and have 10 configurations, each configuration runs 1024 shots (10,240 total shots executed).
</Admonition>

## Randomization and the `shape` parameter

When using a [samplex](/docs/guides/directed-execution-model), each element of the extrinsic shape corresponds to an independent circuit
execution. The samplex typically injects randomness (for example, gate twirling) into each
execution, so even without explicitly requesting multiple randomizations, each element
receives a random realization.

You can use the `shape` parameter to augment the extrinsic shape for the item, effectively
adding axes that correspond specifically to randomizing the same configuration many times. It must be
broadcastable from the shape implicit in your `samplex_arguments`. Axes where `shape` exceeds
the implicit shape enumerate additional independent randomizations.

### No explicit randomization axes

If you omit `shape` (or set it to match your input shapes), you get one execution per
input configuration. Each execution is still randomized by the samplex, but with only a
single random realization you don't benefit from averaging over multiple randomizations.

<Admonition type="note">
If you're accustomed to enabling twirling with a simple flag like `twirling=True`, note that
the Executor requires you to explicitly request multiple randomizations with the `shape` argument to
allow your post-processing routines to get the benefits of averaging over multiple
randomizations. A single randomization (the default when `shape` is omitted) applies
random gates but typically offers no advantage over running the base circuit without
randomization.
</Admonition>

The following example demonstrates the default behavior:

```python
program.append_samplex_item(
template_circuit,
samplex=samplex,
samplex_arguments={
"parameter_values": np.random.rand(10, 2), # extrinsic (10,)
},
# shape defaults to (10,) - one randomized execution per config
)
# Output shape for "meas": (10, num_shots, creg_size)
```

### Single randomization axis

To run multiple randomizations per configuration, extend the shape with additional axes.
For example, the following code runs 20 randomizations for each of 10 parameter configurations:

```python
program.append_samplex_item(
template_circuit,
samplex=samplex,
samplex_arguments={
"parameter_values": np.random.rand(10, 2), # extrinsic (10,)
},
shape=(20, 10), # 20 randomizations × 10 configurations
)
# Output shape for "meas": (20, 10, num_shots, creg_size)
```

### Multiple randomization axes

You can organize randomizations into a multi-dimensional grid. This is useful for structured
analysis, for example, separating randomizations by type or grouping them for statistical processing.

Here, the input extrinsic shape `(10,)` broadcasts to the requested shape `(2, 14, 10)`,
with axes 0 and 1 filled by independent randomizations.

```python
program.append_samplex_item(
template_circuit,
samplex=samplex,
samplex_arguments={
"parameter_values": np.random.rand(10, 2), # extrinsic (10,)
},
# 2×14=28 randomizations per configuration, 10 configurations
# Or you could set shape=(28, 10) for the same effect
shape=(2, 14, 10),
)
# Output shape for "meas": (2, 14, 10, num_shots, creg_size)
```

### How `shape` and input shapes interact

The `shape` parameter must be broadcastable *from* your input extrinsic shapes. This means:

- Input shapes with size-1 dimensions can expand to match `shape`.
- Input shapes must align from the right with `shape`.
- Axes in `shape` that exceed the input dimensions enumerate randomizations.

Note that `shape` can contain size-1 dimensions
that expand to match input dimensions, as is illustrated in the last row of the following table.

Examples:

| Input extrinsic | Shape | Result |
|---------------|----------|-----------------------------------------------------------------|
| (10,) | (10,) | 10 configurations, 1 randomization each |
| (10,) | (5, 10) | 10 configurations, 5 randomizations each |
| (10,) | (2, 3, 10) | 10 configurations, 2×3=6 randomizations each |
| (4, 1) | (4, 5) | 4 configurations, 5 randomizations each |
| (4, 3) | (2, 4, 3) | 4×3=12 configurations, 2 randomizations each |
| (4, 3) | (2, 1, 3) | 4×3=12 configurations, 2 randomizations each (the 1 expands to 4) |



### Index into results


With randomization axes, you can index into specific randomization/parameter combinations:

```python
# Using shape=(2, 14, 10) with input extrinsic shape (10,), and
# 1024 shots and 4 classical registers.
result = executor.run(program).result()
meas_data = result[0]["meas"] # shape (2, 14, 10, 1024, 4)

# Get all shots for randomization (0, 7) and parameter config 3
specific = meas_data[0, 7, 3, :, :] # shape (1024, 4)

# Average over all randomizations for parameter config 5 on bit 2
averaged = meas_data[:, :, 5, :, 2].mean(axis=(0, 1))
```

## Common patterns

### Sweep a single parameter
Use code like the following to sweep one parameter while holding others fixed:

```python
# Circuit has 2 parameters, sweep first one over 20 values
sweep_values = np.linspace(0, 2*np.pi, 20)

parameter_values = np.column_stack([
sweep_values,
np.full(20, 0.5),
]) # shape (20, 2)
```

### Creating a 2D grid sweep
To create a grid over three parameters:

```python
# Sweep param 0 over 10 values, param 1 over 8 values, param 2 fixed
p0 = np.linspace(0, np.pi, 10)[:, np.newaxis, np.newaxis] # (10, 1, 1)
p1 = np.linspace(0, np.pi, 8)[np.newaxis, :, np.newaxis] # (1, 8, 1)
p2 = np.array([[[0.5]]]) # (1, 1, 1)

parameter_values = np.broadcast_arrays(p0, p1, p2)
parameter_values = np.stack(parameter_values, axis=-1).squeeze() # (10, 8, 3)

# Extrinsic shape: (10, 8), intrinsic shape: (3,)
```

### Combining multiple inputs

When combining inputs with different intrinsic shapes, align extrinsic dimensions using
size-1 axes:

```python
# 4 parameter configurations, 3 noise scales → 4×3 = 12 total configurations
parameter_values = np.random.rand(4, 1, 2) # extrinsic (4, 1), intrinsic (2,)
noise_scale = np.array([0.8, 1.0, 1.2]) # extrinsic (3,), intrinsic ()

# Broadcasted extrinsic shape: (4, 3)
```

## Next steps

<Admonition type="tip" title="Recommendations">
- Review the [broadcasting](/docs/guides/primitive-input-output#broadcasting) overview.
- Understand [Executor inputs and outputs](/docs/guides/executor-input-output).
</Admonition>
Loading
Loading