Skip to content

Commit 5a46091

Browse files
updated notebooks after change
1 parent 23fcccd commit 5a46091

17 files changed

+628
-1138
lines changed

applications/cfd/qls_for_hybrid_solvers/banded_be.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,47 @@ def block_encode_banded_sym(
223223
),
224224
),
225225
)
226+
227+
228+
def get_banded_diags_be(mat_raw_scr):
229+
"""
230+
Get relevant block-encoding properties for `block_encode_banded` block encoding,
231+
232+
Parameters
233+
----------
234+
mat_raw_scr : scipy.sparse.spmatrix
235+
Square sparse matrix of shape (N, N), real or complex, to be block-encoded.
236+
237+
Returns
238+
-------
239+
data_size : int
240+
Size of the data variable.
241+
block_size : int
242+
Size of the block variable.
243+
be_scaling_factor : float
244+
The scaling factor of the block-encoding unitary
245+
BlockEncodedState : QStruct
246+
QSVT-compatible QStruct holding the quantum variables, with fields:
247+
- data : QNum[data_size]
248+
- block : QNum[block_size]
249+
be_qfunc : qfunc
250+
Quantum function that implements the block encoding. Signature:
251+
be_qfunc(be: BlockEncodedState) → None
252+
"""
253+
raw_size = mat_raw_scr.shape[0]
254+
data_size = max(1, (raw_size - 1).bit_length())
255+
offsets, diags, diags_maxima, prepare_norm = get_be_banded_data(mat_raw_scr)
256+
block_size = int(np.ceil(np.log2(len(offsets)))) + 1
257+
be_scaling_factor = prepare_norm
258+
259+
@qfunc
260+
def be_qfunc(block: QNum, data: QNum):
261+
block_encode_banded(
262+
offsets=offsets,
263+
diags=diags,
264+
prep_diag=diags_maxima,
265+
block=block,
266+
data=data,
267+
)
268+
269+
return data_size, block_size, be_scaling_factor, be_qfunc

applications/cfd/qls_for_hybrid_solvers/banded_be.synthesis_options.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66
"preferences": {
77
"custom_hardware_settings": {
88
"basis_gates": [
9-
"sx",
10-
"p",
11-
"tdg",
9+
"z",
10+
"ry",
11+
"h",
1212
"x",
13-
"cz",
14-
"u2",
13+
"u1",
1514
"id",
1615
"sxdg",
17-
"y",
18-
"cy",
19-
"s",
20-
"ry",
21-
"cx",
22-
"t",
23-
"r",
24-
"u",
16+
"sx",
2517
"rz",
26-
"u1",
27-
"z",
2818
"rx",
2919
"sdg",
30-
"h"
20+
"tdg",
21+
"cy",
22+
"cz",
23+
"cx",
24+
"u",
25+
"y",
26+
"s",
27+
"r",
28+
"t",
29+
"u2",
30+
"p"
3131
],
3232
"is_symmetric_connectivity": true
3333
},
@@ -36,7 +36,7 @@
3636
"optimization_level": 1,
3737
"output_format": ["qasm"],
3838
"pretty_qasm": true,
39-
"random_seed": 2454004842,
39+
"random_seed": 2459810836,
4040
"synthesize_all_separately": false,
4141
"timeout_seconds": 300,
4242
"transpilation_option": "auto optimize"

applications/cfd/qls_for_hybrid_solvers/banded_sym_be.synthesis_options.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66
"preferences": {
77
"custom_hardware_settings": {
88
"basis_gates": [
9-
"sx",
10-
"p",
11-
"tdg",
9+
"z",
10+
"ry",
11+
"h",
1212
"x",
13-
"cz",
14-
"u2",
13+
"u1",
1514
"id",
1615
"sxdg",
17-
"y",
18-
"cy",
19-
"s",
20-
"ry",
21-
"cx",
22-
"t",
23-
"r",
24-
"u",
16+
"sx",
2517
"rz",
26-
"u1",
27-
"z",
2818
"rx",
2919
"sdg",
30-
"h"
20+
"tdg",
21+
"cy",
22+
"cz",
23+
"cx",
24+
"u",
25+
"y",
26+
"s",
27+
"r",
28+
"t",
29+
"u2",
30+
"p"
3131
],
3232
"is_symmetric_connectivity": true
3333
},
@@ -36,7 +36,7 @@
3636
"optimization_level": 1,
3737
"output_format": ["qasm"],
3838
"pretty_qasm": true,
39-
"random_seed": 3750507641,
39+
"random_seed": 1840897986,
4040
"synthesize_all_separately": false,
4141
"timeout_seconds": 300,
4242
"transpilation_option": "auto optimize"

0 commit comments

Comments
 (0)