Instructions to use Venkatesulu/training_for_practice with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Venkatesulu/training_for_practice with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Venkatesulu/training_for_practice")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Venkatesulu/training_for_practice", device_map="auto") - PEFT
How to use Venkatesulu/training_for_practice with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Venkatesulu/training_for_practice with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Venkatesulu/training_for_practice" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Venkatesulu/training_for_practice", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Venkatesulu/training_for_practice
- SGLang
How to use Venkatesulu/training_for_practice with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Venkatesulu/training_for_practice" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Venkatesulu/training_for_practice", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Venkatesulu/training_for_practice" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Venkatesulu/training_for_practice", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Venkatesulu/training_for_practice with Docker Model Runner:
docker model run hf.co/Venkatesulu/training_for_practice
training_for_practice
Two complete, tested LLM training systems, plus one small model actually trained with them. Built end to end on a 2012 laptop β an Intel i3-3110M, 8 GB RAM, no GPU β which is the point: the constraint forces every step to be measured rather than assumed.
mmllm/ |
A multimodal LLM pretrained from scratch β architecture, tokenizer, data pipeline, training loop. 38 tests. |
finetune/ |
LoRA fine-tuning of an existing model, with a hand-rolled LoRA implementation. 38 tests. |
model/ |
A SmolLM2-135M LoRA fine-tune produced by finetune/. |
β οΈ Read this before using the model
The model in model/ is a practice artifact, not a useful model. It is 135M
parameters trained for 60 steps. It is published to show that the pipeline works,
not because the result is good.
- It learned format, not knowledge. Asked what a function does, it answers in the right terse docstring register β and frequently invents the content.
- On at least one held-out prompt it degenerates into a repetition loop.
- Training data provenance: it was fine-tuned on 5,249 question/answer pairs generated automatically from a private codebase's Markdown docs and Python docstrings. That dataset is not included in this repo. The model may surface file and symbol names from that codebase.
Do not use it for anything real. Use the code.
What the model actually achieved
Trained on CPU, 60 steps, ~20 tokens/second.
| Measurement | Base | Fine-tuned | Change |
|---|---|---|---|
| Held-out loss (identical 40 batches) | 2.9769 | 2.5900 | β0.3869 |
| Perplexity | 19.6 | 13.3 | β32% |
| Validation loss during training | 3.4212 | 2.8850 | β0.5362 |
| Trainable parameters | β | 4,884,480 | 3.5% of 139M |
A representative before/after, on a held-out prompt:
Q: What does the
storefunction do?Base: sixty words inventing a plausible-sounding data structure it had never seen β fluent, confident, and entirely wrong.
Tuned: "Store the entry for later retrieval."
Reference: "Store entry with embedding for semantic search."
The register is right. The content is still wrong. That is what 135M parameters and 60 steps buys.
The interesting part: the code
finetune/ β LoRA, implemented directly
LoRA is ~60 lines, written out rather than pulled from peft, so it can be tested
exactly and does not break when adapter libraries lag a transformers release.
W_effective = W_frozen + (alpha/r) * B @ A A: (r, in) B: (out, r)
B starts at zero, so an untrained adapter is bit-identical to the base model β a
free correctness check before you spend anything.
pip install -r finetune/requirements.txt
PYTHONPATH=finetune/src python -m ft.build_dataset --input /path/to/repo --out data
PYTHONPATH=finetune/src python -m ft.train --config finetune/configs/smol135m_cpu.yaml
PYTHONPATH=finetune/src python -m ft.evaluate --adapter runs/smol135m/adapter_best.pt
PYTHONPATH=finetune/src python -m ft.merge --adapter runs/smol135m/adapter_best.pt --out export/
ft.planner prices a run β time, cost and peak GPU memory including activations β
from a model's config.json alone, without downloading weights.
mmllm/ β pretraining from scratch
A hybrid architecture built for long context: most layers are linear-time state-space (Mamba-2 SSD) rather than attention, because at 300k tokens the KV cache, not compute, is the binding constraint.
| Design | KV cache at 300k ctx |
|---|---|
| This hybrid (22 SSD / 5 sliding-window / 5 global, GQA-2) | 1.47 GiB |
| All layers global attention, same GQA | 9.16 GiB (6.2Γ) |
| All layers conventional MHA | 73.24 GiB (49.8Γ) |
scripts/trace_pipeline.py walks one real batch through all sixteen stages β raw text,
cleaning, tokenizer, ids, embeddings, layers, attention, next-token prediction, target
comparison, loss, backward, gradients, optimizer, weight update β printing the actual
tensors at each step. It is the fastest way to understand what training does.
Why the tests exist
Both packages ship tests that pin failure modes producing a plausible-looking but wrong run rather than a crash. Those are the only ones worth the compute. A sample:
| Test | Failure it prevents |
|---|---|
| Prompt tokens are masked | Without it, most of the gradient teaches the model to generate user questions β and the loss curve looks perfectly healthy |
| Drop-rate guard | A max_len shorter than your data yields an empty training set, silently. On a reasoning dataset with 7,700-token median, max_len=1024 keeps zero examples |
| JSONL line-breaker escaping | json.dumps(ensure_ascii=False) leaves U+0085/U+2028/U+2029 raw; str.splitlines(), jq and pandas all treat them as newlines. This shredded 11 records before it was caught |
| Merge is numerically equivalent (float64) | Shipping a different model than the one you evaluated |
| LoRA adapter dtype matches base | Harmless on CPU; fatal on every bf16 GPU run |
| Cached generation == full forward | Decode path drifting from training path |
| SSD chunked scan == reference scan | The whole long-context argument rests on this |
Ten real bugs were found this way during development. Every one was silent.
Hardware reality
Measured, not estimated:
| Peak matmul throughput | 24 GFLOP/s (i3-3110M, 2 cores, CPU only) |
| Achieved in training | ~11.7 GFLOP/s (48% MFU) |
| From-scratch pretraining of a useful model | ~10β·Γ beyond this machine |
That gap is why the repo contains a fine-tuned model and not a pretrained one, and why
planner.py exists. Fine-tuning a 7B model on a rented A100 costs single-digit dollars;
pretraining a 2B model costs ~19,600 GPU-hours. For domain adaptation, fine-tuning wins
by roughly five orders of magnitude.
License
Apache-2.0. The base model is SmolLM2-135M-Instruct, also Apache-2.0.
Model tree for Venkatesulu/training_for_practice
Base model
HuggingFaceTB/SmolLM2-135M