|
| 1 | +# TensorCircuit-NG Repository Guide for AI Agents |
| 2 | + |
| 3 | +## Repository Overview |
| 4 | + |
| 5 | +TensorCircuit is a high-performance unified quantum computing framework designed for the NISQ (Noisy Intermediate-Scale Quantum) era. It provides a comprehensive set of tools for quantum circuit simulation with support for multiple backends including Numpy, TensorFlow, JAX, and PyTorch. |
| 6 | + |
| 7 | +## Documentation and AI Native Services |
| 8 | + |
| 9 | +### Official Documentation |
| 10 | + |
| 11 | +- Main Documentation: https://tensorcircuit-ng.readthedocs.io/ |
| 12 | +- Quick Start Guide: https://tensorcircuit-ng.readthedocs.io/en/latest/quickstart.html |
| 13 | +- Tutorials: https://tensorcircuit-ng.readthedocs.io/en/latest/tutorial.html |
| 14 | +- API Reference: Available in docstrings throughout the codebase |
| 15 | + |
| 16 | +### AI-Native Documentation Services |
| 17 | + |
| 18 | +- Devin Deepwiki: https://deepwiki.com/tensorcircuit/tensorcircuit-ng |
| 19 | +- Context7 MCP: https://context7.com/tensorcircuit/tensorcircuit-ng |
| 20 | + |
| 21 | +### Educational Resources |
| 22 | + |
| 23 | +- Quantum Computing Lectures with TC-NG: https://github.com/sxzgroup/qc_lecture |
| 24 | + |
| 25 | +## Configuration and Dependencies |
| 26 | + |
| 27 | +### Core Dependencies |
| 28 | + |
| 29 | +- numpy |
| 30 | +- scipy |
| 31 | +- tensorflow |
| 32 | +- tensornetwork-ng |
| 33 | +- graphviz |
| 34 | +- jax |
| 35 | +- jaxlib |
| 36 | +- networkx |
| 37 | +- optax |
| 38 | + |
| 39 | +### Development Dependencies |
| 40 | + |
| 41 | +- mypy (1.11.2) |
| 42 | +- pytest (7.4.4) |
| 43 | +- black (with jupyter support) |
| 44 | +- pylint (3.2.6) |
| 45 | +- sphinx (>=4.0) |
| 46 | + |
| 47 | +### Configuration Files |
| 48 | + |
| 49 | +1. `requirements/` - Contains various requirement files: |
| 50 | + |
| 51 | + - [requirements.txt](file:///Users/shixin/Nutstore%20Files/newwork/quantum-information/codebases/tensorcircuit/requirements/requirements.txt) - Core dependencies |
| 52 | + - [requirements-dev.txt](file:///Users/shixin/Nutstore%20Files/newwork/quantum-information/codebases/tensorcircuit/requirements/requirements-dev.txt) - Development tools |
| 53 | + - [requirements-extra.txt](file:///Users/shixin/Nutstore%20Files/newwork/quantum-information/codebases/tensorcircuit/requirements/requirements-extra.txt) - Optional dependencies |
| 54 | + - [requirements-types.txt](file:///Users/shixin/Nutstore%20Files/newwork/quantum-information/codebases/tensorcircuit/requirements/requirements-types.txt) - Type checking dependencies |
| 55 | + |
| 56 | +2. [mypy.ini](file:///Users/shixin/Nutstore%20Files/newwork/quantum-information/codebases/tensorcircuit/mypy.ini) - Type checking configuration with strict mode enabled |
| 57 | + |
| 58 | +3. `.pylintrc` - Code style enforcement with specific rules enabled |
| 59 | + |
| 60 | +4. [pytest.ini](file:///Users/shixin/Nutstore%20Files/newwork/quantum-information/codebases/tensorcircuit/pytest.ini) - Test configuration with deprecation warnings filtered |
| 61 | + |
| 62 | +## Common Bash Commands |
| 63 | + |
| 64 | +### Development Checks |
| 65 | + |
| 66 | +```bash |
| 67 | +# Run all checks (black, mypy, pylint, pytest, sphinx) |
| 68 | +bash check_all.sh |
| 69 | + |
| 70 | +# Equivalent to the following individual checks: |
| 71 | +black . --check # Code formatting check |
| 72 | +mypy tensorcircuit # Type checking |
| 73 | +pylint tensorcircuit tests examples/*.py # Code linting |
| 74 | +pytest -n auto --cov=tensorcircuit -vv -W ignore::DeprecationWarning # Run tests |
| 75 | + |
| 76 | +# Run all tests with coverage report |
| 77 | +pytest --cov=tensorcircuit --cov-report=xml -svv --benchmark-skip |
| 78 | + |
| 79 | +# Run specific test file |
| 80 | +pytest tests/test_circuit.py |
| 81 | + |
| 82 | +# Install dependencies |
| 83 | +pip install --upgrade pip |
| 84 | +pip install -r requirements/requirements.txt |
| 85 | +pip install -r requirements/requirements-dev.txt |
| 86 | +pip install -r requirements/requirements-extra.txt |
| 87 | +pip install -r requirements/requirements-types.txt |
| 88 | +``` |
| 89 | + |
| 90 | +## AI Agent Best Practices |
| 91 | + |
| 92 | +### Efficient Code Navigation |
| 93 | + |
| 94 | +- Use the search function to find specific classes and functions rather than browsing files |
| 95 | +- Look for example usage in the /examples/ directory when learning new features |
| 96 | +- Check tests in /tests/ directory for detailed usage examples |
| 97 | +- Refer to docstrings for API documentation |
| 98 | + |
| 99 | +### Common Patterns in the Codebase |
| 100 | + |
| 101 | +- Backend-agnostic operations through the tc.backend interface |
| 102 | +- JIT compilation support via tc.backend.jit(), JIT is prefered for performance |
| 103 | +- Automatic differentiation support via tc.backend.grad() |
| 104 | +- Vectorized operations using tc.backend.vmap patterns |
| 105 | +- Context managers for temporary configuration changes |
| 106 | + |
| 107 | +### Working with Quantum Concepts |
| 108 | + |
| 109 | +- Familiarity with quantum computing basics (qubits, gates, measurements) |
| 110 | +- Understanding of tensor network concepts for advanced features |
| 111 | +- Knowledge of different quantum computing paradigms (digital, analog, noisy, etc.) |
| 112 | + |
| 113 | +## Additional Information |
| 114 | + |
| 115 | +### Test Structure |
| 116 | + |
| 117 | +- Tests located in /tests/ directory |
| 118 | +- Example scripts in /examples/ directory also serve as integration tests |
| 119 | +- CI runs example demos to ensure functionality |
| 120 | + |
| 121 | +### Documentation |
| 122 | + |
| 123 | +- Documentation built with Sphinx |
| 124 | +- Both English and Chinese versions generated |
| 125 | +- Located in /docs/ directory |
| 126 | + |
| 127 | +### Package Distribution |
| 128 | + |
| 129 | +- Distributed as tensorcircuit-ng package |
| 130 | +- Supports extra dependencies for specific backends (tensorflow, jax, torch, qiskit, cloud) |
| 131 | + |
| 132 | +### Core Design Principles |
| 133 | + |
| 134 | +- Unified interface across multiple backends |
| 135 | +- High performance through tensor network optimizations |
| 136 | +- Extensible architecture for quantum computing research |
| 137 | +- Compatibility with major quantum computing frameworks |
| 138 | + |
| 139 | +### Branch Strategy |
| 140 | + |
| 141 | +- main/master branch for stable releases |
| 142 | +- beta branch for nightly builds (as seen in nightly_release.yml) |
| 143 | +- pull requests for feature development |
0 commit comments