mirror of
https://github.com/saymrwulf/QuantumLearning.git
synced 2026-05-14 20:58:00 +00:00
799 lines
40 KiB
Text
799 lines
40 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>META READING</strong> · Difficulty 1/10 · Notebook-level rule, objective, or usage guidance.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"# Qiskit Patterns and Workflow Design Lecture\n"
|
|
],
|
|
"id": "da7b5c04"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>META READING</strong> · Difficulty 1/10 · Official walkthrough guardrail.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"<!-- COURSE_NAV_TOP -->\n",
|
|
"## Mainline Navigation\n",
|
|
"\n",
|
|
"Step 43 of 59. Follow the official walkthrough in order.\n",
|
|
"\n",
|
|
"Previous notebook: [Grover and Amplitude Amplification Studio](../../algorithms/module_04_grover/studio.ipynb)\n",
|
|
"\n",
|
|
"Next notebook: [Qiskit Patterns and Workflow Design Lab](lab.ipynb)\n",
|
|
"\n",
|
|
"Rule: complete the mandatory cells in this notebook before you open the next one.\n"
|
|
],
|
|
"id": "c07ae669"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>META READING</strong> · Difficulty 1/10 · Notebook-level rule, objective, or usage guidance.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"The first professional-design module changes the unit of thinking. Up to this point, the course has trained you to understand circuits, engineer them cleanly, and reason about algorithms as reusable motifs. That is necessary, but it is still not the full shape of professional work. In a real project, a circuit almost never lives alone. It sits inside a broader workflow: a design brief defines what question is being asked, configuration or preprocessing shapes the inputs, the circuit is built and executed under explicit assumptions, and a downstream step interprets the outputs into a decision, score, or report. This module teaches that larger unit.\n"
|
|
],
|
|
"id": "150bb2d8"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"## Learning Objective\n",
|
|
"\n",
|
|
"\n",
|
|
" By the end of this lecture you should be able to explain why a Qiskit pattern is more than a reusable circuit, how the map-optimize-execute-post-process cycle changes notebook design, and how to structure a local-first workflow so that another engineer can tell what the stable routine is, what the variable experimental question is, and how the final recommendation is being derived from the raw evidence.\n"
|
|
],
|
|
"id": "3b3fab16"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"The word pattern is easy to misuse. In weak notebook culture, a pattern can mean nothing more than a favorite code idiom or a circuit shape copied into multiple files. In this course the word is stricter. A pattern is a reusable arrangement of responsibilities. It says where configuration belongs, where the quantum body belongs, where the compile or execution context belongs, and where the reporting or decision rule belongs. That definition matters because it turns a runnable notebook into something you can vary, extend, and review without losing the causal story.\n"
|
|
],
|
|
"id": "76e9e58e"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"The best way to see the need for patterns is to notice how many notebook failures are really workflow failures. A beginner might put configuration, circuit construction, execution, plotting, and interpretation in one long cell. The cell runs, but the roles are mixed together. A later reader cannot tell which parts are stable, which parts are experimental knobs, and which assumptions the final interpretation is silently relying on. The purpose of this module is to prevent that kind of muddle before it hardens into habit.\n"
|
|
],
|
|
"id": "02f58cc0"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"The map-optimize-execute-post-process language helps because it gives the notebook a sequence of burdens. Map means: what question or data is being translated into a circuit-ready form? Optimize means: what compilation or structural decisions are shaping the circuit before execution? Execute means: under what local conditions is the circuit being sampled or simulated? Post-process means: what derived quantity or decision rule is being computed from the result? None of these stages is optional in serious work, even when some of them remain small in a teaching notebook.\n"
|
|
],
|
|
"id": "7c793dc7"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"One subtle benefit of pattern thinking is that it improves the quality of explanation as much as the quality of code. When the workflow is well structured, the prose can name each layer cleanly. You can tell a reviewer where the question is configured, where the stable quantum routine lives, and where the score or judgment is produced. That kind of narratability is not fluff. It is the difference between a notebook that merely runs today and a notebook that another engineer could trust, critique, or adapt later.\n"
|
|
],
|
|
"id": "42ee2eeb"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"Pattern design is also where local-first discipline becomes especially valuable. If every stage of the workflow lives inside the same project and can be rerun locally, then debugging becomes much less theatrical. A bad score can be traced back through the record: was the circuit itself wrong, did the measurement contract drift, did the post-processing assume a readout order that the builder never stated, or did the question configuration silently change? These are concrete engineering questions, and they are easiest to learn when the whole loop stays close at hand.\n"
|
|
],
|
|
"id": "4315fa88"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"The point of the module is therefore not to make the notebook feel more corporate. It is to give circuits a professional habitat. Once you can build a small local pattern that survives variation and yields a reviewable record, the later modules on redesign, verification, and capstone decision-making become much more natural. They stop feeling like add-ons and start feeling like the next responsibilities inside the same overall workflow.\n"
|
|
],
|
|
"id": "42610c32"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "setup"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #6b7280; background:#e5e7eb; color:#111827; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY SETUP</strong> · Difficulty 1/10 · Environment, import, or helper cell required by the notebook.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "fa7a20a3"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from pathlib import Path\n",
|
|
"import sys\n",
|
|
"\n",
|
|
"project_root = Path.cwd().resolve()\n",
|
|
"while not (project_root / \"pyproject.toml\").exists():\n",
|
|
" if project_root.parent == project_root:\n",
|
|
" raise RuntimeError(\"Could not locate the project root from this notebook.\")\n",
|
|
" project_root = project_root.parent\n",
|
|
"\n",
|
|
"src_path = project_root / \"src\"\n",
|
|
"if str(src_path) not in sys.path:\n",
|
|
" sys.path.insert(0, str(src_path))\n"
|
|
],
|
|
"id": "677711d4"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "636750ad"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from quantum_learning import (\n",
|
|
" build_demo_noise_model,\n",
|
|
" counts_to_probabilities,\n",
|
|
" draw_circuit,\n",
|
|
" editable_circuit_lab,\n",
|
|
" evidence_checklist,\n",
|
|
" feedback_iteration_panel,\n",
|
|
" line_coupling_map,\n",
|
|
" load_assessment_blueprint,\n",
|
|
" plot_counts,\n",
|
|
" plot_probabilities,\n",
|
|
" quiz_block,\n",
|
|
" reflection_box,\n",
|
|
" rubric_scorecard,\n",
|
|
" simulate_counts,\n",
|
|
" statevector_probabilities,\n",
|
|
" step_reference_table,\n",
|
|
" transpile_summary,\n",
|
|
")\n",
|
|
"from qiskit import QuantumCircuit\n",
|
|
"from qiskit.providers.basic_provider import BasicSimulator\n"
|
|
],
|
|
"id": "c24aed18"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"## Code-To-Diagram Anchor\n",
|
|
"\n",
|
|
"\n",
|
|
" The anchor pattern is intentionally small. Its purpose is to make the workflow layers visible, not to impress with circuit complexity. Read the reference table first. Then inspect how the same small routine can be embedded inside a larger record that states the question being asked and the decision derived from the raw counts.\n"
|
|
],
|
|
"id": "33c3af2f"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "fb5b68bb"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"step_reference_table([{'marker': '[1]', 'code_focus': 'Treat the question being asked of the circuit as configuration, not as a hidden side effect.', 'diagram_effect': 'The rendered circuit becomes one phase of a workflow rather than the whole workflow.', 'why_it_matters': 'Professional notebooks separate design brief, circuit body, and evaluation record.'}, {'marker': '[2]', 'code_focus': 'Keep basis adaptation or other query-specific logic in a clearly named layer.', 'diagram_effect': 'The middle of the circuit shows which part is core routine and which part customizes the question.', 'why_it_matters': 'Patterns become reusable only when stable and variable regions are visibly distinct.'}, {'marker': '[3]', 'code_focus': 'Make the reporting contract explicit instead of relying on later guesswork.', 'diagram_effect': 'The diagram ends with an auditable readout layer.', 'why_it_matters': 'Workflow quality includes trustworthy evidence, not only a correct quantum body.'}, {'marker': '[4]', 'code_focus': 'Pair the circuit with post-processing that produces a reviewable record rather than an isolated histogram.', 'diagram_effect': 'The circuit is now visibly part of a larger map-optimize-execute-post-process cycle.', 'why_it_matters': 'Patterns matter when circuits live inside applications, experiments, and reports.'}])\n"
|
|
],
|
|
"id": "a244ba8b"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "cb0164f8"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"editable_code = '\\nfrom qiskit import QuantumCircuit\\n\\ndef build_agreement_probe(basis: str = \"z\") -> QuantumCircuit:\\n circuit = QuantumCircuit(2, 2)\\n # [1] The workflow chooses the question before the circuit is built.\\n circuit.h(0)\\n circuit.cx(0, 1)\\n # [2] Basis adaptation belongs in its own visible layer.\\n if basis == \"x\":\\n circuit.h([0, 1])\\n elif basis != \"z\":\\n raise ValueError(\"basis must be \\'z\\' or \\'x\\'\")\\n # [3] Keep the reporting contract explicit.\\n circuit.measure([0, 1], [0, 1])\\n return circuit\\n\\ncircuit = build_agreement_probe(basis=\"x\")\\n'\n",
|
|
"editable_circuit_lab(\n",
|
|
" initial_code=editable_code,\n",
|
|
" context={\"QuantumCircuit\": QuantumCircuit, \"simulate_counts\": simulate_counts},\n",
|
|
" title='Qiskit Patterns and Workflow Design Anchor',\n",
|
|
" instructions='Edit one structural burden at a time and use the reference table to keep the code and the engineering story aligned.',\n",
|
|
" shots=256,\n",
|
|
")\n"
|
|
],
|
|
"id": "b09ca015"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "87de2dab"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def build_agreement_probe(basis: str = \"z\") -> QuantumCircuit:\n",
|
|
" circuit = QuantumCircuit(2, 2)\n",
|
|
" circuit.h(0)\n",
|
|
" circuit.cx(0, 1)\n",
|
|
" if basis == \"x\":\n",
|
|
" circuit.h([0, 1])\n",
|
|
" elif basis != \"z\":\n",
|
|
" raise ValueError(\"basis must be 'z' or 'x'\")\n",
|
|
" circuit.measure([0, 1], [0, 1])\n",
|
|
" return circuit\n",
|
|
"\n",
|
|
"def run_pattern(basis: str, shots: int = 256) -> dict[str, object]:\n",
|
|
" circuit = build_agreement_probe(basis)\n",
|
|
" compiled = transpile_summary(\n",
|
|
" circuit,\n",
|
|
" BasicSimulator(),\n",
|
|
" basis_gates=[\"rz\", \"sx\", \"x\", \"cx\"],\n",
|
|
" )\n",
|
|
" counts = simulate_counts(circuit, shots=shots)\n",
|
|
" probabilities = counts_to_probabilities(counts)\n",
|
|
" agreement = round(probabilities.get(\"00\", 0.0) + probabilities.get(\"11\", 0.0), 3)\n",
|
|
" return {\n",
|
|
" \"basis\": basis,\n",
|
|
" \"depth_after\": compiled[\"depth_after\"],\n",
|
|
" \"agreement_rate\": agreement,\n",
|
|
" \"counts\": counts,\n",
|
|
" }\n",
|
|
"\n",
|
|
"[run_pattern(basis) for basis in [\"z\", \"x\"]]\n"
|
|
],
|
|
"id": "db127e21"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "test"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY TEST</strong> · Difficulty 2/10 · Official walkthrough multiple-choice test.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "4b2f8085"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"quiz_block([{'prompt': 'What is the main reason to separate workflow configuration from the circuit builder?', 'options': ['So the stable quantum routine and the changing experimental question can be reviewed independently', 'So the circuit always uses fewer gates', 'So Qiskit can avoid classical data structures'], 'correct_index': 0, 'explanation': 'Pattern design depends on making stable and variable responsibilities visible.'}, {'prompt': 'Why is an explicit reporting contract part of a pattern notebook?', 'options': ['Because the evidence layer is part of the design, not a last-minute add-on', 'Because all patterns must measure every qubit twice', 'Because plotting replaces analysis'], 'correct_index': 0, 'explanation': 'Professional workflow design includes trustworthy readout and post-processing.'}, {'prompt': 'What makes a notebook pattern reusable?', 'options': ['It keeps intent, circuit body, and evaluation record distinct enough to vary inputs without losing the story', 'It hides the circuit inside a large helper', 'It avoids any post-processing code'], 'correct_index': 0, 'explanation': 'Reusable patterns survive variation because their boundaries are clear.'}], heading='Lecture Checkpoint A')\n"
|
|
],
|
|
"id": "b2eddd56"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"A strong self-check for this module is whether you can point to each stage of the workflow and say what would count as a mistake there. If the question configuration is wrong, the circuit may still run while answering the wrong question. If the circuit body is wrong, the result record may be beautifully structured and still meaningless. If the measurement contract drifts, the post-processing may produce a polished lie. Pattern thinking helps because it lets you localize those risks instead of treating the whole notebook as one opaque blob.\n"
|
|
],
|
|
"id": "c2280f4f"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"Another self-check is whether your prose tracks the code boundaries honestly. If the notebook says the builder is reusable, can you name which parameters are genuinely meant to vary? If it says the output score is meaningful, can you say exactly how that score is derived from the counts? Professional workflow design is not only about code refactoring. It is about making the notebook legible as an engineering argument.\n"
|
|
],
|
|
"id": "3caaa5ba"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"## Reading Discipline For This Module\n",
|
|
"\n",
|
|
"The professional band demands slower reading than the earlier bands because the unit of judgment is larger. You are no longer inspecting only a circuit body. You are inspecting a design brief, a constraint model, a verification story, or a recommendation workflow. That means every notebook should be read with questions like these in mind: what burden is this stage carrying, what evidence would justify it, and what kind of failure would falsify the current explanation? If those questions stay active while you read, the notebook becomes training. If they disappear, the notebook becomes performance.\n",
|
|
"\n",
|
|
"Another discipline worth installing here is conditional confidence. Professional engineering rarely says only \"this works.\" It says \"under these assumptions, with this evidence, this is the choice I recommend.\" That conditional phrasing is not weakness. It is rigor. The purpose of the final band is to make that rigor normal in both your code and your prose.\n"
|
|
],
|
|
"id": "709c6d96"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"## Professional Review Habit\n",
|
|
"\n",
|
|
"Another habit worth building here is review-minded reading. Do not read these notebooks only as the author of the current code cell. Read them as the future reviewer who must decide whether the workflow, redesign, diagnosis, or recommendation is trustworthy. That reviewer wants to know what assumptions were fixed, what evidence was gathered, what remained uncertain, and what could still break if the surrounding constraints changed. Practicing that perspective now is what turns the final band into professional training instead of advanced entertainment.\n"
|
|
],
|
|
"id": "399f1ac1"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"## Forward Link\n",
|
|
"\n",
|
|
"Every later notebook artifact in a real project will inherit the standards practiced here. Workflow patterns affect how experiments are reproduced. Hardware-aware redesign affects whether ideal elegance survives implementation. Verification determines whether bad results are diagnosed honestly. And capstone review determines whether a chosen circuit can actually be defended. The point of this band is not to add optional polish. It is to make the entire project behave like professional engineering work.\n"
|
|
],
|
|
"id": "de17da6a"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "test"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY TEST</strong> · Difficulty 2/10 · Official walkthrough multiple-choice test.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "fcc59720"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"quiz_block([{'prompt': 'What should a workflow record contain beyond raw counts?', 'options': ['The design brief, circuit or compile context, and a derived decision or score', 'Only the screenshot of the circuit', 'Only the token URL of the notebook server'], 'correct_index': 0, 'explanation': 'Pattern notebooks need enough context to be reviewed later.'}, {'prompt': \"Why is 'the code runs' a weak endpoint for this module?\", 'options': ['Because workflow design is about repeatable evidence and interfaces, not only execution success', 'Because workflows should never execute locally', 'Because classical preprocessing is irrelevant'], 'correct_index': 0, 'explanation': 'A runnable cell is not yet a professional workflow artifact.'}], heading='Lecture Checkpoint B')\n"
|
|
],
|
|
"id": "95ef03dc"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "e28fb931"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"reflection_box('Write a paragraph explaining why a circuit builder and a workflow pattern are not the same thing.')\n"
|
|
],
|
|
"id": "a78b55c0"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "d9316687"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"reflection_box('Describe one hidden assumption between execution and post-processing that you would want a professional notebook to state explicitly.')\n"
|
|
],
|
|
"id": "476471a8"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "db56ed9f"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"feedback_iteration_panel(title='Qiskit Patterns and Workflow Design Lecture Revision Loop', prompt='State the judgement this lecture is training, the strongest evidence that would justify it, the current weakness in your own explanation, and the next revision you should make.')\n"
|
|
],
|
|
"id": "82ae0e38"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "mandatory",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY EXERCISE</strong> · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "1a46c83a"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"assessment_blueprint = load_assessment_blueprint()\n",
|
|
"rubric_scorecard(\n",
|
|
" assessment_blueprint.get_rubric('module_self_review'),\n",
|
|
" title='Qiskit Patterns and Workflow Design Lecture Self-Grading',\n",
|
|
")\n"
|
|
],
|
|
"id": "277d106f"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #15803d; background:#dcfce7; color:#14532d; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>MANDATORY READING</strong> · Difficulty 2/10 · Official walkthrough reading cell.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"## Mastery Gate\n",
|
|
"\n",
|
|
"Leave this lecture only when you can explain what evidence would justify the final professional judgment and what evidence would force you to revise it.\n"
|
|
],
|
|
"id": "287a580b"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>META READING</strong> · Difficulty 1/10 · Official walkthrough guardrail.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"<!-- COURSE_NAV_BOTTOM -->\n",
|
|
"## What To Open Next\n",
|
|
"\n",
|
|
"Next notebook: [Qiskit Patterns and Workflow Design Lab](lab.ipynb)\n",
|
|
"\n",
|
|
"Official walkthrough rule: once every mandatory cell above is complete, open the next notebook. Anything below this cell is facultative.\n"
|
|
],
|
|
"id": "8fa7bc2c"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "facultative_zone",
|
|
"ql_track": "meta",
|
|
"ql_role": "reading",
|
|
"ql_difficulty": 1,
|
|
"ql_note": "Optional-zone boundary. The official walkthrough is already complete above."
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #2563eb; background:#dbeafe; color:#1e3a8a; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>META READING</strong> · Difficulty 1/10 · Optional-zone boundary. The official walkthrough is already complete above.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"<!-- QL_OPTIONAL_ZONE -->\n",
|
|
"## Facultative Extension Zone\n",
|
|
"\n",
|
|
"You have already completed the mandatory walkthrough for **Qiskit Patterns and Workflow Design Lecture**. Everything below is optional. Use it only if you want deeper consolidation or extra transfer work.\n"
|
|
],
|
|
"id": "344e0360"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "facultative",
|
|
"ql_track": "facultative",
|
|
"ql_role": "reading",
|
|
"ql_difficulty": 4,
|
|
"ql_note": "Optional extension reading."
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #ea580c; background:#ffedd5; color:#9a3412; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>FACULTATIVE READING</strong> · Difficulty 4/10 · Optional extension reading.\n",
|
|
"</div>\n",
|
|
"\n",
|
|
"## Facultative Extension Reading\n",
|
|
"\n",
|
|
"Treat **Qiskit Patterns and Workflow Design Lecture** as a transfer checkpoint. Ask which mechanism from the mandatory cells would still matter if one qubit, one basis choice, or one comparison target changed. This optional reading cell exists to stretch the idea without changing the official route.\n"
|
|
],
|
|
"id": "58dd1d20"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "facultative",
|
|
"ql_role": "test"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #ea580c; background:#ffedd5; color:#9a3412; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>FACULTATIVE TEST</strong> · Difficulty 5/10 · Optional multiple-choice extension.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "407cc7e3"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"ql_injected": "facultative",
|
|
"ql_track": "facultative",
|
|
"ql_role": "test",
|
|
"ql_difficulty": 5,
|
|
"ql_note": "Optional multiple-choice extension.",
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"quiz_block([{'prompt': 'What should stay stable if you transfer the main mechanism from Qiskit Patterns and Workflow Design Lecture into a new small circuit?', 'options': ['The causal idea being tested', 'The exact notebook filename', 'The original counts histogram regardless of the change'], 'correct_index': 0, 'explanation': 'Transfer begins by preserving the mechanism, not the surface form.'}, {'prompt': 'What is the point of a facultative lecture extension?', 'options': ['To deepen transfer after the mandatory path is already complete', 'To replace the mandatory cells', 'To skip the lab and studio'], 'correct_index': 0, 'explanation': 'Facultative cells extend; they do not redefine the route.'}], heading='Facultative Extension Test')\n"
|
|
],
|
|
"id": "6bec3ff0"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"ql_injected": "badge",
|
|
"ql_track": "facultative",
|
|
"ql_role": "exercise"
|
|
},
|
|
"source": [
|
|
"<!-- QL_BADGE -->\n",
|
|
"<div style=\"padding:0.55rem 0.8rem; border-left:6px solid #ea580c; background:#ffedd5; color:#9a3412; border-radius:0.35rem; font-family:Helvetica, Arial, sans-serif; margin:0.15rem 0 0.85rem 0;\">\n",
|
|
"<strong>FACULTATIVE EXERCISE</strong> · Difficulty 6/10 · Optional written exercise.\n",
|
|
"</div>\n"
|
|
],
|
|
"id": "330da4f2"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"ql_injected": "facultative",
|
|
"ql_track": "facultative",
|
|
"ql_role": "exercise",
|
|
"ql_difficulty": 6,
|
|
"ql_note": "Optional written exercise.",
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"tags": [
|
|
"hide-input"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"reflection_box('State one mechanism from Qiskit Patterns and Workflow Design Lecture that you could now transfer to a slightly different circuit, and name the first thing you would hold fixed while testing that transfer.')\n"
|
|
],
|
|
"id": "84f87464"
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "QuantumLearning (.venv)",
|
|
"language": "python",
|
|
"name": "quantum-learning"
|
|
},
|
|
"language_info": {
|
|
"name": "python",
|
|
"version": "3.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|