-
Notifications
You must be signed in to change notification settings - Fork 6
QKAN Core Upgrade with dtype Management, Usability Enhancements, and Expanded Dependencies #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Initial plan * Optimize performance: remove unnecessary clones, fix redundant zero_grad, and improve tensor operations Co-authored-by: Jim137 <[email protected]> * Additional optimizations: improve h_gate computation and reuse sum computations in regularization Co-authored-by: Jim137 <[email protected]> * Address code review feedback: fix dtype parameter and use named constant Co-authored-by: Jim137 <[email protected]> * Fix dtype consistency across all DQStateVector gate operations Co-authored-by: Jim137 <[email protected]> * Improve numerical precision and add dtype validation for tensor operations Co-authored-by: Jim137 <[email protected]> * fix requirements-dev * fix group when preact trainable * fix lint * fix mypy check --------- Co-authored-by: J.-C. Jiang <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Jim137 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances the QKAN project with comprehensive dtype management, new utility functions, and expanded documentation. The core changes introduce explicit control over compute and parameter data types throughout the quantum simulation layers, enabling better numerical precision and hardware compatibility.
Key changes:
- Added
c_dtype(compute) andp_dtype(parameter) options toQKANLayerandQKANfor explicit dtype control across quantum operations - Introduced
info.pymodule with distributed training utilities (print0,print_banner,print_version,get_dist_info) - Enhanced
fit_from_qkanin KAN with configurable early stopping based on loss tolerance and maximum iterations
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/qkan/torch_qc.py | Added dtype parameters to gate functions, optimized Hadamard gate constant computation, implemented Pauli X/Z gates, added fast_measure parameter to measurement functions |
| src/qkan/solver.py | Refactored internal encoding functions with underscore prefix, threaded dtype parameter through all quantum state operations, updated documentation for shape parameters |
| src/qkan/qkan.py | Introduced c_dtype/p_dtype parameters throughout layer initialization, optimized tensor operations (detach vs clone), integrated distributed training support via info module |
| src/qkan/kan.py | Enhanced fit_from_qkan with early stopping mechanism using configurable max_iter and tolerance parameters |
| src/qkan/info.py | New utility module providing distributed training helpers and version display functions (contains implementation issues) |
| src/qkan/init.py | Updated version to 0.1.3, exported new info module functions |
| requirements-dev.txt | Added transformers==4.57.1 dependency |
| pyproject.toml | Added transformers and torchvision to optional doc dependencies |
| docs/index.rst | Updated citation text and added software citation entry |
| README.md | Added Zenodo DOI badge and software citation entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This pull request introduces several improvements and new features to the QKAN project, focusing on enhanced citation support, improved documentation, expanded optional dependencies, and major upgrades to the handling of data types in the core QKAN implementation. The most significant changes include support for specifying compute and parameter data types throughout the quantum simulation layers, new informational utilities, and updated citation and documentation to reflect the latest software release.
Dependency updates:
transformersandtorchvisionto the optional documentation dependencies inpyproject.tomland includedtransformersinrequirements-dev.txt.Core QKAN functionality and API improvements:
c_dtype(compute dtype) andp_dtype(parameter dtype) options toQKANLayerandQKAN, allowing explicit control over floating point and complex types for tensors and parameters. All relevant tensor initializations and operations now respect these dtypes for improved numerical control and compatibility.New informational utilities:
src/qkan/info.pywith utility functions (print0,print_banner,print_version,get_dist_info) for consistent logging, version display, and distributed training support. These are now imported and exposed in the main package.Algorithmic and usability improvements:
fit_from_qkaninKANto support early stopping based on loss tolerance and configurable maximum iterations, making training more robust and flexible.These changes collectively improve the usability, reproducibility, and configurability of the QKAN codebase, especially for research and publication purposes.