Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/functional_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,15 @@ es_runs/
.vscode-upload.json

mnist_data/

configs.yml
debug_qiskit.txt
fix_note.txt
h2_new.txt
max-acc-valid.pt
model.pt
.cursor/rules/*.mdc

.cursorignore
.cursor/
.github/copilot-instructions.md
116 changes: 116 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Contributing to TorchQuantum

Thank you for your interest in contributing to TorchQuantum! This document provides guidelines and instructions for contributing.

## Getting Started

### Setting Up Development Environment

1. Fork the repository on GitHub
2. Clone your fork locally:
```bash
git clone https://github.com/YOUR_USERNAME/torchquantum.git
cd torchquantum
```
3. Install in development mode:
```bash
pip install --editable .
```

### Branch Strategy

- **main**: Stable release branch
- **dev**: Development branch for integrating features

**Always create pull requests to the `dev` branch, not `main`.**

## Making Contributions

### Pull Request Process

1. Create a new branch from `dev` for your feature or fix:
```bash
git checkout dev
git pull origin dev
git checkout -b feature/your-feature-name
```

2. Make your changes following the code style guidelines below

3. Test your changes thoroughly:
```bash
# Run existing tests
pytest tests/

# For new features, add corresponding tests
```

4. Commit your changes with clear, descriptive messages:
```bash
git commit -m "Brief description of changes"
```

5. Push to your fork and create a pull request:
```bash
git push origin feature/your-feature-name
```

6. In your PR description:
- Describe what changes you made and why
- Reference any related issues (e.g., "Fixes #123")
- Include test results or examples if applicable

7. Ping a maintainer for review by tagging them in the PR

### Code Style Guidelines

- Follow [PEP 8](https://pep8.org/) style guidelines
- Use meaningful variable and function names
- Add docstrings to new functions and classes
- Keep functions focused and modular
- Use type hints where appropriate

### Testing Requirements

- **All changes must pass existing tests**
- **New features must include corresponding tests**
- Test edge cases and error conditions
- Ensure backward compatibility when modifying existing functionality

### Documentation

- Update docstrings for any modified functions
- Add examples for new features
- Update README if adding major functionality

## Types of Contributions

### Bug Fixes

1. Check if the bug is already reported in [Issues](https://github.com/mit-han-lab/torchquantum/issues)
2. If not, create a new issue describing the bug
3. Reference the issue in your PR

### New Features

1. Open an issue first to discuss the feature
2. Wait for maintainer feedback before starting implementation
3. Follow the PR process above

### Documentation

- Improvements to README, docstrings, or examples are always welcome
- For major documentation changes, open an issue first

## Code of Conduct

- Be respectful and inclusive
- Provide constructive feedback
- Help others learn and grow

## Questions?

- Open an issue for questions about contributing
- Tag maintainers for guidance on complex changes

Thank you for helping improve TorchQuantum!
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ Simulate quantum computations on classical hardware using PyTorch. It supports s
Researchers on quantum algorithm design, parameterized quantum circuit training, quantum optimal control, quantum machine learning, quantum neural networks.
#### Differences from Qiskit/Pennylane

Dynamic computation graph, automatic gradient computation, fast GPU support, batch model tersorized processing.
Dynamic computation graph, automatic gradient computation, fast GPU support, batch model tensorized processing.

## News
- Torchquantum is used in the winning team for ACM Quantum Computing for Drug Discovery Challenge.
- Torchquantum is highlighted in [UnitaryHack](https://unitaryhack.dev/projects/torchquantum/).
- TorchQuantum received [UnitaryFund](https://unitary.fund/).
- Torchquantum is highlighted in [unitaryHACK](https://2024.unitaryhack.dev/projects/torchquantum/).
- TorchQuantum received a [Unitary Foundation microgrant](https://unitary.foundation/grants/).
- TorchQuantum is integrated to [IBM Qiskit Ecosystem](https://qiskit.github.io/ecosystem/).
- TorchQuantum is integrated to [PyTorch Ecosystem](https://pytorch.org/ecosystem/).
- v0.1.8 Available!
Expand Down
5 changes: 3 additions & 2 deletions examples/QuantumNAS/quantumnas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4056,7 +4056,8 @@
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "torchquantum",
"language": "python",
"name": "python3"
},
"language_info": {
Expand All @@ -4069,7 +4070,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.9.20"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
2 changes: 1 addition & 1 deletion examples/gradient_pruning/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from torchpack.utils.logging import logger
from torchpack.utils.typing import Trainer
from torchpack import distributed as dist
from torchquantum.super_utils import get_named_sample_arch
from torchquantum.algorithm.quantumnas.super_utils import get_named_sample_arch
from torchquantum.util import legalize_unitary


Expand Down
6 changes: 3 additions & 3 deletions examples/regression/new_run_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@


def gen_data(L, N):
omega_0 = np.zeros([2**L], dtype="complex_")
omega_0 = np.zeros([2**L], dtype=complex)
omega_0[0] = 1 + 0j

omega_1 = np.zeros([2**L], dtype="complex_")
omega_1 = np.zeros([2**L], dtype=complex)
omega_1[-1] = 1 + 0j

states = np.zeros([N, 2**L], dtype="complex_")
states = np.zeros([N, 2**L], dtype=complex)

thetas = 2 * np.pi * np.random.rand(N)
phis = 2 * np.pi * np.random.rand(N)
Expand Down
6 changes: 3 additions & 3 deletions examples/regression/run_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@


def gen_data(L, N):
omega_0 = np.zeros([2**L], dtype="complex_")
omega_0 = np.zeros([2**L], dtype=complex)
omega_0[0] = 1 + 0j

omega_1 = np.zeros([2**L], dtype="complex_")
omega_1 = np.zeros([2**L], dtype=complex)
omega_1[-1] = 1 + 0j

states = np.zeros([N, 2**L], dtype="complex_")
states = np.zeros([N, 2**L], dtype=complex)

thetas = 2 * np.pi * np.random.rand(N)
phis = 2 * np.pi * np.random.rand(N)
Expand Down
2 changes: 1 addition & 1 deletion examples/save_load_example/save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def save_load2():

torch.save(model, "model_whole.pt")

model2 = torch.load("model_whole.pt")
model2 = torch.load("model_whole.pt", weights_only=False)
y2 = model2(x)
print(y2)
assert torch.equal(y, y2)
Expand Down
24 changes: 24 additions & 0 deletions requirement_update.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

dill
matplotlib
nbsphinx
numpy

opt_einsum
pathos
pylatexenc
pyscf
qiskit
recommonmark
qiskit_ibm_runtime
qiskit-aer

scipy
setuptools
tensorflow
torch
torchdiffeq
torchpack
torchquantum
torchvision
tqdm
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ opt_einsum
pathos>=0.2.7
pylatexenc>=2.10
pyscf>=2.0.1
qiskit>=0.39.0,<1.0.0
qiskit==1.4.3
recommonmark
qiskit_ibm_runtime==0.20.0
qiskit-aer==0.13.3
qiskit_ibm_runtime
qiskit-aer

scipy>=1.5.2
setuptools>=52.0.0
Expand All @@ -21,4 +21,4 @@ torchdiffeq>=0.2.3
torchpack>=0.3.0
torchquantum>=0.1
torchvision>=0.9.0.dev20210130
tqdm>=4.56.0
tqdm>=4.56.0
Loading