|
309 | 309 | " In the previous code example, the first two `if_test`s on `c0` are considered one broadcast because the content of `c0` did not change, and thus does not need to be re-broadcasted. The `if_test` on `c1` is a second broadcast. The first one broadcasts all three bits in `c0` and the second broadcasts just one bit, making a total of four broadcasted bits.\n",
|
310 | 310 | "\n",
|
311 | 311 | " Currently, if you broadcast 60 bits each time, then the job can have approximately 300 broadcasts. If you broadcast just one bit each time, however, then the job can have 2400 broadcasts.\n",
|
312 |
| - "- Limitations on classical registers:\n", |
313 |
| - " - The operand used in an `if_test` statement must be 32 or fewer bits. Thus, if you are comparing an entire `ClassicalRegister`, the size of that `ClassicalRegister` must be 32 or fewer bits. If you are comparing just a single bit from a `ClassicalRegister`, however, that `ClassicalRegister` can be of any size (since the operand is only one bit).\n", |
314 |
| - "\n", |
315 |
| - " For example, the \"invalid\" code block does not work because `cr` is more than 32 bits. You can, however, use a classical register wider than 32 bits if you are testing only one bit, as shown in the \"valid\" code block.\n", |
316 |
| - "\n", |
317 |
| - " <Tabs>\n", |
318 |
| - " <TabItem value=\"Invalid\" label=\"Invalid\">\n", |
319 |
| - " ```python\n", |
320 |
| - " cr = ClassicalRegister(50)\n", |
321 |
| - " qr = QuantumRegister(50)\n", |
322 |
| - " circuit = QuantumCircuit(qr, cr)\n", |
323 |
| - " ...\n", |
324 |
| - " circ.measure(qr, cr)\n", |
325 |
| - " with circ.if_test((cr, 15)):\n", |
326 |
| - " ...\n", |
327 |
| - " ```\n", |
328 |
| - " </TabItem>\n", |
329 |
| - " <TabItem value=\"Valid\" label=\"Valid\">\n", |
330 |
| - " ```python\n", |
331 |
| - " cr = ClassicalRegister(50)\n", |
332 |
| - " qr = QuantumRegister(50)\n", |
333 |
| - " circuit = QuantumCircuit(qr, cr)\n", |
334 |
| - " ...\n", |
335 |
| - " circ.measure(qr, cr)\n", |
336 |
| - " with circ.if_test((cr[5], 1)):\n", |
337 |
| - " ...\n", |
338 |
| - " ```\n", |
339 |
| - " </TabItem>\n", |
340 |
| - " </Tabs>\n", |
341 |
| - " - Qiskit Runtime cannot _broadcast_ (a bit is broadcasted if it's used in an `if_test` statement) more than 60 bits at a time. You can explicitly ensure that you are working with different broadcasts by adding barriers.\n", |
342 |
| - "\n", |
343 |
| - " <Tabs>\n", |
344 |
| - " <TabItem value=\"Invalid\" label=\"Invalid\">\n", |
345 |
| - " The following code block does not work because it contains 64 broadcasted bits:\n", |
346 |
| - " ```python\n", |
347 |
| - " cr1 = ClassicalRegister(32)\n", |
348 |
| - " cr2 = ClassicalRegister(32)\n", |
349 |
| - " qr = QuantumRegister(64)\n", |
350 |
| - " circuit = QuantumCircuit(qr, cr1, cr2)\n", |
351 |
| - " ...\n", |
352 |
| - " circ.measure(qr[0:32], cr1)\n", |
353 |
| - " circ.measure(qr[32:], cr2)\n", |
354 |
| - " with circ.if_test((cr1, 32)): # 32 bits are broadcasted here\n", |
355 |
| - " ...\n", |
356 |
| - " with circ.if_test((cr2, 32)): # Another 32 bits are broadcasted here, exceeding the limit!\n", |
357 |
| - " ...\n", |
358 |
| - " ```\n", |
359 |
| - " </TabItem>\n", |
360 |
| - " <TabItem value=\"Valid\" label=\"Valid\">\n", |
361 |
| - " ```python\n", |
362 |
| - " cr1 = ClassicalRegister(32)\n", |
363 |
| - " cr2 = ClassicalRegister(32)\n", |
364 |
| - " qr = QuantumRegister(64)\n", |
365 |
| - " ...\n", |
366 |
| - " circ.measure(qr[0:32], cr1)\n", |
367 |
| - " with circ.if_test((cr1, 32)):\n", |
368 |
| - " ...\n", |
369 |
| - " circ.barrier()\n", |
370 |
| - " circ.measure(qr[32:], cr2)\n", |
371 |
| - " with circ.if_test((cr2, 32)):\n", |
372 |
| - " ...\n", |
373 |
| - " ```\n", |
374 |
| - " </TabItem>\n", |
375 |
| - " </Tabs>\n", |
| 312 | + "\n", |
| 313 | + "- The operand used in an `if_test` statement must be 32 or fewer bits. Thus, if you are comparing an entire `ClassicalRegister`, the size of that `ClassicalRegister` must be 32 or fewer bits. If you are comparing just a single bit from a `ClassicalRegister`, however, that `ClassicalRegister` can be of any size (since the operand is only one bit).\n", |
| 314 | + "\n", |
| 315 | + " For example, the \"Not valid\" code block does not work because `cr` is more than 32 bits. You can, however, use a classical register wider than 32 bits if you are testing only one bit, as shown in the \"Valid\" code block.\n", |
| 316 | + "\n", |
| 317 | + " <Tabs>\n", |
| 318 | + " <TabItem value=\"Not valid\" label=\"Not valid\">\n", |
| 319 | + " ```python\n", |
| 320 | + " cr = ClassicalRegister(50)\n", |
| 321 | + " qr = QuantumRegister(50)\n", |
| 322 | + " circuit = QuantumCircuit(qr, cr)\n", |
| 323 | + " ...\n", |
| 324 | + " circ.measure(qr, cr)\n", |
| 325 | + " with circ.if_test((cr, 15)):\n", |
| 326 | + " ...\n", |
| 327 | + " ```\n", |
| 328 | + " </TabItem>\n", |
| 329 | + " <TabItem value=\"Valid\" label=\"Valid\">\n", |
| 330 | + " ```python\n", |
| 331 | + " cr = ClassicalRegister(50)\n", |
| 332 | + " qr = QuantumRegister(50)\n", |
| 333 | + " circuit = QuantumCircuit(qr, cr)\n", |
| 334 | + " ...\n", |
| 335 | + " circ.measure(qr, cr)\n", |
| 336 | + " with circ.if_test((cr[5], 1)):\n", |
| 337 | + " ...\n", |
| 338 | + " ```\n", |
| 339 | + " </TabItem>\n", |
| 340 | + " </Tabs>\n", |
376 | 341 | "\n",
|
377 | 342 | "- Nested conditionals are not allowed. For example, the following code block will not work because it has an `if_test` inside another `if_test`:\n",
|
378 | 343 | " <Tabs>\n",
|
379 |
| - " <TabItem value=\"Invalid\" label=\"Invalid\">\n", |
| 344 | + " <TabItem value=\"Not valid\" label=\"Not valid\">\n", |
380 | 345 | " ```python\n",
|
381 | 346 | " c1 = ClassicalRegister(1, \"c1\")\n",
|
382 | 347 | " c2 = ClassicalRegister(2, \"c2\")\n",
|
|
0 commit comments