Hussein Claude Opus 5 (1M context) commited on
Commit
f8a54ab
·
1 Parent(s): 5cd2d33

Let the data stage run without a GPU, and split the Colab notebook by intent

Browse files

Benchmarking needs the held-out split but not an accelerator, and `train_gpu.sh`
probed CUDA, sized batches against VRAM, and refused to continue long before it
reached the data stage. `--prepare-only` skips every GPU probe and stops once
the manifests exist, printing their record counts. Verified on a machine with no
CUDA at all: it succeeds with the flag and still refuses without it.

That unlocks the useful thing to do with a second machine while a first one is
training: score the stock checkpoints. The Colab notebook now separates setup
from two independent sections -- benchmark, which duplicates no other run, and
train, which does and says so. A closing cell puts the fine-tuned adapter in the
same table as the baselines, on the same speakers and the same drawn sample,
which is the comparison the paper had no fine-tune to make.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uis9uRynosX69gefzFQeNN

Files changed (2) hide show
  1. notebooks/colab_train.ipynb +88 -24
  2. scripts/train_gpu.sh +15 -0
notebooks/colab_train.ipynb CHANGED
@@ -4,17 +4,24 @@
4
  "cell_type": "markdown",
5
  "metadata": {},
6
  "source": [
7
- "# Buddi ASR — training on Colab\n",
8
  "\n",
9
- "A second path to the same artifact, for when Kaggle's weekly GPU allowance is\n",
10
  "spent or its scheduler hands out a GPU this PyTorch cannot use.\n",
11
  "\n",
12
  "**Set the runtime first:** Runtime → Change runtime type → T4 GPU. The check\n",
13
  "below refuses to continue without one, because a CPU runtime would spend an\n",
14
  "hour preparing 40k files and then fail at the first optimizer step.\n",
15
  "\n",
16
- "No credentials are needed anywhere in this notebook. Both repositories are\n",
17
- "public."
 
 
 
 
 
 
 
18
  ]
19
  },
20
  {
@@ -84,15 +91,27 @@
84
  "print(\"audio is real, 16 kHz\")"
85
  ]
86
  },
 
 
 
 
 
 
 
 
 
 
 
 
87
  {
88
  "cell_type": "code",
89
  "execution_count": null,
90
  "metadata": {},
91
  "outputs": [],
92
  "source": [
93
- "# 20 optimizer steps into a separate directory. Preflight rejects speaker\n",
94
- "# overlap here, where it costs seconds rather than a GPU hour.\n",
95
- "!cd /content/buddi-asr && ./scripts/train_gpu.sh tiny-lora --smoke --skip-install"
96
  ]
97
  },
98
  {
@@ -101,13 +120,47 @@
101
  "metadata": {},
102
  "outputs": [],
103
  "source": [
104
- "# Colab disconnects idle sessions and reclaims the disk with them, so mount\n",
105
- "# Drive and train into it. Resuming a dropped run then costs the time since the\n",
106
- "# last checkpoint rather than the whole run.\n",
 
 
 
 
 
 
 
 
 
107
  "from google.colab import drive\n",
108
  "\n",
109
  "drive.mount(\"/content/drive\")\n",
110
- "!mkdir -p /content/drive/MyDrive/buddi-asr/artifacts"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  ]
112
  },
113
  {
@@ -116,11 +169,18 @@
116
  "metadata": {},
117
  "outputs": [],
118
  "source": [
119
- "# --resume auto picks up the newest complete checkpoint, so re-running this\n",
120
- "# cell after a disconnect continues instead of starting over.\n",
121
  "!cd /content/buddi-asr && ./scripts/train_gpu.sh tiny-lora --skip-install \\\n",
122
- " --output-dir /content/drive/MyDrive/buddi-asr/artifacts/tiny-lora \\\n",
123
- " --resume auto"
 
 
 
 
 
 
 
 
 
124
  ]
125
  },
126
  {
@@ -129,20 +189,24 @@
129
  "metadata": {},
130
  "outputs": [],
131
  "source": [
132
- "# Score the fine-tuned adapter against the stock checkpoints on the same\n",
133
- "# held-out speakers and the same drawn sample -- the comparison the paper at\n",
134
- "# arXiv:2510.23319 could only make between stock variants.\n",
135
- "!cd /content/buddi-asr && ./scripts/benchmark_whisper.sh \\\n",
136
- " /content/drive/MyDrive/buddi-asr/artifacts/tiny-lora/final \\\n",
137
- " openai/whisper-tiny openai/whisper-small openai/whisper-large-v3-turbo"
138
  ]
139
  }
140
  ],
141
  "metadata": {
142
  "accelerator": "GPU",
143
- "colab": {"provenance": [], "gpuType": "T4"},
144
- "kernelspec": {"display_name": "Python 3", "name": "python3"},
145
- "language_info": {"name": "python"}
 
 
 
 
 
 
 
 
146
  },
147
  "nbformat": 4,
