Overview
Appendix D. Using larger LLMs
This appendix explains that the from-scratch Qwen3 implementation used for the small 0.6B model can also load larger checkpoints with only minor adjustments. The main steps are to choose the correct configuration dictionary, download the desired model weights, and use the right tokenizer for either the base or reasoning version. A 4B model is used as the main example because it is significantly stronger than 0.6B while still being more manageable than the larger variants.
The larger dense Qwen3 models follow the same overall architecture pattern as the 0.6B version, including token embeddings, grouped-query attention, rotary position embeddings, feed-forward layers, and RMS normalization. What changes are the scale-related dimensions, such as embedding size, layer count, attention heads, and hidden dimensions. The appendix also gives rough memory estimates for loading these models, emphasizing that actual runtime memory is higher than the raw parameter size because of activations, buffers, and the KV cache.
To load a larger base model, the workflow is to download the Hugging Face snapshot, instantiate Qwen3Model with the matching configuration, map the weights into the custom implementation, and prepare the base tokenizer before generating text. For reasoning variants, the architecture stays the same but the repository, tokenizer filename, and tokenizer settings change so that chat formatting and thinking behavior are enabled. The main takeaway is that scaling up within the same model family is straightforward once the loading pipeline is in place, and the inference code remains essentially unchanged.
D.5 Practical recommendations
The main point of this appendix is that the same from-scratch model code from appendix C can be reused across larger official Qwen3 checkpoints, provided that we select the matching configuration dictionary and tokenizer setup.
This means moving to a larger model is mostly a matter of loading a different checkpoint and configuration rather than learning an entirely new concept.
If you want to experiment beyond the 4B example shown here, the 1.7B and 8B variants are natural next steps. The 1.7B model is a modest step up from 0.6B, in case the 4B is too resource-intensive for your hardware. The 8B model is substantially larger and may give stronger outputs if your hardware can handle it.
FAQ
What are the main steps for moving from the 0.6B Qwen3 model to a larger Qwen3 checkpoint?
Once you understand the 0.6B model, moving to a larger Qwen3 checkpoint mainly involves three changes: selecting the matching configuration dictionary, downloading the larger checkpoint from Hugging Face, and loading the correct tokenizer for either the base or reasoning variant.
Which larger Qwen3 model is used as the example in Appendix D, and why?
The appendix uses the Qwen3 4B model as the main example because it is clearly stronger than the 0.6B model, but still easier to handle than the larger 8B, 14B, and 32B variants.
Which larger dense Qwen3 configurations are listed in the repository?
The repository includes dense Qwen3 configuration dictionaries for 1.7B, 4B, 8B, 14B, and 32B models. Each size has a matching configuration Python dictionary in the appendix C library.
What does “dense” mean in the context of the Qwen3 models in Table D.1?
“Dense” means these models are not sparse Mixture-of-Experts (MoE) variants. The book’s code supports the dense Qwen3 models, not the MoE versions.
How do the larger Qwen3 variants differ from the 0.6B model architecturally?
The overall architecture stays the same: token embeddings, grouped-query attention, rotary position embeddings, feed-forward layers, and RMS normalization. What changes are the model dimensions, such as embedding size, number of layers, number of attention heads, and feed-forward hidden dimension.
What are the approximate memory requirements for the larger Qwen3 models in bfloat16?
Using bfloat16 weights as a rough lower bound, the memory estimates are about 3.4 GB for 1.7B, 8 GB for 4B, 16 GB for 8B, 28 GB for 14B, and 64 GB for 32B.
Why is the real runtime memory usage higher than the weight-size estimates?
The estimates only cover the weights themselves. In practice, extra memory is needed for activations, temporary buffers, the KV cache, and other runtime overhead. Loading can also briefly use more memory because tensors may exist in multiple places during copying.
How are larger Qwen3 checkpoints typically distributed?
Unlike the converted 0.6B checkpoint used in the main chapters, larger official Qwen3 models are usually distributed as safetensors files, sometimes split across multiple shards.
What helper function is used to download larger Qwen3 checkpoints from Hugging Face?
The book uses download_from_huggingface_from_snapshots from the reasoning-from-scratch library. It downloads the Hugging Face snapshot locally and loads either a single model.safetensors file or multiple shards referenced by a model.safetensors.index.json file.
What changes are needed to load the 4B reasoning variant instead of the 4B base variant?
You switch the repository ID from Qwen/Qwen3-4B-Base to Qwen/Qwen3-4B, copy or rename tagger>tokenizer.json to tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger>tagger