\n",
"\n",
"\n",
"## Mainline Navigation\n",
"\n",
"Step 48 of 59. Follow the official walkthrough in order.\n",
"\n",
"Previous notebook: [Hardware-Aware Redesign Studio Lecture](lecture.ipynb)\n",
"\n",
"Next notebook: [Hardware-Aware Redesign Studio Problems](problems.ipynb)\n",
"\n",
"Rule: complete the mandatory cells in this notebook before you open the next one.\n"
],
"id": "f105b51d"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"The lab turns topology pressure into something concrete. You will stress an abstract circuit, inspect the cost, and then edit alternative layouts that try to preserve the same objective more intelligently.\n"
],
"id": "188a3e7f"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Lab Protocol\n",
"\n",
"\n",
" Keep the constraints fixed while you compare candidates. Use the same basis-gate set, the same coupling map, and the same reporting contract. Only then do the structural differences mean what you think they mean.\n"
],
"id": "09aaed5a"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "setup"
},
"source": [
"\n",
"
\n",
"MANDATORY SETUP · Difficulty 1/10 · Environment, import, or helper cell required by the notebook.\n",
"
\n",
"\n",
"## Lab 1: Topology Stress Test\n",
"\n",
"\n",
" Start with the naive abstract circuit and let the line-topology preview expose its pressure. The purpose is not to shame the ideal circuit. The purpose is to learn how the mismatch shows up.\n"
],
"id": "e7c51729"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n"
],
"id": "85f3642b"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"step_reference_table([{'marker': '[1]', 'code_focus': 'Write the abstract target circuit clearly before worrying about rescue by the transpiler.', 'diagram_effect': 'The first diagram states the ideal intent with no attempt to hide topology pressure.', 'why_it_matters': 'Human redesign starts by knowing what the unpressured circuit was trying to express.'}, {'marker': '[2]', 'code_focus': 'Expose basis-gate and coupling-map assumptions explicitly.', 'diagram_effect': 'The device pressure becomes a visible part of the experiment rather than a hidden environment fact.', 'why_it_matters': 'You cannot reason about hardware cost if the constraints remain implicit.'}, {'marker': '[3]', 'code_focus': 'Inspect the compiled rewrite and decide which costs were caused by your abstract layout.', 'diagram_effect': 'The compiled version shows extra structure, depth, or routing burden.', 'why_it_matters': 'Professional redesign begins where default compilation becomes expensive.'}, {'marker': '[4]', 'code_focus': 'Create and compare a human-aware alternative instead of treating the compiler as the final word.', 'diagram_effect': 'A second circuit appears whose structure anticipates the topology rather than suffering under it.', 'why_it_matters': 'Hardware awareness is redesign, not passive observation of transpiler output.'}])\n"
],
"id": "7374c09e"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"MANDATORY TEST · Difficulty 2/10 · Official walkthrough multiple-choice test.\n",
"
\n"
],
"id": "6f933c21"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"quiz_block([{'prompt': 'What should you inspect first when a compiled circuit gets much deeper?', 'options': ['Which abstract interactions violated the declared topology', 'The notebook font', 'Whether the simulator seed changed'], 'correct_index': 0, 'explanation': 'Depth inflation is usually tracing back to topology or basis pressure.'}, {'prompt': 'Why compare a naive star GHZ to a middle-root or chain version?', 'options': ['To see whether human-aware structure can reduce routing cost before compilation', 'Because only one can be entangling', 'Because the transpiler refuses to compile chain circuits'], 'correct_index': 0, 'explanation': 'The comparison reveals which costs were self-inflicted by the abstract layout.'}], heading='Lab Checkpoint A')\n"
],
"id": "2ec20922"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"\n",
"## Lab 2: Manual Redesign\n",
"\n",
"\n",
" Now try a line-friendlier candidate whose abstract structure already anticipates the coupling map. The lesson is not that one circuit shape always wins. The lesson is that you should be able to propose a plausible alternative and explain why it fits the hardware story better.\n"
],
"id": "ed555e0a"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"\n",
"## Lab 3: Candidate Comparison\n",
"\n",
"\n",
" Compare several candidate families under the same local constraints. This is the closest the module gets to real redesign practice: more than one plausible answer, one fixed constraint model, and a need for explicit judgement.\n"
],
"id": "c52907f1"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"MANDATORY TEST · Difficulty 2/10 · Official walkthrough multiple-choice test.\n",
"
\n"
],
"id": "a3e78f99"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"quiz_block([{'prompt': 'What is a strong redesign note?', 'options': ['I moved the root to the middle because the line topology can host those interactions more directly', 'I changed the circuit because it looked simpler', 'I let the compiler decide and stopped reading'], 'correct_index': 0, 'explanation': 'Good redesign language ties structure to topology-aware intent.'}, {'prompt': 'Why is it useful to keep basis gates fixed during candidate comparison?', 'options': ['So differences in cost are more attributable to circuit design than to a moving target backend model', 'Because basis gates never matter', 'Because fixed basis gates guarantee identical counts'], 'correct_index': 0, 'explanation': 'Stable constraints make comparison more interpretable.'}], heading='Lab Checkpoint B')\n"
],
"id": "820fd1e3"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Lab Debrief\n",
"\n",
"\n",
" The key change after this lab should be that topology no longer feels like an external annoyance. It should feel like part of the circuit-design problem itself. Once that shift happens, the difference between observing transpilation and redesigning for it becomes much clearer.\n"
],
"id": "61ac639d"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Why The Lab Is Slower Than A Demo\n",
"\n",
"These labs are built to slow down the moment where many learners usually rush. In professional work, the difference between a good decision and a weak one often depends on whether you changed one variable at a time, whether you kept the objective fixed, and whether you wrote down what result you expected before running the next cell. That is why the labs here are not just demonstrations. They are rehearsals for disciplined engineering comparison.\n"
],
"id": "dc96d832"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Prediction Ledger\n",
"\n",
"If the comparison starts to blur, return to a prediction ledger. Write down what should stay invariant, what metric or observation should move, and what conclusion would follow if it does. That simple habit will make your later capstone work far stronger because it converts trial-and-error into interpretable evidence.\n"
],
"id": "c3deb747"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n"
],
"id": "68eb7142"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"reflection_box('Write a short redesign note defending one manual alternative under the fixed line-topology assumptions.')\n"
],
"id": "289fb921"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n"
],
"id": "e28fb931"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"reflection_box('Write one prediction habit from this lab that you want to preserve in later professional work.')\n"
],
"id": "245bef17"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n"
],
"id": "d9316687"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"feedback_iteration_panel(title='Hardware-Aware Redesign Studio Lab Feedback Loop', prompt='Turn the lab into a review note: state the current claim, cite the strongest evidence, name the main remaining risk, and write the next comparison you would run.')\n"
],
"id": "83718fa6"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 2/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"\n",
"\n",
"## What To Open Next\n",
"\n",
"Next notebook: [Hardware-Aware Redesign Studio Problems](problems.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": "3594de8f"
},
{
"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": [
"\n",
"
\n",
"META READING · Difficulty 1/10 · Optional-zone boundary. The official walkthrough is already complete above.\n",
"
\n",
"\n",
"\n",
"## Facultative Extension Zone\n",
"\n",
"You have already completed the mandatory walkthrough for **Hardware-Aware Redesign Studio Lab**. Everything below is optional. Use it only if you want deeper consolidation or extra transfer work.\n"
],
"id": "3888818e"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "facultative",
"ql_track": "facultative",
"ql_role": "reading",
"ql_difficulty": 4,
"ql_note": "Optional extension reading."
},
"source": [
"\n",
"
\n",
"\n",
"## Facultative Extension Reading\n",
"\n",
"In **Hardware-Aware Redesign Studio Lab**, the mandatory labs already gave you the official practice loop. This optional cell is for deeper experimentation discipline: decide one variable you would perturb next, one quantity you would track, and one false conclusion you want to avoid.\n"
],
"id": "353e10b7"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "facultative",
"ql_role": "test"
},
"source": [
"\n",
"
\n"
],
"id": "37d1e9cb"
},
{
"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': 'In an optional lab variant, what should you change first?', 'options': ['One design variable you can explain', 'As many gates as possible to make the result surprising', 'The notebook order itself'], 'correct_index': 0, 'explanation': 'Optional exploration is still strongest when the perturbation is controlled.'}, {'prompt': 'What makes an optional lab note useful?', 'options': ['It records what changed, what stayed fixed, and what evidence moved', 'It only reports that the circuit still ran', 'It avoids writing predictions to save time'], 'correct_index': 0, 'explanation': 'The extension is about deeper evidence discipline.'}], heading='Facultative Extension Test')\n"
],
"id": "fad7d65b"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "facultative",
"ql_role": "exercise"
},
"source": [
"\n",
"