diff --git a/notebooks/COURSE_BLUEPRINT.ipynb b/notebooks/COURSE_BLUEPRINT.ipynb index 2cad177..23b5a3e 100644 --- a/notebooks/COURSE_BLUEPRINT.ipynb +++ b/notebooks/COURSE_BLUEPRINT.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 2 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n- Previous notebook: [Start Here](START_HERE.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](START_HERE.ipynb)\n2. **Course Blueprint** <- you are here\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 2 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n- Previous notebook: [Start Here](START_HERE.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](START_HERE.ipynb)\n2. **Course Blueprint** <- you are here\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "What This Course Separates" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
What This Course Separates
\n
\n\nThis course keeps three stories separate on purpose:\n\n- the algebraic purpose of the transform\n- the local in-place butterfly dataflow\n- the Kyber-specific implementation conventions\n\nThe point is to stop those three from collapsing into one blurry \u201cFFT-like thing\u201d.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

What This Course Separates

\n
\n\nThis course keeps three stories separate on purpose:\n\n- the algebraic purpose of the transform\n- the local in-place butterfly dataflow\n- the Kyber-specific implementation conventions\n\nThe point is to stop those three from collapsing into one blurry \u201cFFT-like thing\u201d.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "The Learning Staircase" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n structure\n
\n
The Learning Staircase
\n
\n\nThe supported staircase is:\n\n1. schoolbook multiplication and diagonals\n2. cyclic and negacyclic wraparound\n3. direct negative-wrapped NTT and iNTT\n4. fast forward CT butterflies\n5. fast inverse GS butterflies\n6. bit-reversal and ordering\n7. Kyber parameter reality and base multiplication\n8. debugging wrong sign / wrong zeta / wrong order / wrong scale failures\n" + "source": "
\n Level 2\n
\n structure\n core path\n
\n

The Learning Staircase

\n
\n\nThe supported staircase is:\n\n1. schoolbook multiplication and diagonals\n2. cyclic and negacyclic wraparound\n3. direct negative-wrapped NTT and iNTT\n4. fast forward CT butterflies\n5. fast inverse GS butterflies\n6. bit-reversal and ordering\n7. Kyber parameter reality and base multiplication\n8. debugging wrong sign / wrong zeta / wrong order / wrong scale failures\n" }, { "cell_type": "markdown", @@ -58,7 +58,7 @@ "title": "Bundles" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n bundles\n
\n
Bundles
\n
\n\nEach serious module uses the same rhythm:\n\n- `lecture.ipynb` = slow explanation plus visual demos\n- `lab.ipynb` = prediction before execution\n- `problems.ipynb` = retrieval and reflection\n- `studio.ipynb` = comparison, debugging, and implementation reading\n" + "source": "
\n Level 2\n
\n bundles\n core path\n
\n

Bundles

\n
\n\nEach serious module uses the same rhythm:\n\n- `lecture.ipynb` = slow explanation plus visual demos\n- `lab.ipynb` = prediction before execution\n- `problems.ipynb` = retrieval and reflection\n- `studio.ipynb` = comparison, debugging, and implementation reading\n" }, { "cell_type": "markdown", @@ -70,7 +70,7 @@ "title": "What \u201cBlunt And Graphical\u201d Means Here" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n expectation\n
\n
What \u201cBlunt And Graphical\u201d Means Here
\n
\n\nThe notebooks should not ask the learner to imagine too much in their head.\n\nExpect:\n\n- schoolbook product grids\n- wraparound arrows\n- explicit stage arrays\n- stage sliders\n- bit-reversal wire maps\n- side-by-side wrong vs right traces\n" + "source": "
\n Level 2\n
\n expectation\n core path\n
\n

What \u201cBlunt And Graphical\u201d Means Here

\n
\n\nThe notebooks should not ask the learner to imagine too much in their head.\n\nExpect:\n\n- schoolbook product grids\n- wraparound arrows\n- explicit stage arrays\n- stage sliders\n- bit-reversal wire maps\n- side-by-side wrong vs right traces\n" }, { "cell_type": "markdown", @@ -82,7 +82,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Course Blueprint**.\n\n**Primary next action**\n- Next notebook: [Step 3 of 27 - Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Start Here](START_HERE.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Course Blueprint**.\n\n**Primary next action**\n- Next notebook: [Step 3 of 27 - Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Start Here](START_HERE.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/COURSE_COMPLETE.ipynb b/notebooks/COURSE_COMPLETE.ipynb index c5e727e..9f853ec 100644 --- a/notebooks/COURSE_COMPLETE.ipynb +++ b/notebooks/COURSE_COMPLETE.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 27 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: you are at the end of the supported route\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](START_HERE.ipynb)\n2. [Course Blueprint](COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n27. **Course Complete** <- you are here\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 27 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: you are at the end of the supported route\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](START_HERE.ipynb)\n2. [Course Blueprint](COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n27. **Course Complete** <- you are here\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Route Complete" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Route Complete
\n
\n\nYou reached the end of the supported route.\n\nIf the course did its job, you should now be able to separate:\n\n- raw polynomial multiplication\n- negacyclic structure\n- direct NTT / iNTT definitions\n- fast CT / GS butterfly flow\n- order changes and scaling\n- Kyber\u2019s specific modulus and base-multiplication story\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Route Complete

\n
\n\nYou reached the end of the supported route.\n\nIf the course did its job, you should now be able to separate:\n\n- raw polynomial multiplication\n- negacyclic structure\n- direct NTT / iNTT definitions\n- fast CT / GS butterfly flow\n- order changes and scaling\n- Kyber\u2019s specific modulus and base-multiplication story\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Exit Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Exit Reflection
\n
\n\nFinal written prompts:\n\n1. Explain the difference between \u201cthe transform as mathematics\u201d and \u201cthe butterfly network as an implementation strategy\u201d.\n2. Explain why Kyber v3 needs more than the naive \u201cjust use a 2n-th root\u201d mental model.\n3. Name the first four checks you would run if an iNTT output looked wrong.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Exit Reflection

\n
\n\nFinal written prompts:\n\n1. Explain the difference between \u201cthe transform as mathematics\u201d and \u201cthe butterfly network as an implementation strategy\u201d.\n2. Explain why Kyber v3 needs more than the naive \u201cjust use a 2n-th root\u201d mental model.\n3. Name the first four checks you would run if an iNTT output looked wrong.\n" }, { "cell_type": "markdown", @@ -58,7 +58,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Course Complete**.\n\n**Primary next action**\n- Next notebook: you are at the end of the supported route\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Course Complete**.\n\n**Primary next action**\n- Next notebook: you are at the end of the supported route\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n- Restart route: [Start Here](START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/START_HERE.ipynb b/notebooks/START_HERE.ipynb index c0325c7..96a8112 100644 --- a/notebooks/START_HERE.ipynb +++ b/notebooks/START_HERE.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 1 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Course Blueprint](COURSE_BLUEPRINT.ipynb)\n- Previous notebook: you are at the start of the supported route\n- Restart route: [Start Here](START_HERE.ipynb)\n\n**Official route chain**\n1. **Start Here** <- you are here\n2. [Course Blueprint](COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 1 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Course Blueprint](COURSE_BLUEPRINT.ipynb)\n- Previous notebook: you are at the start of the supported route\n- Restart route: [Start Here](START_HERE.ipynb)\n\n**Official route chain**\n1. **Start Here** <- you are here\n2. [Course Blueprint](COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Welcome" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Welcome
\n
\n\nThis course is for people who need to see the algorithm move.\n\nThe goal is not to hide behind abstract formulas. The goal is to make the NTT and iNTT feel physically inspectable:\n\n- every stage should look like values moving through wires\n- every wraparound should be visible\n- every ordering change should be concrete\n- every Kyber-specific choice should be motivated by what the arithmetic allows\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Welcome

\n
\n\nThis course is for people who need to see the algorithm move.\n\nThe goal is not to hide behind abstract formulas. The goal is to make the NTT and iNTT feel physically inspectable:\n\n- every stage should look like values moving through wires\n- every wraparound should be visible\n- every ordering change should be concrete\n- every Kyber-specific choice should be motivated by what the arithmetic allows\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Official Route" } }, - "source": "## MANDATORY\n\n
\n Level 1\n
\n MANDATORY\n route\n
\n
Official Route
\n
\n\nFollow exactly one supported route:\n\n1. `START_HERE.ipynb`\n2. `COURSE_BLUEPRINT.ipynb`\n3. each bundle in `Lecture -> Lab -> Problems -> Studio` order\n4. `COURSE_COMPLETE.ipynb`\n\nSupported bundles:\n\n- `foundations/01_convolution_to_toy_ntt`\n- `foundations/02_negative_wrapped_ntt`\n- `butterfly_mechanics/03_fast_forward_ct`\n- `butterfly_mechanics/04_fast_inverse_gs`\n- `kyber_mapping/05_kyber_ntt_and_base_multiplication`\n- `professional/06_debugging_ntt_failures`\n" + "source": "
\n Level 1\n
\n route\n core path\n
\n

Official Route

\n
\n\nFollow exactly one supported route:\n\n1. `START_HERE.ipynb`\n2. `COURSE_BLUEPRINT.ipynb`\n3. each bundle in `Lecture -> Lab -> Problems -> Studio` order\n4. `COURSE_COMPLETE.ipynb`\n\nSupported bundles:\n\n- `foundations/01_convolution_to_toy_ntt`\n- `foundations/02_negative_wrapped_ntt`\n- `butterfly_mechanics/03_fast_forward_ct`\n- `butterfly_mechanics/04_fast_inverse_gs`\n- `kyber_mapping/05_kyber_ntt_and_base_multiplication`\n- `professional/06_debugging_ntt_failures`\n" }, { "cell_type": "markdown", @@ -55,10 +55,10 @@ "role": "mandatory", "difficulty": 1, "kind": "contract", - "title": "Visible Cell Contract" + "title": "How To Read The Notebook Cards" } }, - "source": "## MANDATORY\n\n
\n Level 1\n
\n MANDATORY\n contract\n
\n
Visible Cell Contract
\n
\n\nCell labels are not decoration. They tell you how to use the notebook:\n\n- `META` = route, pacing, and handoff\n- `MANDATORY` = the official walkthrough\n- `FACULTATIVE` = optional deepening only\n- difficulty `1-3` is reserved for mandatory work\n- difficulty `4-10` is reserved for facultative work\n" + "source": "
\n Level 1\n
\n how to use this\n core path\n
\n

How To Read The Notebook Cards

\n
\n\nThe colored card at the top of each cell tells you how to treat that block:\n\n- blue cards keep you on the route and stop you from getting lost\n- gold cards are the official walkthrough and should not be skipped\n- coral cards are optional deepening once the core path is solid\n- the small level badge is only a density warning, not the title of the cell\n" }, { "cell_type": "markdown", @@ -70,7 +70,7 @@ "title": "Local Operations" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n operations\n
\n
Local Operations
\n
\n\nRepo-local commands:\n\n- `scripts/bootstrap.sh`\n- `scripts/start.sh`\n- `scripts/status.sh`\n- `scripts/validate.sh`\n" + "source": "
\n Level 1\n
\n local setup\n route help\n
\n

Local Operations

\n
\n\nRepo-local commands:\n\n- `scripts/bootstrap.sh`\n- `scripts/start.sh`\n- `scripts/status.sh`\n- `scripts/validate.sh`\n" }, { "cell_type": "markdown", @@ -82,7 +82,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Start Here**.\n\n**Primary next action**\n- Next notebook: [Step 2 of 27 - Course Blueprint](COURSE_BLUEPRINT.ipynb)\n\n**Recovery links if you get lost**\n- Restart route: [Start Here](START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Start Here**.\n\n**Primary next action**\n- Next notebook: [Step 2 of 27 - Course Blueprint](COURSE_BLUEPRINT.ipynb)\n\n**Recovery links if you get lost**\n- Restart route: [Start Here](START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/03_fast_forward_ct/lab.ipynb b/notebooks/butterfly_mechanics/03_fast_forward_ct/lab.ipynb index 3e347a8..96da57f 100644 --- a/notebooks/butterfly_mechanics/03_fast_forward_ct/lab.ipynb +++ b/notebooks/butterfly_mechanics/03_fast_forward_ct/lab.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 12 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n12. **Butterfly Mechanics / 03 Fast Forward CT / Lab** <- you are here\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 12 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n12. **Butterfly Mechanics / 03 Fast Forward CT / Lab** <- you are here\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Lab Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Lab Goals
\n
\n\nYou should predict stage pairings and zetas before running the stage explorer.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Lab Goals

\n
\n\nYou should predict stage pairings and zetas before running the stage explorer.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Exercise 1" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 1
\n
\n\nFor the `n = 4` example, predict:\n\n- which original coefficients pair in stage 1\n- which adjacent positions pair in stage 2\n- why the output is not yet in normal order\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 1

\n
\n\nFor the `n = 4` example, predict:\n\n- which original coefficients pair in stage 1\n- which adjacent positions pair in stage 2\n- why the output is not yet in normal order\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Prediction Check For n=4\n# kind: exercise | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import butterfly_story_player, interactive_trace\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ndisplay(butterfly_story_player(trace))\ndisplay(interactive_trace(trace, title=\"Check your n=4 prediction\"))\n" + "source": "# Prediction Check For n=4\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import butterfly_story_player, interactive_trace\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ndisplay(butterfly_story_player(trace))\ndisplay(interactive_trace(trace, title=\"Check your n=4 prediction\"))\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Exercise 2" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 2
\n
\n\nFor the `n = 8` example, name the stage count before you run the next cell.\nThen name which stage feels most confusing and why.\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 2

\n
\n\nFor the `n = 8` example, name the stage count before you run the next cell.\nThen name which stage feels most confusing and why.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Prediction Check For n=8\n# kind: exercise | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\nfrom ntt_learning.visuals import interactive_trace\n\ntrace = fast_ntt_psi_ct_trace([0, 1, 2, 3, 4, 5, 6, 7], 97, find_psi(8, 97))\ndisplay(interactive_trace(trace, title=\"Check your n=8 prediction\"))\n" + "source": "# Prediction Check For n=8\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\nfrom ntt_learning.visuals import interactive_trace\n\ntrace = fast_ntt_psi_ct_trace([0, 1, 2, 3, 4, 5, 6, 7], 97, find_psi(8, 97))\ndisplay(interactive_trace(trace, title=\"Check your n=8 prediction\"))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nReflection prompt:\n\n- Which stage feels easiest to see by eye?\n- Which stage feels most like \u201cpure schedule\u201d rather than \u201cnew algebra\u201d?\n- Why is BO output not a bug?\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nReflection prompt:\n\n- Which stage feels easiest to see by eye?\n- Which stage feels most like \u201cpure schedule\u201d rather than \u201cnew algebra\u201d?\n- Why is BO output not a bug?\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Change The n=8 Signal\n# kind: exploration | level: 4\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\nfrom ntt_learning.visuals import interactive_trace\n\npsi = find_psi(8, 97)\n\ndef preview(a0=0, a1=1, a2=2, a3=3, a4=4, a5=5, a6=6, a7=7):\n trace = fast_ntt_psi_ct_trace([a0, a1, a2, a3, a4, a5, a6, a7], 97, psi)\n display(interactive_trace(trace, title=\"Interactive n=8 CT trace\"))\n\ndisplay(\n widgets.interact(\n preview,\n a0=(0, 12),\n a1=(0, 12),\n a2=(0, 12),\n a3=(0, 12),\n a4=(0, 12),\n a5=(0, 12),\n a6=(0, 12),\n a7=(0, 12),\n )\n)\n" + "source": "# Optional: Change The n=8 Signal\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\nfrom ntt_learning.visuals import interactive_trace\n\npsi = find_psi(8, 97)\n\ndef preview(a0=0, a1=1, a2=2, a3=3, a4=4, a5=5, a6=6, a7=7):\n trace = fast_ntt_psi_ct_trace([a0, a1, a2, a3, a4, a5, a6, a7], 97, psi)\n display(interactive_trace(trace, title=\"Interactive n=8 CT trace\"))\n\ndisplay(\n widgets.interact(\n preview,\n a0=(0, 12),\n a1=(0, 12),\n a2=(0, 12),\n a3=(0, 12),\n a4=(0, 12),\n a5=(0, 12),\n a6=(0, 12),\n a7=(0, 12),\n )\n)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 13 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 13 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/03_fast_forward_ct/lecture.ipynb b/notebooks/butterfly_mechanics/03_fast_forward_ct/lecture.ipynb index 68a31cd..e385000 100644 --- a/notebooks/butterfly_mechanics/03_fast_forward_ct/lecture.ipynb +++ b/notebooks/butterfly_mechanics/03_fast_forward_ct/lecture.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 11 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. **Butterfly Mechanics / 03 Fast Forward CT / Lecture** <- you are here\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 11 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. **Butterfly Mechanics / 03 Fast Forward CT / Lecture** <- you are here\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Objectives" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Objectives
\n
\n\nThis bundle is where the transform stops being a full matrix multiplication and becomes a staged butterfly network.\n\nFocus:\n\n- CT as the fast forward NTT strategy\n- visible stage arrays\n- explicit zeta values per pair\n- BO output vs NO output\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Objectives

\n
\n\nThis bundle is where the transform stops being a full matrix multiplication and becomes a staged butterfly network.\n\nFocus:\n\n- CT as the fast forward NTT strategy\n- visible stage arrays\n- explicit zeta values per pair\n- BO output vs NO output\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "CT Is A Schedule For Reusing Work" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
CT Is A Schedule For Reusing Work
\n
\n\nThe point of the CT butterfly is not to invent a new transform.\nThe point is to compute the same transform by reusing shared bracket terms instead of recomputing everything from scratch.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

CT Is A Schedule For Reusing Work

