A computer can store a number with lots of detail, or with less detail. Less detail means less memory, but less precision. The format is called the data type, or d type.
Float thirty two uses four bytes. It's very precise, and it's the default for training on a CPU. Float sixteen uses two bytes, but it can't hold very large numbers. B float sixteen also uses two bytes, and it can hold huge numbers, with less precision. It's the favourite for modern training. And int eight, and four bit formats, use even less. We'll meet those later, with QLoRA.
Let's store pi, in three data types. Item gives us the stored value back. Element size gives the bytes per number. Then we print the largest number each sixteen bit type can hold. Run it. Float thirty two keeps seven correct digits. The sixteen bit types keep only three. And look at the maximum. Float sixteen stops at sixty five thousand. B float sixteen goes up to a number with thirty eight zeros.
During training, some numbers get very big. In float sixteen, they can overflow, which means they become infinity, and training breaks. B float sixteen has the same big range as float thirty two. So it's half the memory, and it rarely breaks. Most modern GPUs support it.
Let's recap. The data type sets how many bytes each number uses. Float thirty two is precise, but large. B float sixteen is half the size, with a big range. That's why it's the favourite for training. Next, why training needs much more memory than just the weights.