148
  "nbformat_minor": 0
 
4
  "cell_type": "markdown",
5
  "metadata": {},
6
  "source": [
7
+ "# Buddi ASR on Colab\n",
8
  "\n",
9
+ "A second machine for this project, for when Kaggle's weekly GPU allowance is\n",
10
  "spent or its scheduler hands out a GPU this PyTorch cannot use.\n",
11
  "\n",
12
  "**Set the runtime first:** Runtime → Change runtime type → T4 GPU. The check\n",
13
  "below refuses to continue without one, because a CPU runtime would spend an\n",
14
  "hour preparing 40k files and then fail at the first optimizer step.\n",
15
  "\n",
16
+ "Run the setup cells, then pick one of the two sections. No credentials are\n",
17
+ "needed anywhere -- both repositories are public."
18
+ ]
19
+ },
20
+ {
21
+ "cell_type": "markdown",
22
+ "metadata": {},
23
+ "source": [
24
+ "## Setup"
25
  ]
26
  },
27
  {
 
91
  "print(\"audio is real, 16 kHz\")"
92
  ]
93
  },
94
+ {
95
+ "cell_type": "markdown",
96
+ "metadata": {},
97
+ "source": [
98
+ "## Benchmark the stock checkpoints\n",
99
+ "\n",
100
+ "Independent of any fine-tune, so this can run while another machine trains,\n",
101
+ "and it is the half of arXiv:2510.23319 that reproduces directly: score a set\n",
102
+ "of Whisper variants on held-out child speech. Ours is 40,646 utterances\n",
103
+ "against the paper's 355, though single words rather than connected speech."
104
+ ]
105
+ },
106
  {
107
  "cell_type": "code",
108
  "execution_count": null,
109
  "metadata": {},
110
  "outputs": [],
111
  "source": [
112
+ "# Build the manifests and splits. --prepare-only skips every GPU probe, so\n",
113
+ "# this stage does not depend on which accelerator the runtime got.\n",
114
+ "!cd /content/buddi-asr && ./scripts/train_gpu.sh tiny-lora --prepare-only --skip-install"
115
  ]
116
  },
117
  {
 
120
  "metadata": {},
121
  "outputs": [],
122
  "source": [
123
+ "# Every checkpoint sees the same drawn sample, and results are keyed by model\n",
124
+ "# so a rerun skips what it already scored.\n",
125
+ "!cd /content/buddi-asr && ./scripts/benchmark_whisper.sh --limit 600 --batch-size 16"
126
+ ]
127
+ },
128
+ {
129
+ "cell_type": "code",
130
+ "execution_count": null,
131
+ "metadata": {},
132
+ "outputs": [],
133
+ "source": [
134
+ "# Copy the reports out before the runtime is reclaimed.\n",
135
  "from google.colab import drive\n",
136
  "\n",
137
  "drive.mount(\"/content/drive\")\n",
138
+ "!mkdir -p /content/drive/MyDrive/buddi-asr\n",
139
+ "!cp -r /content/buddi-asr/reports /content/drive/MyDrive/buddi-asr/\n",
140
+ "!ls /content/drive/MyDrive/buddi-asr/reports/benchmark/"
141
+ ]
142
+ },
143
+ {
144
+ "cell_type": "markdown",
145
+ "metadata": {},
146
+ "source": [
147
+ "## Train\n",
148
+ "\n",
149
+ "Skip this while a run is in flight elsewhere -- it produces the same artifact\n",
150
+ "twice. Training writes into Drive because Colab reclaims the container disk\n",
151
+ "when it drops an idle session; `--resume auto` then costs the time since the\n",
152
+ "last checkpoint rather than the whole run."
153
+ ]
154
+ },
155
+ {
156
+ "cell_type": "code",
157
+ "execution_count": null,
158
+ "metadata": {},
159
+ "outputs": [],
160
+ "source": [
161
+ "# 20 optimizer steps into a separate directory. Preflight rejects speaker\n",
162
+ "# overlap here, where it costs seconds rather than a GPU hour.\n",
163
+ "!cd /content/buddi-asr && ./scripts/train_gpu.sh tiny-lora --smoke --skip-install"
164
  ]
165
  },
166
  {
 
169
  "metadata": {},
170
  "outputs": [],
171
  "source": [
 
 
172
  "!cd /content/buddi-asr && ./scripts/train_gpu.sh tiny-lora --skip-install \\\n",
173
+ " --output-dir /content/drive/MyDrive/buddi-asr/artifacts/tiny-lora --resume auto"
174
+ ]
175
+ },
176
+ {
177
+ "cell_type": "markdown",
178
+ "metadata": {},
179
+ "source": [
180
+ "## Put the fine-tuned adapter in the same table\n",
181
+ "\n",
182
+ "The comparison the paper could not make: the same held-out speakers and the\n",
183
+ "same drawn sample, with and without adaptation."
184
  ]
185
  },
