There are GitHub repos with the code from Sebastian Raschka's books, which build an LLM from scratch in PyTorch (some examples run fine even on CPU-only setups) using a GPT-2-like architecture, as well as his new book on reasoning models that came out recently.
[Off-topic] Your name sounds familiar...