{"id":5649138,"date":"2023-10-31T20:41:18","date_gmt":"2023-11-01T00:41:18","guid":{"rendered":"https:\/\/lightning.ai\/pages\/?p=5649138"},"modified":"2023-11-14T11:54:02","modified_gmt":"2023-11-14T16:54:02","slug":"doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques","status":"publish","type":"post","link":"https:\/\/lightning.ai\/pages\/community\/tutorial\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/","title":{"rendered":"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques"},"content":{"rendered":"<div class=\"takeaways card-glow p-4 my-4\"><h3 class=\"w-100 d-block\">Takeaways<\/h3>This guide targets PyTorch model training, illustrating how you can adjust the floating point precision to drastically enhance training speed and halve memory consumption, all without compromising the prediction accuracy.<\/div>\n<div id=\"attachment_5649139\" style=\"width: 631px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649139\" class=\" wp-image-5649139\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png\" alt=\"\" width=\"621\" height=\"274\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png 1570w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured-300x132.png 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured-1024x451.png 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured-1536x677.png 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured-300x132@2x.png 600w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><p id=\"caption-attachment-5649139\" class=\"wp-caption-text\">An excerpt of the improvements we can gain from leveraging the techniques introduced in this article.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">In this article, we will work with a vision transformer from PyTorch&#8217;s <\/span><a href=\"https:\/\/pytorch.org\/vision\/stable\/index.html\"><span style=\"font-weight: 400;\">Torchvision<\/span><\/a><span style=\"font-weight: 400;\"> library, providing simple code examples that you can execute on your own machine without the need to download and install numerous code and dataset dependencies. The self-contained baseline training script comprises approximately 100 lines of code, excluding whitespace and code comments.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">All benchmarks were executed using the open source <\/span><a href=\"https:\/\/lightning.ai\/pages\/community\/lightning-releases\/lightning-2.1-train-bigger-better-faster\/\"><span style=\"font-weight: 400;\">Lightning 2.1<\/span><\/a><span style=\"font-weight: 400;\"> package with PyTorch 2.1 and CUDA 12.1 on a single A100 GPU. You can find all code examples <\/span><a href=\"https:\/\/github.com\/rasbt\/ViT-finetuning-scripts\/tree\/main\/precision-benchmarks\/torchvision-vit16-large\"><span style=\"font-weight: 400;\">here on GitHub<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"toc1\"><span style=\"font-weight: 400;\">Finetuning a Vision Transformer on a Single GPU<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">While we are working with a vision transformer here (the ViT-L-16 model from the paper\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/arxiv.org\/abs\/2010.11929\"><span style=\"font-weight: 400;\">An Image is Worth 16&#215;16 Words: Transformers for Image Recognition at Scale<\/span><\/a><span style=\"font-weight: 400;\">), all the techniques used in this article transfer to other models as well: Convolutional networks, large language models (LLMs), and others.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Note that we are finetuning the model for classification instead of training it from scratch to optimize predictive performance.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s begin with a simple baseline in PyTorch. The complete code is available <\/span><a href=\"https:\/\/github.com\/rasbt\/ViT-finetuning-scripts\/blob\/main\/precision-benchmarks\/torchvision-vit16-large\/01_pytorch-fp32.py\"><span style=\"font-weight: 400;\">here on GitHub<\/span><\/a><span style=\"font-weight: 400;\">, which implements and finetunes a vision transformer:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The core code for implementing this vision transformers is as follows:<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\"># Import torchvision\r\nfrom torchvision.models import vit_l_16\r\nfrom torchvision.models import ViT_L_16_Weights\r\n\r\n# Initialize pretrained vision transformer\r\nmodel = vit_l_16(weights=ViT_L_16_Weights.IMAGENET1K_V1)\r\n\r\n# replace output layer\r\nmodel.heads.head = torch.nn.Linear(in_features=1024, out_features=10)\r\n\r\n# finetune model<\/pre>\n<p><span style=\"font-weight: 400;\">The relevant benchmark numbers for this baseline are as follows:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Training runtime: 16.88 min<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">GPU memory: 16.70 GB\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Test accuracy: 94.06%<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2 id=\"toc2\">Introducing the Open Source Fabric Library<\/h2>\n<p><span style=\"font-weight: 400;\">To simplify the PyTorch code for the experiments, we will be introducing the <\/span><a href=\"https:\/\/lightning.ai\/docs\/fabric\/stable\/\"><span style=\"font-weight: 400;\">open-source Fabric library<\/span><\/a><span style=\"font-weight: 400;\">, which allows us to apply various advanced PyTorch techniques (automatic mixed-precision training, multi-GPU training, tensor sharding, etc.) with a handful (instead of dozens) lines of code.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The difference between simple PyTorch code and the modified one to use Fabric is subtle and involves only minor modifications, as highlighted in the code below.<\/span><\/p>\n<div id=\"attachment_5649145\" style=\"width: 2009px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649145\" class=\"size-full wp-image-5649145\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image6.jpg\" alt=\"\" width=\"1999\" height=\"1350\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image6.jpg 1999w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image6-300x203.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image6-1024x692.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image6-1536x1037.jpg 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image6-300x203@2x.jpg 600w\" sizes=\"(max-width: 1999px) 100vw, 1999px\" \/><p id=\"caption-attachment-5649145\" class=\"wp-caption-text\">It requires only a handful of changes to utilize the open-source Fabric library for PyTorch model training.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">As mentioned above, these minor changes now provide a gateway to utilize advanced features in PyTorch, as we will see in a bit, without restructuring any more of the existing code.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To summarize the figure above, the main 3 steps for converting plain PyTorch code to PyTorch+Fabric are as follows:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Since Fabric is a wrapper around PyTorch, it should not affect the runtime of our code, a fact we can confirm via the performance benchmarks below.<\/span><\/p>\n<div id=\"attachment_5649142\" style=\"width: 702px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649142\" class=\" wp-image-5649142\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image3.jpg\" alt=\"\" width=\"692\" height=\"527\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image3.jpg 1346w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image3-300x229.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image3-1024x781.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image3-300x229@2x.jpg 600w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><p id=\"caption-attachment-5649142\" class=\"wp-caption-text\">Training time, memory usage, and prediction accuracy are the same for plain PyTorch and PyTorch augmented with Fabric.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Note that if there are minor differences in the bar plots above, these can be attributed to the randomness inherent in training neural networks and machine fluctuations. If we were to repeat the runs multiple times and examine the averaged results, the bar plots would be exactly the same.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"toc3\"><span style=\"font-weight: 400;\">16-bit Mixed Precision Training<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In the previous section, we modified our PyTorch code using Fabric. Why go through all this hassle? As we will see below, we can now try advanced techniques, like mixed-precision training, by only changing one line of code. (Similarly, we can enable distributed training in one line of code, but this is a topic for a different article.)<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3>Using Mixed-Precision Training<\/h3>\n<p><span style=\"font-weight: 400;\">We can use mixed-precision training with only one small modification, changing<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\">fabric = Fabric(accelerator=\"cuda\", devices=1)<\/pre>\n<p><span style=\"font-weight: 400;\">to the following:<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\">fabric = Fabric(accelerator=\"cuda\", devices=1, precision=\"16-mixed\")<\/pre>\n<p><span style=\"font-weight: 400;\">As we can see in the charts below, using mixed-precision training, we cut down the training time by more than 30%. We also improved the peak memory consumption by more than 25% while maintaining the same prediction accuracy. Based on my personal experience, I observed even more significant gains when working with larger models.<\/span><\/p>\n<div id=\"attachment_5649141\" style=\"width: 1356px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649141\" class=\"size-full wp-image-5649141\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image2.jpg\" alt=\"\" width=\"1346\" height=\"1138\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image2.jpg 1346w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image2-300x254.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image2-1024x866.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image2-300x254@2x.jpg 600w\" sizes=\"(max-width: 1346px) 100vw, 1346px\" \/><p id=\"caption-attachment-5649141\" class=\"wp-caption-text\">Mixed-precision training significantly reduces training time and memory consumption.<\/p><\/div>\n<p>&nbsp;<\/p>\n<h3>What Is Mixed-Precision Training?<\/h3>\n<p><span style=\"font-weight: 400;\">Mixed precision training utilizes both 16-bit and 32-bit precision to ensure no loss in accuracy. The computation of gradients in 16-bit representation is much faster than in 32-bit format, which also saves a significant amount of memory. This strategy is particularly beneficial when we are constrained by memory or computational resources.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The term &#8220;mixed&#8221; rather than &#8220;low&#8221; precision training is used because not all parameters and operations are transferred to 16-bit floats. Instead, we alternate between 32-bit and 16-bit operations during training, hence the term &#8220;mixed&#8221; precision.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">As illustrated in the figure below, mixed precision training involves converting weights to lower precision (16-bit floats, or FP16) for faster computation, calculating gradients, converting gradients back to higher precision (FP32) for numerical stability, and updating the original weights with the scaled gradients.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This approach enables efficient training while maintaining the accuracy and stability of the neural network.<\/span><\/p>\n<div id=\"attachment_5649148\" style=\"width: 471px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649148\" class=\" wp-image-5649148\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image9.jpg\" alt=\"\" width=\"461\" height=\"153\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image9.jpg 1788w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image9-300x99.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image9-1024x339.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image9-1536x509.jpg 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image9-300x99@2x.jpg 600w\" sizes=\"(max-width: 461px) 100vw, 461px\" \/><p id=\"caption-attachment-5649148\" class=\"wp-caption-text\">An overview of mixed-precision training. For additional details, I also cover this concept in <a href=\"https:\/\/lightning.ai\/courses\/deep-learning-fundamentals\/9.0-overview-techniques-for-speeding-up-model-training\/unit-9.1-accelerated-model-training-via-mixed-precision-training\/\">Unit 9.1<\/a> of my Deep Learning Fundamentals class.<\/p><\/div>\n<p>&nbsp;<\/p>\n<h2 id=\"toc4\"><span style=\"font-weight: 400;\">Full 16-bit Precision Training<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">We can also take it a step further and attempt running with &#8220;full&#8221; lower 16-bit precision, as opposed to mixed precision, which converts intermediate results back to a 32-bit representation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We can enable lower-precision training by changing<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\">fabric = Fabric(accelerator=\"cuda\", precision=\"16-mixed\")<\/pre>\n<p><span style=\"font-weight: 400;\">to the following:<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\">fabric = Fabric(accelerator=\"cuda\", precision=\"16-true\")<\/pre>\n<p><span style=\"font-weight: 400;\">(Note that &#8220;16-true&#8221; is a new feature in <\/span><a href=\"https:\/\/lightning.ai\/pages\/community\/lightning-releases\/lightning-2.1-train-bigger-better-faster\/\"><span style=\"font-weight: 400;\">Lightning 2.1<\/span><\/a><span style=\"font-weight: 400;\"> and is not available in older versions.)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">However, you may notice that when running this code, you\u2019ll encounter NaN values in the loss:<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\"><span style=\"font-weight: 400;\">Epoch: 0001\/0001 | Batch 0000\/0703 | Loss: 2.4105\r\nEpoch: 0001\/0001 | Batch 0300\/0703 | Loss: nan\r\nEpoch: 0001\/0001 | Batch 0600\/0703 | Loss: nan\r\n...<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">This is because regular 16-bit floats can only represent numbers between -65,504 and 65,504:<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\">In [1]: import torch<\/pre>\n<pre class=\"hljs collapse-false language-python\">In [2]: torch.finfo(torch.float16)\r\nOut[2]: finfo(resolution=0.001, min=-65504, max=65504, eps=0.000976562, smallest_normal=6.10352e-05, tiny=6.10352e-05, dtype=float16)<\/pre>\n<p><span style=\"font-weight: 400;\">To avoid this NaN issue, we can use bfloat16, an alternative to 16-bit floating points, which will be discussed in the next section.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"toc5\"><span style=\"font-weight: 400;\">Full 16-bit Precision Training with BFloat-16<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">To circumvent the NaN issue we encountered with full 16-bit precision training in the previous section, we can utilize an alternative 16-bit format called bfloat16. This can be implemented using the &#8220;bf16-true&#8221; setting in Fabric:<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\">fabric = Fabric(accelerator=\"cuda\", precision=\"bf16-true\")<\/pre>\n<p><span style=\"font-weight: 400;\">(Note that bfloat16 can also be used for mixed precision training, and the results are included in the chart below.)<\/span><\/p>\n<div id=\"attachment_5649146\" style=\"width: 1594px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649146\" class=\"size-full wp-image-5649146\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image7.jpg\" alt=\"\" width=\"1584\" height=\"694\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image7.jpg 1584w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image7-300x131.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image7-1024x449.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image7-1536x673.jpg 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image7-300x131@2x.jpg 600w\" sizes=\"(max-width: 1584px) 100vw, 1584px\" \/><p id=\"caption-attachment-5649146\" class=\"wp-caption-text\">Full bfloat16 training does not suffer from the same stability issues as regular 16-bit precision training for this particular vision transformer.<\/p><\/div>\n<p><span style=\"font-weight: 400;\">But more impressively, by employing full bfloat16 training, we can achieve another significant improvement over mixed-precision training in terms of speed. And compared to the original 32-bit floating point training, which is the default option in deep learning (the first row, <\/span><span style=\"font-weight: 400;\">01_pytorch-fp32.py<\/span><span style=\"font-weight: 400;\">), we can halve the training time.<\/span><\/p>\n<div id=\"attachment_5649144\" style=\"width: 1600px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649144\" class=\"size-full wp-image-5649144\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image5.jpg\" alt=\"\" width=\"1590\" height=\"704\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image5.jpg 1590w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image5-300x133.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image5-1024x453.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image5-1536x680.jpg 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image5-300x133@2x.jpg 600w\" sizes=\"(max-width: 1590px) 100vw, 1590px\" \/><p id=\"caption-attachment-5649144\" class=\"wp-caption-text\">Full bfloat16 training is substantially faster than mixed-precision training, and it is about twice as fast as regular 32-bit precision training.<\/p><\/div>\n<p><span style=\"font-weight: 400;\">Just as using the bfloat16 format can halve training time, it also offers substantial memory savings, allowing us to train larger models on smaller GPUs.<\/span><\/p>\n<div id=\"attachment_5649147\" style=\"width: 1580px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5649147\" class=\"size-full wp-image-5649147\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image8.jpg\" alt=\"\" width=\"1570\" height=\"704\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image8.jpg 1570w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image8-300x135.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image8-1024x459.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image8-1536x689.jpg 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image8-300x135@2x.jpg 600w\" sizes=\"(max-width: 1570px) 100vw, 1570px\" \/><p id=\"caption-attachment-5649147\" class=\"wp-caption-text\">Bf16-training requires substantially less memory compared to mixed-precision training.<\/p><\/div>\n<p><span style=\"font-weight: 400;\">In my experiments, full bfloat16 training didn&#8217;t compromise prediction accuracy. However, this might not hold true for all models. When working with new architectures, it&#8217;s crucial to verify this. If you observe a decline in predictive performance with bfloat16 (even after running the training for just a few epochs or iterations), I recommend transitioning to 16-mixed or b16-mixed. Mixed precision training typically matches the performance of full 32-bit training.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3>What Is Bfloat16?<\/h3>\n<p><span style=\"font-weight: 400;\">The \u201cbf16\u201d in <\/span><span style=\"font-weight: 400;\">&#8220;bf16-true&#8221;<\/span><span style=\"font-weight: 400;\"> stands for <\/span><a href=\"https:\/\/cloud.google.com\/tpu\/docs\/bfloat16\"><span style=\"font-weight: 400;\">Brain Floating Point<\/span><\/a><span style=\"font-weight: 400;\"> (bfloat16). Google developed this format for machine learning and deep learning applications, particularly in their Tensor Processing Units (TPUs). Bfloat16 extends the dynamic range compared to the conventional float16 format at the expense of decreased precision.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5649143\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image4.jpg\" alt=\"\" width=\"608\" height=\"472\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image4.jpg 1640w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image4-300x233.jpg 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image4-1024x795.jpg 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image4-1536x1193.jpg 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16image4-300x233@2x.jpg 600w\" sizes=\"(max-width: 608px) 100vw, 608px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Bfloat16&#8217;s extended dynamic range allows it to represent very large and very small numbers effectively, making it well-suited for deep learning applications with their wide value ranges.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Although its lower precision could impact certain calculations or introduce rounding errors, this typically has a negligible effect on the overall performance in many deep learning tasks.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0Initially developed for TPUs, bfloat16 is now also supported by various NVIDIA GPUs, starting with the A100 Tensor Core GPUs that belong to the NVIDIA Ampere architecture.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can check whether your GPU supports <\/span><span style=\"font-weight: 400;\">bfloat16<\/span><span style=\"font-weight: 400;\"> via the following code:<\/span><\/p>\n<pre class=\"hljs collapse-false language-python\">&gt;&gt;&gt; import torch\r\n&gt;&gt;&gt; torch.cuda.is_bf16_supported()\r\nTrue<\/pre>\n<p>&nbsp;<\/p>\n<h2 id=\"toc6\"><span style=\"font-weight: 400;\">Conclusion<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In this article, we explored how low-precision training techniques can speed up PyTorch model training by a factor of 2 and halve peak memory consumption. This enables the training of larger models on less expensive hardware. Notably, employing full bfloat16 precision, which is now supported in Lightning 2.1, was able to preserve the model&#8217;s prediction accuracy, so using it can be a cost-effective and efficient strategy for scaling deep learning tasks without sacrificing performance.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">If you found this article useful, consider sharing it with your colleagues. For any questions or suggestions, feel free to join our <\/span><a href=\"https:\/\/discord.com\/invite\/XncpTy7DSt\"><span style=\"font-weight: 400;\">Discord community<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; In this article, we will work with a vision transformer from PyTorch&#8217;s Torchvision library, providing simple code examples that you can execute on your own machine without the need to download and install numerous code and dataset dependencies. The self-contained baseline training script comprises approximately 100 lines of code, excluding whitespace and code comments.<a class=\"excerpt-read-more\" href=\"https:\/\/lightning.ai\/pages\/community\/tutorial\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\" title=\"ReadDoubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques\">&#8230; Read more &raquo;<\/a><\/p>\n","protected":false},"author":16,"featured_media":5649139,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[29,106,41],"tags":[96,31,186,111,51],"glossary":[],"acf":{"additional_authors":false,"hide_from_archive":false,"content_type":"Blog Post","sticky":false,"code_embed":false,"custom_styles":"main h2 {\r\n    scroll-margin-top: 75px;\r\n    scroll-padding-top: 75px;\r\n}","mathjax":false,"default_editor":true,"show_table_of_contents":true,"tabs":false,"table_of_contents":"<h4>Table of Contents<\/h4>\n<ul>\n<li><a href=\"#toc1\">Finetuning a Vision Transformer on a Single GPU<\/a><\/li>\n<li><a href=\"#toc2\">Introducing the Open Source Fabric Library<\/a><\/li>\n<li><a href=\"#toc3\">16-bit Mixed Precision Training<\/a><\/li>\n<li><a href=\"#toc4\">Full 16-bit Precision Training<\/a><\/li>\n<li><a href=\"#toc5\">Full 16-bit Precision Training with BFloat-16<\/a><\/li>\n<li><a href=\"#toc6\">Conclusion<br \/>\n<\/a><\/li>\n<\/ul>\n"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques - Lightning AI<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques - Lightning AI\" \/>\n<meta property=\"og:description\" content=\"&nbsp; In this article, we will work with a vision transformer from PyTorch&#8217;s Torchvision library, providing simple code examples that you can execute on your own machine without the need to download and install numerous code and dataset dependencies. The self-contained baseline training script comprises approximately 100 lines of code, excluding whitespace and code comments.... Read more &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\" \/>\n<meta property=\"og:site_name\" content=\"Lightning AI\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-01T00:41:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-14T16:54:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1570\" \/>\n\t<meta property=\"og:image:height\" content=\"692\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"JP Hennessy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@LightningAI\" \/>\n<meta name=\"twitter:site\" content=\"@LightningAI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"JP Hennessy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\"},\"author\":{\"name\":\"JP Hennessy\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6\"},\"headline\":\"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques\",\"datePublished\":\"2023-11-01T00:41:18+00:00\",\"dateModified\":\"2023-11-14T16:54:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\"},\"wordCount\":1494,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png\",\"keywords\":[\"ai\",\"deep learning\",\"finetuning\",\"Open Source\",\"pytorch\"],\"articleSection\":[\"Blog\",\"Community\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\",\"url\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\",\"name\":\"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques - Lightning AI\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png\",\"datePublished\":\"2023-11-01T00:41:18+00:00\",\"dateModified\":\"2023-11-14T16:54:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage\",\"url\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png\",\"contentUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png\",\"width\":1570,\"height\":692,\"caption\":\"An excerpt of the improvements we can gain from leveraging the techniques introduced in this article.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lightning.ai\/pages\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lightning.ai\/pages\/#website\",\"url\":\"https:\/\/lightning.ai\/pages\/\",\"name\":\"Lightning AI\",\"description\":\"The platform for teams to build AI.\",\"publisher\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lightning.ai\/pages\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\",\"name\":\"Lightning AI\",\"url\":\"https:\/\/lightning.ai\/pages\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png\",\"contentUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png\",\"width\":1744,\"height\":856,\"caption\":\"Lightning AI\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/LightningAI\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6\",\"name\":\"JP Hennessy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g\",\"caption\":\"JP Hennessy\"},\"url\":\"https:\/\/lightning.ai\/pages\/author\/jplightning-ai\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques - Lightning AI","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/","og_locale":"en_US","og_type":"article","og_title":"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques - Lightning AI","og_description":"&nbsp; In this article, we will work with a vision transformer from PyTorch&#8217;s Torchvision library, providing simple code examples that you can execute on your own machine without the need to download and install numerous code and dataset dependencies. The self-contained baseline training script comprises approximately 100 lines of code, excluding whitespace and code comments.... Read more &raquo;","og_url":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/","og_site_name":"Lightning AI","article_published_time":"2023-11-01T00:41:18+00:00","article_modified_time":"2023-11-14T16:54:02+00:00","og_image":[{"width":1570,"height":692,"url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png","type":"image\/png"}],"author":"JP Hennessy","twitter_card":"summary_large_image","twitter_creator":"@LightningAI","twitter_site":"@LightningAI","twitter_misc":{"Written by":"JP Hennessy","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#article","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/"},"author":{"name":"JP Hennessy","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6"},"headline":"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques","datePublished":"2023-11-01T00:41:18+00:00","dateModified":"2023-11-14T16:54:02+00:00","mainEntityOfPage":{"@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/"},"wordCount":1494,"commentCount":0,"publisher":{"@id":"https:\/\/lightning.ai\/pages\/#organization"},"image":{"@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png","keywords":["ai","deep learning","finetuning","Open Source","pytorch"],"articleSection":["Blog","Community","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/","url":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/","name":"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques - Lightning AI","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage"},"image":{"@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png","datePublished":"2023-11-01T00:41:18+00:00","dateModified":"2023-11-14T16:54:02+00:00","breadcrumb":{"@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#primaryimage","url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png","contentUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/10\/bf16-featured.png","width":1570,"height":692,"caption":"An excerpt of the improvements we can gain from leveraging the techniques introduced in this article."},{"@type":"BreadcrumbList","@id":"https:\/\/lightning.ai\/pages\/blog\/doubling-neural-network-finetuning-efficiency-with-16-bit-precision-techniques\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lightning.ai\/pages\/"},{"@type":"ListItem","position":2,"name":"Doubling Neural Network Finetuning Efficiency with 16-bit Precision Techniques"}]},{"@type":"WebSite","@id":"https:\/\/lightning.ai\/pages\/#website","url":"https:\/\/lightning.ai\/pages\/","name":"Lightning AI","description":"The platform for teams to build AI.","publisher":{"@id":"https:\/\/lightning.ai\/pages\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lightning.ai\/pages\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/lightning.ai\/pages\/#organization","name":"Lightning AI","url":"https:\/\/lightning.ai\/pages\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/","url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png","contentUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png","width":1744,"height":856,"caption":"Lightning AI"},"image":{"@id":"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/LightningAI"]},{"@type":"Person","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6","name":"JP Hennessy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g","caption":"JP Hennessy"},"url":"https:\/\/lightning.ai\/pages\/author\/jplightning-ai\/"}]}},"_links":{"self":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts\/5649138"}],"collection":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/comments?post=5649138"}],"version-history":[{"count":0,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts\/5649138\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media\/5649139"}],"wp:attachment":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media?parent=5649138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/categories?post=5649138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/tags?post=5649138"},{"taxonomy":"glossary","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/glossary?post=5649138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}