Anvaya-1B
Anvaya-1B is a 1,018,126,848-parameter dense decoder-only language model pretrained from random Transformer initialization on FineWeb-derived tokens as an educational systems project: training a real billion-parameter model on 2×16GB NVIDIA Tesla T4 GPUs.
The reference run is complete. It reached its configured whole-update training boundary at u11445 / 1,500,119,040 model-input tokens. The default main revision contains that final model-only FP16 export.
“From scratch” refers to the Transformer weights. The tokenizer is reused from the Llama 3.2 1B tokenizer family rather than trained in this project.
Final checkpoint
| Field | Value |
|---|---|
| Parameters | 1,018,126,848 |
| Final checkpoint | u11445 |
| Model-input tokens | 1,500,119,040 |
| Context length | 4096 |
| Layers / width / heads | 29 / 1536 / 24 |
| FFN width | 6144 |
| Vocabulary | 128,256 |
| Training hardware | 2× Tesla T4 16 GB |
| Distributed strategy | PyTorch FSDP FULL_SHARD |
| Public export dtype | FP16 |
| Validation NLL | 3.212374 |
| Validation perplexity | 24.83799 |
| Validation token accuracy | 39.3593% |
| Validation sample | 131,072 tokens |
The trainer saved u11445, evaluated that exact checkpoint, and terminated normally with [complete] reached training token target.
Public training-checkpoint lineage
Anvaya-1B is published as one model repository with immutable training revisions. This preserves the evolution of the same architecture during pretraining rather than presenting the checkpoints as separate models.
| Revision | Update | Exact model-input tokens | Validation NLL | PPL | Token accuracy |
|---|---|---|---|---|---|
160M |
1,225 | 160,563,200 | 4.75070 | 115.67 | 25.21% |
240M |
1,829 | 239,730,688 | 4.26552 | 71.20 | 30.09% |
320M |
2,436 | 319,291,392 | 3.98411 | 53.74 | 32.38% |
400M |
3,031 | 397,279,232 | 3.81320 | 45.30 | 33.69% |
560M |
4,269 | 559,546,368 | 3.58536 | 36.07 | 35.71% |
800M |
6,042 | 791,937,024 | 3.41344 | 30.37 | 37.31% |
1B |
7,879 | 1,032,716,288 | 3.30334 | 27.20 | 38.32% |
1.2B |
9,090 | 1,191,444,480 | 3.25586 | 25.94 | 38.92% |
1.35B |
10,282 | 1,347,682,304 | 3.22915 | 25.26 | 39.13% |
1.5B-final |
11,445 | 1,500,119,040 | 3.21237 | 24.84 | 39.36% |
main points to the final model. Earlier revisions remain frozen historical checkpoints.
Loading the final model
import os
import torch
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
repo_id = "Vijayendra/Anvaya-1B"
revision = "1.5B-final"
model_dir = snapshot_download(
repo_id=repo_id,
revision=revision,
token=os.environ.get("HF_TOKEN"),
)
import sys
sys.path.insert(0, model_dir)
from modeling_anvaya import Anvaya1B
tokenizer = AutoTokenizer.from_pretrained(
model_dir,
use_fast=True,
)
device = "cuda" if torch.cuda.is_available() else "cpu"
model = Anvaya1B.from_local_dir(
model_dir,
dtype=torch.float16,
device=device,
)
To load an earlier point in training, change only the revision:
revision = "160M"
# or "240M", "320M", "400M", "560M", "800M",
# "1B", "1.2B", "1.35B", "1.5B-final"
The reference model implementation intentionally stays close to the training code and does not implement a KV cache.
Architecture
The architecture is deliberately conventional so that the project focuses on the engineering of billion-parameter pretraining rather than a novel model design:
- 29 decoder blocks
- hidden width 1536
- 24 attention heads × 64 dimensions
- FFN width 6144
- RMSNorm
- half-split RoPE
- dense causal PyTorch SDPA
- standard two-layer GELU MLP
- tied input/output embeddings
- context length 4096
This is a dense model and is not an SCA checkpoint.
Training system
The run uses:
- 2× NVIDIA Tesla T4 16 GB
- PyTorch FSDP
FULL_SHARD - activation checkpointing
- FP16 mixed precision
- gradient accumulation
- 131,072 model-input tokens per optimizer update
- fixed 131,072-token validation
- transactional COMPLETE-only distributed checkpoints
- immutable mounted-parent continuation across temporary Kaggle sessions
The recorded rank-0 PyTorch allocator high-water mark was approximately 11.41 GiB.
Data and tokenizer
Training uses tokenized data derived from HuggingFaceFW/fineweb, revision v1.4.0, config CC-MAIN-2025-26.
Historical corpus contract:
- 1.485B training tokens
- 15M validation tokens
- 24 training shards
- little-endian uint32 token IDs
- vocabulary size 128,256
Tokenizer family: meta-llama/Llama-3.2-1B, vocabulary 128,256, EOS 128001.
The sampler draws deterministic 4096-token windows with replacement, so the reported training number is a model-input token ledger, not a claim that every corpus token was seen exactly once.
Export and provenance
Each public revision was reconstructed from a COMPLETE two-rank FSDP training checkpoint and exported as model-only FP16 safetensors.
The release pipeline verifies:
- exact architecture and tensor names/shapes
- exact 1,018,126,848 parameter count
- tokenizer identity
- safetensors package completeness
- SHA-256 file hashes
- finite-logits forward smoke test when CUDA is available
Raw optimizer and GradScaler state are not part of the user-facing model package.
Full trainer, data contract, checkpoint protocol, validation ledger, and engineering documentation:
https://github.com/VijayendraDwari/pretrain-1b-on-2xT4
What the run demonstrates
This project demonstrates that a real 1.018B-parameter dense language model can be continuously pretrained from random initialization at 4K context on two 16 GB T4 GPUs using a carefully designed sharding, accumulation, checkpointing and continuation system.
The public checkpoint lineage also makes it possible to study how generation behavior changes as pretraining progresses.
Limitations
This is an educational and systems-focused run, not a competitive production foundation model.
In particular:
- 1.5B model-input tokens is a deliberately limited training budget for a 1B-parameter model;
- no comprehensive downstream benchmark suite is claimed here;
- the reference implementation has no KV cache and is not optimized for serving;
- the model can generate inaccurate, incoherent, biased, repetitive or unsafe text;
- next-token validation metrics do not establish general reasoning or factual capability;
- the project does not claim architectural novelty, compute optimality, or performance superiority over modern pretrained models.
Do not use the model for high-stakes decisions.
Licensing
The original training/model code in the GitHub project is MIT-licensed.
The weights repository remains marked license: other until a dedicated weights license is explicitly selected. Tokenizer and dataset artifacts retain their upstream terms. Nothing in this repository overrides third-party licenses or terms.
Author
Vijayendra Dwari
- Downloads last month
- 315