{ "cells": [ { "cell_type": "markdown", "metadata": { "pedagogy": { "role": "meta", "difficulty": 1, "kind": "orientation", "title": "Studio Goals" } }, "source": "## META | difficulty 1 | Studio Goals\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", "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 3, "kind": "explanation", "title": "Same Schedule, Different Signals" } }, "source": "## MANDATORY | difficulty 3 | Same Schedule, Different Signals\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", "execution_count": null, "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 3, "kind": "demo", "title": "Compare Two CT Traces" } }, "outputs": [], "source": "# MANDATORY | difficulty 3 | 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", "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 2, "kind": "exercise", "title": "Debug Checklist" } }, "source": "## MANDATORY | difficulty 2 | Debug Checklist\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", "execution_count": null, "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 2, "kind": "exercise", "title": "See A Wrong-Order Comparison Failure" } }, "outputs": [], "source": "# MANDATORY | difficulty 2 | 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", "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 2, "kind": "reflection", "title": "Reflection" } }, "source": "## MANDATORY | difficulty 2 | Reflection\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", "execution_count": null, "metadata": { "pedagogy": { "role": "facultative", "difficulty": 4, "kind": "exploration", "title": "Optional: Inspect The zeta schedule" } }, "outputs": [], "source": "# FACULTATIVE | difficulty 4 | 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", "metadata": { "pedagogy": { "role": "meta", "difficulty": 1, "kind": "handoff", "title": "Next Notebook" } }, "source": "## META | difficulty 1 | Next Notebook\n\nNext notebook: `../../../butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb`\n" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" }, "ntt_learning": { "title": "Studio: Fast Forward CT", "contract_version": "0.2", "sequence": [ "notebooks/START_HERE.ipynb", "notebooks/COURSE_BLUEPRINT.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/lecture.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/lab.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/problems.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/studio.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/lecture.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/lab.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/problems.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/studio.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/lab.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/problems.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/studio.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb", "notebooks/professional/06_debugging_ntt_failures/lecture.ipynb", "notebooks/professional/06_debugging_ntt_failures/lab.ipynb", "notebooks/professional/06_debugging_ntt_failures/problems.ipynb", "notebooks/professional/06_debugging_ntt_failures/studio.ipynb", "notebooks/COURSE_COMPLETE.ipynb" ] } }, "nbformat": 4, "nbformat_minor": 5 }