Skip to content

Commit 5274948

Browse files
rename to AGENTS.md
1 parent 8f4a146 commit 5274948

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

llm.md renamed to AGENTS.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@
55
TensorCircuit is a **Tensor Network-first**, **Multi-Backend** quantum computing framework. When contributing to this codebase, you must adhere to the following architectural principles:
66

77
### Unified Backend Interface
8+
89
- **Rule**: Never use backend-specific libraries (numpy, tensorflow, jax) directly in core logic.
910
- **Pattern**: Use the `tc.backend` abstraction for all tensor operations.
1011
- **Example**: Use `tc.backend.sin(x)` instead of `np.sin(x)` or `tf.math.sin(x)`. This ensures code runs seamlessly on TensorFlow, JAX, PyTorch, and NumPy.
1112

1213
### Differentiable Programming (AD)
14+
1315
- **Rule**: All core components must be differentiable.
1416
- **Pattern**: Avoid operations that break the computation graph (e.g., converting to numpy inside a differentiable function, using in-place assignments on tensors).
1517
- **Goal**: End-to-end differentiability allows variational algorithms and gradient-based optimization to work out of the box.
1618

1719
### JIT-First Optimization
20+
1821
- **Rule**: Write code that is JIT-compilable (Just-In-Time).
1922
- **Pattern**: Avoid Python control flow (if/else) that depends on tensor values. Use `tc.backend.cond` or `tc.backend.switch` if necessary, or structure code to be statically analyzable.
2023
- **Benefit**: This enables massive speedups on JAX and TensorFlow backends.
2124

22-
2325
## Repository Structure
2426

2527
- `tensorcircuit/`: Core package source code.
@@ -60,7 +62,6 @@ TensorCircuit is a **Tensor Network-first**, **Multi-Backend** quantum computing
6062
### Configuration Files
6163

6264
1. `requirements/` - Contains various requirement files:
63-
6465
- [requirements.txt](requirements/requirements.txt) - Core dependencies
6566
- [requirements-dev.txt](requirements/requirements-dev.txt) - Development tools
6667
- [requirements-extra.txt](requirements/requirements-extra.txt) - Optional dependencies
@@ -70,23 +71,34 @@ TensorCircuit is a **Tensor Network-first**, **Multi-Backend** quantum computing
7071

7172
3. `.pylintrc` - Code style enforcement with specific rules enabled
7273

73-
7474
## AI Agent Best Practices
7575

7676
### Code Navigation
77+
7778
- **Search First**: The codebase is extensive. Search for class definitions (e.g., `class Hamiltonian`) rather than guessing file paths.
7879
- **Check Tests**: `tests/test_*.py` files are the ultimate source of truth for how APIs are intended to be used.
7980

8081
### Coding Standards
82+
8183
- **Linting**: We enforce strict **Pylint** and **Black** formatting.
8284
- Run `bash check_all.sh` before submitting changes.
8385
- Target Pylint score: 10.0/10.
8486
- **Type Hinting**: Use type hints liberally to aid static analysis.
8587
- **Documentation**: Write clear docstrings (reStructuredText format) for all public APIs.
8688

89+
### Coding Style Suggestions
90+
91+
Follow these rules for all code changes in this repository:
92+
93+
- Minimize comments; be concise; code should be self-explanatory and self-documenting.
94+
- Comments should be useful, for example, comments that remind the reader about some global context that is non-obvious and can't be inferred locally.
95+
- Match existing code style and architectural patterns of the codebase.
96+
- If uncertain, choose the simpler, more concise implementation.
97+
8798
### Common Workflows
8899

89100
#### 1. Running Tests
101+
90102
```bash
91103
# Run all tests (auto-parallelized)
92104
pytest -n auto
@@ -96,6 +108,7 @@ pytest tests/test_hamiltonians.py
96108
```
97109

98110
#### 2. Checking Code Quality
111+
99112
```bash
100113
# Check formatting
101114
black . --check
@@ -145,5 +158,3 @@ pylint tensorcircuit/quantum.py
145158

146159
- Devin Deepwiki: https://deepwiki.com/tensorcircuit/tensorcircuit-ng
147160
- Context7 MCP: https://context7.com/tensorcircuit/tensorcircuit-ng
148-
149-

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ For beginners, please refer to [quantum computing lectures with TC-NG](https://g
4444
To write TC-NG scripts and applications efficiently with AI coding agents (e.g., Claude Code, Cursor, Antigravity), we strongly recommend **working directly within the local tensorcircuit-ng repository** rather than an empty folder.
4545

4646
1. **Rich Context:** The 100+ scripts in `examples/` and extensive test cases in `tests/` provide essential references that significantly reduce AI hallucinations.
47-
2. **Built-in Rules:** We provide a dedicated **[`llm.md`](/llm.md)** file. It serves as the "handbook" (i.e. `CLAUDE.md`) for AI agents, defining coding standards and best practices to ensure the generated code is idiomatic.
47+
2. **Built-in Rules:** We provide a dedicated **[`AGENTS.md`](/AGENTS.md)** file. It serves as the "handbook" (i.e. `CLAUDE.md`) for AI agents, defining coding standards and best practices to ensure the generated code is idiomatic.
4848

4949
**Recommended Workflow:**
5050

5151
1. Clone the repository: `git clone https://github.com/tensorcircuit/tensorcircuit-ng.git`
5252
2. Switch to a local playground branch: `git checkout -b my-playground` in case messing up with the original repository.
5353
3. Open the repository folder in your AI IDE. And you are ready to start writing TC-NG scripts.
5454

55-
Now, enjoy implementing quantum algorithms entirely through natural language.
55+
Now, enjoy implementing quantum algorithms entirely through natural language!
56+
57+
### Quick Demos
5658

5759
The following are some minimal demos.
5860

@@ -198,9 +200,7 @@ We also have [Docker support](/docker).
198200
- Support **Fermion Gaussian state** simulation with expectation, entanglement, measurement, ground state, real and imaginary time evolution.
199201
- Support **qudits simulation** for tensor network and MPS approximation modes.
200202
- Support **parallel** quantum circuit evaluation across **multiple GPUs**.
201-
202203
- Highly customizable **noise model** with gate error and scalable readout error.
203-
204204
- Support for **non-unitary** gate and post-selection simulation.
205205

206206
- Support **real quantum devices access** from different providers.

0 commit comments

Comments
 (0)