mirror of
https://github.com/saymrwulf/QuantumLearning.git
synced 2026-05-30 23:18:38 +00:00
281 lines
12 KiB
Text
281 lines
12 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Hardware-Aware Redesign Studio Problems\n"
|
|
],
|
|
"id": "5d9a8f25"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"These problems check whether you can turn compile evidence into design judgement instead of stopping at surface observations.\n"
|
|
],
|
|
"id": "efa77236"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## How To Use This Notebook\n",
|
|
"\n",
|
|
"\n",
|
|
" Prefer answers that locate cost in structure and keep the objective stable. Reject answers that talk about hardware awareness as though it were a mood instead of a concrete constraint-and-redesign practice.\n"
|
|
],
|
|
"id": "a4a94cef"
|
|
},
|
|
{
|
|
"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": "3e7046de"
|
|
},
|
|
{
|
|
"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": "2e8f1586"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Constraint Reading\n",
|
|
"\n",
|
|
"Treat these questions as miniature review situations rather than as trivia. The correct answer should survive a serious engineering conversation.\n"
|
|
],
|
|
"id": "bbb5fed3"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"quiz_block([{'prompt': 'Which question belongs first in a hardware-aware review?', 'options': ['Which interactions in the abstract circuit stress the stated topology?', 'Which color theme does the notebook use?', 'How many markdown cells are present?'], 'correct_index': 0, 'explanation': 'Redesign starts with locating the structural source of cost.'}, {'prompt': 'Why is a coupling map a design object here?', 'options': ['Because it changes what circuit structure is cheap, awkward, or compiler-rescued', 'Because it determines the correct measurement result directly', 'Because it replaces basis gates'], 'correct_index': 0, 'explanation': 'The topology reshapes the engineering trade space.'}], heading='Constraint Reading')\n"
|
|
],
|
|
"id": "49291d4f"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Compiler Versus Designer\n",
|
|
"\n",
|
|
"Treat these questions as miniature review situations rather than as trivia. The correct answer should survive a serious engineering conversation.\n"
|
|
],
|
|
"id": "eb2b0f38"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"quiz_block([{'prompt': 'What is the weak attitude this module opposes?', 'options': ['The transpiler will fix everything, so I do not need to read the compiled circuit', 'I should compare alternative layouts', 'I should measure cost with the same constraints across candidates'], 'correct_index': 0, 'explanation': 'Passive trust in compilation is not hardware-aware design.'}, {'prompt': 'What is a strong reason to inspect `depth_after` and `ops_after` together?', 'options': ['They tell a more complete story about route-induced structural cost', 'They are interchangeable numbers', 'They eliminate the need to see the compiled circuit'], 'correct_index': 0, 'explanation': 'Multiple metrics help connect design moves to concrete burden.'}], heading='Compiler Versus Designer')\n"
|
|
],
|
|
"id": "4fc3d01b"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Manual Alternatives\n",
|
|
"\n",
|
|
"Treat these questions as miniature review situations rather than as trivia. The correct answer should survive a serious engineering conversation.\n"
|
|
],
|
|
"id": "1c52f02d"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"quiz_block([{'prompt': 'What makes a manual alternative worth keeping?', 'options': ['It preserves the objective while reducing avoidable compile-time pressure', 'It simply has fewer lines of Python', 'It hides more logic inside helpers'], 'correct_index': 0, 'explanation': 'The best redesigns keep behavior while improving structural fit.'}, {'prompt': 'Why might a middle-root GHZ be better than a star-root GHZ on a line?', 'options': ['Because the central qubit can reach both sides with less routing strain', 'Because middle qubits are more quantum', 'Because it avoids measurement entirely'], 'correct_index': 0, 'explanation': 'Positioning the root can align the abstract circuit with the topology.'}], heading='Manual Alternatives')\n"
|
|
],
|
|
"id": "c500f512"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Review Language\n",
|
|
"\n",
|
|
"Treat these questions as miniature review situations rather than as trivia. The correct answer should survive a serious engineering conversation.\n"
|
|
],
|
|
"id": "f5bfa2b8"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"quiz_block([{'prompt': 'Which review statement is strongest?', 'options': ['The abstract layout asks one qubit to talk nonlocally to two distant neighbors, so the compile cost is largely self-created', 'The transpiler output is ugly', 'The circuit should use more barriers'], 'correct_index': 0, 'explanation': 'Good review language names the structural reason for the cost.'}, {'prompt': 'What should support a final redesign claim?', 'options': ['Stable constraints, candidate metrics, and a narrative linking the better structure to those numbers', 'Only personal preference', 'Only the ideal-state intuition'], 'correct_index': 0, 'explanation': 'A redesign recommendation should be evidence-backed and constraint-aware.'}], heading='Review Language')\n"
|
|
],
|
|
"id": "76edb0ee"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Mini Case\n",
|
|
"\n",
|
|
"\n",
|
|
" A weak hardware-aware notebook often has the right ingredients but the wrong posture. It shows an abstract circuit, a compiled circuit, and maybe a couple of metrics, but it never really asks whether the original layout was a wise thing to ask of the hardware in the first place. This problems notebook pushes against that passivity. The point is not to admire compiler output. The point is to decide whether a human should have designed differently.\n"
|
|
],
|
|
"id": "1ae01e9a"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## What These Questions Are Really Testing\n",
|
|
"\n",
|
|
"The multiple-choice format is only the surface. Underneath it, the notebook is testing whether you can preserve the right burdens while the wording shifts. If your understanding is strong, a changed phrase still points you back to the same structure, constraint, invariant, or recommendation logic. If your understanding is weak, the wording change will tempt you into vague or prestige-based answers. That is why these problem sets matter.\n"
|
|
],
|
|
"id": "992ecd47"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Common Failure Mode\n",
|
|
"\n",
|
|
"A common failure mode in advanced notebook work is broad correctness with local vagueness. A learner says something true at a high level, yet still fails to name what this particular workflow, redesign, diagnosis, or recommendation is actually doing. The problems notebook is meant to squeeze that vagueness out. It prefers circuit-specific or review-specific sentences over vague correctness.\n"
|
|
],
|
|
"id": "e62cbfe8"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Why Written Justification Matters\n",
|
|
"\n",
|
|
"The written prompts at the end of this notebook are not filler. They are where you prove that the right distinctions are surviving contact with your own prose. Multiple-choice blocks can tell you whether a distinction still feels recognizable. A written answer tells you whether you can actually deploy that distinction in a design note, verification memo, or review comment. Professional skill depends on that second ability.\n"
|
|
],
|
|
"id": "78179f06"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Written Checks\n",
|
|
"\n",
|
|
"Use the prompts below to practice full-sentence engineering judgement.\n"
|
|
],
|
|
"id": "1dfac3e9"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"reflection_box('Explain why a topology-aware alternative is not automatically better unless the objective is kept stable.')\n"
|
|
],
|
|
"id": "f808c23d"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"reflection_box('Describe the minimum evidence you would want before accepting a hardware-aware redesign recommendation.')\n"
|
|
],
|
|
"id": "eea38f55"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"feedback_iteration_panel(title='Hardware-Aware Redesign Studio Problem-Set Review Loop', prompt='After the quizzes, write the claim you now trust most, the evidence pattern behind it, the phrasing that still feels weak, and the next rewrite you owe yourself.')\n"
|
|
],
|
|
"id": "4e38bb03"
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"assessment_blueprint = load_assessment_blueprint()\n",
|
|
"rubric_scorecard(\n",
|
|
" assessment_blueprint.get_rubric('module_self_review'),\n",
|
|
" title='Hardware-Aware Redesign Studio Problem Self-Grading',\n",
|
|
")\n"
|
|
],
|
|
"id": "c05b32a9"
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Exit Condition\n",
|
|
"\n",
|
|
"\n",
|
|
" Move on when you can name the structural source of compile cost and propose a plausible human-aware alternative under fixed constraints.\n"
|
|
],
|
|
"id": "a956e11d"
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "QuantumLearning (.venv)",
|
|
"language": "python",
|
|
"name": "quantum-learning"
|
|
},
|
|
"language_info": {
|
|
"name": "python",
|
|
"version": "3.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|