---
type: "post"
id: "train-a-small-gpt-on-a-hugging-face-fe15ad"
slug: "train-a-small-gpt-on-a-hugging-face-fe15ad"
title: "Train a small GPT on a Hugging Face GPU, without changing your code"
description: "The repository trains a 51M-parameter GPT-style model on TinyStories and includes run_on_hf.sh, which its README says can be copied into other projects—not just this one."
retrieval_nugget: "The repository trains a 51M-parameter GPT-style model on TinyStories and includes run_on_hf.sh, which its README says can be copied into other projects—not just this one."
published_at: "2026-11-27"
updated_at: "2026-11-27"
record_date: "2026-11-27"
date_kind: "published_at"
topics: ["compute","developer-tools","models"]
entities: ["Hugging Face","Hugging Face Jobs","nanogpt-jobs","TinyStories"]
related_patterns: ["hardware-adoption-is-routed-through-familiar-ai-software-stacks"]
novelty_label: "new_fact"
what_changed: null
prior_refs: []
source_url: "https://github.com/scienceetonnante/nanogpt-jobs"
source_urls: ["https://github.com/scienceetonnante/nanogpt-jobs"]
production: {"schema":"newruntime-production-v1","desk":"newsroom","first_seen_at":"2026-11-27T19:21:52.129Z","independent_sources":1,"notes_synthesized":null,"writer_model":"gpt-6-luna","critic":null,"checks":["primary_source_verified","source_fresh","one_story","copy_contract"],"novelty":null,"editorial_value":"medium","human_review":"selective"}
citations: [{"claim":"","quotes":["The tutorial’s repository provides code to train a 51-million-parameter GPT-style model on TinyStories.","run_on_hf.sh contains nothing specific to this project, and can be copied as it is to another one."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20tutorial%E2%80%99s%20repository%20provides%20code%20to%20train%20a%2051%2Dmillion%2Dparameter%20GPT%2Dstyle%20model%20on%20TinyStories.&text=run_on_hf.sh%20contains%20nothing%20specific%20to%20this%20project%2C%20and%20can%20be%20copied%20as%20it%20is%20to%20another%20one.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"For a remote job, the wrapper copies the project folder to a private Hub storage bucket, excluding hidden files and folders, pycache and out/; it installs requirements.txt and invokes the script with the same command used locally.","quotes":["The script runs as it is on a Mac, on an NVIDIA GPU or on a CPU."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20script%20runs%20as%20it%20is%20on%20a%20Mac%2C%20on%20an%20NVIDIA%20GPU%20or%20on%20a%20CPU.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"It links the job's out/ directory to the bucket so outputs persist after the job machine is deleted.","quotes":["The script does three things: It copies this folder to a private storage bucket on the Hub, /nanogpt-jobs , in the folder code/ . Hidden files and folders ( .git , .venv , …), pycache and out/ are left out.","It installs the packages of requirements.txt and runs the file with the same command as on your machine."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20script%20does%20three%20things%3A%20It%20copies%20this%20folder%20to%20a%20private%20storage%20bucket%20on%20the%20Hub%2C%20%2Fnanogpt%2Djobs%20%2C%20in%20the%20folder%20code%2F%20.%20Hidden%20files%20and%20folders%20%28%20.git%20%2C%20.venv%20%2C%20%E2%80%A6%29%2C%20pycache%20and%20out%2F%20are%20left%20out.&text=It%20installs%20the%20packages%20of%20requirements.txt%20and%20runs%20the%20file%20with%20the%20same%20command%20as%20on%20your%20machine.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"A separate sample.py script generates stories with the trained model.","quotes":["The model is saved to out/model.pt . Every 100 steps the script prints the loss, the speed and the time left.","Every 100 steps the script prints the loss, the speed and the time left.","Every 2,000 steps it prints a story written by the model."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20model%20is%20saved%20to%20out%2Fmodel.pt%20.%20Every%20100%20steps%20the%20script%20prints%20the%20loss%2C%20the%20speed%20and%20the%20time%20left.&text=Every%20100%20steps%20the%20script%20prints%20the%20loss%2C%20the%20speed%20and%20the%20time%20left.&text=Every%202%2C000%20steps%20it%20prints%20a%20story%20written%20by%20the%20model.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"","quotes":["The job starts in the background, and the script prints its ID."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20job%20starts%20in%20the%20background%2C%20and%20the%20script%20prints%20its%20ID.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"These are repository-reported figures, not benchmarks established here.","quotes":["Its README reports that the same training script takes about 12 hours on an M4 Pro MacBook Pro and about 30 minutes on an A100 through Hugging Face Jobs.","Use the trained model hf … Footer &copy; 2026 GitHub, Inc."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Its%20README%20reports%20that%20the%20same%20training%20script%20takes%20about%2012%20hours%20on%20an%20M4%20Pro%20MacBook%20Pro%20and%20about%2030%20minutes%20on%20an%20A100%20through%20Hugging%20Face%20Jobs.&text=Use%20the%20trained%20model%20hf,Footer%20%26copy%3B%202026%20GitHub%2C%20Inc.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"","quotes":["Its README reports that the same training script takes about 12 hours on an M4 Pro MacBook Pro and about 30 minutes on an A100 through Hugging Face Jobs.","Use the trained model hf … Footer &copy; 2026 GitHub, Inc."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Its%20README%20reports%20that%20the%20same%20training%20script%20takes%20about%2012%20hours%20on%20an%20M4%20Pro%20MacBook%20Pro%20and%20about%2030%20minutes%20on%20an%20A100%20through%20Hugging%20Face%20Jobs.&text=Use%20the%20trained%20model%20hf,Footer%20%26copy%3B%202026%20GitHub%2C%20Inc.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"Remote GPU use requires a Hugging Face account with a PRO subscription or credits; log in with hf auth login.","quotes":["Use the trained model hf … Footer &copy; 2026 GitHub, Inc."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Use%20the%20trained%20model%20hf,Footer%20%26copy%3B%202026%20GitHub%2C%20Inc.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"Then launch an A100 job, with a two-hour maximum runtime, using./runonhf.sh train.py a100-large.","quotes":["Run on a Hugging Face GPU You need a Hugging Face account with a PRO subscription or credits, and you need to be logged in ( hf auth login )."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Run%20on%20a%20Hugging%20Face%20GPU%20You%20need%20a%20Hugging%20Face%20account%20with%20a%20PRO%20subscription%20or%20credits%2C%20and%20you%20need%20to%20be%20logged%20in%20%28%20hf%20auth%20login%20%29.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"There is no default GPU flavor; hf jobs hardware lists flavors and prices.","quotes":["./run_on_hf.sh train.py a100-large # on an A100, stopped after 2 hours at most ./run_on_hf.sh train.py l4x1 4h # on another GPU, with another time limit The GPU type (the \"flavor\") has no default, so that you never start an expensive machine by mistake."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=.%2Frun_on_hf.sh%20train.py%20a100%2Dlarge%20%23%20on%20an%20A100%2C%20stopped%20after%202%20hours%20at%20most%20.%2Frun_on_hf.sh%20train.py%20l4x1%204h%20%23%20on%20another%20GPU%2C%20with%20another%20time%20limit%20The%20GPU%20type%20%28the%20%22flavor%22%29%20has%20no%20default%2C%20so%20that%20you%20never%20start%20an%20expensive%20machine%20by%20mistake.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"Follow progress with hf jobs logs -f <job id>.","quotes":["./run_on_hf.sh train.py a100-large # on … the flavors and their prices."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=.%2Frun_on_hf.sh%20train.py%20a100%2Dlarge%20%23%20on,the%20flavors%20and%20their%20prices.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"},{"claim":"","quotes":["Follow it with hf jobs logs -f , or on the job page at huggingface.co."],"cite_url":"https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Follow%20it%20with%20hf%20jobs%20logs%20%2Df%20%2C%20or%20on%20the%20job%20page%20at%20huggingface.co.","source_url":"https://github.com/scienceetonnante/nanogpt-jobs","publisher":"github.com"}]
schema_version: "newruntime-agent-readable-v0.2"
stable_id: "post:train-a-small-gpt-on-a-hugging-face-fe15ad"
status: "published"
visuals: []
editor: {"role":"editor","name":"Andrey Reshetnikov","profile":"https://newruntime.com/owner-profile.md","profile_json":"https://newruntime.com/owner-profile.json","same_as":["https://www.linkedin.com/in/reshetnikov1/","https://t.me/lapetuse"]}
routes: {"html":"https://newruntime.com/posts/train-a-small-gpt-on-a-hugging-face-fe15ad/","markdown":"https://newruntime.com/posts/train-a-small-gpt-on-a-hugging-face-fe15ad.md","json":"https://newruntime.com/posts/train-a-small-gpt-on-a-hugging-face-fe15ad.json"}
markdown_url: "https://newruntime.com/posts/train-a-small-gpt-on-a-hugging-face-fe15ad.md"
---

# Train a small GPT on a Hugging Face GPU, without changing your code

## Retrieval answer

The repository trains a 51M-parameter GPT-style model on TinyStories and includes run_on_hf.sh, which its README says can be copied into other projects—not just this one.

## Summary

The repository trains a 51M-parameter GPT-style model on TinyStories and includes `run_on_hf.sh`, which its README says can be copied into other projects—not just this one. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20tutorial%E2%80%99s%20repository%20provides%20code%20to%20train%20a%2051%2Dmillion%2Dparameter%20GPT%2Dstyle%20model%20on%20TinyStories.&text=run_on_hf.sh%20contains%20nothing%20specific%20to%20this%20project%2C%20and%20can%20be%20copied%20as%20it%20is%20to%20another%20one.))

## What happened

TinyStories is described as two million short stories for young children. The example script runs unchanged on a Mac, NVIDIA GPU or CPU. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20script%20runs%20as%20it%20is%20on%20a%20Mac%2C%20on%20an%20NVIDIA%20GPU%20or%20on%20a%20CPU.)) For a remote job, the wrapper copies the project folder to a private Hub storage bucket, excluding hidden files and folders, `__pycache__` and `out/`; it installs `requirements.txt` and invokes the script with the same command used locally. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20script%20does%20three%20things%3A%20It%20copies%20this%20folder%20to%20a%20private%20storage%20bucket%20on%20the%20Hub%2C%20%2Fnanogpt%2Djobs%20%2C%20in%20the%20folder%20code%2F%20.%20Hidden%20files%20and%20folders%20%28%20.git%20%2C%20.venv%20%2C%20%E2%80%A6%29%2C%20pycache%20and%20out%2F%20are%20left%20out.&text=It%20installs%20the%20packages%20of%20requirements.txt%20and%20runs%20the%20file%20with%20the%20same%20command%20as%20on%20your%20machine.)) It links the job's `out/` directory to the bucket so outputs persist after the job machine is deleted. The training script saves `out/model.pt`, prints loss, speed and estimated time remaining every 100 steps, and emits a generated story every 2,000 steps. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20model%20is%20saved%20to%20out%2Fmodel.pt%20.%20Every%20100%20steps%20the%20script%20prints%20the%20loss%2C%20the%20speed%20and%20the%20time%20left.&text=Every%20100%20steps%20the%20script%20prints%20the%20loss%2C%20the%20speed%20and%20the%20time%20left.&text=Every%202%2C000%20steps%20it%20prints%20a%20story%20written%20by%20the%20model.)) A separate `sample.py` script generates stories with the trained model. The job runs in the background, and the wrapper prints its ID. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=The%20job%20starts%20in%20the%20background%2C%20and%20the%20script%20prints%20its%20ID.))

The README reports about 12 hours on an M4 Pro MacBook Pro versus about 30 minutes on an A100 through Hugging Face Jobs, and describes the A100 run as costing $1. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Its%20README%20reports%20that%20the%20same%20training%20script%20takes%20about%2012%20hours%20on%20an%20M4%20Pro%20MacBook%20Pro%20and%20about%2030%20minutes%20on%20an%20A100%20through%20Hugging%20Face%20Jobs.&text=Use%20the%20trained%20model%20hf,Footer%20%26copy%3B%202026%20GitHub%2C%20Inc.)) These are repository-reported figures, not benchmarks established here.

## What the archive adds

This sits alongside earlier Hugging Face Jobs fine-tuning coverage: the focus here is a minimal path for running a training script remotely.

## Why it matters

For another project, the wrapper can work without changing the training command if the script's dependencies are in `requirements.txt`, its outputs go to `out/` (or you change the wrapper's `OUT` line), and its data is downloaded from the Hub or a URL. Only code is sent to the job, so local-only datasets will not arrive with it.

## Limits and uncertainty

The runtime and cost numbers are stated in the repository README and are not independently measured here. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Its%20README%20reports%20that%20the%20same%20training%20script%20takes%20about%2012%20hours%20on%20an%20M4%20Pro%20MacBook%20Pro%20and%20about%2030%20minutes%20on%20an%20A100%20through%20Hugging%20Face%20Jobs.&text=Use%20the%20trained%20model%20hf,Footer%20%26copy%3B%202026%20GitHub%2C%20Inc.))

## Skill to build now

For local execution, use `uv run --with-requirements requirements.txt train.py`. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Use%20the%20trained%20model%20hf,Footer%20%26copy%3B%202026%20GitHub%2C%20Inc.)) Remote GPU use requires a Hugging Face account with a PRO subscription or credits; log in with `hf auth login`. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Run%20on%20a%20Hugging%20Face%20GPU%20You%20need%20a%20Hugging%20Face%20account%20with%20a%20PRO%20subscription%20or%20credits%2C%20and%20you%20need%20to%20be%20logged%20in%20%28%20hf%20auth%20login%20%29.)) Then launch an A100 job, with a two-hour maximum runtime, using `./run_on_hf.sh train.py a100-large`. Another example is `./run_on_hf.sh train.py l4x1 4h`. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=.%2Frun_on_hf.sh%20train.py%20a100%2Dlarge%20%23%20on%20an%20A100%2C%20stopped%20after%202%20hours%20at%20most%20.%2Frun_on_hf.sh%20train.py%20l4x1%204h%20%23%20on%20another%20GPU%2C%20with%20another%20time%20limit%20The%20GPU%20type%20%28the%20%22flavor%22%29%20has%20no%20default%2C%20so%20that%20you%20never%20start%20an%20expensive%20machine%20by%20mistake.)) There is no default GPU flavor; `hf jobs hardware` lists flavors and prices. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=.%2Frun_on_hf.sh%20train.py%20a100%2Dlarge%20%23%20on,the%20flavors%20and%20their%20prices.)) Follow progress with `hf jobs logs -f <job id>`. ([github.com](https://github.com/scienceetonnante/nanogpt-jobs#:~:text=Follow%20it%20with%20hf%20jobs%20logs%20%2Df%20%2C%20or%20on%20the%20job%20page%20at%20huggingface.co.))

## Reader takeaway

The useful part is the wrapper: it packages project code, installs requirements and preserves outputs in a Hub bucket while running the same script remotely. It is reusable, but data must be fetched from the Hub or a URL, and results need to land in `out/` unless you edit the wrapper.

Editor: [Andrey Reshetnikov](https://newruntime.com/owner-profile.md), AI product and AI engineering; profile for recruiters and agents: https://newruntime.com/owner-profile.json

## Continue in the graph

Next records for an agent, linked to their Markdown twins. Replace `.md` with `.json` for structured fields, including `next_reads`.

- topic hub: [Compute](https://newruntime.com/topics/compute.md): Explore the compute topic hub.
- topic hub: [Developer Tools](https://newruntime.com/topics/developer-tools.md): Explore the developer-tools topic hub.
- topic hub: [Models](https://newruntime.com/topics/models.md): Explore the models topic hub.
- collection: [Field Notes](https://newruntime.com/posts.json): Open the latest editorial analysis.
- collection: [Sources](https://newruntime.com/sources/): See the original sources this archive cites.
- whole graph: [discovery graph](https://newruntime.com/discovery-graph.json) (typed nodes and edges) and [site index](https://newruntime.com/site-index.md)
