Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:quantum:categorical [2025/04/30 09:01] – [Categories: The Foundational Structure] kymkiprojects:quantum:categorical [2025/05/01 21:23] (current) – [Shim - a Rust library for categorical quantum computing] kymki
Line 48: Line 48:
 ===== Reader Guidance  ===== ===== Reader Guidance  =====
  
-This entry is a an overview of the code examples (shorter bits of demonstrative code that use the Shim library) that I have implemented. It is technical. It is assumed that this is perhaps not the first time the reader has heard of category theory. The reading will benefit greatly from basic prior knowledge of concepts like monads, functors (ofc how can we otherwise grok monads), categories. Basic knowledge of quantum computing is needed but I set the level of the text to not assume deep prior expertise. +This entry is a an overview of the code examples (shorter bits of demonstrative code that use the [[https://github.com/erikkallman/shim|Shim library]]) that I have implemented. It is technical. It is assumed that this is perhaps not the first time the reader has heard of category theory. The reading will benefit greatly from basic prior knowledge of concepts like monads, functors (ofc how can we otherwise grok monads), categories. Basic knowledge of quantum computing is needed but I set the level of the text to not assume deep prior expertise. 
  
 What im hoping is that for someone active in category theory research, ML, or quantum computing can read this post and understand why I started writing Shim and see its value as a research tool. Please do contact me should you find this interesting and if any inaccuracies (I know quite a few in the code already) exist. Im happy to collaborate and discuss. What im hoping is that for someone active in category theory research, ML, or quantum computing can read this post and understand why I started writing Shim and see its value as a research tool. Please do contact me should you find this interesting and if any inaccuracies (I know quite a few in the code already) exist. Im happy to collaborate and discuss.
Line 55: Line 55:
 ===== Shim - a Rust library for categorical quantum computing ===== ===== Shim - a Rust library for categorical quantum computing =====
  
-Shim is a Rust library that provides a mathematical foundation for quantum machine learning using category theory. It aims to describe quantum computation and machine learning through categorical structures, enabling composition of quantum operations and data transformations.+Shim is a Rust library ([[https://github.com/erikkallman/shim|https://github.com/erikkallman/shim]], distributed under the MIT license) that provides a mathematical foundation for quantum machine learning using category theory. It aims to describe quantum computation and machine learning through categorical structures, enabling composition of quantum operations and data transformations.
  
 In the repo there are three larger illustrative examples that showcase its usage. This is just a highlight of some of the categorical concepts used in Shim. For a full read, clone the git repo and run the examples that come with extensive documentation.  In the repo there are three larger illustrative examples that showcase its usage. This is just a highlight of some of the categorical concepts used in Shim. For a full read, clone the git repo and run the examples that come with extensive documentation. 
Line 226: Line 226:
   * **Associativity Law**: For morphisms f, g, h, we have (h ∘ g) ∘ f = h ∘ (g ∘ f)   * **Associativity Law**: For morphisms f, g, h, we have (h ∘ g) ∘ f = h ∘ (g ∘ f)
  
-These properties ensure that quantum operations can be composed reliably, with the identity operation (doing nothing) behaving as expected and sequential operations grouping consistently regardless of evaluation order.+These more "basic" properties ensure that quantum operations can be composed reliably, with the identity operation (doing nothing) behaving as expected and sequential operations grouping consistently regardless of evaluation order.
  
 ==== Monoidal Categories: Modeling Multi-Qubit Systems ==== ==== Monoidal Categories: Modeling Multi-Qubit Systems ====
Line 318: Line 318:
 The categorical verification in Shim offers several practical benefits for quantum programming: The categorical verification in Shim offers several practical benefits for quantum programming:
  
-  * **Error Detection**: Violations of categorical laws often indicate implementation bugs or inconsistencies +  * **Error Detection**: Violations of categorical laws could indicate implementation bugs or inconsistencies 
-  * **Correctness Guarantees**: Verified categorical structures ensure quantum operations behave as mathematically expected+  * **Correctness**: Verified categorical structures ensure quantum operations behave as mathematically expected
   * **Compositional Reasoning**: Category theory enables reasoning about complex quantum algorithms through their compositional structure   * **Compositional Reasoning**: Category theory enables reasoning about complex quantum algorithms through their compositional structure
   * **Protocol Verification**: Categorical laws provide a basis for verifying quantum communication and cryptographic protocols   * **Protocol Verification**: Categorical laws provide a basis for verifying quantum communication and cryptographic protocols
Line 335: Line 335:
 </code> </code>
  
-This diagnostic capability helps quantum algorithm developers identify and fix structural issues in their implementations.+This helps quantum algorithm developers identify and fix structural issues in their implementations using category theory as a toolset for formal verification.
  
 ==== Integration with Quantum Neural Networks ==== ==== Integration with Quantum Neural Networks ====
Line 341: Line 341:
 The categorical verification framework complements the quantum neural network architecture we explored earlier. While QNNs rely on adjunctions and 2-morphisms, these structures themselves depend on the fundamental categorical properties verified in this example. The categorical verification framework complements the quantum neural network architecture we explored earlier. While QNNs rely on adjunctions and 2-morphisms, these structures themselves depend on the fundamental categorical properties verified in this example.
  
-The integration creates a coherent mathematical framework spanning from basic quantum operations to complex learning systems:+The integration spans basic quantum operations and complex learning systems:
  
   * **Verified Base Categories**: Ensure quantum operations satisfy basic compositional properties   * **Verified Base Categories**: Ensure quantum operations satisfy basic compositional properties
   * **Monoidal Structure**: Enables correct handling of multi-qubit systems in QNNs   * **Monoidal Structure**: Enables correct handling of multi-qubit systems in QNNs
-  * **Verified Functors**: Allow systematic transformations of quantum learning algorithms+  * **Functors**: Allow systematic transformations of quantum learning algorithms
   * **Monadic Effects**: Provide formal handling of measurement in quantum learning   * **Monadic Effects**: Provide formal handling of measurement in quantum learning
  
-I'll continue developing the blog post with the next section, using the proper DokuWiki code block format. +====== 3. Practical Applications of Categorical Quantum ML: Building a Complete Pipeline ======
- +
-====== Practical Applications of Categorical Quantum ML: Building a Complete Pipeline ======+
  
 ==== Configurable Quantum ML Pipeline ==== ==== Configurable Quantum ML Pipeline ====
  
-This final chapter explores how Shim implements a complete quantum machine learning pipeline using categorical principles. The code provides configurable framework for experimenting with different quantum architectures while maintaining mathematical formalism.+This final chapter explores how Shim implements a complete quantum machine learning pipeline using categorical principles. The code can be used as base for experimenting with different quantum architectures under categorical formalism.
  
 The framework is organized into three interconnected components: The framework is organized into three interconnected components:
  
-  * **Dataset parameters**: Control the complexity and structure of synthetic data +  * **Dataset parameters**: Parametrization of synthetic data 
-  * **Quantum model parameters**: Define the quantum resources and encoding strategies +  * **Quantum model parameters**: Quantum resources and encoding strategies 
-  * **Circuit design parameters**: Specify the architectural patterns for quantum operations+  * **Circuit design parameters**: Architectural patterns for quantum operations
  
 <code rust> <code rust>
Line 386: Line 384:
 } }
 </code> </code>
- 
-This parameterization allows the user to vary different components of the quantum machine learning pipeline while preserving their mathematical relationships. 
- 
 ==== Categorical Structure of Quantum ML ==== ==== Categorical Structure of Quantum ML ====
  
-This demo operates with four main categories:+Four main categories are used in the demo:
  
   * **DataCategory**: For classical data and transformations   * **DataCategory**: For classical data and transformations
Line 416: Line 411:
 </code> </code>
  
-The functors formalize how classical data is encoded into quantum states and how quantum measurements are decoded into predictions. This categorical structure ensures that these transformations preserve essential algebraic properties.+The functors formalize how classical data is encoded into quantum states and how quantum measurements are decoded into predictions. 
  
 ==== Natural Transformations for Quantum Processes ==== ==== Natural Transformations for Quantum Processes ====
Line 565: Line 560:
 </code> </code>
  
-This verification ensures that the categorical structure is properly maintained, which is essential for the mathematical consistency of the quantum machine learning pipeline.+This verification ensures that the categorical structure is properly maintained for the mathematical consistency of the quantum machine learning pipeline.
  
 ==== Inference Pipeline and Evaluation ==== ==== Inference Pipeline and Evaluation ====
Line 632: Line 627:
 </code> </code>
  
-This inference pipeline processes classical data through the entire quantum machine learning workflow, from data encoding to prediction, illustrating how the categorical structure enables a coherent quantum information processing workflow.+This inference pipeline processes classical data through the entire quantum machine learning workflow, from data encoding to prediction.
  
 ==== End-to-End Categorical Composition ==== ==== End-to-End Categorical Composition ====
  
-The framework demonstrates how to compose the entire quantum machine learning pipeline using categorical operations:+The code further demonstrates how to compose the entire quantum machine learning pipeline using categorical operations:
  
 <code rust> <code rust>
Line 753: Line 748:
 </code> </code>
  
-This encoding strategy demonstrates how classical features can be systematically mapped to quantum operations, creating a well-defined interface between classical and quantum data. +Here, via the above encoding strategyclassical features can be systematically mapped to quantum operations, creating a well-defined interface between classical and quantum data.
- +
-==== Practical Benefits of the Categorical Approach ====+
  
-The implementation demonstrates several practical benefits of the categorical approach to quantum machine learning: 
  
-  * **Systematic Experimentation**: The parameterized framework enables systematic exploration of different quantum architectures +===== 4. Conclusion and Outlook: The Power of Categorical Quantum ML =====
-  * **Formal Verification**: Categorical laws provide formal verification of the implementation's mathematical correctness +
-  * **Compositionality**: The categorical structure naturally supports composition of quantum operations and data transformations +
-  * **Abstraction**: The framework abstracts away implementation details while preserving essential mathematical properties +
-  * **Scalability**: The categorical structure provides a consistent framework for scaling to more complex quantum models+
  
-===== Conclusion and Outlook: The Power of Categorical Quantum ML =====+What I wanted to demonstrate with the implementation of Shim is that that category theory provides a useful mathematical language for quantum computing with specific applications towards machine learning. 
  
-What I wanted to demonstrate with the implementation of Shim is that that category theory provides a useful mathematical language for quantum computing with specific applications towards machine learning. By formalizing quantum operations, data transformations, and their compositions, Shim enables:+By formalizing quantum operations, data transformations, and their compositions, Shim enables:
  
   * **Mathematical Verification**: Formal verification of categorical properties ensures correctness   * **Mathematical Verification**: Formal verification of categorical properties ensures correctness