{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Capstone Circuit Design Review Studio\n" ], "id": "9779455f" }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Mainline Navigation\n", "\n", "Step 58 of 59. Follow the mainline in order and do not skip ahead.\n", "\n", "Previous notebook: [Capstone Circuit Design Review Problems](problems.ipynb)\n", "\n", "Next notebook: [Course Complete](../../COURSE_COMPLETE.ipynb)\n", "\n", "Rule: finish this notebook top-to-bottom before you open the next one.\n" ], "id": "07460552" }, { "cell_type": "markdown", "metadata": {}, "source": [ "The final studio asks for the closest thing in the repository to a professional design memo.\n" ], "id": "476c0151" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Design Brief\n", "\n", "\n", " Produce a compact local design review that states a brief, compares at least two plausible candidates under the same local constraints, and ends with a recommendation whose confidence and limits are both explicit.\n" ], "id": "e0a0e8bf" }, { "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": "50c7b992" }, { "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": "933f1ed0" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Studio Prompt 1: Freeze The Brief\n", "\n", "\n", " State the objective and constraints clearly enough that candidate comparison can stay honest.\n" ], "id": "c3b3e252" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "LOCAL_BASIS = [\"rz\", \"sx\", \"x\", \"cx\"]\n", "capstone_noise = build_demo_noise_model(\n", " single_qubit_error=0.01,\n", " two_qubit_error=0.04,\n", " readout_error=0.02,\n", ")\n", "\n", "def simulate_capstone_counts(circuit, shots=256):\n", " return simulate_counts(\n", " circuit,\n", " shots=shots,\n", " noise_model=capstone_noise,\n", " basis_gates=LOCAL_BASIS,\n", " coupling_map=line_coupling_map(circuit.num_qubits),\n", " optimization_level=1,\n", " )\n", "\n", "editable_code = '\\nfrom qiskit import QuantumCircuit\\n\\ndef ghz_candidate(style: str = \"middle_root\") -> QuantumCircuit:\\n circuit = QuantumCircuit(3, 3)\\n if style == \"naive\":\\n circuit.h(0)\\n circuit.cx(0, 1)\\n circuit.cx(0, 2)\\n elif style == \"chain\":\\n circuit.h(0)\\n circuit.cx(0, 1)\\n circuit.cx(1, 2)\\n elif style == \"middle_root\":\\n circuit.h(1)\\n circuit.cx(1, 0)\\n circuit.cx(1, 2)\\n else:\\n raise ValueError(\"style must be naive, chain, or middle_root\")\\n circuit.measure([0, 1, 2], [0, 1, 2])\\n return circuit\\n\\ncircuit = ghz_candidate(style=\"middle_root\")\\n'\n", "editable_circuit_lab(\n", " initial_code=editable_code,\n", " context={\"QuantumCircuit\": QuantumCircuit, \"simulate_counts\": simulate_capstone_counts},\n", " title='Studio 1: Freeze The Brief',\n", " instructions='Use the candidate family as answers to one shared brief, not as unrelated demos.',\n", " shots=256,\n", ")\n" ], "id": "dc786aca" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Studio Prompt 2: Compare The Evidence\n", "\n", "\n", " Keep at least two candidates alive and compare them through the same ideal, compiled, and noisy lenses.\n" ], "id": "54ae22b3" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "LOCAL_BASIS = [\"rz\", \"sx\", \"x\", \"cx\"]\n", "capstone_noise = build_demo_noise_model(\n", " single_qubit_error=0.01,\n", " two_qubit_error=0.04,\n", " readout_error=0.02,\n", ")\n", "\n", "def simulate_capstone_counts(circuit, shots=256):\n", " return simulate_counts(\n", " circuit,\n", " shots=shots,\n", " noise_model=capstone_noise,\n", " basis_gates=LOCAL_BASIS,\n", " coupling_map=line_coupling_map(circuit.num_qubits),\n", " optimization_level=1,\n", " )\n", "\n", "editable_code = '\\nfrom qiskit import QuantumCircuit\\n\\ndef ghz_candidate(style: str = \"chain\") -> QuantumCircuit:\\n circuit = QuantumCircuit(3, 3)\\n if style == \"naive\":\\n circuit.h(0)\\n circuit.cx(0, 1)\\n circuit.cx(0, 2)\\n elif style == \"chain\":\\n circuit.h(0)\\n circuit.cx(0, 1)\\n circuit.cx(1, 2)\\n elif style == \"middle_root\":\\n circuit.h(1)\\n circuit.cx(1, 0)\\n circuit.cx(1, 2)\\n else:\\n raise ValueError(\"style must be naive, chain, or middle_root\")\\n circuit.measure([0, 1, 2], [0, 1, 2])\\n return circuit\\n\\ncircuit = ghz_candidate(style=\"chain\")\\n'\n", "editable_circuit_lab(\n", " initial_code=editable_code,\n", " context={\"QuantumCircuit\": QuantumCircuit, \"simulate_counts\": simulate_capstone_counts},\n", " title='Studio 2: Compare The Evidence',\n", " instructions='Do not choose a winner until the same evidence layers have been inspected for each plausible candidate.',\n", " shots=256,\n", ")\n" ], "id": "b52a6e09" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Studio Prompt 3: Write The Final Review\n", "\n", "\n", " End with a recommendation that another engineer could read, challenge, and still respect.\n" ], "id": "175f95cd" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "LOCAL_BASIS = [\"rz\", \"sx\", \"x\", \"cx\"]\n", "capstone_noise = build_demo_noise_model(\n", " single_qubit_error=0.01,\n", " two_qubit_error=0.04,\n", " readout_error=0.02,\n", ")\n", "\n", "def simulate_capstone_counts(circuit, shots=256):\n", " return simulate_counts(\n", " circuit,\n", " shots=shots,\n", " noise_model=capstone_noise,\n", " basis_gates=LOCAL_BASIS,\n", " coupling_map=line_coupling_map(circuit.num_qubits),\n", " optimization_level=1,\n", " )\n", "\n", "editable_code = '\\nfrom qiskit import QuantumCircuit\\n\\ndef ghz_candidate(style: str = \"middle_root\", add_extra_layer: bool = False) -> QuantumCircuit:\\n circuit = QuantumCircuit(3, 3)\\n if style == \"chain\":\\n circuit.h(0)\\n circuit.cx(0, 1)\\n circuit.cx(1, 2)\\n else:\\n circuit.h(1)\\n circuit.cx(1, 0)\\n circuit.cx(1, 2)\\n if add_extra_layer:\\n circuit.cz(0, 2)\\n circuit.measure([0, 1, 2], [0, 1, 2])\\n return circuit\\n\\ncircuit = ghz_candidate(style=\"middle_root\", add_extra_layer=False)\\n'\n", "editable_circuit_lab(\n", " initial_code=editable_code,\n", " context={\"QuantumCircuit\": QuantumCircuit, \"simulate_counts\": simulate_capstone_counts},\n", " title='Studio 3: Final Review',\n", " instructions='Use the editable candidate to stress-test the final recommendation and write down what would change your mind.',\n", " shots=256,\n", ")\n" ], "id": "b9bda3a4" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "quiz_block([{'prompt': 'What is the right studio goal for the capstone module?', 'options': ['Produce a compact design review that compares candidates and defends one under explicit constraints', 'Produce the largest notebook in the repository', 'Avoid final judgement to stay neutral'], 'correct_index': 0, 'explanation': 'The capstone should culminate in argued choice, not indefinite comparison.'}, {'prompt': 'Why is the capstone still local-first here?', 'options': ['Because the aim is to train judgement and workflow discipline without outsourcing the reasoning loop', 'Because hardware-aware thinking is unnecessary', 'Because local simulation gives exact hardware truth'], 'correct_index': 0, 'explanation': 'Local-first keeps the course controllable while still training real design habits.'}], heading='Studio Design Check')\n" ], "id": "4aca886c" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "evidence_checklist(['The design brief states both objective and local constraints.', 'At least two plausible candidate circuits are compared.', 'Ideal evidence is shown before constrained claims are made.', 'Compiled burden is compared under a fixed local constraint model.', 'Noise-aware evidence is compared under a declared local model.', 'The notebook ends with an explicit recommendation.', 'Residual risk or limits are named honestly.', 'Another engineer could reproduce the comparison from the notebook.'], title='Capstone Circuit Design Review Evidence Checklist')\n" ], "id": "5d951e6f" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Studio Debrief\n", "\n", "\n", " A successful final studio notebook should feel like a design review someone could actually use. It should communicate the brief, the candidate family, the evidence, the recommendation, and the residual uncertainty without hiding behind either hype or vagueness.\n" ], "id": "37b8b543" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Studio Standard\n", "\n", "A strong studio notebook is compact, explicit, and reviewable. It does not hide behind volume. It makes the objective clear, the candidate or case structure visible, the evidence traceable, and the final judgement conditional in the right way. If those things are not yet present, the notebook is not finished no matter how many cells it contains.\n" ], "id": "2db1e1f8" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What A Finished Studio Should Feel Like\n", "\n", "The finished notebook should feel like something another engineer could open and use. They should be able to understand what the notebook is trying to decide, how the circuits were compared, what evidence was gathered, and why the recommendation or diagnosis ended where it did. That is the practical definition of \"world-class\" in this project: not theatrical polish, but concentrated clarity under real engineering burdens.\n" ], "id": "5246c40b" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Final Check Before You Stop\n", "\n", "Before you leave a studio notebook, ask one last question: if another engineer disagreed with my conclusion, would the notebook give them enough material to locate the disagreement precisely? If the answer is yes, the studio is doing its job.\n" ], "id": "6add3b66" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "reflection_box('What brief did you ultimately freeze for the final review, and why was it appropriate?')\n" ], "id": "3b5afc73" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "reflection_box('Which evidence layer most influenced the final ranking of your candidates?')\n" ], "id": "40108682" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "reflection_box('What residual risk did you include in the recommendation, and why did it matter?')\n" ], "id": "4876575a" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "reflection_box('Name the single most important course habit that now feels non-negotiable in professional circuit design.')\n" ], "id": "9ee233ce" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "feedback_iteration_panel(title='Capstone Circuit Design Review Studio Revision Loop', prompt='Write the decision or diagnosis the studio currently supports, the evidence carrying that weight, the main remaining uncertainty, and the next revision that would sharpen the notebook.')\n" ], "id": "aea91a1c" }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "assessment_blueprint = load_assessment_blueprint()\n", "rubric_scorecard(\n", " assessment_blueprint.get_rubric('capstone_design_review'),\n", " title='Capstone Circuit Design Review Studio Self-Grading',\n", ")\n" ], "id": "bd3da293" }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## What To Open Next\n", "\n", "Next notebook: [Course Complete](../../COURSE_COMPLETE.ipynb)\n", "\n", "When you finish this notebook, open the next notebook shown above. Stay on the guarded mainline route.\n" ], "id": "ce05556f" } ], "metadata": { "kernelspec": { "display_name": "QuantumLearning (.venv)", "language": "python", "name": "quantum-learning" }, "language_info": { "name": "python", "version": "3.12" } }, "nbformat": 4, "nbformat_minor": 5 }