\n
\n\nThe point of the CT butterfly is not to invent a new transform.\nThe point is to compute the same transform by reusing shared bracket terms instead of recomputing everything from scratch.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See The Schedule Geometry Before The Numbers\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_stage_pairing_map, plot_stage_schedule\n\ndisplay(plot_stage_schedule(8, title=\"CT schedule skeleton for n=8\"))\ndisplay(plot_stage_pairing_map(8, 2, title=\"Stage 1 pairings for n=8\"))\ndisplay(plot_stage_pairing_map(8, 4, title=\"Stage 2 pairings for n=8\"))\ndisplay(plot_stage_pairing_map(8, 8, title=\"Stage 3 pairings for n=8\"))\n" + "source": "# See The Schedule Geometry Before The Numbers\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_stage_pairing_map, plot_stage_schedule\n\ndisplay(plot_stage_schedule(8, title=\"CT schedule skeleton for n=8\"))\ndisplay(plot_stage_pairing_map(8, 2, title=\"Stage 1 pairings for n=8\"))\ndisplay(plot_stage_pairing_map(8, 4, title=\"Stage 2 pairings for n=8\"))\ndisplay(plot_stage_pairing_map(8, 8, title=\"Stage 3 pairings for n=8\"))\n" }, { "cell_type": "code", @@ -74,7 +74,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Trace The Exact n=4 Paper Example\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, forward_ntt_psi\nfrom ntt_learning.visuals import butterfly_story_player, interactive_trace, plot_butterfly_network, plot_trace_overview\n\nsignal = [1, 2, 3, 4]\nmodulus = 7681\npsi = 1925\ntrace = fast_ntt_psi_ct_trace(signal, modulus, psi)\n\nprint(\"raw CT output (BO):\", trace.raw_output)\nprint(\"bit-reversed back to NO:\", trace.normal_order_output)\nprint(\"direct NTT_psi:\", forward_ntt_psi(signal, modulus, psi))\ndisplay(butterfly_story_player(trace))\ndisplay(plot_trace_overview(trace, title=\"CT overview for [1,2,3,4]\"))\ndisplay(plot_butterfly_network(trace, title=\"Full CT network for [1,2,3,4]\"))\ndisplay(interactive_trace(trace, title=\"CT forward trace\"))\n" + "source": "# Trace The Exact n=4 Paper Example\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, forward_ntt_psi\nfrom ntt_learning.visuals import butterfly_story_player, interactive_trace, plot_butterfly_network, plot_trace_overview\n\nsignal = [1, 2, 3, 4]\nmodulus = 7681\npsi = 1925\ntrace = fast_ntt_psi_ct_trace(signal, modulus, psi)\n\nprint(\"raw CT output (BO):\", trace.raw_output)\nprint(\"bit-reversed back to NO:\", trace.normal_order_output)\nprint(\"direct NTT_psi:\", forward_ntt_psi(signal, modulus, psi))\ndisplay(butterfly_story_player(trace))\ndisplay(plot_trace_overview(trace, title=\"CT overview for [1,2,3,4]\"))\ndisplay(plot_butterfly_network(trace, title=\"Full CT network for [1,2,3,4]\"))\ndisplay(interactive_trace(trace, title=\"CT forward trace\"))\n" }, { "cell_type": "markdown", @@ -86,7 +86,7 @@ "title": "What You Should Notice In The Stage Viewer" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
What You Should Notice In The Stage Viewer
\n
\n\nDo not just read the final answer.\nNotice:\n\n- which pairs talk to each other in each stage\n- which `zeta` each pair uses\n- how the array order changes before the final bit-reversal correction\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

What You Should Notice In The Stage Viewer

\n
\n\nDo not just read the final answer.\nNotice:\n\n- which pairs talk to each other in each stage\n- which `zeta` each pair uses\n- how the array order changes before the final bit-reversal correction\n" }, { "cell_type": "code", @@ -100,7 +100,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Run The Second n=4 Paper Example\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import interactive_trace\n\nsignal = [5, 6, 7, 8]\ntrace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\nprint(\"BO output:\", trace.raw_output)\nprint(\"NO output:\", trace.normal_order_output)\ndisplay(interactive_trace(trace, title=\"Second CT trace\"))\n" + "source": "# Run The Second n=4 Paper Example\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import interactive_trace\n\nsignal = [5, 6, 7, 8]\ntrace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\nprint(\"BO output:\", trace.raw_output)\nprint(\"NO output:\", trace.normal_order_output)\ndisplay(interactive_trace(trace, title=\"Second CT trace\"))\n" }, { "cell_type": "code", @@ -114,7 +114,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Go One Stage Deeper With n=8\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\nfrom ntt_learning.visuals import butterfly_story_player, interactive_trace, plot_butterfly_network, plot_trace_overview\n\nsignal = [0, 1, 2, 3, 4, 5, 6, 7]\nmodulus = 97\npsi = find_psi(8, modulus)\ntrace = fast_ntt_psi_ct_trace(signal, modulus, psi)\n\nprint(\"psi:\", psi)\nprint(\"BO output:\", trace.raw_output)\nprint(\"NO output:\", trace.normal_order_output)\ndisplay(butterfly_story_player(trace))\ndisplay(plot_trace_overview(trace, title=\"Three CT stages for n=8\"))\ndisplay(plot_butterfly_network(trace, title=\"Full CT network for n=8\"))\ndisplay(interactive_trace(trace, title=\"n=8 CT stage explorer\"))\n" + "source": "# Go One Stage Deeper With n=8\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\nfrom ntt_learning.visuals import butterfly_story_player, interactive_trace, plot_butterfly_network, plot_trace_overview\n\nsignal = [0, 1, 2, 3, 4, 5, 6, 7]\nmodulus = 97\npsi = find_psi(8, modulus)\ntrace = fast_ntt_psi_ct_trace(signal, modulus, psi)\n\nprint(\"psi:\", psi)\nprint(\"BO output:\", trace.raw_output)\nprint(\"NO output:\", trace.normal_order_output)\ndisplay(butterfly_story_player(trace))\ndisplay(plot_trace_overview(trace, title=\"Three CT stages for n=8\"))\ndisplay(plot_butterfly_network(trace, title=\"Full CT network for n=8\"))\ndisplay(interactive_trace(trace, title=\"n=8 CT stage explorer\"))\n" }, { "cell_type": "code", @@ -128,7 +128,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See BO Output And NO Output Side By Side\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_bit_reversal_mapping, plot_vector_comparison\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n trace.normal_order_output,\n left_label=\"BO\",\n right_label=\"NO\",\n title=\"Same CT values, different ordering\",\n )\n)\ndisplay(plot_bit_reversal_mapping(4, title=\"Why BO becomes NO after bit-reversal\"))\n" + "source": "# See BO Output And NO Output Side By Side\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_bit_reversal_mapping, plot_vector_comparison\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n trace.normal_order_output,\n left_label=\"BO\",\n right_label=\"NO\",\n title=\"Same CT values, different ordering\",\n )\n)\ndisplay(plot_bit_reversal_mapping(4, title=\"Why BO becomes NO after bit-reversal\"))\n" }, { "cell_type": "markdown", @@ -140,7 +140,7 @@ "title": "Retrieval Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Retrieval Check
\n
\n\n1. What does CT change: the transform definition or the computation schedule?\n2. Why is the output naturally in BO rather than NO?\n3. In a stage diagram, what are the first three things you should inspect before any formula?\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Retrieval Check

\n
\n\n1. What does CT change: the transform definition or the computation schedule?\n2. Why is the output naturally in BO rather than NO?\n3. In a stage diagram, what are the first three things you should inspect before any formula?\n" }, { "cell_type": "code", @@ -154,7 +154,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Inspect Stage Rows As Data\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, stage_rows\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nfor stage in trace.stages:\n print(\"stage\", stage.stage_index)\n for row in stage_rows(stage):\n print(row)\n" + "source": "# Optional: Inspect Stage Rows As Data\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, stage_rows\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nfor stage in trace.stages:\n print(\"stage\", stage.stage_index)\n for row in stage_rows(stage):\n print(row)\n" }, { "cell_type": "markdown", @@ -166,7 +166,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 12 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 12 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/03_fast_forward_ct/problems.ipynb b/notebooks/butterfly_mechanics/03_fast_forward_ct/problems.ipynb index 9f69dc3..025daf0 100644 --- a/notebooks/butterfly_mechanics/03_fast_forward_ct/problems.ipynb +++ b/notebooks/butterfly_mechanics/03_fast_forward_ct/problems.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 13 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n13. **Butterfly Mechanics / 03 Fast Forward CT / Problems** <- you are here\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 13 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n13. **Butterfly Mechanics / 03 Fast Forward CT / Problems** <- you are here\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Problem Set Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Problem Set Goals
\n
\n\nThis notebook checks whether the CT schedule is now a visible object rather than a name.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Problem Set Goals

\n
\n\nThis notebook checks whether the CT schedule is now a visible object rather than a name.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Multiple-Choice Retrieval" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Multiple-Choice Retrieval
\n
\n\nChoose one answer for each:\n\n1. CT makes the transform faster by:\n A. changing the ring\n B. reusing bracket structure through staged butterflies\n C. deleting the inverse\n\n2. The natural output order of the direct CT schedule discussed here is:\n A. normal order\n B. bit-reversed order\n C. random order\n\n3. A stage explorer is useful mainly because it:\n A. hides the pairings\n B. makes data movement and zeta usage inspectable\n C. removes the need for examples\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Multiple-Choice Retrieval

\n
\n\nChoose one answer for each:\n\n1. CT makes the transform faster by:\n A. changing the ring\n B. reusing bracket structure through staged butterflies\n C. deleting the inverse\n\n2. The natural output order of the direct CT schedule discussed here is:\n A. normal order\n B. bit-reversed order\n C. random order\n\n3. A stage explorer is useful mainly because it:\n A. hides the pairings\n B. makes data movement and zeta usage inspectable\n C. removes the need for examples\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Answer Key\n# kind: quiz | level: 2\n\nanswers = {1: \"B\", 2: \"B\", 3: \"B\"}\nprint(answers)\n" + "source": "# Answer Key\n\nanswers = {1: \"B\", 2: \"B\", 3: \"B\"}\nprint(answers)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Paper Example Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Paper Example Check
\n
\n\nVerify that the CT trace on `[1,2,3,4]` in `Z_7681` with `\u03c8 = 1925` lands on the paper\u2019s BO output.\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Paper Example Check

\n
\n\nVerify that the CT trace on `[1,2,3,4]` in `Z_7681` with `\u03c8 = 1925` lands on the paper\u2019s BO output.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Check The BO Output\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nprint(trace.raw_output)\nassert list(trace.raw_output) == [1467, 3471, 2807, 7621]\n" + "source": "# Check The BO Output\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nprint(trace.raw_output)\nassert list(trace.raw_output) == [1467, 3471, 2807, 7621]\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Written Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Written Reflection
\n
\n\nExplain why the phrase \u201csame transform, better schedule\u201d is the right headline for CT.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Written Reflection

\n
\n\nExplain why the phrase \u201csame transform, better schedule\u201d is the right headline for CT.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional Challenge\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\n\ntrace = fast_ntt_psi_ct_trace([3, 1, 4, 1, 5, 9, 2, 6], 97, find_psi(8, 97))\nfor stage in trace.stages:\n print(stage.stage_index, stage.output_values)\n" + "source": "# Optional Challenge\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, find_psi\n\ntrace = fast_ntt_psi_ct_trace([3, 1, 4, 1, 5, 9, 2, 6], 97, find_psi(8, 97))\nfor stage in trace.stages:\n print(stage.stage_index, stage.output_values)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 14 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 14 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/03_fast_forward_ct/studio.ipynb b/notebooks/butterfly_mechanics/03_fast_forward_ct/studio.ipynb index 9fba748..4421853 100644 --- a/notebooks/butterfly_mechanics/03_fast_forward_ct/studio.ipynb +++ b/notebooks/butterfly_mechanics/03_fast_forward_ct/studio.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 14 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n14. **Butterfly Mechanics / 03 Fast Forward CT / Studio** <- you are here\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 14 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n14. **Butterfly Mechanics / 03 Fast Forward CT / Studio** <- you are here\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Studio Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Studio Goals
\n
\n\nThis studio compares CT traces and inspects where learners usually lose the plot: stage order, pair order, and BO output.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Studio Goals

\n
\n\nThis studio compares CT traces and inspects where learners usually lose the plot: stage order, pair order, and BO output.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Same Schedule, Different Signals" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Same Schedule, Different Signals
\n
\n\nThe butterfly pattern is structural.\nThe signal values change, but the pairing pattern and the zeta schedule stay tied to `n`, the modulus, and the chosen root.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Same Schedule, Different Signals

\n
\n\nThe butterfly pattern is structural.\nThe signal values change, but the pairing pattern and the zeta schedule stay tied to `n`, the modulus, and the chosen root.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Compare Two CT Traces\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_butterfly_network, plot_trace_overview\n\ntrace_a = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ntrace_b = fast_ntt_psi_ct_trace([5, 6, 7, 8], 7681, 1925)\n\ndisplay(plot_trace_overview(trace_a, title=\"CT trace A\"))\ndisplay(plot_trace_overview(trace_b, title=\"CT trace B\"))\ndisplay(plot_butterfly_network(trace_a, title=\"CT network A\"))\ndisplay(plot_butterfly_network(trace_b, title=\"CT network B\"))\n" + "source": "# Compare Two CT Traces\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_butterfly_network, plot_trace_overview\n\ntrace_a = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ntrace_b = fast_ntt_psi_ct_trace([5, 6, 7, 8], 7681, 1925)\n\ndisplay(plot_trace_overview(trace_a, title=\"CT trace A\"))\ndisplay(plot_trace_overview(trace_b, title=\"CT trace B\"))\ndisplay(plot_butterfly_network(trace_a, title=\"CT network A\"))\ndisplay(plot_butterfly_network(trace_b, title=\"CT network B\"))\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Debug Checklist" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Debug Checklist
\n
\n\nIf a CT implementation looks wrong, inspect:\n\n1. the chosen `\u03c8`\n2. the stage pairings\n3. the zeta exponent sequence\n4. whether you remembered the final BO -> NO reorder when comparing against the direct transform\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Debug Checklist

\n
\n\nIf a CT implementation looks wrong, inspect:\n\n1. the chosen `\u03c8`\n2. the stage pairings\n3. the zeta exponent sequence\n4. whether you remembered the final BO -> NO reorder when comparing against the direct transform\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See A Wrong-Order Comparison Failure\n# kind: exercise | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ndirect = forward_ntt_psi([1, 2, 3, 4], 7681, 1925)\n\nprint(\"wrong comparison: CT BO output vs direct NO output\")\nprint(trace.raw_output, direct)\nprint(\"correct comparison: CT NO output vs direct NO output\")\nprint(trace.normal_order_output, direct)\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n direct,\n left_label=\"CT_BO\",\n right_label=\"direct_NO\",\n title=\"Wrong comparison: BO against NO\",\n )\n)\ndisplay(\n plot_vector_comparison(\n trace.normal_order_output,\n direct,\n left_label=\"CT_NO\",\n right_label=\"direct_NO\",\n title=\"Correct comparison after reordering\",\n )\n)\n" + "source": "# See A Wrong-Order Comparison Failure\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ndirect = forward_ntt_psi([1, 2, 3, 4], 7681, 1925)\n\nprint(\"wrong comparison: CT BO output vs direct NO output\")\nprint(trace.raw_output, direct)\nprint(\"correct comparison: CT NO output vs direct NO output\")\nprint(trace.normal_order_output, direct)\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n direct,\n left_label=\"CT_BO\",\n right_label=\"direct_NO\",\n title=\"Wrong comparison: BO against NO\",\n )\n)\ndisplay(\n plot_vector_comparison(\n trace.normal_order_output,\n direct,\n left_label=\"CT_NO\",\n right_label=\"direct_NO\",\n title=\"Correct comparison after reordering\",\n )\n)\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nIn one paragraph, explain why a learner can understand the direct transform and still get lost in CT if the stage order and output order are not shown visually.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nIn one paragraph, explain why a learner can understand the direct transform and still get lost in CT if the stage order and output order are not shown visually.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Inspect The zeta schedule\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nfor stage in trace.stages:\n print(\"stage\", stage.stage_index, \"zetas:\", stage.zetas)\n" + "source": "# Optional: Inspect The zeta schedule\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nfor stage in trace.stages:\n print(\"stage\", stage.stage_index, \"zetas:\", stage.zetas)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 15 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 03 Fast Forward CT / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 15 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../04_fast_inverse_gs/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/04_fast_inverse_gs/lab.ipynb b/notebooks/butterfly_mechanics/04_fast_inverse_gs/lab.ipynb index 2747c8a..50e2009 100644 --- a/notebooks/butterfly_mechanics/04_fast_inverse_gs/lab.ipynb +++ b/notebooks/butterfly_mechanics/04_fast_inverse_gs/lab.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 16 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n16. **Butterfly Mechanics / 04 Fast Inverse GS / Lab** <- you are here\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 16 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n16. **Butterfly Mechanics / 04 Fast Inverse GS / Lab** <- you are here\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Lab Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Lab Goals
\n
\n\nPredict the BO input and the final scaling before you run the stage explorer.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Lab Goals

\n
\n\nPredict the BO input and the final scaling before you run the stage explorer.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Exercise 1" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 1
\n
\n\nExplain before running the next cell:\n\n- why the GS input must be BO in the standard schedule\n- why the unscaled output is not yet the original signal\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 1

\n
\n\nExplain before running the next cell:\n\n- why the GS input must be BO in the standard schedule\n- why the unscaled output is not yet the original signal\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Prediction Check\n# kind: exercise | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace\n\ntrace = fast_intt_psi_gs_trace([1467, 3471, 2807, 7621], 7681, 1925)\ndisplay(interactive_trace(trace, title=\"Check your GS prediction\"))\n" + "source": "# Prediction Check\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace\n\ntrace = fast_intt_psi_gs_trace([1467, 3471, 2807, 7621], 7681, 1925)\ndisplay(interactive_trace(trace, title=\"Check your GS prediction\"))\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Exercise 2" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 2
\n
\n\nPredict the bit-reversal of `[0,1,2,3,4,5,6,7]` before running the next cell.\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 2

\n
\n\nPredict the bit-reversal of `[0,1,2,3,4,5,6,7]` before running the next cell.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Prediction Check For Ordering\n# kind: exercise | level: 3\n\nfrom ntt_learning.toy_ntt import bit_reversed_order\n\nprint(bit_reversed_order([0, 1, 2, 3, 4, 5, 6, 7]))\n" + "source": "# Prediction Check For Ordering\n\nfrom ntt_learning.toy_ntt import bit_reversed_order\n\nprint(bit_reversed_order([0, 1, 2, 3, 4, 5, 6, 7]))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nReflection prompt:\n\n- Which part of GS felt like a true inverse to you?\n- Which part felt like pure bookkeeping?\n- Why is the ordering story impossible to ignore?\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nReflection prompt:\n\n- Which part of GS felt like a true inverse to you?\n- Which part felt like pure bookkeeping?\n- Why is the ordering story impossible to ignore?\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Explore Another BO Input\n# kind: exploration | level: 4\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace\n\ndef preview(x0=1467, x1=3471, x2=2807, x3=7621):\n trace = fast_intt_psi_gs_trace([x0, x1, x2, x3], 7681, 1925)\n display(interactive_trace(trace, title=\"Interactive GS trace\"))\n\ndisplay(\n widgets.interact(\n preview,\n x0=(0, 7680),\n x1=(0, 7680),\n x2=(0, 7680),\n x3=(0, 7680),\n )\n)\n" + "source": "# Optional: Explore Another BO Input\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace\n\ndef preview(x0=1467, x1=3471, x2=2807, x3=7621):\n trace = fast_intt_psi_gs_trace([x0, x1, x2, x3], 7681, 1925)\n display(interactive_trace(trace, title=\"Interactive GS trace\"))\n\ndisplay(\n widgets.interact(\n preview,\n x0=(0, 7680),\n x1=(0, 7680),\n x2=(0, 7680),\n x3=(0, 7680),\n )\n)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 17 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 17 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb b/notebooks/butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb index a0680c7..b6e8d26 100644 --- a/notebooks/butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb +++ b/notebooks/butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 15 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. **Butterfly Mechanics / 04 Fast Inverse GS / Lecture** <- you are here\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 15 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. **Butterfly Mechanics / 04 Fast Inverse GS / Lecture** <- you are here\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Objectives" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Objectives
\n
\n\nThis bundle makes the inverse flow explicit.\n\nFocus:\n\n- GS as the fast inverse schedule\n- BO input and NO output\n- why the final `n^-1` scaling appears\n- how bit-reversal fits the forward/inverse pair\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Objectives

\n
\n\nThis bundle makes the inverse flow explicit.\n\nFocus:\n\n- GS as the fast inverse schedule\n- BO input and NO output\n- why the final `n^-1` scaling appears\n- how bit-reversal fits the forward/inverse pair\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "GS Feels Like The Same Network Seen From The Other End" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
GS Feels Like The Same Network Seen From The Other End
\n
\n\nThe inverse is not \u201cmysterious undoing\u201d.\nIt is a staged network with the same family resemblance as CT, but with a different direction of arithmetic and a final scaling.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

GS Feels Like The Same Network Seen From The Other End

\n
\n\nThe inverse is not \u201cmysterious undoing\u201d.\nIt is a staged network with the same family resemblance as CT, but with a different direction of arithmetic and a final scaling.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Trace The Exact n=4 GS Paper Example\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace, plot_butterfly_network, plot_trace_overview, plot_vector_comparison\n\nbo_input = [1467, 3471, 2807, 7621]\ntrace = fast_intt_psi_gs_trace(bo_input, 7681, 1925)\n\nprint(\"unscaled NO output:\", trace.raw_output)\nprint(\"scaled NO output:\", trace.scaled_output)\ndisplay(plot_trace_overview(trace, title=\"GS overview for the n=4 paper example\"))\ndisplay(plot_butterfly_network(trace, title=\"Full GS network for the n=4 paper example\"))\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n trace.scaled_output,\n left_label=\"unscaled\",\n right_label=\"scaled\",\n title=\"Why the final n^-1 scaling matters\",\n )\n)\ndisplay(interactive_trace(trace, title=\"GS inverse trace\"))\n" + "source": "# Trace The Exact n=4 GS Paper Example\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace, plot_butterfly_network, plot_trace_overview, plot_vector_comparison\n\nbo_input = [1467, 3471, 2807, 7621]\ntrace = fast_intt_psi_gs_trace(bo_input, 7681, 1925)\n\nprint(\"unscaled NO output:\", trace.raw_output)\nprint(\"scaled NO output:\", trace.scaled_output)\ndisplay(plot_trace_overview(trace, title=\"GS overview for the n=4 paper example\"))\ndisplay(plot_butterfly_network(trace, title=\"Full GS network for the n=4 paper example\"))\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n trace.scaled_output,\n left_label=\"unscaled\",\n right_label=\"scaled\",\n title=\"Why the final n^-1 scaling matters\",\n )\n)\ndisplay(interactive_trace(trace, title=\"GS inverse trace\"))\n" }, { "cell_type": "code", @@ -74,7 +74,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See The Bit-Reversal Map Explicitly\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_bit_reversal_mapping\n\ndisplay(plot_bit_reversal_mapping(4, title=\"Bit-reversal for n=4\"))\ndisplay(plot_bit_reversal_mapping(8, title=\"Bit-reversal for n=8\"))\n" + "source": "# See The Bit-Reversal Map Explicitly\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_bit_reversal_mapping\n\ndisplay(plot_bit_reversal_mapping(4, title=\"Bit-reversal for n=4\"))\ndisplay(plot_bit_reversal_mapping(8, title=\"Bit-reversal for n=8\"))\n" }, { "cell_type": "markdown", @@ -86,7 +86,7 @@ "title": "Why Scaling Waits Until The End" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Why Scaling Waits Until The End
\n
\n\nEach GS stage avoids local division by `2`.\nThe accumulated effect of those missing local divisions is corrected by the final multiplication with `n^-1`.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Why Scaling Waits Until The End

\n
\n\nEach GS stage avoids local division by `2`.\nThe accumulated effect of those missing local divisions is corrected by the final multiplication with `n^-1`.\n" }, { "cell_type": "code", @@ -100,7 +100,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Full Forward And Inverse Round Trip\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nforward_trace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nprint(\"forward BO output:\", forward_trace.raw_output)\nprint(\"inverse scaled output:\", inverse_trace.scaled_output)\ndisplay(\n plot_vector_comparison(\n signal,\n inverse_trace.scaled_output,\n left_label=\"original\",\n right_label=\"recovered\",\n title=\"Forward CT followed by inverse GS\",\n )\n)\n" + "source": "# Full Forward And Inverse Round Trip\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nforward_trace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nprint(\"forward BO output:\", forward_trace.raw_output)\nprint(\"inverse scaled output:\", inverse_trace.scaled_output)\ndisplay(\n plot_vector_comparison(\n signal,\n inverse_trace.scaled_output,\n left_label=\"original\",\n right_label=\"recovered\",\n title=\"Forward CT followed by inverse GS\",\n )\n)\n" }, { "cell_type": "markdown", @@ -112,7 +112,7 @@ "title": "Retrieval Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Retrieval Check
\n
\n\n1. Why does GS want BO input?\n2. Why does the final scaling not disappear?\n3. What would go wrong if you visually compared GS input and CT NO output without respecting the order change?\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Retrieval Check

\n
\n\n1. Why does GS want BO input?\n2. Why does the final scaling not disappear?\n3. What would go wrong if you visually compared GS input and CT NO output without respecting the order change?\n" }, { "cell_type": "code", @@ -126,7 +126,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: A Second GS Example\n# kind: exploration | level: 4\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace\n\ntrace = fast_intt_psi_gs_trace([2489, 6478, 7489, 6607], 7681, 1925)\nprint(\"scaled output:\", trace.scaled_output)\ndisplay(interactive_trace(trace, title=\"Second GS trace\"))\n" + "source": "# Optional: A Second GS Example\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import interactive_trace\n\ntrace = fast_intt_psi_gs_trace([2489, 6478, 7489, 6607], 7681, 1925)\nprint(\"scaled output:\", trace.scaled_output)\ndisplay(interactive_trace(trace, title=\"Second GS trace\"))\n" }, { "cell_type": "markdown", @@ -138,7 +138,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 16 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 16 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/04_fast_inverse_gs/problems.ipynb b/notebooks/butterfly_mechanics/04_fast_inverse_gs/problems.ipynb index b9ffce3..4e732fe 100644 --- a/notebooks/butterfly_mechanics/04_fast_inverse_gs/problems.ipynb +++ b/notebooks/butterfly_mechanics/04_fast_inverse_gs/problems.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 17 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n17. **Butterfly Mechanics / 04 Fast Inverse GS / Problems** <- you are here\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 17 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n17. **Butterfly Mechanics / 04 Fast Inverse GS / Problems** <- you are here\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Problem Set Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Problem Set Goals
\n
\n\nThis notebook checks whether the inverse flow, ordering, and scaling are now mechanically stable.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Problem Set Goals

\n
\n\nThis notebook checks whether the inverse flow, ordering, and scaling are now mechanically stable.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Multiple-Choice Retrieval" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Multiple-Choice Retrieval
\n
\n\nChoose one answer for each:\n\n1. GS is used here as the fast schedule for:\n A. direct forward NTT\n B. inverse NTT\n C. schoolbook multiplication\n\n2. The final `n^-1` matters because:\n A. each stage skipped local divisions that accumulate\n B. the modulus changed mid-computation\n C. bit-reversal requires scaling\n\n3. In the standard pairing, GS expects:\n A. NO input and BO output\n B. BO input and NO output\n C. random order on both ends\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Multiple-Choice Retrieval

\n
\n\nChoose one answer for each:\n\n1. GS is used here as the fast schedule for:\n A. direct forward NTT\n B. inverse NTT\n C. schoolbook multiplication\n\n2. The final `n^-1` matters because:\n A. each stage skipped local divisions that accumulate\n B. the modulus changed mid-computation\n C. bit-reversal requires scaling\n\n3. In the standard pairing, GS expects:\n A. NO input and BO output\n B. BO input and NO output\n C. random order on both ends\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Answer Key\n# kind: quiz | level: 2\n\nanswers = {1: \"B\", 2: \"A\", 3: \"B\"}\nprint(answers)\n" + "source": "# Answer Key\n\nanswers = {1: \"B\", 2: \"A\", 3: \"B\"}\nprint(answers)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Paper Example Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Paper Example Check
\n
\n\nVerify that the GS trace on the paper\u2019s BO input scales back to `[1,2,3,4]`.\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Paper Example Check

\n
\n\nVerify that the GS trace on the paper\u2019s BO input scales back to `[1,2,3,4]`.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Check The Final Scaling\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\n\ntrace = fast_intt_psi_gs_trace([1467, 3471, 2807, 7621], 7681, 1925)\nprint(trace.scaled_output)\nassert list(trace.scaled_output) == [1, 2, 3, 4]\n" + "source": "# Check The Final Scaling\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\n\ntrace = fast_intt_psi_gs_trace([1467, 3471, 2807, 7621], 7681, 1925)\nprint(trace.scaled_output)\nassert list(trace.scaled_output) == [1, 2, 3, 4]\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Written Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Written Reflection
\n
\n\nIn one paragraph, explain why \u201csame structure, opposite direction\u201d is a better intuition for GS than \u201ctotally different algorithm\u201d.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Written Reflection

\n
\n\nIn one paragraph, explain why \u201csame structure, opposite direction\u201d is a better intuition for GS than \u201ctotally different algorithm\u201d.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional Challenge\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\n\ntrace = fast_intt_psi_gs_trace([2489, 6478, 7489, 6607], 7681, 1925)\nfor stage in trace.stages:\n print(stage.stage_index, stage.output_values)\n" + "source": "# Optional Challenge\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\n\ntrace = fast_intt_psi_gs_trace([2489, 6478, 7489, 6607], 7681, 1925)\nfor stage in trace.stages:\n print(stage.stage_index, stage.output_values)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 18 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 18 of 27 - Butterfly Mechanics / 04 Fast Inverse GS / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/butterfly_mechanics/04_fast_inverse_gs/studio.ipynb b/notebooks/butterfly_mechanics/04_fast_inverse_gs/studio.ipynb index a78e2c3..5510a09 100644 --- a/notebooks/butterfly_mechanics/04_fast_inverse_gs/studio.ipynb +++ b/notebooks/butterfly_mechanics/04_fast_inverse_gs/studio.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 18 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n18. **Butterfly Mechanics / 04 Fast Inverse GS / Studio** <- you are here\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 18 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n18. **Butterfly Mechanics / 04 Fast Inverse GS / Studio** <- you are here\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Studio Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Studio Goals
\n
\n\nThe studio puts CT and GS next to each other and treats ordering as a first-class object, not a side note.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Studio Goals

\n
\n\nThe studio puts CT and GS next to each other and treats ordering as a first-class object, not a side note.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Forward And Inverse Need To Meet In The Middle Cleanly" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Forward And Inverse Need To Meet In The Middle Cleanly
\n
\n\nThe whole point of the pair is:\n\n- CT gets you into the transform domain efficiently\n- GS gets you back out efficiently\n- the two only meet cleanly if you respect BO/NO and the final scaling\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Forward And Inverse Need To Meet In The Middle Cleanly

\n
\n\nThe whole point of the pair is:\n\n- CT gets you into the transform domain efficiently\n- GS gets you back out efficiently\n- the two only meet cleanly if you respect BO/NO and the final scaling\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See CT Output Feed GS Input\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [5, 6, 7, 8]\nforward_trace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nprint(\"CT BO output:\", forward_trace.raw_output)\nprint(\"GS scaled output:\", inverse_trace.scaled_output)\ndisplay(\n plot_vector_comparison(\n signal,\n inverse_trace.scaled_output,\n left_label=\"start\",\n right_label=\"after_CT_then_GS\",\n title=\"CT output cleanly feeds GS input\",\n )\n)\n" + "source": "# See CT Output Feed GS Input\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [5, 6, 7, 8]\nforward_trace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nprint(\"CT BO output:\", forward_trace.raw_output)\nprint(\"GS scaled output:\", inverse_trace.scaled_output)\ndisplay(\n plot_vector_comparison(\n signal,\n inverse_trace.scaled_output,\n left_label=\"start\",\n right_label=\"after_CT_then_GS\",\n title=\"CT output cleanly feeds GS input\",\n )\n)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Debug Checklist" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Debug Checklist
\n
\n\nIf the inverse output is wrong, inspect:\n\n1. whether the input was BO\n2. whether the zetas were inverse-stage zetas\n3. whether the final `n^-1` scaling was applied\n4. whether you compared the correct order against the direct reference\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Debug Checklist

\n
\n\nIf the inverse output is wrong, inspect:\n\n1. whether the input was BO\n2. whether the zetas were inverse-stage zetas\n3. whether the final `n^-1` scaling was applied\n4. whether you compared the correct order against the direct reference\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See A Missing-Scale Failure\n# kind: exercise | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import plot_vector_comparison\n\ntrace = fast_intt_psi_gs_trace([1467, 3471, 2807, 7621], 7681, 1925)\nprint(\"unscaled:\", trace.raw_output)\nprint(\"scaled:\", trace.scaled_output)\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n trace.scaled_output,\n left_label=\"missing_scale\",\n right_label=\"correct\",\n title=\"Missing n^-1 scale vs correct output\",\n )\n)\n" + "source": "# See A Missing-Scale Failure\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace\nfrom ntt_learning.visuals import plot_vector_comparison\n\ntrace = fast_intt_psi_gs_trace([1467, 3471, 2807, 7621], 7681, 1925)\nprint(\"unscaled:\", trace.raw_output)\nprint(\"scaled:\", trace.scaled_output)\ndisplay(\n plot_vector_comparison(\n trace.raw_output,\n trace.scaled_output,\n left_label=\"missing_scale\",\n right_label=\"correct\",\n title=\"Missing n^-1 scale vs correct output\",\n )\n)\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nExplain why \u201cthe inverse looked almost right\u201d is a dangerous debugging sentence unless you say what happened with ordering and scaling.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nExplain why \u201cthe inverse looked almost right\u201d is a dangerous debugging sentence unless you say what happened with ordering and scaling.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Another bit-reversal map\n# kind: exploration | level: 4\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_bit_reversal_mapping\n\ndisplay(plot_bit_reversal_mapping(16, title=\"Bit-reversal for n=16\"))\n" + "source": "# Optional: Another bit-reversal map\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_bit_reversal_mapping\n\ndisplay(plot_bit_reversal_mapping(16, title=\"Bit-reversal for n=16\"))\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 19 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Butterfly Mechanics / 04 Fast Inverse GS / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 19 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb b/notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb index ba58549..0107ef2 100644 --- a/notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb +++ b/notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 4 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n4. **Foundations / 01 Convolution To Toy NTT / Lab** <- you are here\n5. [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 4 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n4. **Foundations / 01 Convolution To Toy NTT / Lab** <- you are here\n5. [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Lab Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Lab Goals
\n
\n\nPredict the movement before you run the code.\n\nThe point is not just to see the picture after the fact.\nThe point is to force your eye to anticipate where the products and wraparound terms will land.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Lab Goals

\n
\n\nPredict the movement before you run the code.\n\nThe point is not just to see the picture after the fact.\nThe point is to force your eye to anticipate where the products and wraparound terms will land.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Exercise 1" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Exercise 1
\n
\n\nBefore running the next cell:\n\n- name the diagonal sums of the raw schoolbook grid\n- say which tail terms will wrap into slot `0`\n- say whether they add or subtract in `x^4 + 1`\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Exercise 1

\n
\n\nBefore running the next cell:\n\n- name the diagonal sums of the raw schoolbook grid\n- say which tail terms will wrap into slot `0`\n- say whether they add or subtract in `x^4 + 1`\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Run The Prediction Check\n# kind: exercise | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import negacyclic_multiply, schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, plot_wraparound, schoolbook_diagonal_player, wraparound_comparison_player\n\nleft = [3, 0, 2, 1]\nright = [1, 4, 0, 2]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nprint(\"negacyclic result:\", negacyclic_multiply(left, right, n=4))\ndisplay(schoolbook_diagonal_player(left, right))\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_convolution_grid(left, right, title=\"Prediction check grid\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Prediction check fold\"))\n" + "source": "# Run The Prediction Check\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import negacyclic_multiply, schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, plot_wraparound, schoolbook_diagonal_player, wraparound_comparison_player\n\nleft = [3, 0, 2, 1]\nright = [1, 4, 0, 2]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nprint(\"negacyclic result:\", negacyclic_multiply(left, right, n=4))\ndisplay(schoolbook_diagonal_player(left, right))\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_convolution_grid(left, right, title=\"Prediction check grid\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Prediction check fold\"))\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Exercise 2" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Exercise 2
\n
\n\nPick one number in the raw tail and follow it all the way to its final slot.\nDo not say \u201cit wraps around\u201d.\nSay exactly:\n\n- where it started\n- how many wraps happened\n- whether the sign flipped\n- where it finished\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Exercise 2

\n
\n\nPick one number in the raw tail and follow it all the way to its final slot.\nDo not say \u201cit wraps around\u201d.\nSay exactly:\n\n- where it started\n- how many wraps happened\n- whether the sign flipped\n- where it finished\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: A Second Visual Drill\n# kind: exercise | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution\nfrom ntt_learning.visuals import plot_wraparound, wraparound_comparison_player\n\nraw = schoolbook_convolution([2, 5, 0, 1], [1, 0, 3, 2])\nprint(\"raw convolution:\", raw)\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Trace one tail coefficient by eye\"))\n" + "source": "# A Second Visual Drill\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution\nfrom ntt_learning.visuals import plot_wraparound, wraparound_comparison_player\n\nraw = schoolbook_convolution([2, 5, 0, 1], [1, 0, 3, 2])\nprint(\"raw convolution:\", raw)\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Trace one tail coefficient by eye\"))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nReflection prompt:\n\n- What felt easier to see in the grid than in symbolic polynomial notation?\n- What exactly makes negacyclic folding more annoying than ordinary wraparound?\n- If you had to explain `x^n + 1` to somebody visually, what would you draw?\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nReflection prompt:\n\n- What felt easier to see in the grid than in symbolic polynomial notation?\n- What exactly makes negacyclic folding more annoying than ordinary wraparound?\n- If you had to explain `x^n + 1` to somebody visually, what would you draw?\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Try Your Own Arrays\n# kind: exploration | level: 4\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, plot_wraparound\n\ndef preview(a0=1, a1=2, a2=3, a3=4, b0=5, b1=6, b2=7, b3=8):\n left = [a0, a1, a2, a3]\n right = [b0, b1, b2, b3]\n raw = schoolbook_convolution(left, right)\n display(plot_convolution_grid(left, right, title=\"Interactive schoolbook grid\"))\n display(plot_wraparound(raw, n=4, negacyclic=True, title=\"Interactive negacyclic fold\"))\n\ndisplay(\n widgets.interact(\n preview,\n a0=(0, 6),\n a1=(0, 6),\n a2=(0, 6),\n a3=(0, 6),\n b0=(0, 6),\n b1=(0, 6),\n b2=(0, 6),\n b3=(0, 6),\n )\n)\n" + "source": "# Optional: Try Your Own Arrays\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, plot_wraparound\n\ndef preview(a0=1, a1=2, a2=3, a3=4, b0=5, b1=6, b2=7, b3=8):\n left = [a0, a1, a2, a3]\n right = [b0, b1, b2, b3]\n raw = schoolbook_convolution(left, right)\n display(plot_convolution_grid(left, right, title=\"Interactive schoolbook grid\"))\n display(plot_wraparound(raw, n=4, negacyclic=True, title=\"Interactive negacyclic fold\"))\n\ndisplay(\n widgets.interact(\n preview,\n a0=(0, 6),\n a1=(0, 6),\n a2=(0, 6),\n a3=(0, 6),\n b0=(0, 6),\n b1=(0, 6),\n b2=(0, 6),\n b3=(0, 6),\n )\n)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 5 of 27 - Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 5 of 27 - Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb b/notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb index 75afdfe..a93f407 100644 --- a/notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb +++ b/notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 3 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n- Previous notebook: [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. **Foundations / 01 Convolution To Toy NTT / Lecture** <- you are here\n4. [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 3 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n- Previous notebook: [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. **Foundations / 01 Convolution To Toy NTT / Lecture** <- you are here\n4. [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Objectives" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Objectives
\n
\n\nThis first bundle is about making the raw multiplication problem visible before any transform is introduced.\n\nFocus:\n\n- the schoolbook product grid\n- diagonal sums\n- cyclic vs negacyclic folding\n- a tiny teaser of why transforms help\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Objectives

\n
\n\nThis first bundle is about making the raw multiplication problem visible before any transform is introduced.\n\nFocus:\n\n- the schoolbook product grid\n- diagonal sums\n- cyclic vs negacyclic folding\n- a tiny teaser of why transforms help\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Schoolbook Multiplication Is A Grid" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n explanation\n
\n
Schoolbook Multiplication Is A Grid
\n
\n\nStop thinking \u201cmultiply two polynomials\u201d as one sentence.\nThe mechanical reality is a grid of pairwise products whose diagonals have to be accumulated.\n\nIf that grid is not concrete, the NTT has nothing to optimize in your mind.\n" + "source": "
\n Level 2\n
\n explanation\n core path\n
\n

Schoolbook Multiplication Is A Grid

\n
\n\nStop thinking \u201cmultiply two polynomials\u201d as one sentence.\nThe mechanical reality is a grid of pairwise products whose diagonals have to be accumulated.\n\nIf that grid is not concrete, the NTT has nothing to optimize in your mind.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Play The Diagonal Sweep\n# kind: demo | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import convolution_contributions, schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, schoolbook_diagonal_player\n\nleft = [1, 2, 3, 4]\nright = [5, 6, 7, 8]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nfor row in convolution_contributions(left, right):\n print(row)\n\ndisplay(schoolbook_diagonal_player(left, right))\nfig = plot_convolution_grid(left, right, title=\"Schoolbook products for [1,2,3,4] * [5,6,7,8]\")\ndisplay(fig)\n" + "source": "# Play The Diagonal Sweep\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import convolution_contributions, schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, schoolbook_diagonal_player\n\nleft = [1, 2, 3, 4]\nright = [5, 6, 7, 8]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nfor row in convolution_contributions(left, right):\n print(row)\n\ndisplay(schoolbook_diagonal_player(left, right))\nfig = plot_convolution_grid(left, right, title=\"Schoolbook products for [1,2,3,4] * [5,6,7,8]\")\ndisplay(fig)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Wraparound Is The First Structural Fork" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n explanation\n
\n
Wraparound Is The First Structural Fork
\n
\n\nOnce the raw tail exists, the ring tells you what to do with it.\n\n- in `x^n - 1`, high-degree terms wrap back with a positive sign\n- in `x^n + 1`, high-degree terms wrap back with a sign flip\n\nThat sign flip is not cosmetic. It is exactly what makes the negacyclic story different.\n" + "source": "
\n Level 2\n
\n explanation\n core path\n
\n

Wraparound Is The First Structural Fork

\n
\n\nOnce the raw tail exists, the ring tells you what to do with it.\n\n- in `x^n - 1`, high-degree terms wrap back with a positive sign\n- in `x^n + 1`, high-degree terms wrap back with a sign flip\n\nThat sign flip is not cosmetic. It is exactly what makes the negacyclic story different.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Play The Wraparound Step By Step\n# kind: demo | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import negacyclic_multiply, schoolbook_convolution, wraparound_contributions\nfrom ntt_learning.visuals import plot_wraparound, wraparound_comparison_player\n\nleft = [1, 2, 3, 4]\nright = [5, 6, 7, 8]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nprint(\"negacyclic in x^4 + 1:\", negacyclic_multiply(left, right, n=4))\nprint(\"cyclic folding rows:\")\nfor row in wraparound_contributions(raw, n=4, negacyclic=False):\n print(row)\nprint(\"negacyclic folding rows:\")\nfor row in wraparound_contributions(raw, n=4, negacyclic=True):\n print(row)\n\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_wraparound(raw, n=4, negacyclic=False, title=\"Cyclic folding into x^4 - 1\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Negacyclic folding into x^4 + 1\"))\n" + "source": "# Play The Wraparound Step By Step\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import negacyclic_multiply, schoolbook_convolution, wraparound_contributions\nfrom ntt_learning.visuals import plot_wraparound, wraparound_comparison_player\n\nleft = [1, 2, 3, 4]\nright = [5, 6, 7, 8]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nprint(\"negacyclic in x^4 + 1:\", negacyclic_multiply(left, right, n=4))\nprint(\"cyclic folding rows:\")\nfor row in wraparound_contributions(raw, n=4, negacyclic=False):\n print(row)\nprint(\"negacyclic folding rows:\")\nfor row in wraparound_contributions(raw, n=4, negacyclic=True):\n print(row)\n\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_wraparound(raw, n=4, negacyclic=False, title=\"Cyclic folding into x^4 - 1\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Negacyclic folding into x^4 + 1\"))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "The Tiny Transform Teaser" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n explanation\n
\n
The Tiny Transform Teaser
\n
\n\nThe transform is not magic. It is a change of coordinates chosen so that multiplication gets easier.\n\nThe next bundle will treat the transform itself directly.\nThis first bundle only makes sure the learner can see the raw thing being optimized.\n" + "source": "
\n Level 2\n
\n explanation\n core path\n
\n

The Tiny Transform Teaser

\n
\n\nThe transform is not magic. It is a change of coordinates chosen so that multiplication gets easier.\n\nThe next bundle will treat the transform itself directly.\nThis first bundle only makes sure the learner can see the raw thing being optimized.\n" }, { "cell_type": "markdown", @@ -110,7 +110,7 @@ "title": "Retrieval Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Retrieval Check
\n
\n\nAnswer in words before moving on:\n\n1. Why do diagonal sums appear in schoolbook multiplication?\n2. What is the one exact sign difference between cyclic and negacyclic folding?\n3. If you cannot track the tail wraparound, what part of the NTT story will stay vague?\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Retrieval Check

\n
\n\nAnswer in words before moving on:\n\n1. Why do diagonal sums appear in schoolbook multiplication?\n2. What is the one exact sign difference between cyclic and negacyclic folding?\n3. If you cannot track the tail wraparound, what part of the NTT story will stay vague?\n" }, { "cell_type": "code", @@ -124,7 +124,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Compare Another Example\n# kind: exploration | level: 4\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import negacyclic_multiply, schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, plot_wraparound\n\nleft = [2, 1, 0, 3]\nright = [4, 0, 1, 2]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nprint(\"negacyclic:\", negacyclic_multiply(left, right, n=4))\ndisplay(plot_convolution_grid(left, right, title=\"A second schoolbook grid\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"A second negacyclic fold\"))\n" + "source": "# Optional: Compare Another Example\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import negacyclic_multiply, schoolbook_convolution\nfrom ntt_learning.visuals import plot_convolution_grid, plot_wraparound\n\nleft = [2, 1, 0, 3]\nright = [4, 0, 1, 2]\nraw = schoolbook_convolution(left, right)\n\nprint(\"raw convolution:\", raw)\nprint(\"negacyclic:\", negacyclic_multiply(left, right, n=4))\ndisplay(plot_convolution_grid(left, right, title=\"A second schoolbook grid\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"A second negacyclic fold\"))\n" }, { "cell_type": "markdown", @@ -136,7 +136,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 4 of 27 - Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 4 of 27 - Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb b/notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb index c8687f6..9740d7e 100644 --- a/notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb +++ b/notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 5 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n5. **Foundations / 01 Convolution To Toy NTT / Problems** <- you are here\n6. [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 5 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n5. **Foundations / 01 Convolution To Toy NTT / Problems** <- you are here\n6. [Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Problem Set Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Problem Set Goals
\n
\n\nThis notebook checks whether the multiplication and folding pictures are now stable in memory.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Problem Set Goals

\n
\n\nThis notebook checks whether the multiplication and folding pictures are now stable in memory.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Multiple-Choice Retrieval" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Multiple-Choice Retrieval
\n
\n\nChoose one answer for each:\n\n1. The diagonal sums in schoolbook multiplication come from:\n A. random coincidence\n B. grouping terms with the same final degree\n C. bit-reversal\n\n2. Negacyclic folding differs from cyclic folding because:\n A. the wrapped tail flips sign\n B. the polynomial degrees disappear\n C. the raw convolution gets shorter before folding\n\n3. The main reason to study the raw grid before NTT is:\n A. because the transform is impossible otherwise\n B. because it makes the optimized algorithm visually grounded\n C. because Kyber never uses transforms\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Multiple-Choice Retrieval

\n
\n\nChoose one answer for each:\n\n1. The diagonal sums in schoolbook multiplication come from:\n A. random coincidence\n B. grouping terms with the same final degree\n C. bit-reversal\n\n2. Negacyclic folding differs from cyclic folding because:\n A. the wrapped tail flips sign\n B. the polynomial degrees disappear\n C. the raw convolution gets shorter before folding\n\n3. The main reason to study the raw grid before NTT is:\n A. because the transform is impossible otherwise\n B. because it makes the optimized algorithm visually grounded\n C. because Kyber never uses transforms\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Answer Key\n# kind: quiz | level: 2\n\nanswers = {1: \"B\", 2: \"A\", 3: \"B\"}\nprint(answers)\n" + "source": "# Answer Key\n\nanswers = {1: \"B\", 2: \"A\", 3: \"B\"}\nprint(answers)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Manual Fold Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Manual Fold Check
\n
\n\nCompute the negacyclic fold of the raw vector `[5, 16, 34, 60, 61, 52, 32]` into `x^4 + 1` by hand before running the next cell.\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Manual Fold Check

\n
\n\nCompute the negacyclic fold of the raw vector `[5, 16, 34, 60, 61, 52, 32]` into `x^4 + 1` by hand before running the next cell.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Check The Fold\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import negacyclic_reduce\n\nraw = [5, 16, 34, 60, 61, 52, 32]\nprint(negacyclic_reduce(raw, n=4))\n" + "source": "# Check The Fold\n\nfrom ntt_learning.toy_ntt import negacyclic_reduce\n\nraw = [5, 16, 34, 60, 61, 52, 32]\nprint(negacyclic_reduce(raw, n=4))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Written Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Written Reflection
\n
\n\nIn one paragraph, explain why \u201cwrap the tail back\u201d is still too vague unless you also specify:\n\n- the divisor\n- the target slot\n- the sign rule\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Written Reflection

\n
\n\nIn one paragraph, explain why \u201cwrap the tail back\u201d is still too vague unless you also specify:\n\n- the divisor\n- the target slot\n- the sign rule\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional Challenge\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import wraparound_contributions\n\nraw = [3, 11, 7, 0, 5, 9, 4]\nfor row in wraparound_contributions(raw, n=4, negacyclic=True):\n print(row)\n" + "source": "# Optional Challenge\n\nfrom ntt_learning.toy_ntt import wraparound_contributions\n\nraw = [3, 11, 7, 0, 5, 9, 4]\nfor row in wraparound_contributions(raw, n=4, negacyclic=True):\n print(row)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 6 of 27 - Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 6 of 27 - Foundations / 01 Convolution To Toy NTT / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb b/notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb index dbd13b7..e14701b 100644 --- a/notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb +++ b/notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 6 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n6. **Foundations / 01 Convolution To Toy NTT / Studio** <- you are here\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 6 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n6. **Foundations / 01 Convolution To Toy NTT / Studio** <- you are here\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Studio Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Studio Goals
\n
\n\nThis studio is about comparison and diagnosis.\nThe learner should leave with a strong visual distinction between cyclic and negacyclic wraparound.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Studio Goals

\n
\n\nThis studio is about comparison and diagnosis.\nThe learner should leave with a strong visual distinction between cyclic and negacyclic wraparound.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Two Folds, Same Raw Tail, Different Result" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Two Folds, Same Raw Tail, Different Result
\n
\n\nIf the raw convolution is fixed, the only thing that changes is the ring rule.\nThat is exactly why the same tail can produce two different reduced polynomials.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Two Folds, Same Raw Tail, Different Result

\n
\n\nIf the raw convolution is fixed, the only thing that changes is the ring rule.\nThat is exactly why the same tail can produce two different reduced polynomials.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Compare The Two Fold Rules\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution\nfrom ntt_learning.visuals import plot_wraparound, wraparound_comparison_player\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nprint(\"raw convolution:\", raw)\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_wraparound(raw, n=4, negacyclic=False, title=\"Positive wrap into x^4 - 1\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Negative wrap into x^4 + 1\"))\n" + "source": "# Compare The Two Fold Rules\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution\nfrom ntt_learning.visuals import plot_wraparound, wraparound_comparison_player\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nprint(\"raw convolution:\", raw)\ndisplay(wraparound_comparison_player(raw, n=4))\ndisplay(plot_wraparound(raw, n=4, negacyclic=False, title=\"Positive wrap into x^4 - 1\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Negative wrap into x^4 + 1\"))\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Debug Checklist" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Debug Checklist
\n
\n\nIf a wraparound result looks wrong, inspect these in order:\n\n1. Was the raw convolution itself correct?\n2. Was the divisor `x^n - 1` or `x^n + 1`?\n3. Did the wrapped tail land in the right slot?\n4. Did the sign flip happen on the wrapped term?\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Debug Checklist

\n
\n\nIf a wraparound result looks wrong, inspect these in order:\n\n1. Was the raw convolution itself correct?\n2. Was the divisor `x^n - 1` or `x^n + 1`?\n3. Did the wrapped tail land in the right slot?\n4. Did the sign flip happen on the wrapped term?\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See A Wrong-Sign Failure\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution, negacyclic_reduce\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nwrong = [raw[0] + raw[4], raw[1] + raw[5], raw[2] + raw[6], raw[3]]\n\nprint(\"raw:\", raw)\nprint(\"wrong sign fold:\", wrong)\nprint(\"correct negacyclic fold:\", negacyclic_reduce(raw, n=4))\n" + "source": "# See A Wrong-Sign Failure\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution, negacyclic_reduce\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nwrong = [raw[0] + raw[4], raw[1] + raw[5], raw[2] + raw[6], raw[3]]\n\nprint(\"raw:\", raw)\nprint(\"wrong sign fold:\", wrong)\nprint(\"correct negacyclic fold:\", negacyclic_reduce(raw, n=4))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nExplain the exact visual difference between \u201cthe wrong-sign fold\u201d and \u201cthe correct negacyclic fold\u201d.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nExplain the exact visual difference between \u201cthe wrong-sign fold\u201d and \u201cthe correct negacyclic fold\u201d.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Fold A Larger Tail\n# kind: exploration | level: 4\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_wraparound\n\nraw = [4, 8, 12, 16, 9, 5, 1, 7, 11]\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Longer tail, same fold rule\"))\n" + "source": "# Optional: Fold A Larger Tail\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_wraparound\n\nraw = [4, 8, 12, 16, 9, 5, 1, 7, 11]\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Longer tail, same fold rule\"))\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 7 of 27 - Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 01 Convolution To Toy NTT / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 7 of 27 - Foundations / 02 Negative Wrapped NTT / Lecture](../02_negative_wrapped_ntt/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/02_negative_wrapped_ntt/lab.ipynb b/notebooks/foundations/02_negative_wrapped_ntt/lab.ipynb index 60615ed..44b06e9 100644 --- a/notebooks/foundations/02_negative_wrapped_ntt/lab.ipynb +++ b/notebooks/foundations/02_negative_wrapped_ntt/lab.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 8 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n8. **Foundations / 02 Negative Wrapped NTT / Lab** <- you are here\n9. [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 8 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n8. **Foundations / 02 Negative Wrapped NTT / Lab** <- you are here\n9. [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Lab Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Lab Goals
\n
\n\nThe lab is about prediction inside the direct transform matrix.\nDo not run the next cells until you name the powers and products you expect to matter.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Lab Goals

\n
\n\nThe lab is about prediction inside the direct transform matrix.\nDo not run the next cells until you name the powers and products you expect to matter.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Exercise 1" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Exercise 1
\n
\n\nFor `signal = [1,2,3,4]`, `n = 4`, `q = 17`, predict:\n\n- which powers of `\u03c8` appear in row `j = 1`\n- whether the inverse should need both `\u03c8^-1` and `n^-1`\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Exercise 1

\n
\n\nFor `signal = [1,2,3,4]`, `n = 4`, `q = 17`, predict:\n\n- which powers of `\u03c8` appear in row `j = 1`\n- whether the inverse should need both `\u03c8^-1` and `n^-1`\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Prediction Check\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import find_psi, ntt_psi_exponent_grid\n\npsi = find_psi(4, 17)\nprint(\"psi:\", psi)\nfor row_index, row in enumerate(ntt_psi_exponent_grid(4)):\n print(\"row\", row_index, row)\n" + "source": "# Prediction Check\n\nfrom ntt_learning.toy_ntt import find_psi, ntt_psi_exponent_grid\n\npsi = find_psi(4, 17)\nprint(\"psi:\", psi)\nfor row_index, row in enumerate(ntt_psi_exponent_grid(4)):\n print(\"row\", row_index, row)\n" }, { "cell_type": "code", @@ -74,7 +74,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Interactive Signal Explorer\n# kind: exercise | level: 3\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi\nfrom ntt_learning.visuals import direct_ntt_player\n\nmodulus = 17\npsi = find_psi(4, modulus)\n\ndef preview(a0=1, a1=2, a2=3, a3=4):\n signal = [a0, a1, a2, a3]\n spectrum = forward_ntt_psi(signal, modulus, psi)\n print(\"signal:\", signal)\n print(\"spectrum:\", spectrum)\n print(\"inverse:\", inverse_ntt_psi(spectrum, modulus, psi))\n display(direct_ntt_player(signal, modulus, psi))\n\ndisplay(\n widgets.interact(\n preview,\n a0=(0, 16),\n a1=(0, 16),\n a2=(0, 16),\n a3=(0, 16),\n )\n)\n" + "source": "# Interactive Signal Explorer\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi\nfrom ntt_learning.visuals import direct_ntt_player\n\nmodulus = 17\npsi = find_psi(4, modulus)\n\ndef preview(a0=1, a1=2, a2=3, a3=4):\n signal = [a0, a1, a2, a3]\n spectrum = forward_ntt_psi(signal, modulus, psi)\n print(\"signal:\", signal)\n print(\"spectrum:\", spectrum)\n print(\"inverse:\", inverse_ntt_psi(spectrum, modulus, psi))\n display(direct_ntt_player(signal, modulus, psi))\n\ndisplay(\n widgets.interact(\n preview,\n a0=(0, 16),\n a1=(0, 16),\n a2=(0, 16),\n a3=(0, 16),\n )\n)\n" }, { "cell_type": "markdown", @@ -86,7 +86,7 @@ "title": "Exercise 2" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Exercise 2
\n
\n\nExplain what the pointwise multiplication in the transform domain is buying you.\nUse the words \u201creplace convolution by slotwise multiplication\u201d in your own sentence.\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Exercise 2

\n
\n\nExplain what the pointwise multiplication in the transform domain is buying you.\nUse the words \u201creplace convolution by slotwise multiplication\u201d in your own sentence.\n" }, { "cell_type": "code", @@ -100,7 +100,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Compare Raw Convolution And Slotwise Multiplication\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import (\n find_psi,\n forward_ntt_psi,\n inverse_ntt_psi,\n pointwise_multiply,\n schoolbook_convolution,\n)\n\nleft = [2, 1, 0, 3]\nright = [4, 0, 1, 2]\npsi = find_psi(4, 17)\nleft_hat = forward_ntt_psi(left, 17, psi)\nright_hat = forward_ntt_psi(right, 17, psi)\n\nprint(\"schoolbook raw:\", schoolbook_convolution(left, right))\nprint(\"left_hat:\", left_hat)\nprint(\"right_hat:\", right_hat)\nprint(\"pointwise product:\", pointwise_multiply(left_hat, right_hat, 17))\nprint(\"inverse:\", inverse_ntt_psi(pointwise_multiply(left_hat, right_hat, 17), 17, psi))\n" + "source": "# Compare Raw Convolution And Slotwise Multiplication\n\nfrom ntt_learning.toy_ntt import (\n find_psi,\n forward_ntt_psi,\n inverse_ntt_psi,\n pointwise_multiply,\n schoolbook_convolution,\n)\n\nleft = [2, 1, 0, 3]\nright = [4, 0, 1, 2]\npsi = find_psi(4, 17)\nleft_hat = forward_ntt_psi(left, 17, psi)\nright_hat = forward_ntt_psi(right, 17, psi)\n\nprint(\"schoolbook raw:\", schoolbook_convolution(left, right))\nprint(\"left_hat:\", left_hat)\nprint(\"right_hat:\", right_hat)\nprint(\"pointwise product:\", pointwise_multiply(left_hat, right_hat, 17))\nprint(\"inverse:\", inverse_ntt_psi(pointwise_multiply(left_hat, right_hat, 17), 17, psi))\n" }, { "cell_type": "markdown", @@ -112,7 +112,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nReflection prompt:\n\n- What feels concrete in the direct transform matrix?\n- What still feels too expensive or repetitive?\n- Why are butterflies the obvious next step?\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nReflection prompt:\n\n- What feels concrete in the direct transform matrix?\n- What still feels too expensive or repetitive?\n- Why are butterflies the obvious next step?\n" }, { "cell_type": "code", @@ -126,7 +126,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Try A Different Modulus\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi\n\nmodulus = 97\npsi = find_psi(4, modulus)\nsignal = [1, 2, 3, 4]\n\nprint(\"modulus:\", modulus)\nprint(\"psi:\", psi)\nprint(\"spectrum:\", forward_ntt_psi(signal, modulus, psi))\n" + "source": "# Optional: Try A Different Modulus\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi\n\nmodulus = 97\npsi = find_psi(4, modulus)\nsignal = [1, 2, 3, 4]\n\nprint(\"modulus:\", modulus)\nprint(\"psi:\", psi)\nprint(\"spectrum:\", forward_ntt_psi(signal, modulus, psi))\n" }, { "cell_type": "markdown", @@ -138,7 +138,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 9 of 27 - Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 9 of 27 - Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/02_negative_wrapped_ntt/lecture.ipynb b/notebooks/foundations/02_negative_wrapped_ntt/lecture.ipynb index 2577a78..27c633c 100644 --- a/notebooks/foundations/02_negative_wrapped_ntt/lecture.ipynb +++ b/notebooks/foundations/02_negative_wrapped_ntt/lecture.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 7 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. **Foundations / 02 Negative Wrapped NTT / Lecture** <- you are here\n8. [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 7 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. **Foundations / 02 Negative Wrapped NTT / Lecture** <- you are here\n8. [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Objectives" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Objectives
\n
\n\nThis bundle introduces the transform itself in its negacyclic form.\n\nFocus:\n\n- the difference between `\u03c9` and `\u03c8`\n- direct NTT\u03c8 and INTT\u03c8\n- the direct convolution theorem in the negacyclic setting\n- why this is still too slow at `O(n^2)` without butterflies\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Objectives

\n
\n\nThis bundle introduces the transform itself in its negacyclic form.\n\nFocus:\n\n- the difference between `\u03c9` and `\u03c8`\n- direct NTT\u03c8 and INTT\u03c8\n- the direct convolution theorem in the negacyclic setting\n- why this is still too slow at `O(n^2)` without butterflies\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Why \u03c8 Shows Up" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n explanation\n
\n
Why \u03c8 Shows Up
\n
\n\nFor negative-wrapped convolution, the clean transform formula uses a `2n`-th root `\u03c8` with:\n\n- `\u03c8^2 = \u03c9`\n- `\u03c8^n = -1`\n\nThat is what bakes the negacyclic sign rule into the transform itself.\n" + "source": "
\n Level 2\n
\n explanation\n core path\n
\n

Why \u03c8 Shows Up

\n
\n\nFor negative-wrapped convolution, the clean transform formula uses a `2n`-th root `\u03c8` with:\n\n- `\u03c8^2 = \u03c9`\n- `\u03c8^n = -1`\n\nThat is what bakes the negacyclic sign rule into the transform itself.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Inspect \u03c9, \u03c8, And The Direct Transform Matrix\n# kind: demo | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, ntt_psi_exponent_grid, ntt_psi_matrix\nfrom ntt_learning.visuals import direct_ntt_player, plot_ntt_psi_exponent_heatmap, plot_ntt_psi_matrix_heatmap\n\nmodulus = 17\nn = 4\nomega = find_primitive_root(n, modulus)\npsi = find_psi(n, modulus)\n\nprint(\"omega:\", omega)\nprint(\"psi:\", psi)\nprint(\"exponent grid:\")\nfor row in ntt_psi_exponent_grid(n):\n print(row)\nprint(\"NTT_psi matrix:\")\nfor row in ntt_psi_matrix(n, modulus, psi):\n print(row)\n\ndisplay(direct_ntt_player([1, 2, 3, 4], modulus, psi))\ndisplay(plot_ntt_psi_exponent_heatmap(n, title=\"Exponents 2ij + i for n=4\"))\ndisplay(plot_ntt_psi_matrix_heatmap(n, modulus, psi, title=\"Concrete NTT_psi matrix in Z_17\"))\n" + "source": "# Inspect \u03c9, \u03c8, And The Direct Transform Matrix\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, ntt_psi_exponent_grid, ntt_psi_matrix\nfrom ntt_learning.visuals import direct_ntt_player, plot_ntt_psi_exponent_heatmap, plot_ntt_psi_matrix_heatmap\n\nmodulus = 17\nn = 4\nomega = find_primitive_root(n, modulus)\npsi = find_psi(n, modulus)\n\nprint(\"omega:\", omega)\nprint(\"psi:\", psi)\nprint(\"exponent grid:\")\nfor row in ntt_psi_exponent_grid(n):\n print(row)\nprint(\"NTT_psi matrix:\")\nfor row in ntt_psi_matrix(n, modulus, psi):\n print(row)\n\ndisplay(direct_ntt_player([1, 2, 3, 4], modulus, psi))\ndisplay(plot_ntt_psi_exponent_heatmap(n, title=\"Exponents 2ij + i for n=4\"))\ndisplay(plot_ntt_psi_matrix_heatmap(n, modulus, psi, title=\"Concrete NTT_psi matrix in Z_17\"))\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Direct NTT\u03c8 Is Mechanically Clear But Still Quadratic" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n explanation\n
\n
Direct NTT\u03c8 Is Mechanically Clear But Still Quadratic
\n
\n\nThe direct transform is useful because every coefficient and every exponent is visible.\nIt is not yet efficient. It still performs the full matrix multiplication.\n" + "source": "
\n Level 2\n
\n explanation\n core path\n
\n

Direct NTT\u03c8 Is Mechanically Clear But Still Quadratic

\n
\n\nThe direct transform is useful because every coefficient and every exponent is visible.\nIt is not yet efficient. It still performs the full matrix multiplication.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Run A Direct NTT\u03c8 / INTT\u03c8 Round Trip\n# kind: demo | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi\nfrom ntt_learning.visuals import direct_ntt_player\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\npsi = find_psi(len(signal), modulus)\nspectrum = forward_ntt_psi(signal, modulus, psi)\n\nprint(\"signal:\", signal)\nprint(\"spectrum:\", spectrum)\nprint(\"inverse recovery:\", inverse_ntt_psi(spectrum, modulus, psi))\ndisplay(direct_ntt_player(signal, modulus, psi))\n" + "source": "# Run A Direct NTT\u03c8 / INTT\u03c8 Round Trip\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi\nfrom ntt_learning.visuals import direct_ntt_player\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\npsi = find_psi(len(signal), modulus)\nspectrum = forward_ntt_psi(signal, modulus, psi)\n\nprint(\"signal:\", signal)\nprint(\"spectrum:\", spectrum)\nprint(\"inverse recovery:\", inverse_ntt_psi(spectrum, modulus, psi))\ndisplay(direct_ntt_player(signal, modulus, psi))\n" }, { "cell_type": "code", @@ -100,7 +100,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Use Direct NTT\u03c8 For Negacyclic Multiplication\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi, negacyclic_multiply, pointwise_multiply\nfrom ntt_learning.visuals import plot_transform_pipeline\n\nleft = [1, 2, 3, 4]\nright = [5, 6, 7, 8]\nmodulus = 17\npsi = find_psi(4, modulus)\n\nleft_hat = forward_ntt_psi(left, modulus, psi)\nright_hat = forward_ntt_psi(right, modulus, psi)\nproduct_hat = pointwise_multiply(left_hat, right_hat, modulus)\n\nprint(\"NTT_psi(left):\", left_hat)\nprint(\"NTT_psi(right):\", right_hat)\nprint(\"pointwise product:\", product_hat)\nprint(\"inverse of pointwise product:\", inverse_ntt_psi(product_hat, modulus, psi))\nprint(\"schoolbook negacyclic:\", negacyclic_multiply(left, right, n=4, modulus=modulus))\ndisplay(plot_transform_pipeline(left, right, modulus=modulus, psi=psi, title=\"Direct negacyclic multiply pipeline\"))\n" + "source": "# Use Direct NTT\u03c8 For Negacyclic Multiplication\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi, negacyclic_multiply, pointwise_multiply\nfrom ntt_learning.visuals import plot_transform_pipeline\n\nleft = [1, 2, 3, 4]\nright = [5, 6, 7, 8]\nmodulus = 17\npsi = find_psi(4, modulus)\n\nleft_hat = forward_ntt_psi(left, modulus, psi)\nright_hat = forward_ntt_psi(right, modulus, psi)\nproduct_hat = pointwise_multiply(left_hat, right_hat, modulus)\n\nprint(\"NTT_psi(left):\", left_hat)\nprint(\"NTT_psi(right):\", right_hat)\nprint(\"pointwise product:\", product_hat)\nprint(\"inverse of pointwise product:\", inverse_ntt_psi(product_hat, modulus, psi))\nprint(\"schoolbook negacyclic:\", negacyclic_multiply(left, right, n=4, modulus=modulus))\ndisplay(plot_transform_pipeline(left, right, modulus=modulus, psi=psi, title=\"Direct negacyclic multiply pipeline\"))\n" }, { "cell_type": "markdown", @@ -112,7 +112,7 @@ "title": "Retrieval Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Retrieval Check
\n
\n\n1. Why is `\u03c8` stronger than `\u03c9` in the negacyclic story?\n2. What exact property does the inverse add that the forward transform does not?\n3. Why are we still dissatisfied after seeing the direct transform work correctly?\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Retrieval Check

\n
\n\n1. Why is `\u03c8` stronger than `\u03c9` in the negacyclic story?\n2. What exact property does the inverse add that the forward transform does not?\n3. Why are we still dissatisfied after seeing the direct transform work correctly?\n" }, { "cell_type": "code", @@ -126,7 +126,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Compare Positive And Negative Wrapped Transforms\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, forward_ntt, forward_ntt_psi\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\nprint(\"positive-wrapped NTT:\", forward_ntt(signal, modulus, omega))\nprint(\"negative-wrapped NTT_psi:\", forward_ntt_psi(signal, modulus, psi))\n" + "source": "# Optional: Compare Positive And Negative Wrapped Transforms\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, forward_ntt, forward_ntt_psi\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\nprint(\"positive-wrapped NTT:\", forward_ntt(signal, modulus, omega))\nprint(\"negative-wrapped NTT_psi:\", forward_ntt_psi(signal, modulus, psi))\n" }, { "cell_type": "markdown", @@ -138,7 +138,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 8 of 27 - Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 8 of 27 - Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/02_negative_wrapped_ntt/problems.ipynb b/notebooks/foundations/02_negative_wrapped_ntt/problems.ipynb index 05d0fff..1089629 100644 --- a/notebooks/foundations/02_negative_wrapped_ntt/problems.ipynb +++ b/notebooks/foundations/02_negative_wrapped_ntt/problems.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 9 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n9. **Foundations / 02 Negative Wrapped NTT / Problems** <- you are here\n10. [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 9 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n9. **Foundations / 02 Negative Wrapped NTT / Problems** <- you are here\n10. [Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Problem Set Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Problem Set Goals
\n
\n\nThis notebook checks whether the direct negative-wrapped transform is now mechanically understandable.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Problem Set Goals

\n
\n\nThis notebook checks whether the direct negative-wrapped transform is now mechanically understandable.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Multiple-Choice Retrieval" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Multiple-Choice Retrieval
\n
\n\nChoose one answer for each:\n\n1. In the negacyclic transform, `\u03c8` matters because:\n A. it makes the modulus disappear\n B. it encodes the `x^n + 1` sign structure\n C. it avoids all inverses\n\n2. The inverse transform differs from the forward transform by:\n A. an inverse root and an `n^-1` scaling\n B. a larger modulus\n C. removing all twiddle factors\n\n3. The direct matrix transform is still pedagogically useful because:\n A. it keeps every coefficient contribution visible\n B. it is how Kyber is implemented directly at full size\n C. it removes the need for butterflies\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Multiple-Choice Retrieval

\n
\n\nChoose one answer for each:\n\n1. In the negacyclic transform, `\u03c8` matters because:\n A. it makes the modulus disappear\n B. it encodes the `x^n + 1` sign structure\n C. it avoids all inverses\n\n2. The inverse transform differs from the forward transform by:\n A. an inverse root and an `n^-1` scaling\n B. a larger modulus\n C. removing all twiddle factors\n\n3. The direct matrix transform is still pedagogically useful because:\n A. it keeps every coefficient contribution visible\n B. it is how Kyber is implemented directly at full size\n C. it removes the need for butterflies\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Answer Key\n# kind: quiz | level: 2\n\nanswers = {1: \"B\", 2: \"A\", 3: \"A\"}\nprint(answers)\n" + "source": "# Answer Key\n\nanswers = {1: \"B\", 2: \"A\", 3: \"A\"}\nprint(answers)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Round-Trip Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Round-Trip Check
\n
\n\nVerify by code that `INTT\u03c8(NTT\u03c8(a)) = a` for a nontrivial vector.\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Round-Trip Check

\n
\n\nVerify by code that `INTT\u03c8(NTT\u03c8(a)) = a` for a nontrivial vector.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Check The Round Trip\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi\n\nsignal = [6, 0, 5, 2]\npsi = find_psi(4, 17)\nrecovered = inverse_ntt_psi(forward_ntt_psi(signal, 17, psi), 17, psi)\nprint(recovered)\nassert recovered == signal\n" + "source": "# Check The Round Trip\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi, inverse_ntt_psi\n\nsignal = [6, 0, 5, 2]\npsi = find_psi(4, 17)\nrecovered = inverse_ntt_psi(forward_ntt_psi(signal, 17, psi), 17, psi)\nprint(recovered)\nassert recovered == signal\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Written Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Written Reflection
\n
\n\nIn one paragraph, explain why the direct transform is the right place to understand the algebra, but not the right place to stop if you care about algorithmic speed.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Written Reflection

\n
\n\nIn one paragraph, explain why the direct transform is the right place to understand the algebra, but not the right place to stop if you care about algorithmic speed.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional Challenge\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi\n\npsi = find_psi(4, 17)\nfor signal in ([1, 1, 1, 1], [0, 1, 0, 1], [3, 5, 7, 9]):\n print(signal, \"->\", forward_ntt_psi(signal, 17, psi))\n" + "source": "# Optional Challenge\n\nfrom ntt_learning.toy_ntt import find_psi, forward_ntt_psi\n\npsi = find_psi(4, 17)\nfor signal in ([1, 1, 1, 1], [0, 1, 0, 1], [3, 5, 7, 9]):\n print(signal, \"->\", forward_ntt_psi(signal, 17, psi))\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 10 of 27 - Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 10 of 27 - Foundations / 02 Negative Wrapped NTT / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/foundations/02_negative_wrapped_ntt/studio.ipynb b/notebooks/foundations/02_negative_wrapped_ntt/studio.ipynb index 7b22ec8..d0b03dd 100644 --- a/notebooks/foundations/02_negative_wrapped_ntt/studio.ipynb +++ b/notebooks/foundations/02_negative_wrapped_ntt/studio.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 10 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n10. **Foundations / 02 Negative Wrapped NTT / Studio** <- you are here\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 10 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n10. **Foundations / 02 Negative Wrapped NTT / Studio** <- you are here\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Studio Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Studio Goals
\n
\n\nThe studio compares direct positive-wrapped and negative-wrapped transforms so the learner stops treating \u201cNTT\u201d as one unqualified object.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Studio Goals

\n
\n\nThe studio compares direct positive-wrapped and negative-wrapped transforms so the learner stops treating \u201cNTT\u201d as one unqualified object.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Same Input, Different Transform Story" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Same Input, Different Transform Story
\n
\n\nThe same coefficient vector can be sent through two different transform stories depending on the quotient ring.\nThat difference is not implementation noise. It is structural.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Same Input, Different Transform Story

\n
\n\nThe same coefficient vector can be sent through two different transform stories depending on the quotient ring.\nThat difference is not implementation noise. It is structural.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Compare Positive-Wrapped And Negative-Wrapped Views\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, forward_ntt, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\npositive = forward_ntt(signal, modulus, omega)\nnegative = forward_ntt_psi(signal, modulus, psi)\n\nprint(\"positive-wrapped NTT:\", positive)\nprint(\"negative-wrapped NTT_psi:\", negative)\ndisplay(\n plot_vector_comparison(\n positive,\n negative,\n left_label=\"positive\",\n right_label=\"negative\",\n title=\"Same signal, different transform story\",\n )\n)\n" + "source": "# Compare Positive-Wrapped And Negative-Wrapped Views\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, forward_ntt, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\npositive = forward_ntt(signal, modulus, omega)\nnegative = forward_ntt_psi(signal, modulus, psi)\n\nprint(\"positive-wrapped NTT:\", positive)\nprint(\"negative-wrapped NTT_psi:\", negative)\ndisplay(\n plot_vector_comparison(\n positive,\n negative,\n left_label=\"positive\",\n right_label=\"negative\",\n title=\"Same signal, different transform story\",\n )\n)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Debug Checklist" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Debug Checklist
\n
\n\nIf a direct transform result looks suspicious, inspect:\n\n1. the chosen modulus\n2. the order of the root\n3. whether you are using `\u03c9` or `\u03c8`\n4. whether the inverse includes `n^-1`\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Debug Checklist

\n
\n\nIf a direct transform result looks suspicious, inspect:\n\n1. the chosen modulus\n2. the order of the root\n3. whether you are using `\u03c9` or `\u03c8`\n4. whether the inverse includes `n^-1`\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See A Wrong-Root Failure\n# kind: exercise | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\ncorrect = forward_ntt_psi(signal, modulus, psi)\nwrong = forward_ntt_psi(signal, modulus, omega)\n\nprint(\"correct psi-based transform:\", correct)\nprint(\"wrongly using omega as if it were psi:\", wrong)\ndisplay(\n plot_vector_comparison(\n wrong,\n correct,\n left_label=\"wrong_root\",\n right_label=\"correct\",\n title=\"Wrong root vs correct root\",\n )\n)\n" + "source": "# See A Wrong-Root Failure\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\ncorrect = forward_ntt_psi(signal, modulus, psi)\nwrong = forward_ntt_psi(signal, modulus, omega)\n\nprint(\"correct psi-based transform:\", correct)\nprint(\"wrongly using omega as if it were psi:\", wrong)\ndisplay(\n plot_vector_comparison(\n wrong,\n correct,\n left_label=\"wrong_root\",\n right_label=\"correct\",\n title=\"Wrong root vs correct root\",\n )\n)\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nExplain why \u201cpick any root of unity\u201d is not an acceptable habit in this subject.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nExplain why \u201cpick any root of unity\u201d is not an acceptable habit in this subject.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Matrix Comparison\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, ntt_psi_matrix\n\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\nprint(\"omega:\", omega)\nprint(\"psi:\", psi)\nfor row in ntt_psi_matrix(4, modulus, psi):\n print(row)\n" + "source": "# Optional: Matrix Comparison\n\nfrom ntt_learning.toy_ntt import find_primitive_root, find_psi, ntt_psi_matrix\n\nmodulus = 17\nomega = find_primitive_root(4, modulus)\npsi = find_psi(4, modulus)\n\nprint(\"omega:\", omega)\nprint(\"psi:\", psi)\nfor row in ntt_psi_matrix(4, modulus, psi):\n print(row)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 11 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Foundations / 02 Negative Wrapped NTT / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 11 of 27 - Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Foundations / 02 Negative Wrapped NTT / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb index a250cfd..f988dcf 100644 --- a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb +++ b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 20 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n20. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab** <- you are here\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 20 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n20. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab** <- you are here\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Lab Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Lab Goals
\n
\n\nThe lab is about making the Kyber modulus obstruction explicit enough that it becomes memorable.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Lab Goals

\n
\n\nThe lab is about making the Kyber modulus obstruction explicit enough that it becomes memorable.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Exercise 1" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 1
\n
\n\nBefore running the next cell, say out loud:\n\n- why `256 | 3328`\n- why `512` does not divide `3328`\n- what that means for the existence of `\u03c8`\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 1

\n
\n\nBefore running the next cell, say out loud:\n\n- why `256 | 3328`\n- why `512` does not divide `3328`\n- what that means for the existence of `\u03c8`\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Prediction Check\n# kind: exercise | level: 3\n\nprint(\"3328 / 256 =\", (3329 - 1) // 256)\nprint(\"3328 % 256 =\", (3329 - 1) % 256)\nprint(\"3328 % 512 =\", (3329 - 1) % 512)\n" + "source": "# Prediction Check\n\nprint(\"3328 / 256 =\", (3329 - 1) // 256)\nprint(\"3328 % 256 =\", (3329 - 1) % 256)\nprint(\"3328 % 512 =\", (3329 - 1) % 512)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Exercise 2" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 2
\n
\n\nVerify the toy base multiplication by hand before running the next cell.\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 2

\n
\n\nVerify the toy base multiplication by hand before running the next cell.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Check The Toy Base Multiplication\n# kind: exercise | level: 3\n\nfrom ntt_learning.toy_ntt import base_multiply_pair\n\nprint(base_multiply_pair([3, 5], [2, 7], zeta=6, modulus=17))\n" + "source": "# Check The Toy Base Multiplication\n\nfrom ntt_learning.toy_ntt import base_multiply_pair\n\nprint(base_multiply_pair([3, 5], [2, 7], zeta=6, modulus=17))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nReflection prompt:\n\n- Why is \u201cthere is no 512-th root\u201d not just a technical footnote?\n- What false picture of Kyber would survive if you ignored that fact?\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nReflection prompt:\n\n- Why is \u201cthere is no 512-th root\u201d not just a technical footnote?\n- What false picture of Kyber would survive if you ignored that fact?\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Tiny Modulus Classifier\n# kind: exploration | level: 4\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\ndef classify(q=17, n=4):\n print({\"q\": q, \"n\": n, \"pwc\": (q - 1) % n == 0, \"nwc\": (q - 1) % (2 * n) == 0})\n\ndisplay(widgets.interact(classify, q=(5, 101), n=(2, 16)))\n" + "source": "# Optional: Tiny Modulus Classifier\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\ndef classify(q=17, n=4):\n print({\"q\": q, \"n\": n, \"pwc\": (q - 1) % n == 0, \"nwc\": (q - 1) % (2 * n) == 0})\n\ndisplay(widgets.interact(classify, q=(5, 101), n=(2, 16)))\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 21 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 21 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb index 89ebac9..034a5e6 100644 --- a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb +++ b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 19 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture** <- you are here\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 19 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture** <- you are here\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Objectives" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Objectives
\n
\n\nThis bundle ties the transform story to Kyber without throwing away the concrete arithmetic.\n\nFocus:\n\n- what Kyber\u2019s `q = 3329`, `n = 256` really allow\n- why the full `2n`-th root mental model breaks at Kyber v3\n- why base multiplication appears\n- how to keep the story NTT-centered without lying about the modulus\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Objectives

\n
\n\nThis bundle ties the transform story to Kyber without throwing away the concrete arithmetic.\n\nFocus:\n\n- what Kyber\u2019s `q = 3329`, `n = 256` really allow\n- why the full `2n`-th root mental model breaks at Kyber v3\n- why base multiplication appears\n- how to keep the story NTT-centered without lying about the modulus\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Kyber Is Not \u201cJust Generic Negacyclic NTT With Big Numbers\u201d" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Kyber Is Not \u201cJust Generic Negacyclic NTT With Big Numbers\u201d
\n
\n\nThe key arithmetic reality is:\n\n- Kyber v3 has `n = 256`\n- `q = 3329`\n- `256` divides `3328`\n- `512` does **not** divide `3328`\n\nThat means a primitive `256`-th root exists, but a primitive `512`-th root does not.\nSo the clean full-length `\u03c8` story from the toy negative-wrapped transform does not lift over unchanged.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Kyber Is Not \u201cJust Generic Negacyclic NTT With Big Numbers\u201d

\n
\n\nThe key arithmetic reality is:\n\n- Kyber v3 has `n = 256`\n- `q = 3329`\n- `256` divides `3328`\n- `512` does **not** divide `3328`\n\nThat means a primitive `256`-th root exists, but a primitive `512`-th root does not.\nSo the clean full-length `\u03c8` story from the toy negative-wrapped transform does not lift over unchanged.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See The Stage Skeleton For n=16 And n=256\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_stage_pairing_map, plot_stage_schedule\n\ndisplay(plot_stage_schedule(16, title=\"Readable schedule skeleton for n=16\"))\ndisplay(plot_stage_pairing_map(16, 2, title=\"Stage 1 geometry for n=16\"))\ndisplay(plot_stage_pairing_map(16, 16, title=\"Final stage geometry for n=16\"))\ndisplay(plot_stage_schedule(256, title=\"Kyber-scale stage skeleton for n=256\"))\n" + "source": "# See The Stage Skeleton For n=16 And n=256\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_stage_pairing_map, plot_stage_schedule\n\ndisplay(plot_stage_schedule(16, title=\"Readable schedule skeleton for n=16\"))\ndisplay(plot_stage_pairing_map(16, 2, title=\"Stage 1 geometry for n=16\"))\ndisplay(plot_stage_pairing_map(16, 16, title=\"Final stage geometry for n=16\"))\ndisplay(plot_stage_schedule(256, title=\"Kyber-scale stage skeleton for n=256\"))\n" }, { "cell_type": "code", @@ -74,7 +74,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Check The Kyber Root Reality Directly\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root\nfrom ntt_learning.visuals import plot_root_order_comparison\n\nprint(\"3329 - 1 =\", 3329 - 1)\nprint(\"primitive 256-th root in Z_3329:\", find_primitive_root(256, 3329))\ntry:\n find_primitive_root(512, 3329)\nexcept Exception as exc:\n print(\"512-th root fails exactly because:\", exc)\n\ndisplay(\n plot_root_order_comparison(\n [(4, 17), (4, 13), (8, 97), (256, 3329)],\n title=\"Which moduli allow n-th and 2n-th root stories?\",\n )\n)\n" + "source": "# Check The Kyber Root Reality Directly\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_primitive_root\nfrom ntt_learning.visuals import plot_root_order_comparison\n\nprint(\"3329 - 1 =\", 3329 - 1)\nprint(\"primitive 256-th root in Z_3329:\", find_primitive_root(256, 3329))\ntry:\n find_primitive_root(512, 3329)\nexcept Exception as exc:\n print(\"512-th root fails exactly because:\", exc)\n\ndisplay(\n plot_root_order_comparison(\n [(4, 17), (4, 13), (8, 97), (256, 3329)],\n title=\"Which moduli allow n-th and 2n-th root stories?\",\n )\n)\n" }, { "cell_type": "markdown", @@ -86,7 +86,7 @@ "title": "Tiny Analogue Of The Same Obstruction" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Tiny Analogue Of The Same Obstruction
\n
\n\nThe easiest way to feel this is to shrink the numbers.\nIn `Z_13`, a 4-th root exists because `4 | 12`, but an 8-th root does not because `8` does not divide `12`.\n\nThat is the same shape of obstruction as Kyber v3, only tiny enough to inspect instantly.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Tiny Analogue Of The Same Obstruction

\n
\n\nThe easiest way to feel this is to shrink the numbers.\nIn `Z_13`, a 4-th root exists because `4 | 12`, but an 8-th root does not because `8` does not divide `12`.\n\nThat is the same shape of obstruction as Kyber v3, only tiny enough to inspect instantly.\n" }, { "cell_type": "code", @@ -100,7 +100,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Run The Tiny Analogue\n# kind: demo | level: 3\n\nfrom ntt_learning.toy_ntt import find_primitive_root\n\nprint(\"primitive 4-th root in Z_13:\", find_primitive_root(4, 13))\ntry:\n find_primitive_root(8, 13)\nexcept Exception as exc:\n print(\"8-th root fails:\", exc)\n" + "source": "# Run The Tiny Analogue\n\nfrom ntt_learning.toy_ntt import find_primitive_root\n\nprint(\"primitive 4-th root in Z_13:\", find_primitive_root(4, 13))\ntry:\n find_primitive_root(8, 13)\nexcept Exception as exc:\n print(\"8-th root fails:\", exc)\n" }, { "cell_type": "markdown", @@ -112,7 +112,7 @@ "title": "Why Base Multiplication Appears" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Why Base Multiplication Appears
\n
\n\nOnce the ring does not split into fully scalar transform slots in the naive `\u03c8` way, multiplication in the transform domain is no longer \u201cjust multiply scalars slot by slot\u201d.\n\nA small block structure remains, and that is why pairwise base multiplication appears.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Why Base Multiplication Appears

\n
\n\nOnce the ring does not split into fully scalar transform slots in the naive `\u03c8` way, multiplication in the transform domain is no longer \u201cjust multiply scalars slot by slot\u201d.\n\nA small block structure remains, and that is why pairwise base multiplication appears.\n" }, { "cell_type": "code", @@ -126,7 +126,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See A Toy Base Multiplication\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import base_multiply_pair\nfrom ntt_learning.visuals import plot_base_multiply_pair_diagram\n\nleft = [7, 11]\nright = [5, 13]\nzeta = 4\nmodulus = 17\n\nraw = [left[0] * right[0], left[0] * right[1] + left[1] * right[0], left[1] * right[1]]\nreduced = [(raw[0] + zeta * raw[2]) % modulus, raw[1] % modulus]\n\nprint(\"raw degree-2 product:\", raw)\nprint(\"reduce with x^2 = zeta:\", reduced)\nprint(\"base_multiply_pair:\", base_multiply_pair(left, right, zeta, modulus))\ndisplay(\n plot_base_multiply_pair_diagram(\n left,\n right,\n zeta=zeta,\n modulus=modulus,\n title=\"Why Kyber-style multiplication stays in 2-slot blocks\",\n )\n)\n" + "source": "# See A Toy Base Multiplication\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import base_multiply_pair\nfrom ntt_learning.visuals import plot_base_multiply_pair_diagram\n\nleft = [7, 11]\nright = [5, 13]\nzeta = 4\nmodulus = 17\n\nraw = [left[0] * right[0], left[0] * right[1] + left[1] * right[0], left[1] * right[1]]\nreduced = [(raw[0] + zeta * raw[2]) % modulus, raw[1] % modulus]\n\nprint(\"raw degree-2 product:\", raw)\nprint(\"reduce with x^2 = zeta:\", reduced)\nprint(\"base_multiply_pair:\", base_multiply_pair(left, right, zeta, modulus))\ndisplay(\n plot_base_multiply_pair_diagram(\n left,\n right,\n zeta=zeta,\n modulus=modulus,\n title=\"Why Kyber-style multiplication stays in 2-slot blocks\",\n )\n)\n" }, { "cell_type": "markdown", @@ -138,7 +138,7 @@ "title": "Retrieval Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Retrieval Check
\n
\n\n1. What exact divisibility fact blocks the naive full `2n`-th root story in Kyber v3?\n2. Why does that obstruction point you toward base multiplication?\n3. Why would it be misleading to teach Kyber as if the toy `\u03c8` story carried over unchanged?\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Retrieval Check

\n
\n\n1. What exact divisibility fact blocks the naive full `2n`-th root story in Kyber v3?\n2. Why does that obstruction point you toward base multiplication?\n3. Why would it be misleading to teach Kyber as if the toy `\u03c8` story carried over unchanged?\n" }, { "cell_type": "code", @@ -152,7 +152,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Compare Several Moduli\n# kind: exploration | level: 4\n\ndef status(n, q):\n pwc = (q - 1) % n == 0\n nwc = (q - 1) % (2 * n) == 0\n return {\"n\": n, \"q\": q, \"pwc\": pwc, \"nwc\": nwc}\n\nfor sample in [(4, 17), (4, 13), (256, 7681), (256, 3329)]:\n print(status(*sample))\n" + "source": "# Optional: Compare Several Moduli\n\ndef status(n, q):\n pwc = (q - 1) % n == 0\n nwc = (q - 1) % (2 * n) == 0\n return {\"n\": n, \"q\": q, \"pwc\": pwc, \"nwc\": nwc}\n\nfor sample in [(4, 17), (4, 13), (256, 7681), (256, 3329)]:\n print(status(*sample))\n" }, { "cell_type": "markdown", @@ -164,7 +164,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 20 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 20 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb index ea4ea4f..f686958 100644 --- a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb +++ b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 21 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n21. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems** <- you are here\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 21 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n21. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems** <- you are here\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Problem Set Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Problem Set Goals
\n
\n\nThis notebook checks whether the Kyber-specific modulus story is now precise instead of fuzzy.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Problem Set Goals

\n
\n\nThis notebook checks whether the Kyber-specific modulus story is now precise instead of fuzzy.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Multiple-Choice Retrieval" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Multiple-Choice Retrieval
\n
\n\nChoose one answer for each:\n\n1. For Kyber v3, the important root fact is:\n A. `512` divides `3328`\n B. `256` divides `3328` but `512` does not\n C. no relevant root exists at all\n\n2. Base multiplication appears because:\n A. the transform-domain multiplication remains structured in small blocks\n B. scalar multiplication is forbidden in finite fields\n C. schoolbook multiplication vanished\n\n3. The biggest pedagogical risk is:\n A. teaching Kyber as if the toy `\u03c8` model applied unchanged\n B. teaching any toy examples at all\n C. comparing moduli\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Multiple-Choice Retrieval

\n
\n\nChoose one answer for each:\n\n1. For Kyber v3, the important root fact is:\n A. `512` divides `3328`\n B. `256` divides `3328` but `512` does not\n C. no relevant root exists at all\n\n2. Base multiplication appears because:\n A. the transform-domain multiplication remains structured in small blocks\n B. scalar multiplication is forbidden in finite fields\n C. schoolbook multiplication vanished\n\n3. The biggest pedagogical risk is:\n A. teaching Kyber as if the toy `\u03c8` model applied unchanged\n B. teaching any toy examples at all\n C. comparing moduli\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Answer Key\n# kind: quiz | level: 2\n\nanswers = {1: \"B\", 2: \"A\", 3: \"A\"}\nprint(answers)\n" + "source": "# Answer Key\n\nanswers = {1: \"B\", 2: \"A\", 3: \"A\"}\nprint(answers)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Quick Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Quick Check
\n
\n\nExplain in one sentence why a primitive 256-th root is not enough to recover the full toy `\u03c8` story at `n = 256`.\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Quick Check

\n
\n\nExplain in one sentence why a primitive 256-th root is not enough to recover the full toy `\u03c8` story at `n = 256`.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Numerical Check\n# kind: exercise | level: 2\n\nprint(\"2 * 256 =\", 2 * 256)\nprint(\"3329 - 1 =\", 3329 - 1)\nprint(\"divides?\", (3329 - 1) % (2 * 256) == 0)\n" + "source": "# Numerical Check\n\nprint(\"2 * 256 =\", 2 * 256)\nprint(\"3329 - 1 =\", 3329 - 1)\nprint(\"divides?\", (3329 - 1) % (2 * 256) == 0)\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Written Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Written Reflection
\n
\n\nIn one paragraph, explain why the Kyber notebook belongs after the toy direct and fast-transform notebooks rather than before them.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Written Reflection

\n
\n\nIn one paragraph, explain why the Kyber notebook belongs after the toy direct and fast-transform notebooks rather than before them.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional Challenge\n# kind: exploration | level: 4\n\nsamples = [(256, 7681), (256, 3329), (8, 97), (8, 41)]\nfor n, q in samples:\n print({\"n\": n, \"q\": q, \"n_divides_q_minus_1\": (q - 1) % n == 0, \"two_n_divides_q_minus_1\": (q - 1) % (2 * n) == 0})\n" + "source": "# Optional Challenge\n\nsamples = [(256, 7681), (256, 3329), (8, 97), (8, 41)]\nfor n, q in samples:\n print({\"n\": n, \"q\": q, \"n_divides_q_minus_1\": (q - 1) % n == 0, \"two_n_divides_q_minus_1\": (q - 1) % (2 * n) == 0})\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 22 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 22 of 27 - Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb index 6f8ae02..993101c 100644 --- a/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb +++ b/notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 22 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n22. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio** <- you are here\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 22 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n22. **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio** <- you are here\n23. [Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](../../professional/06_debugging_ntt_failures/lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](../../professional/06_debugging_ntt_failures/problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](../../professional/06_debugging_ntt_failures/studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Studio Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Studio Goals
\n
\n\nThis studio compares the clean toy story with the Kyber-specific modulus reality and treats the mismatch as the lesson.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Studio Goals

\n
\n\nThis studio compares the clean toy story with the Kyber-specific modulus reality and treats the mismatch as the lesson.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "The Mismatch Is Not A Bug In The Course" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
The Mismatch Is Not A Bug In The Course
\n
\n\nThe mismatch between \u201ctoy full `\u03c8` story\u201d and \u201cKyber v3 modulus reality\u201d is exactly what the learner needs to understand.\n\nThat mismatch is why base multiplication and implementation-specific scheduling matter.\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

The Mismatch Is Not A Bug In The Course

\n
\n\nThe mismatch between \u201ctoy full `\u03c8` story\u201d and \u201cKyber v3 modulus reality\u201d is exactly what the learner needs to understand.\n\nThat mismatch is why base multiplication and implementation-specific scheduling matter.\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Toy Full \u03c8 Story vs Kyber Root Reality\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi\nfrom ntt_learning.visuals import plot_root_order_comparison\n\nprint(\"toy n=4, q=17 has psi:\", find_psi(4, 17))\ntry:\n find_psi(256, 3329)\nexcept Exception as exc:\n print(\"Kyber v3 does not have that full psi story:\", exc)\n\ndisplay(\n plot_root_order_comparison(\n [(4, 17), (256, 7681), (256, 3329)],\n title=\"Toy full psi story vs Kyber modulus reality\",\n )\n)\n" + "source": "# Toy Full \u03c8 Story vs Kyber Root Reality\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import find_psi\nfrom ntt_learning.visuals import plot_root_order_comparison\n\nprint(\"toy n=4, q=17 has psi:\", find_psi(4, 17))\ntry:\n find_psi(256, 3329)\nexcept Exception as exc:\n print(\"Kyber v3 does not have that full psi story:\", exc)\n\ndisplay(\n plot_root_order_comparison(\n [(4, 17), (256, 7681), (256, 3329)],\n title=\"Toy full psi story vs Kyber modulus reality\",\n )\n)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Debug Checklist" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Debug Checklist
\n
\n\nIf somebody says \u201cKyber is just the same toy negative-wrapped NTT with bigger numbers\u201d, inspect:\n\n1. whether they checked `2n | q - 1`\n2. whether they accounted for the missing `\u03c8`\n3. whether they know why base multiplication appears\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Debug Checklist

\n
\n\nIf somebody says \u201cKyber is just the same toy negative-wrapped NTT with bigger numbers\u201d, inspect:\n\n1. whether they checked `2n | q - 1`\n2. whether they accounted for the missing `\u03c8`\n3. whether they know why base multiplication appears\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See The Exact Obstruction Again\n# kind: exercise | level: 2\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_root_order_comparison\n\nq = 3329\nn = 256\nprint({\"q_minus_1\": q - 1, \"n\": n, \"2n\": 2 * n, \"q_minus_1_mod_n\": (q - 1) % n, \"q_minus_1_mod_2n\": (q - 1) % (2 * n)})\ndisplay(plot_root_order_comparison([(256, 3329)], title=\"Kyber v3 obstruction in one row\"))\n" + "source": "# See The Exact Obstruction Again\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_root_order_comparison\n\nq = 3329\nn = 256\nprint({\"q_minus_1\": q - 1, \"n\": n, \"2n\": 2 * n, \"q_minus_1_mod_n\": (q - 1) % n, \"q_minus_1_mod_2n\": (q - 1) % (2 * n)})\ndisplay(plot_root_order_comparison([(256, 3329)], title=\"Kyber v3 obstruction in one row\"))\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nExplain why the Kyber base-multiplication story is easier to trust once you have already internalized the toy negacyclic transform.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nExplain why the Kyber base-multiplication story is easier to trust once you have already internalized the toy negacyclic transform.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Another toy base multiplication\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import base_multiply_pair\n\nprint(base_multiply_pair([7, 9], [4, 6], zeta=11, modulus=17))\n" + "source": "# Optional: Another toy base multiplication\n\nfrom ntt_learning.toy_ntt import base_multiply_pair\n\nprint(base_multiply_pair([7, 9], [4, 6], zeta=11, modulus=17))\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 23 of 27 - Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 23 of 27 - Professional / 06 Debugging NTT Failures / Lecture](../../professional/06_debugging_ntt_failures/lecture.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/professional/06_debugging_ntt_failures/lab.ipynb b/notebooks/professional/06_debugging_ntt_failures/lab.ipynb index 61787aa..2c48684 100644 --- a/notebooks/professional/06_debugging_ntt_failures/lab.ipynb +++ b/notebooks/professional/06_debugging_ntt_failures/lab.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 24 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n24. **Professional / 06 Debugging NTT Failures / Lab** <- you are here\n25. [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 24 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n24. **Professional / 06 Debugging NTT Failures / Lab** <- you are here\n25. [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Lab Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Lab Goals
\n
\n\nThe lab asks you to match output fingerprints to the underlying bug.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Lab Goals

\n
\n\nThe lab asks you to match output fingerprints to the underlying bug.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Exercise 1" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 1
\n
\n\nBefore running the next cell, predict which of these bug labels goes with each fingerprint:\n\n- shuffled but otherwise familiar values\n- values that look uniformly too large\n- values broken already in a local stage pair\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 1

\n
\n\nBefore running the next cell, predict which of these bug labels goes with each fingerprint:\n\n- shuffled but otherwise familiar values\n- values that look uniformly too large\n- values broken already in a local stage pair\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Prediction Check\n# kind: exercise | level: 3\n\nfingerprints = {\n \"wrong_order\": \"shuffled but same value set\",\n \"missing_scale\": \"same shape but uniformly off by a factor\",\n \"wrong_zeta\": \"local pair outputs go bad immediately\",\n}\nprint(fingerprints)\n" + "source": "# Prediction Check\n\nfingerprints = {\n \"wrong_order\": \"shuffled but same value set\",\n \"missing_scale\": \"same shape but uniformly off by a factor\",\n \"wrong_zeta\": \"local pair outputs go bad immediately\",\n}\nprint(fingerprints)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Exercise 2" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n exercise\n
\n
Exercise 2
\n
\n\nExplain why \u201calmost right\u201d is a useless debugging description unless you also specify whether the issue is:\n\n- sign\n- order\n- zeta\n- scaling\n" + "source": "
\n Level 3\n
\n exercise\n core path\n
\n

Exercise 2

\n
\n\nExplain why \u201calmost right\u201d is a useless debugging description unless you also specify whether the issue is:\n\n- sign\n- order\n- zeta\n- scaling\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: A Small Debugging Drill\n# kind: exercise | level: 3\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\n\nforward_trace = fast_ntt_psi_ct_trace([5, 6, 7, 8], 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nprint(\"forward BO output:\", forward_trace.raw_output)\nprint(\"forward NO output:\", forward_trace.normal_order_output)\nprint(\"inverse unscaled:\", inverse_trace.raw_output)\nprint(\"inverse scaled:\", inverse_trace.scaled_output)\n" + "source": "# A Small Debugging Drill\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\n\nforward_trace = fast_ntt_psi_ct_trace([5, 6, 7, 8], 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nprint(\"forward BO output:\", forward_trace.raw_output)\nprint(\"forward NO output:\", forward_trace.normal_order_output)\nprint(\"inverse unscaled:\", inverse_trace.raw_output)\nprint(\"inverse scaled:\", inverse_trace.scaled_output)\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Reflection
\n
\n\nReflection prompt:\n\n- Which bug fingerprint feels easiest to recognize now?\n- Which one still needs more repetition?\n- What is your debugging order of operations now?\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Reflection

\n
\n\nReflection prompt:\n\n- Which bug fingerprint feels easiest to recognize now?\n- Which one still needs more repetition?\n- What is your debugging order of operations now?\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Build Your Own Fingerprint Table\n# kind: exploration | level: 4\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\ndef note_bug(mode=\"wrong_order\"):\n print({\"mode\": mode, \"what_to_check_first\": {\"wrong_order\": \"bit reversal\", \"missing_scale\": \"n^-1\", \"wrong_zeta\": \"local pair twiddle\", \"wrong_sign\": \"negacyclic fold sign\"}[mode]})\n\ndisplay(widgets.interact(note_bug, mode=[\"wrong_order\", \"missing_scale\", \"wrong_zeta\", \"wrong_sign\"]))\n" + "source": "# Optional: Build Your Own Fingerprint Table\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\ndef note_bug(mode=\"wrong_order\"):\n print({\"mode\": mode, \"what_to_check_first\": {\"wrong_order\": \"bit reversal\", \"missing_scale\": \"n^-1\", \"wrong_zeta\": \"local pair twiddle\", \"wrong_sign\": \"negacyclic fold sign\"}[mode]})\n\ndisplay(widgets.interact(note_bug, mode=[\"wrong_order\", \"missing_scale\", \"wrong_zeta\", \"wrong_sign\"]))\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 25 of 27 - Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Lab**.\n\n**Primary next action**\n- Next notebook: [Step 25 of 27 - Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/professional/06_debugging_ntt_failures/lecture.ipynb b/notebooks/professional/06_debugging_ntt_failures/lecture.ipynb index 69e9dbe..3915ec7 100644 --- a/notebooks/professional/06_debugging_ntt_failures/lecture.ipynb +++ b/notebooks/professional/06_debugging_ntt_failures/lecture.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 23 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. **Professional / 06 Debugging NTT Failures / Lecture** <- you are here\n24. [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 23 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. **Professional / 06 Debugging NTT Failures / Lecture** <- you are here\n24. [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n26. [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Objectives" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Objectives
\n
\n\nThis final bundle turns common failure modes into visible patterns instead of vague warnings.\n\nFocus:\n\n- wrong sign in wraparound\n- wrong root or wrong zeta\n- wrong BO / NO comparison\n- missing final scaling\n- wrong mental model for the Kyber modulus\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Objectives

\n
\n\nThis final bundle turns common failure modes into visible patterns instead of vague warnings.\n\nFocus:\n\n- wrong sign in wraparound\n- wrong root or wrong zeta\n- wrong BO / NO comparison\n- missing final scaling\n- wrong mental model for the Kyber modulus\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Bad Outputs Have Fingerprints" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
Bad Outputs Have Fingerprints
\n
\n\nDebugging NTTs is easier when you stop staring at the final vector as one blob.\nEach common mistake leaves a characteristic fingerprint:\n\n- wrong sign flips specific wrapped slots\n- wrong order makes a correct value set appear shuffled\n- missing `n^-1` keeps the shape but scales everything wrong\n- wrong zeta corrupts local pair structure early\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

Bad Outputs Have Fingerprints

\n
\n\nDebugging NTTs is easier when you stop staring at the final vector as one blob.\nEach common mistake leaves a characteristic fingerprint:\n\n- wrong sign flips specific wrapped slots\n- wrong order makes a correct value set appear shuffled\n- missing `n^-1` keeps the shape but scales everything wrong\n- wrong zeta corrupts local pair structure early\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: See Four Failure Modes Side By Side\n# kind: demo | level: 3\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import (\n fast_intt_psi_gs_trace,\n fast_ntt_psi_ct_trace,\n forward_ntt_psi,\n negacyclic_reduce,\n schoolbook_convolution,\n)\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nforward_trace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nwrong_sign = [raw[0] + raw[4], raw[1] + raw[5], raw[2] + raw[6], raw[3]]\nwrong_order = list(forward_trace.raw_output)\nwrong_scale = list(inverse_trace.raw_output)\nwrong_root = forward_ntt_psi(signal, 7681, 3383)\n\nprint(\"wrong sign fold:\", wrong_sign)\nprint(\"correct sign fold:\", negacyclic_reduce(raw, n=4))\nprint(\"wrong BO-vs-NO comparison:\", wrong_order)\nprint(\"correct NO output:\", forward_trace.normal_order_output)\nprint(\"missing final scaling:\", wrong_scale)\nprint(\"wrong root in direct transform:\", wrong_root)\ndisplay(\n plot_vector_comparison(\n wrong_sign,\n negacyclic_reduce(raw, n=4),\n left_label=\"wrong_sign\",\n right_label=\"correct_sign\",\n title=\"Wrong sign vs correct negacyclic fold\",\n )\n)\ndisplay(\n plot_vector_comparison(\n wrong_order,\n forward_trace.normal_order_output,\n left_label=\"wrong_order\",\n right_label=\"correct_order\",\n title=\"Wrong BO/NO comparison\",\n )\n)\ndisplay(\n plot_vector_comparison(\n wrong_scale,\n inverse_trace.scaled_output,\n left_label=\"missing_scale\",\n right_label=\"correct_scale\",\n title=\"Missing scale vs corrected inverse\",\n )\n)\n" + "source": "# See Four Failure Modes Side By Side\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import (\n fast_intt_psi_gs_trace,\n fast_ntt_psi_ct_trace,\n forward_ntt_psi,\n negacyclic_reduce,\n schoolbook_convolution,\n)\nfrom ntt_learning.visuals import plot_vector_comparison\n\nsignal = [1, 2, 3, 4]\nforward_trace = fast_ntt_psi_ct_trace(signal, 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nwrong_sign = [raw[0] + raw[4], raw[1] + raw[5], raw[2] + raw[6], raw[3]]\nwrong_order = list(forward_trace.raw_output)\nwrong_scale = list(inverse_trace.raw_output)\nwrong_root = forward_ntt_psi(signal, 7681, 3383)\n\nprint(\"wrong sign fold:\", wrong_sign)\nprint(\"correct sign fold:\", negacyclic_reduce(raw, n=4))\nprint(\"wrong BO-vs-NO comparison:\", wrong_order)\nprint(\"correct NO output:\", forward_trace.normal_order_output)\nprint(\"missing final scaling:\", wrong_scale)\nprint(\"wrong root in direct transform:\", wrong_root)\ndisplay(\n plot_vector_comparison(\n wrong_sign,\n negacyclic_reduce(raw, n=4),\n left_label=\"wrong_sign\",\n right_label=\"correct_sign\",\n title=\"Wrong sign vs correct negacyclic fold\",\n )\n)\ndisplay(\n plot_vector_comparison(\n wrong_order,\n forward_trace.normal_order_output,\n left_label=\"wrong_order\",\n right_label=\"correct_order\",\n title=\"Wrong BO/NO comparison\",\n )\n)\ndisplay(\n plot_vector_comparison(\n wrong_scale,\n inverse_trace.scaled_output,\n left_label=\"missing_scale\",\n right_label=\"correct_scale\",\n title=\"Missing scale vs corrected inverse\",\n )\n)\n" }, { "cell_type": "code", @@ -74,7 +74,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Interactive Failure Picker\n# kind: demo | level: 3\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\nforward_trace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nfailures = {\n \"wrong_order\": list(forward_trace.raw_output),\n \"correct_order\": list(forward_trace.normal_order_output),\n \"missing_scale\": list(inverse_trace.raw_output),\n \"scaled\": list(inverse_trace.scaled_output),\n \"wrong_root\": forward_ntt_psi([1, 2, 3, 4], 7681, 3383),\n}\nreferences = {\n \"wrong_order\": list(forward_trace.normal_order_output),\n \"correct_order\": list(forward_trace.normal_order_output),\n \"missing_scale\": list(inverse_trace.scaled_output),\n \"scaled\": list(inverse_trace.scaled_output),\n \"wrong_root\": list(forward_ntt_psi([1, 2, 3, 4], 7681, 1925)),\n}\n\ndef preview(mode=\"wrong_order\"):\n print(mode, \"->\", failures[mode])\n display(\n plot_vector_comparison(\n failures[mode],\n references[mode],\n left_label=mode,\n right_label=\"reference\",\n title=f\"{mode} compared with the correct reference\",\n )\n )\n\ndisplay(widgets.interact(preview, mode=sorted(failures)))\n" + "source": "# Interactive Failure Picker\n\nimport ipywidgets as widgets\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace, forward_ntt_psi\nfrom ntt_learning.visuals import plot_vector_comparison\n\nforward_trace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 7681, 1925)\n\nfailures = {\n \"wrong_order\": list(forward_trace.raw_output),\n \"correct_order\": list(forward_trace.normal_order_output),\n \"missing_scale\": list(inverse_trace.raw_output),\n \"scaled\": list(inverse_trace.scaled_output),\n \"wrong_root\": forward_ntt_psi([1, 2, 3, 4], 7681, 3383),\n}\nreferences = {\n \"wrong_order\": list(forward_trace.normal_order_output),\n \"correct_order\": list(forward_trace.normal_order_output),\n \"missing_scale\": list(inverse_trace.scaled_output),\n \"scaled\": list(inverse_trace.scaled_output),\n \"wrong_root\": list(forward_ntt_psi([1, 2, 3, 4], 7681, 1925)),\n}\n\ndef preview(mode=\"wrong_order\"):\n print(mode, \"->\", failures[mode])\n display(\n plot_vector_comparison(\n failures[mode],\n references[mode],\n left_label=mode,\n right_label=\"reference\",\n title=f\"{mode} compared with the correct reference\",\n )\n )\n\ndisplay(widgets.interact(preview, mode=sorted(failures)))\n" }, { "cell_type": "markdown", @@ -86,7 +86,7 @@ "title": "Retrieval Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Retrieval Check
\n
\n\n1. Which mistake keeps the general shape of the inverse output but leaves every entry too large by a shared factor?\n2. Which mistake often disappears once you apply the correct BO -> NO reorder?\n3. Which mistake shows up earliest in local pair traces rather than only at the very end?\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Retrieval Check

\n
\n\n1. Which mistake keeps the general shape of the inverse output but leaves every entry too large by a shared factor?\n2. Which mistake often disappears once you apply the correct BO -> NO reorder?\n3. Which mistake shows up earliest in local pair traces rather than only at the very end?\n" }, { "cell_type": "code", @@ -100,7 +100,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Trace Rows For Debugging\n# kind: exploration | level: 4\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, stage_rows\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nfor stage in trace.stages:\n print(\"stage\", stage.stage_index)\n for row in stage_rows(stage):\n print(row)\n" + "source": "# Optional: Trace Rows For Debugging\n\nfrom ntt_learning.toy_ntt import fast_ntt_psi_ct_trace, stage_rows\n\ntrace = fast_ntt_psi_ct_trace([1, 2, 3, 4], 7681, 1925)\nfor stage in trace.stages:\n print(\"stage\", stage.stage_index)\n for row in stage_rows(stage):\n print(row)\n" }, { "cell_type": "markdown", @@ -112,7 +112,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 24 of 27 - Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Lecture**.\n\n**Primary next action**\n- Next notebook: [Step 24 of 27 - Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/professional/06_debugging_ntt_failures/problems.ipynb b/notebooks/professional/06_debugging_ntt_failures/problems.ipynb index d754b4d..e6a0c15 100644 --- a/notebooks/professional/06_debugging_ntt_failures/problems.ipynb +++ b/notebooks/professional/06_debugging_ntt_failures/problems.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 25 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n25. **Professional / 06 Debugging NTT Failures / Problems** <- you are here\n26. [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 25 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n25. **Professional / 06 Debugging NTT Failures / Problems** <- you are here\n26. [Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Problem Set Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Problem Set Goals
\n
\n\nThis notebook checks whether the main NTT bug classes are now distinct in memory.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Problem Set Goals

\n
\n\nThis notebook checks whether the main NTT bug classes are now distinct in memory.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "Multiple-Choice Retrieval" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n quiz\n
\n
Multiple-Choice Retrieval
\n
\n\nChoose one answer for each:\n\n1. A shuffled but otherwise familiar forward result most strongly suggests:\n A. missing final scaling\n B. wrong BO / NO comparison\n C. wrong modulus\n\n2. An inverse output that looks like a clean multiple of the target most strongly suggests:\n A. missing `n^-1`\n B. wrong wraparound sign\n C. wrong bit-reversal map\n\n3. A local pair that already looks broken in stage 1 most strongly suggests:\n A. wrong zeta\n B. correct CT output\n C. harmless ordering noise\n" + "source": "
\n Level 2\n
\n quiz\n core path\n
\n

Multiple-Choice Retrieval

\n
\n\nChoose one answer for each:\n\n1. A shuffled but otherwise familiar forward result most strongly suggests:\n A. missing final scaling\n B. wrong BO / NO comparison\n C. wrong modulus\n\n2. An inverse output that looks like a clean multiple of the target most strongly suggests:\n A. missing `n^-1`\n B. wrong wraparound sign\n C. wrong bit-reversal map\n\n3. A local pair that already looks broken in stage 1 most strongly suggests:\n A. wrong zeta\n B. correct CT output\n C. harmless ordering noise\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Answer Key\n# kind: quiz | level: 2\n\nanswers = {1: \"B\", 2: \"A\", 3: \"A\"}\nprint(answers)\n" + "source": "# Answer Key\n\nanswers = {1: \"B\", 2: \"A\", 3: \"A\"}\nprint(answers)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Debug Priority Check" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Debug Priority Check
\n
\n\nList the first four checks you would run on a suspicious iNTT output.\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Debug Priority Check

\n
\n\nList the first four checks you would run on a suspicious iNTT output.\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: One Good Ordering\n# kind: exercise | level: 2\n\ndebug_order = [\n \"check BO / NO assumption\",\n \"check root / zeta schedule\",\n \"check final n^-1 scaling\",\n \"check sign / wraparound conventions\",\n]\nprint(debug_order)\n" + "source": "# One Good Ordering\n\ndebug_order = [\n \"check BO / NO assumption\",\n \"check root / zeta schedule\",\n \"check final n^-1 scaling\",\n \"check sign / wraparound conventions\",\n]\nprint(debug_order)\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Written Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Written Reflection
\n
\n\nIn one paragraph, explain why visible traces are much better debugging tools than only comparing final vectors.\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Written Reflection

\n
\n\nIn one paragraph, explain why visible traces are much better debugging tools than only comparing final vectors.\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional Challenge\n# kind: exploration | level: 4\n\nmistakes = {\n \"wrong_order\": \"fix the permutation first\",\n \"missing_scale\": \"multiply by n^-1\",\n \"wrong_zeta\": \"rebuild the twiddle schedule\",\n \"wrong_sign\": \"inspect the quotient ring\",\n}\nfor key, value in mistakes.items():\n print(key, \"->\", value)\n" + "source": "# Optional Challenge\n\nmistakes = {\n \"wrong_order\": \"fix the permutation first\",\n \"missing_scale\": \"multiply by n^-1\",\n \"wrong_zeta\": \"rebuild the twiddle schedule\",\n \"wrong_sign\": \"inspect the quotient ring\",\n}\nfor key, value in mistakes.items():\n print(key, \"->\", value)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 26 of 27 - Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Problems**.\n\n**Primary next action**\n- Next notebook: [Step 26 of 27 - Professional / 06 Debugging NTT Failures / Studio](studio.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/notebooks/professional/06_debugging_ntt_failures/studio.ipynb b/notebooks/professional/06_debugging_ntt_failures/studio.ipynb index fb8d28c..3dd2256 100644 --- a/notebooks/professional/06_debugging_ntt_failures/studio.ipynb +++ b/notebooks/professional/06_debugging_ntt_failures/studio.ipynb @@ -10,7 +10,7 @@ "title": "Notebook Theme" } }, - "source": "## META\n\n\n" + "source": "\n" }, { "cell_type": "markdown", @@ -22,7 +22,7 @@ "title": "Route Guardrails" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n route nav\n
\n
Route Guardrails
\n
\n\nYou are at **step 26 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Course Complete](../../COURSE_COMPLETE.ipynb)\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n26. **Professional / 06 Debugging NTT Failures / Studio** <- you are here\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" + "source": "
\n Level 1\n
\n route map\n route help\n
\n

Route Guardrails

\n
\n\nYou are at **step 26 of 27** in the only supported route.\n\nNever choose the next notebook manually from the file tree. Use only the links in this cell and the final handoff cell.\n\n**Immediate navigation**\n- Next notebook: [Course Complete](../../COURSE_COMPLETE.ipynb)\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n\n**Official route chain**\n1. [Start Here](../../START_HERE.ipynb)\n2. [Course Blueprint](../../COURSE_BLUEPRINT.ipynb)\n3. [Foundations / 01 Convolution To Toy NTT / Lecture](../../foundations/01_convolution_to_toy_ntt/lecture.ipynb)\n4. [Foundations / 01 Convolution To Toy NTT / Lab](../../foundations/01_convolution_to_toy_ntt/lab.ipynb)\n5. [Foundations / 01 Convolution To Toy NTT / Problems](../../foundations/01_convolution_to_toy_ntt/problems.ipynb)\n6. [Foundations / 01 Convolution To Toy NTT / Studio](../../foundations/01_convolution_to_toy_ntt/studio.ipynb)\n7. [Foundations / 02 Negative Wrapped NTT / Lecture](../../foundations/02_negative_wrapped_ntt/lecture.ipynb)\n8. [Foundations / 02 Negative Wrapped NTT / Lab](../../foundations/02_negative_wrapped_ntt/lab.ipynb)\n9. [Foundations / 02 Negative Wrapped NTT / Problems](../../foundations/02_negative_wrapped_ntt/problems.ipynb)\n10. [Foundations / 02 Negative Wrapped NTT / Studio](../../foundations/02_negative_wrapped_ntt/studio.ipynb)\n11. [Butterfly Mechanics / 03 Fast Forward CT / Lecture](../../butterfly_mechanics/03_fast_forward_ct/lecture.ipynb)\n12. [Butterfly Mechanics / 03 Fast Forward CT / Lab](../../butterfly_mechanics/03_fast_forward_ct/lab.ipynb)\n13. [Butterfly Mechanics / 03 Fast Forward CT / Problems](../../butterfly_mechanics/03_fast_forward_ct/problems.ipynb)\n14. [Butterfly Mechanics / 03 Fast Forward CT / Studio](../../butterfly_mechanics/03_fast_forward_ct/studio.ipynb)\n15. [Butterfly Mechanics / 04 Fast Inverse GS / Lecture](../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb)\n16. [Butterfly Mechanics / 04 Fast Inverse GS / Lab](../../butterfly_mechanics/04_fast_inverse_gs/lab.ipynb)\n17. [Butterfly Mechanics / 04 Fast Inverse GS / Problems](../../butterfly_mechanics/04_fast_inverse_gs/problems.ipynb)\n18. [Butterfly Mechanics / 04 Fast Inverse GS / Studio](../../butterfly_mechanics/04_fast_inverse_gs/studio.ipynb)\n19. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lecture](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb)\n20. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Lab](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb)\n21. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Problems](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb)\n22. [Kyber Mapping / 05 Kyber NTT And Base Multiplication / Studio](../../kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb)\n23. [Professional / 06 Debugging NTT Failures / Lecture](lecture.ipynb)\n24. [Professional / 06 Debugging NTT Failures / Lab](lab.ipynb)\n25. [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n26. **Professional / 06 Debugging NTT Failures / Studio** <- you are here\n27. [Course Complete](../../COURSE_COMPLETE.ipynb)\n" }, { "cell_type": "markdown", @@ -34,7 +34,7 @@ "title": "Studio Goals" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n orientation\n
\n
Studio Goals
\n
\n\nThe last studio compresses the whole course into one debugging mindset.\n" + "source": "
\n Level 1\n
\n big picture\n route help\n
\n

Studio Goals

\n
\n\nThe last studio compresses the whole course into one debugging mindset.\n" }, { "cell_type": "markdown", @@ -46,7 +46,7 @@ "title": "The Whole Course Is A Debugging Ladder" } }, - "source": "## MANDATORY\n\n
\n Level 3\n
\n MANDATORY\n explanation\n
\n
The Whole Course Is A Debugging Ladder
\n
\n\nEvery earlier bundle built one layer of the debugging stack:\n\n- schoolbook grid and wraparound\n- direct transform algebra\n- CT stage schedule\n- GS inverse schedule\n- bit-reversal and scaling\n- Kyber modulus constraints and base multiplication\n" + "source": "
\n Level 3\n
\n explanation\n core path\n
\n

The Whole Course Is A Debugging Ladder

\n
\n\nEvery earlier bundle built one layer of the debugging stack:\n\n- schoolbook grid and wraparound\n- direct transform algebra\n- CT stage schedule\n- GS inverse schedule\n- bit-reversal and scaling\n- Kyber modulus constraints and base multiplication\n" }, { "cell_type": "code", @@ -60,7 +60,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: Print The Whole Debugging Ladder\n# kind: demo | level: 3\n\nladder = [\n \"Can I see the raw schoolbook product grid?\",\n \"Can I explain the negacyclic wraparound sign?\",\n \"Can I reproduce the direct NTT_psi / INTT_psi round trip?\",\n \"Can I trace CT stages with the right zetas?\",\n \"Can I trace GS stages with the right order and scaling?\",\n \"Can I explain why Kyber v3 does not inherit the full toy psi story unchanged?\",\n]\nfor item in ladder:\n print(\"-\", item)\n" + "source": "# Print The Whole Debugging Ladder\n\nladder = [\n \"Can I see the raw schoolbook product grid?\",\n \"Can I explain the negacyclic wraparound sign?\",\n \"Can I reproduce the direct NTT_psi / INTT_psi round trip?\",\n \"Can I trace CT stages with the right zetas?\",\n \"Can I trace GS stages with the right order and scaling?\",\n \"Can I explain why Kyber v3 does not inherit the full toy psi story unchanged?\",\n]\nfor item in ladder:\n print(\"-\", item)\n" }, { "cell_type": "markdown", @@ -72,7 +72,7 @@ "title": "Final Debug Checklist" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n exercise\n
\n
Final Debug Checklist
\n
\n\nKeep this order:\n\n1. ring rule and wraparound\n2. root existence and root choice\n3. stage pairings and zetas\n4. BO vs NO comparison\n5. final `n^-1` scaling\n6. Kyber-specific modulus / base-multiplication assumptions\n" + "source": "
\n Level 2\n
\n exercise\n core path\n
\n

Final Debug Checklist

\n
\n\nKeep this order:\n\n1. ring rule and wraparound\n2. root existence and root choice\n3. stage pairings and zetas\n4. BO vs NO comparison\n5. final `n^-1` scaling\n6. Kyber-specific modulus / base-multiplication assumptions\n" }, { "cell_type": "code", @@ -86,7 +86,7 @@ } }, "outputs": [], - "source": "# MANDATORY\n# title: One Last Round Trip\n# kind: exercise | level: 2\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\n\nsignal = [3, 1, 4, 1]\nforward_trace = fast_ntt_psi_ct_trace(signal, 17, 2)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 17, 2)\n\nprint(\"signal:\", signal)\nprint(\"forward BO:\", forward_trace.raw_output)\nprint(\"inverse scaled:\", inverse_trace.scaled_output)\n" + "source": "# One Last Round Trip\n\nfrom ntt_learning.toy_ntt import fast_intt_psi_gs_trace, fast_ntt_psi_ct_trace\n\nsignal = [3, 1, 4, 1]\nforward_trace = fast_ntt_psi_ct_trace(signal, 17, 2)\ninverse_trace = fast_intt_psi_gs_trace(forward_trace.raw_output, 17, 2)\n\nprint(\"signal:\", signal)\nprint(\"forward BO:\", forward_trace.raw_output)\nprint(\"inverse scaled:\", inverse_trace.scaled_output)\n" }, { "cell_type": "markdown", @@ -98,7 +98,7 @@ "title": "Final Reflection" } }, - "source": "## MANDATORY\n\n
\n Level 2\n
\n MANDATORY\n reflection\n
\n
Final Reflection
\n
\n\nFinal prompt:\n\n- Which image now anchors your understanding of NTT best: the schoolbook grid, the fold arrows, the CT stage view, the GS stage view, or the bit-reversal map?\n- Why that one?\n" + "source": "
\n Level 2\n
\n reflection\n core path\n
\n

Final Reflection

\n
\n\nFinal prompt:\n\n- Which image now anchors your understanding of NTT best: the schoolbook grid, the fold arrows, the CT stage view, the GS stage view, or the bit-reversal map?\n- Why that one?\n" }, { "cell_type": "code", @@ -112,7 +112,7 @@ } }, "outputs": [], - "source": "# FACULTATIVE\n# title: Optional: Personal Debug Rule\n# kind: exploration | level: 4\n\npersonal_rule = \"Never trust a final vector until I have checked the stage trace, the order, and the scaling.\"\nprint(personal_rule)\n" + "source": "# Optional: Personal Debug Rule\n\npersonal_rule = \"Never trust a final vector until I have checked the stage trace, the order, and the scaling.\"\nprint(personal_rule)\n" }, { "cell_type": "markdown", @@ -124,7 +124,7 @@ "title": "Next Notebook" } }, - "source": "## META\n\n
\n Level 1\n
\n META\n handoff\n
\n
Next Notebook
\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 27 of 27 - Course Complete](../../COURSE_COMPLETE.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" + "source": "
\n Level 1\n
\n next step\n route help\n
\n

Next Notebook

\n
\n\nYou finished **Professional / 06 Debugging NTT Failures / Studio**.\n\n**Primary next action**\n- Next notebook: [Step 27 of 27 - Course Complete](../../COURSE_COMPLETE.ipynb)\n\n**Recovery links if you get lost**\n- Previous notebook: [Professional / 06 Debugging NTT Failures / Problems](problems.ipynb)\n- Restart route: [Start Here](../../START_HERE.ipynb)\n" } ], "metadata": { diff --git a/ntt_learning/visuals.py b/ntt_learning/visuals.py index 94a934b..102024d 100644 --- a/ntt_learning/visuals.py +++ b/ntt_learning/visuals.py @@ -153,7 +153,29 @@ def _svg_text(x: float, y: float, text: str, *, size: int = 14, weight: str = "4 return f'{escape(text)}' -def _convolution_frame_svg( +def _html_token(label: str, value: str, *, fill: str, border: str, text: str = SVG_INK) -> str: + return f""" +
+
{escape(label)}
+
{escape(value)}
+
+ """ + + +def _convolution_frame_html( left: Sequence[int], right: Sequence[int], diagonal_index: int, @@ -163,75 +185,206 @@ def _convolution_frame_svg( rows = convolution_contributions(left, right) current = rows[diagonal_index] grid = pairwise_product_grid(left, right) - cell = 68 - left_margin = 78 - top_margin = 78 - bottom_y = top_margin + len(left) * cell + 70 - width = left_margin + len(right) * cell + 120 - height = bottom_y + 110 + terms = current["terms"] + grid_columns = "72px " + " ".join(["minmax(74px, 1fr)"] * len(right)) + output_columns = " ".join(["minmax(70px, 1fr)"] * len(rows)) - parts = [ - f'', - f'', - _svg_text(34, 48, title, size=22, weight="800"), - _svg_text(34, 68, f"Diagonal {diagonal_index}: every highlighted cell lands in output coefficient y{diagonal_index}", size=13, fill="#486581"), - ] + product_cells = [] + for column_index, value in enumerate(right): + product_cells.append( + f""" +
+ b{column_index} = {value} +
+ """ + ) - for row in range(len(left)): - parts.append(_svg_text(54, top_margin + row * cell + 42, f"a{row}", size=12, anchor="middle")) - for col in range(len(right)): - parts.append(_svg_text(left_margin + col * cell + 28, 64, f"b{col}", size=12, anchor="middle")) - - for row, row_values in enumerate(grid): - for col, value in enumerate(row_values): - active = row + col == diagonal_index - done = row + col < diagonal_index + for row_index, row_values in enumerate(grid): + product_cells.append( + f""" +
+ a{row_index} = {left[row_index]} +
+ """ + ) + for column_index, value in enumerate(row_values): + active = row_index + column_index == diagonal_index + done = row_index + column_index < diagonal_index fill = SVG_HILITE if active else "#e6fffa" if done else "#f8f9fa" - stroke = SVG_ACCENT if active else SVG_GOOD if done else "#cbd2d9" - parts.append( - _svg_box( - left_margin + col * cell, - top_margin + row * cell, - 56, - 56, - f"a{row}·b{col}", + border = SVG_ACCENT if active else SVG_GOOD if done else "#cbd2d9" + product_cells.append( + _html_token( + f"a{row_index}·b{column_index}", str(value), fill=fill, - stroke=stroke, - stroke_width=3.2 if active else 1.8, + border=border, ) ) + output_cells = [] for row in rows: output_index = int(row["output_index"]) fill = SVG_HILITE if output_index == diagonal_index else "#d9f0ff" if output_index < diagonal_index else "#f1f5f9" - stroke = SVG_ACCENT if output_index == diagonal_index else SVG_BLUE if output_index < diagonal_index else "#cbd2d9" - parts.append( - _svg_box( - left_margin + output_index * cell * 0.92, - bottom_y, - 60, - 56, + border = SVG_ACCENT if output_index == diagonal_index else SVG_BLUE if output_index < diagonal_index else "#cbd2d9" + output_cells.append( + _html_token( f"y{output_index}", str(row["total"]), fill=fill, - stroke=stroke, - stroke_width=3.2 if output_index == diagonal_index else 1.8, + border=border, ) ) - terms = [f"{term['left_value']}×{term['right_value']}={term['product']}" for term in current["terms"]] - equation = " + ".join(terms) if terms else "0" - parts.append(_svg_text(34, height - 34, f"Current diagonal sum: {equation} = {current['total']}", size=15, weight="700")) - parts.append("") - return "".join(parts) + equation_chips = [] + for term in terms: + equation_chips.append( + f""" +
+ {term["left_value"]} x {term["right_value"]} = {term["product"]} +
+ """ + ) + equation = " + ".join( + f"{term['left_value']}x{term['right_value']}={term['product']}" + for term in terms + ) or "0" + + return f""" +
+
+
+ Active diagonal: y{diagonal_index} +
+
+ Highlight every cell where row index + column index = {diagonal_index} +
+
+ +
+
Left polynomial
+ {"".join(_html_token(f"a{i}", str(value), fill="#edf6f9", border="#8ecae6") for i, value in enumerate(left))} +
+ +
+
Right polynomial
+ {"".join(_html_token(f"b{i}", str(value), fill="#fef6e4", border="#f6bd60") for i, value in enumerate(right))} +
+ +
+
{escape(title)}
+
+ Each highlighted product belongs to the same output coefficient. +
+
+
+
+ {"".join(product_cells)} +
+
+
+ +
+
Output coefficients after this sweep
+
+ {"".join(output_cells)} +
+
+ +
+
Current diagonal terms
+
+ {"".join(equation_chips) or '
No terms yet.
'} +
+
+ y{diagonal_index} = {escape(equation)} = {current["total"]} +
+
+
+ """ def schoolbook_diagonal_player(left: Sequence[int], right: Sequence[int]) -> widgets.Widget: """Interactive diagonal-by-diagonal walkthrough of schoolbook multiplication.""" rows = convolution_contributions(left, right) frames = [ - _convolution_frame_svg(left, right, diagonal_index=index, title="Schoolbook Multiplication As A Moving Diagonal") + _convolution_frame_html(left, right, diagonal_index=index, title="Schoolbook multiplication as a moving diagonal") for index in range(len(rows)) ] captions = [ diff --git a/tests/test_course_contract.py b/tests/test_course_contract.py index 9425745..1008003 100644 --- a/tests/test_course_contract.py +++ b/tests/test_course_contract.py @@ -59,9 +59,26 @@ class CourseContractTests(unittest.TestCase): ) if cell["cell_type"] == "markdown": - self.assertTrue(source.startswith(f"## {role.upper()}"), f"{notebook}: missing visible label") + if kind == "theme": + self.assertIn("