Skip to content

Commit 328dea1

Browse files
authored
Add AGENTS.md (#1430)
1 parent 8d13759 commit 328dea1

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

AGENTS.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<!-- AGENTS.md: Guidance for AI agents to navigate, build, test, and contribute to this repository -->
2+
# AGENTS
3+
4+
This file provides instructions for AI agents to understand the layout of the `mistral.rs` repository, run builds/tests, and follow project conventions.
5+
6+
## Repository Structure
7+
8+
- `/mistralrs/` : Main Rust crate (text & multimodal inference API)
9+
- `/mistralrs-core/` : Core inference logic and tensor operations (text models)
10+
- `/mistralrs-vision/` : Vision inference support (image-based inputs & vision-enabled models)
11+
- `/mistralrs-quant/` : Quantization support (ISQ, GGUF, GPTQ, AWQ, FP8, HQQ, etc.)
12+
- `/mistralrs-paged-attn/`: PagedAttention implementation
13+
- `/mistralrs-pyo3/` : Python bindings (PyO3)
14+
- `/mistralrs-server/` : CLI & OpenAI-compatible HTTP server (subcommands: run/vision-plain, diffusion, speech)
15+
- `/mistralrs-server-core/`: Shared server core logic
16+
- `/mistralrs-web-chat/` : Web chat application (static assets & backend integration)
17+
- `/mistralrs-bench/` : Benchmarking tools
18+
- `/docs/` : Markdown documentation for models, features, and guides
19+
- `/examples/` : Usage examples (Rust, Python, server samples, notebooks)
20+
- `/chat_templates/` : Chat formatting templates (JSON/Jinja)
21+
- `/scripts/` : Utility scripts (e.g., AWQ conversion)
22+
23+
## Feature Organization
24+
25+
Mistral.rs supports multiple model types and advanced features via dedicated crates and CLI subcommands:
26+
27+
- **Text Inference**
28+
- Crate: `mistralrs-core` (low-level ops), `mistralrs` (API wrapper)
29+
- CLI: `run` / `plain` subcommand in `mistralrs-server`
30+
- Docs: `docs/SAMPLING.md`, `docs/TOOL_CALLING.md`
31+
- **Vision Models**
32+
- Crate: `mistralrs-vision`
33+
- CLI: `vision-plain` subcommand
34+
- Docs: `docs/VISION_MODELS.md`, `docs/IMAGEGEN_MODELS.md`, `docs/IMATRIX.md`
35+
- **Diffusion Models**
36+
- CLI: `diffusion` subcommand
37+
- Docs: `docs/FLUX.md`
38+
- **Speech Models**
39+
- CLI: `speech` subcommand
40+
- Docs: `docs/DIA.md`
41+
- **Quantization & ISQ**
42+
- Crate: `mistralrs-quant`
43+
- Docs: `docs/QUANTS.md`, `docs/ISQ.md`
44+
- Conversion Script: `scripts/convert_awq_marlin.py`
45+
- **Paged Attention**
46+
- Crate: `mistralrs-paged-attn`
47+
- Docs: `docs/PAGED_ATTENTION.md`
48+
- **Adapters & LoRA/X-LoRA**
49+
- Docs: `docs/ADAPTER_MODELS.md`, `docs/LORA_XLORA.md`
50+
- **Mixture of Experts (AnyMoE)**
51+
- Docs: `docs/ANYMOE.md`
52+
53+
## Building
54+
55+
1. Install Rust via rustup (Rust 2021 edition).
56+
2. Choose optional features (e.g., `cuda`, `flash-attn`, `cudnn`, `metal`, `mkl`, `accelerate`).
57+
3. Build the entire workspace:
58+
```bash
59+
cargo build --workspace --release --features "<features>"
60+
```
61+
4. Or build/install only the server binary:
62+
```bash
63+
cargo build --release --package mistralrs-server --features "<features>"
64+
cargo install --path mistralrs-server --features "<features>"
65+
```
66+
67+
## Testing
68+
69+
- Core test suite (requires HF token for some tests):
70+
```bash
71+
export HF_TOKEN=<your_token> # or TESTS_HF_TOKEN for CI parity
72+
cargo test -p mistralrs-core -p mistralrs-quant -p mistralrs-vision
73+
```
74+
- Run all tests across workspace (may skip some crates without tests):
75+
```bash
76+
cargo test --workspace
77+
```
78+
79+
## Formatting & Linting
80+
81+
- Format all Rust code:
82+
```bash
83+
cargo fmt --all
84+
make fmt # also formats Python/CUDA/C++ files via ruff, clang-format
85+
```
86+
- Lint with Clippy:
87+
```bash
88+
cargo clippy --workspace --tests --examples -- -D warnings
89+
```
90+
91+
## Documentation
92+
93+
- Generate Rust docs for all crates:
94+
```bash
95+
cargo doc --workspace
96+
```
97+
- Preview at `target/doc/` or publish to GitHub Pages as configured.
98+
- Refer to `/docs/` for in-depth markdown guides (e.g., DEVICE_MAPPING.md, TOOL_CALLING.md).
99+
100+
## Examples
101+
102+
- Rust examples: `mistralrs/examples/`
103+
- Python examples: `examples/python/`
104+
- Server samples: `examples/server/`
105+
- Run Python scripts:
106+
```bash
107+
python3 examples/python/<script>.py
108+
```
109+
- Run server/CLI:
110+
```bash
111+
./target/release/mistralrs-server -i <mode> -m <model> [options]
112+
```
113+
114+
## CI Parity
115+
116+
The CI pipeline is defined in `.github/workflows/ci.yml` and includes:
117+
- `cargo check` for all targets
118+
- `cargo test` on core crates
119+
- `cargo fmt -- --check`
120+
- `cargo clippy -D warnings`
121+
- `cargo doc`
122+
- Typos check (`crate-ci/typos`)
123+
124+
## Contribution Conventions
125+
126+
- Follow Rust 2021 idioms, keep code minimal and focused.
127+
- Update `/docs/` and examples when adding features or breaking changes.
128+
- Add tests and examples for new functionality.
129+
- Commit messages should be clear and follow conventional style where possible.
130+
```
131+
feat(crate): describe new feature
132+
fix(crate): describe bug fix
133+
docs: update docs for ...
134+
```
135+
136+
---
137+
*This AGENTS.md file is intended solely to improve AI-driven assistance and does not affect runtime behavior.*

0 commit comments

Comments
 (0)