186
  {
 
189
  "metadata": {},
190
  "outputs": [],
191
  "source": [
192
+ "!cd /content/buddi-asr && ./scripts/benchmark_whisper.sh --limit 600 --batch-size 16 \\\n",
193
+ " /content/drive/MyDrive/buddi-asr/artifacts/tiny-lora/final openai/whisper-tiny"
 
 
 
 
194
  ]
195
  }
196
  ],
197
  "metadata": {
198
  "accelerator": "GPU",
199
+ "colab": {
200
+ "provenance": [],
201
+ "gpuType": "T4"
202
+ },
203
+ "kernelspec": {
204
+ "display_name": "Python 3",
205
+ "name": "python3"
206
+ },
207
+ "language_info": {
208
+ "name": "python"
209
+ }
210
  },
211
  "nbformat": 4,
212
  "nbformat_minor": 0
scripts/train_gpu.sh CHANGED
@@ -25,6 +25,7 @@ Options:
25
  --smoke Run 20 optimizer steps in a separate output directory
26
  --evaluate-test Evaluate the held-out test set after training
27
  --skip-install Use the already-active Python environment
 
28
  --torch-index-url URL Install torch from a PyTorch wheel index before extras
29
  -h, --help Show this help
30
 
@@ -52,6 +53,7 @@ output_dir=""
52
  smoke=0
53
  evaluate_test=0
54
  skip_install=0
 
55
  torch_index_url="${BUDDI_TORCH_INDEX_URL:-}"
56
 
57
  while [[ $# -gt 0 ]]; do
@@ -69,6 +71,7 @@ while [[ $# -gt 0 ]]; do
69
  --smoke) smoke=1; shift ;;
70
  --evaluate-test) evaluate_test=1; shift ;;
71
  --skip-install) skip_install=1; shift ;;
 
72
  -h|--help) usage; exit 0 ;;
73
  *) echo "Unknown option: $1" >&2; usage >&2; exit 2 ;;
74
  esac
@@ -134,6 +137,8 @@ elif [[ -f "$venv_dir/bin/activate" ]]; then
134
  source "$venv_dir/bin/activate"
135
  fi
136
 
 
 
137
  python - <<'PY'
138
  import torch
139
 
@@ -191,6 +196,8 @@ fi
191
  exit 2
192
  }
193
 
 
 
194
  train_manifest="data/manifests/splits/train.jsonl"
195
  validation_manifest="data/manifests/splits/validation.jsonl"
196
  test_manifest="data/manifests/splits/test.jsonl"
@@ -233,6 +240,14 @@ for manifest in "$train_manifest" "$validation_manifest" "$test_manifest"; do
233
  }
234
  done
235
 
 
 
 
 
 
 
 
 
236
  if [[ -z "$output_dir" ]]; then
237
  if [[ "$smoke" -eq 1 ]]; then
238
  output_dir="artifacts/smoke-${profile}"
 
25
  --smoke Run 20 optimizer steps in a separate output directory
26
  --evaluate-test Evaluate the held-out test set after training
27
  --skip-install Use the already-active Python environment
28
+ --prepare-only Build the manifests and splits, then stop (no GPU needed)
29
  --torch-index-url URL Install torch from a PyTorch wheel index before extras
30
  -h, --help Show this help
31
 
 
53
  smoke=0
54
  evaluate_test=0
55
  skip_install=0
56
+ prepare_only=0
57
  torch_index_url="${BUDDI_TORCH_INDEX_URL:-}"
58
 
59
  while [[ $# -gt 0 ]]; do
 
71
  --smoke) smoke=1; shift ;;
72
  --evaluate-test) evaluate_test=1; shift ;;
73
  --skip-install) skip_install=1; shift ;;
74
+ --prepare-only) prepare_only=1; shift ;;
75
  -h|--help) usage; exit 0 ;;
76
  *) echo "Unknown option: $1" >&2; usage >&2; exit 2 ;;
77
  esac
 
137
  source "$venv_dir/bin/activate"
138
  fi
139
 
140
+ if [[ "$prepare_only" -eq 0 ]]; then
141
+
142
  python - <<'PY'
143
  import torch
144
 
 
196
  exit 2
197
  }
198
 
199
+ fi
200
+
201
  train_manifest="data/manifests/splits/train.jsonl"
202
  validation_manifest="data/manifests/splits/validation.jsonl"
203
  test_manifest="data/manifests/splits/test.jsonl"
 
240
  }
241
  done
242
 
243
+ if [[ "$prepare_only" -eq 1 ]]; then
244
+ echo "Manifests ready:"
245
+ for manifest in "$train_manifest" "$validation_manifest" "$test_manifest"; do
246
+ echo " $manifest ($(wc -l < "$manifest") records)"
247
+ done
248
+ exit 0
249
+ fi
250
+
251
  if [[ -z "$output_dir" ]]; then
252
  if [[ "$smoke" -eq 1 ]]; then
253
  output_dir="artifacts/smoke-${profile}"