mrsandip commited on
Commit
b641637
·
verified ·
1 Parent(s): 492340a

Add Colab free T4 notebook

Browse files
Files changed (1) hide show
  1. notebooks/colab_t4.ipynb +47 -0
notebooks/colab_t4.ipynb ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": ["# Alfa-Code Tiny-50M — Colab Free T4\n", "Runtime → Change runtime type → T4 GPU. Then Run all."]
7
+ },
8
+ {
9
+ "cell_type": "code",
10
+ "execution_count": null,
11
+ "metadata": {},
12
+ "outputs": [],
13
+ "source": ["!nvidia-smi --query-gpu=name,memory.total --format=csv\n", "!pip install -q torch transformers datasets tokenizers accelerate huggingface_hub"]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": null,
18
+ "metadata": {},
19
+ "outputs": [],
20
+ "source": ["from huggingface_hub import snapshot_download\n", "snapshot_download('mrsandip/Alfa-Code', local_dir='/content/alfa', repo_type='model')\n", "%cd /content/alfa\n", "!ls scripts/ data/processed/"]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": null,
25
+ "metadata": {},
26
+ "outputs": [],
27
+ "source": ["# bigger data (500 rows) for real train\n", "!python scripts/download_data.py --dataset code_small_test --max-rows 2000\n", "!python scripts/train_tokenizer.py\n", "!ls -lh tokenizers/ data/processed/"]
28
+ },
29
+ {
30
+ "cell_type": "code",
31
+ "execution_count": null,
32
+ "metadata": {},
33
+ "outputs": [],
34
+ "source": ["!python scripts/train_hf.py --data data/processed/train.jsonl --out /content/outputs/tiny-50M --epochs 1\n", "!ls -lh /content/outputs/tiny-50M"]
35
+ },
36
+ {
37
+ "cell_type": "code",
38
+ "execution_count": null,
39
+ "metadata": {},
40
+ "outputs": [],
41
+ "source": ["# push back to Hub (set HF_TOKEN in Colab Secrets)\n", "import os\n", "from huggingface_hub import HfApi\n", "tok = os.getenv('HF_TOKEN')\n", "api = HfApi(token=tok)\n", "api.upload_folder(folder_path='/content/outputs/tiny-50M', repo_id='mrsandip/Alfa-Code', path_in_repo='outputs/tiny-50M')\n", "print('uploaded')"]
42
+ }
43
+ ],
44
+ "metadata": {"kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}},
45
+ "nbformat": 4,
46
+ "nbformat_minor": 5
47
+ }