Skip to content

Commit 994cafb

Browse files
committed
init
0 parents  commit 994cafb

56 files changed

Lines changed: 12210 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.envrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
export VIRTUAL_ENV="$PWD/.venv"
3+
export PATH="$VIRTUAL_ENV/bin:$PATH"
4+
export DEV=1

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
- uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
18+
with:
19+
enable-cache: true
20+
- run: uv tool run ruff check .
21+
- run: uv tool run ruff format --check .
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
- uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
28+
with:
29+
enable-cache: true
30+
python-version: "3.13"
31+
- run: uv sync --extra dev
32+
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
33+
with:
34+
path: ~/.cache/huggingface
35+
key: hf-${{ runner.os }}-gte-modernbert-base
36+
- run: uv run pytest -vv

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.DS_Store
2+
*.pyc
3+
*.egg-info/
4+
__pycache__/
5+
.venv/
6+
7+
# Data
8+
*.csv
9+
!tests/fixtures/train_tiny.csv
10+
eval/similarities/
11+
eval/similarities-uncompiled/

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
# Ruff lint + format. Config lives in pyproject.toml.
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.15.6
5+
hooks:
6+
- id: ruff-check
7+
args: [--fix]
8+
- id: ruff-format
9+
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v5.0.0
12+
hooks:
13+
- id: check-case-conflict
14+
- id: check-merge-conflict
15+
- id: check-yaml
16+
- id: check-toml
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace
19+
- id: debug-statements

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

.vscode/settings.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"editor.rulers": [
3+
120
4+
],
5+
"autoDocstring.docstringFormat": "numpy",
6+
"autoDocstring.startOnNewLine": true,
7+
"editor.defaultFormatter": "charliermarsh.ruff",
8+
"editor.formatOnSave": true,
9+
"[markdown]": {
10+
"editor.formatOnSave": false
11+
},
12+
"editor.codeActionsOnSave": {
13+
"source.organizeImports.ruff": "explicit"
14+
},
15+
"rewrap.autoWrap.enabled": true,
16+
"notebook.formatOnSave.enabled": true,
17+
"notebook.defaultFormatter": "charliermarsh.ruff",
18+
"python.defaultInterpreterPath": ".venv/bin/python"
19+
}

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# grouping-trainer
2+
3+
Training code for Sentry's AI grouping model.
4+
5+
Sampling and labeling is in [data-analysis](https://github.com/getsentry/data-analysis/tree/main/grouping/data).
6+
7+
8+
## Set up locally
9+
10+
```bash
11+
./bin/set_up_local.sh
12+
```
13+
14+
15+
## Usage
16+
17+
### Train
18+
19+
```bash
20+
python train.py --gpu h100 --run_shortname my-run
21+
```
22+
23+
Train and eval metrics are logged to https://wandb.ai/sentry-seer/grouping-trainer.
24+
25+
For DDP:
26+
27+
```bash
28+
python train.py --gpu h100-ddp-4 --run_shortname my-run
29+
```
30+
31+
32+
### Debug
33+
34+
<details>
35+
<summary>Launch a bare instance to SSH into</summary>
36+
37+
```bash
38+
python -m grouping_trainer.launch --gpu h100
39+
```
40+
41+
</details>
42+
43+
44+
<details>
45+
<summary>SSH into an instance from local</summary>
46+
47+
Add this function to your `~/.zshrc`:
48+
49+
```bash
50+
gssh() {
51+
gcloud compute ssh "$1" --zone="${2:-us-central1-a}" --project=ml-ai-420606 --tunnel-through-iap
52+
}
53+
```
54+
55+
Then:
56+
57+
```bash
58+
gssh grouping-trainer-h100
59+
# or override the zone:
60+
gssh grouping-trainer-a100 europe-west4-a
61+
```
62+
63+
</details>
64+
65+
66+
<details>
67+
<summary>Check instance output</summary>
68+
69+
SSH into the instance and run:
70+
71+
```bash
72+
logs
73+
# shortcut for:
74+
# sudo tail -f /var/log/grouping_trainer_run.log
75+
```
76+
77+
If that file doesn't exist, the startup script never reached the `eval $COMMAND` block. Check what it actually did:
78+
79+
```bash
80+
sudo journalctl -u google-startup-scripts.service --no-pager
81+
```
82+
83+
From local (use when you can't SSH in, e.g., the boot itself failed):
84+
85+
```bash
86+
gcloud compute instances get-serial-port-output grouping-trainer-l4-eval --zone=us-central1-a --project=ml-ai-420606 | tail -100
87+
```
88+
89+
</details>
90+
91+
92+
### Eval
93+
94+
See [`./eval/`](./eval/).

benchmark/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# benchmark_compiled report
2+
3+
## Run
4+
5+
```
6+
run_gcs_dir=gs://grouping-data/runs/2026-04-10-12-39-45-large-no-prefix
7+
df_path=final_csvs/test_full2.csv
8+
stamp=2026-04-24-23-44-59
9+
sample_size=66753
10+
text_prefix=''
11+
model_kwargs={'dtype': torch.bfloat16, 'attn_implementation': 'sdpa'}
12+
```
13+
14+
- Token bucket boundaries used for analysis: `(64, 128, 256, 512, 1024)`
15+
- Rows: 66,753
16+
17+
## Headline
18+
19+
- Median compiled: **14.7 ms**
20+
- Median base: **36.8 ms**
21+
- Per-row speedup p10/p50/p90: **1.01x / 2.51x / 3.45x**
22+
- Compiled wins on **92.6%** of rows
23+
24+
## Per-bucket
25+
26+
| bucket | n | tok_p50 | compiled_ms_p50 | base_ms_p50 | compiled_ms_p90 | base_ms_p90 | speedup_p50 |
27+
|----------|-------|---------|-----------------|-------------|-----------------|-------------|-------------|
28+
| <=64 | 8301 | 35.0 | 10.58 | 35.17 | 11.72 | 35.99 | 3.32 |
29+
| 65-128 | 7628 | 93.0 | 10.68 | 35.4 | 11.65 | 36.21 | 3.31 |
30+
| 129-256 | 13930 | 194.0 | 11.62 | 36.05 | 12.85 | 37.02 | 3.1 |
31+
| 257-512 | 14804 | 369.0 | 15.54 | 36.97 | 17.3 | 38.1 | 2.38 |
32+
| 513-1024 | 13858 | 682.0 | 26.9 | 38.86 | 28.97 | 40.85 | 1.44 |
33+
| >1024 | 8232 | 1494.5 | 48.06 | 47.04 | 115.66 | 115.89 | 0.98 |
34+
35+
## Worst 5 rows for compiled
36+
37+
| num_tokens | compiled_ms | base_ms | speedup |
38+
|------------|-------------|---------|---------|
39+
| 1252 | 54.8 | 43.26 | 0.789 |
40+
| 1043 | 50.24 | 42.14 | 0.839 |
41+
| 2020 | 82.6 | 70.98 | 0.859 |
42+
| 1122 | 49.67 | 42.91 | 0.864 |
43+
| 2040 | 79.23 | 69.04 | 0.871 |

0 commit comments

Comments
 (0)