{"id":5649153,"date":"2023-11-01T15:35:27","date_gmt":"2023-11-01T19:35:27","guid":{"rendered":"https:\/\/lightning.ai\/pages\/?p=5649153"},"modified":"2023-11-02T10:10:32","modified_gmt":"2023-11-02T14:10:32","slug":"quickstart-to-lightning-fabric","status":"publish","type":"post","link":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/","title":{"rendered":"Quickstart to Lightning Fabric"},"content":{"rendered":"<div class=\"takeaways card-glow p-4 my-4\"><h3 class=\"w-100 d-block\">Takeaways<\/h3> Readers will learn how to convert and scale PyTorch models and training loops with Lightning Fabric. <\/div>\n<h2>Introduction<\/h2>\n<p>Some engineers may prefer the greatest amount of control as possible over their PyTorch training loop. Yet, those same engineers also know the benefits of a lightweight, production ready framework that handles the heavy lifting when it comes to SOTA distributed training features.<\/p>\n<h2>The Power of Lightning Fabric<\/h2>\n<p><a href=\"https:\/\/lightning.ai\/docs\/fabric\/stable\/\" target=\"_blank\" rel=\"noopener\">Lightning Fabric<\/a> does this heavy lifting by enabling researchers and machine learning engineers to train PyTorch models at scale \u2013 and with minimal code changes. In as few as five lines, Lightning Fabric orchestrates training across multi-GPU and multi-Node environments. Letting you focus on the science behind your model, instead of the engineering.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-5649154\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-1024x722.png\" alt=\"\" width=\"1024\" height=\"722\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-1024x722.png 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-300x212.png 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-1536x1083.png 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-2048x1444.png 2048w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-300x212@2x.png 600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>The image above shows how easy it is to implement Lightning Fabric into PyTorch training logic. Below we can see where Lightning Fabric fits into the PyTorch ecosystem, in that it is used to train domain specific models in research areas like audio, vision, and text (i.e. LLMs).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5649155 size-large\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/PyTorch-Lightning-and-Fabric-2-e1698865256927-1024x428.png\" alt=\"\" width=\"1024\" height=\"428\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/PyTorch-Lightning-and-Fabric-2-e1698865256927-1024x428.png 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/PyTorch-Lightning-and-Fabric-2-e1698865256927-300x125.png 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/PyTorch-Lightning-and-Fabric-2-e1698865256927-768x321.png 768w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/PyTorch-Lightning-and-Fabric-2-e1698865256927.png 1229w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>Given the previous image \u2013 let\u2019s take note that Lightning Fabric is not a replacement for PyTorch. Instead, Lightning Fabric integrates into vanilla PyTorch training loops. And it does this via a powerful Core API \u2013 which we will discuss below.<\/p>\n<h2>Lightning Fabric\u2019s Core API<\/h2>\n<p>Lightning Fabric has just one Core API class \u2013 Fabric. Fabric can be used to configure your environment with <a href=\"https:\/\/lightning.ai\/docs\/fabric\/stable\/api\/fabric_args.html\" target=\"_blank\" rel=\"noopener\">arguments<\/a> like <code>devices<\/code>, <code>accelerator<\/code>, <code>strategy<\/code>. This core class also comes equipped with several <a href=\"https:\/\/lightning.ai\/docs\/fabric\/stable\/api\/fabric_methods.html#\" target=\"_blank\" rel=\"noopener\">methods<\/a> that accomplish things like launching scripts for distributed training, setting up your model and optimizers, and performing collective operations like broadcasting, gathering, and reducing.<\/p>\n<h3>Configuring Environments with the Fabric Class<\/h3>\n<p>Shown below are a few of Fabric\u2019s arguments that can be used to configure the training environment.<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">from lightning.fabric import Fabric\r\nfrom lightning.fabric.loggers import CSVLogger\r\n\r\nfabric = Fabric(\r\n    accelerator=\"auto\",\r\n    strategy=\"auto\",\r\n    devices=\"auto\",\r\n    num_nodes=1,\r\n    precision=\"32-true\",\r\n    logger=CSVLogger(root_dir=\"lightning-logs\"),\r\n)<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><code>accelerator<\/code><\/span><span style=\"font-weight: 400;\">: supports passing in different accelerator types, like \u201ccpu\u201d or \u201cgpu\u201d<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><code>strategy<\/code><\/span><span style=\"font-weight: 400;\">: supports passing in different training strategies like \u201cddp\u201d or \u201cfsdp\u201d<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><code>devices<\/code><\/span><span style=\"font-weight: 400;\">: takes an <\/span><span style=\"font-weight: 400;\">int<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">list<\/span><span style=\"font-weight: 400;\">, or <\/span><span style=\"font-weight: 400;\">str<\/span><span style=\"font-weight: 400;\"> with the number of devices or the indices of devices<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><code>num_nodes<\/code><\/span><span style=\"font-weight: 400;\">: the number of cluster nodes for distributed training<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><code>precision<\/code><\/span><span style=\"font-weight: 400;\">: supports double (64-bit), full (32-bit), or half (16-bit) precision<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><code>logger<\/code>: supports either CSVLogger or TensorBoardLogger<\/li>\n<\/ol>\n<p>Fabric also has <code>plugins<\/code> and <code>callbacks<\/code> arguments. These two arguments allow for us to pass in custom built callbacks, and additional plugins like <code>BitsandbytesPrecision<\/code> for quantization. If we were to not set any of the arguments from the previous snippet and just use the default configuration, this would look like:<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">from lightning.fabric.plugins import BitsandbytesPrecision\r\n\r\nplugins = [BitsandbytesPrecision(mode=\"nf4\")]\r\ncallbacks = [MyCustomCallback()]\r\n\r\nfabric = Fabric(\r\n    plugins=plugins,\r\n    callbacks=callbacks,\r\n)<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<h3>Using Fabric&#8217;s Methods<\/h3>\n<p>Fabric\u2019s class methods are used for a range of tasks \u2013 including setting up models and data loaders, loading and saving checkpoints, performing gradient clipping, and logging metrics. Let\u2019s check out the four methods we need to scale our PyTorch training loop with Fabric.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-5649154\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-1024x722.png\" alt=\"\" width=\"1024\" height=\"722\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-1024x722.png 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-300x212.png 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-1536x1083.png 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-2048x1444.png 2048w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3-300x212@2x.png 600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>Shown above is our code snippet with the red highlighted lines that we can remove, and the green highlighted lines containing the Fabric code we must add. Note, we also have the line numbers shown \u2013 and this lets us know that we will be concentrating on lines 6, 10, 16, and 28 since we have moved on to Fabric\u2019s methods.<\/p>\n<p>We\u2019ve already configured our environment by declaring a <code>fabric<\/code> object in line 5. Next, in line 6, we need to launch our script or function to multiple processes with the following code:<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">fabric.launch()<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<p>After we launch our processes in line 6, we need to set up our data loader, model, and optimizers \u2013 as shown in lines 10 and 16. Let\u2019s note that we do not need to explicitly place the model on our device type \u2013 this is handled automatically by Fabric.<\/p>\n<p>In order to set up our data loader we need to do the following. First, we read in the dataset and then create a PyTorch Dataloader with that dataset. In the final line, we set up the data loader with <code>fabric.setup_dataloaders<\/code>. That\u2019s it! Our data loader is now ready for distributed training.<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">dataset = MyCustomDataset()\r\ndataloader = torch.utils.data.DataLoader(dataset)\r\ndataloader = fabric.setup_dataloaders(dataloader)<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<p>Now that we\u2019ve prepared our data loader, we need to instantiate and set up our model and optimizer with the following lines of code. First we create model and optimizer objects, and then we pass both of these into fabric.setup. And now our model and optimizers are ready for training at scale!<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">model = MyCustomModel()\r\noptimizer = torch.optim.SGD(model.parameters(), lr=0.1)\r\nmodel, optimizer = fabric.setup(model, optimizer)<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<p>Okay \u2013 we\u2019ve prepared our data loader, model, and optimizer \u2013 what about the actual training loop? Well, we only need line 28 from the code snippet:<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">fabric.backward(loss)<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<p>And when we remove the PyTorch code that we no longer need, our training loop looks like this:<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">model.train()\r\nfor epoch in range(20):\r\n    for batch in dataloader:\r\n        input, target = batch\r\n        optimizer.zero_grad()\r\n        output = model(input, target)\r\n        loss = torch.nn.functional.nll_loss(output, target.view(-1))\r\n        fabric.backward(loss)\r\n        optimizer.step()<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<p>We\u2019re done! Putting it all together for a complete script without the extra PyTorch code is shown below.<\/p>\n<pre class=\"snippet-shortcode code-shortcode dark-theme collapse-false\"><code class=\"hljs language-python\">import torch\r\nfrom lightning.fabric import Fabric\r\n\r\nfabric = Fabric(accelerator=\"cuda\", devices=8, strategy=\"ddp\")\r\nfabric.launch()\r\n\r\ndataset = MyCustomDataset()\r\ndataloader = torch.utils.data.DataLoader(dataset)\r\ndataloader = fabric.setup_dataloaders(dataloader)\r\n\r\nmodel = MyCustomModel()\r\noptimizer = torch.optim.SGD(model.parameters(), lr=0.1)\r\nmodel, optimizer = fabric.setup(model, optimizer)\r\n\r\nmodel.train()\r\nfor epoch in range(20):\r\n    for batch in dataloader:\r\n        input, target = batch\r\n        optimizer.zero_grad()\r\n        output = model(input, target)\r\n        loss = torch.nn.functional.nll_loss(output, target.view(-1))\r\n        fabric.backward(loss)\r\n        optimizer.step()<\/code><div class=\"copy-button\"><button class=\"expand-button active\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<h2>Conclusion<\/h2>\n<p>Fabric is fast to implement and provides maximum flexibility and control over our training logic. This makes Fabric super easy to adopt and add into existing PyTorch training loops without any need to restructure our code. Leaving the system design and orchestration to us \u2013 the engineers \u2013 so that we can get the job done in the way that works best for us!<\/p>\n<p>Want to see Lightning Fabric in action? Then clone and install <a href=\"https:\/\/github.com\/JustinGoheen\/fabric-lab\" target=\"_blank\" rel=\"noopener\">fabric-lab<\/a> to run the example language transformer using these 4 easy steps from your terminal!<\/p>\n<pre class=\"code-shortcode dark-theme window- collapse-false \" style=\"--height:falsepx\"><code class=\"language-python\"># 1:  clone fabric lab<br \/>\ngit clone https:\/\/github.com\/JustinGoheen\/fabric-lab.git<br \/>\ncd fabric-lab<br \/>\n# 2:  create a virtual environment<br \/>\npython -m venv .venv<br \/>\nsource .venv\/bin\/activate<br \/>\n# 3:  install fabric lab<br \/>\npip install -e \".[text]\"<br \/>\n# 4:  run the demo<br \/>\nlab run demo<\/code><div class=\"copy-button\"><button class=\"expand-button\">Expand<\/button><button class=\"copy\">Copy<\/button><\/div><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5649157 size-full\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/quickstart-fabric.gif\" alt=\"\" width=\"1152\" height=\"648\" \/><\/p>\n<h2>Still have questions?<\/h2>\n<p>We have an amazing community and team of core engineers ready to answer questions you might have about the Lightning AI ecosystem. So, join us on <a href=\"https:\/\/discord.gg\/XncpTy7DSt\" target=\"_blank\" rel=\"noopener\">Discord<\/a> or <a href=\"https:\/\/lightning.ai\/forums\/\" target=\"_blank\" rel=\"noopener\">Discourse<\/a>. See you there!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Some engineers may prefer the greatest amount of control as possible over their PyTorch training loop. Yet, those same engineers also know the benefits of a lightweight, production ready framework that handles the heavy lifting when it comes to SOTA distributed training features. The Power of Lightning Fabric Lightning Fabric does this heavy lifting<a class=\"excerpt-read-more\" href=\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/\" title=\"ReadQuickstart to Lightning Fabric\">&#8230; Read more &raquo;<\/a><\/p>\n","protected":false},"author":16,"featured_media":5649154,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[29,41],"tags":[],"glossary":[],"acf":{"mathjax":false,"default_editor":true,"show_table_of_contents":false,"additional_authors":false,"hide_from_archive":false,"content_type":"Blog Post","sticky":false,"code_embed":true,"code_shortcode":[{"shortcode_title":"snippet_1","code":"from lightning.fabric import Fabric\r\nfrom lightning.fabric.loggers import CSVLogger\r\n\r\nfabric = Fabric(\r\n    accelerator=\"auto\",\r\n    strategy=\"auto\",\r\n    devices=\"auto\",\r\n    num_nodes=1,\r\n    precision=\"32-true\",\r\n    logger=CSVLogger(root_dir=\"lightning-logs\"),\r\n)","syntax":"python","collapse":true},{"shortcode_title":"snippet_2","code":"from lightning.fabric.plugins import BitsandbytesPrecision\r\n\r\nplugins = [BitsandbytesPrecision(mode=\"nf4\")]\r\ncallbacks = [MyCustomCallback()]\r\n\r\nfabric = Fabric(\r\n    plugins=plugins,\r\n    callbacks=callbacks,\r\n)","syntax":"python","collapse":true},{"shortcode_title":"snippet_3","code":"fabric.launch()","syntax":"python","collapse":true},{"shortcode_title":"snippet_4","code":"dataset = MyCustomDataset()\r\ndataloader = torch.utils.data.DataLoader(dataset)\r\ndataloader = fabric.setup_dataloaders(dataloader)","syntax":"python","collapse":true},{"shortcode_title":"snippet_5","code":"model = MyCustomModel()\r\noptimizer = torch.optim.SGD(model.parameters(), lr=0.1)\r\nmodel, optimizer = fabric.setup(model, optimizer)","syntax":"python","collapse":true},{"shortcode_title":"snippet_6","code":"fabric.backward(loss)","syntax":"python","collapse":true},{"shortcode_title":"snippet_7","code":"model.train()\r\nfor epoch in range(20):\r\n    for batch in dataloader:\r\n        input, target = batch\r\n        optimizer.zero_grad()\r\n        output = model(input, target)\r\n        loss = torch.nn.functional.nll_loss(output, target.view(-1))\r\n        fabric.backward(loss)\r\n        optimizer.step()","syntax":"python","collapse":true},{"shortcode_title":"snippet_8","code":"import torch\r\nfrom lightning.fabric import Fabric\r\n\r\nfabric = Fabric(accelerator=\"cuda\", devices=8, strategy=\"ddp\")\r\nfabric.launch()\r\n\r\ndataset = MyCustomDataset()\r\ndataloader = torch.utils.data.DataLoader(dataset)\r\ndataloader = fabric.setup_dataloaders(dataloader)\r\n\r\nmodel = MyCustomModel()\r\noptimizer = torch.optim.SGD(model.parameters(), lr=0.1)\r\nmodel, optimizer = fabric.setup(model, optimizer)\r\n\r\nmodel.train()\r\nfor epoch in range(20):\r\n    for batch in dataloader:\r\n        input, target = batch\r\n        optimizer.zero_grad()\r\n        output = model(input, target)\r\n        loss = torch.nn.functional.nll_loss(output, target.view(-1))\r\n        fabric.backward(loss)\r\n        optimizer.step()","syntax":"javascript","collapse":true},{"shortcode_title":"snippet_9","code":"# 1:  clone fabric lab\r\ngit clone https:\/\/github.com\/JustinGoheen\/fabric-lab.git\r\ncd fabric-lab\r\n# 2:  create a virtual environment\r\npython -m venv .venv\r\nsource .venv\/bin\/activate\r\n# 3:  install fabric lab\r\npip install -e \".[text]\"\r\n# 4:  run the demo\r\nlab run demo","syntax":"html","collapse":true}],"tabs":false,"custom_styles":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Quickstart to Lightning Fabric - 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\/quickstart-to-lightning-fabric\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Quickstart to Lightning Fabric - Lightning AI\" \/>\n<meta property=\"og:description\" content=\"Introduction Some engineers may prefer the greatest amount of control as possible over their PyTorch training loop. Yet, those same engineers also know the benefits of a lightweight, production ready framework that handles the heavy lifting when it comes to SOTA distributed training features. The Power of Lightning Fabric Lightning Fabric does this heavy lifting... Read more &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/\" \/>\n<meta property=\"og:site_name\" content=\"Lightning AI\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-01T19:35:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-02T14:10:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png\" \/>\n\t<meta property=\"og:image:width\" content=\"5560\" \/>\n\t<meta property=\"og:image:height\" content=\"3920\" \/>\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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/\"},\"author\":{\"name\":\"JP Hennessy\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6\"},\"headline\":\"Quickstart to Lightning Fabric\",\"datePublished\":\"2023-11-01T19:35:27+00:00\",\"dateModified\":\"2023-11-02T14:10:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/\"},\"wordCount\":938,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png\",\"articleSection\":[\"Blog\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/\",\"url\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/\",\"name\":\"Quickstart to Lightning Fabric - Lightning AI\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png\",\"datePublished\":\"2023-11-01T19:35:27+00:00\",\"dateModified\":\"2023-11-02T14:10:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage\",\"url\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png\",\"contentUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png\",\"width\":5560,\"height\":3920},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lightning.ai\/pages\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Quickstart to Lightning Fabric\"}]},{\"@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":"Quickstart to Lightning Fabric - 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\/quickstart-to-lightning-fabric\/","og_locale":"en_US","og_type":"article","og_title":"Quickstart to Lightning Fabric - Lightning AI","og_description":"Introduction Some engineers may prefer the greatest amount of control as possible over their PyTorch training loop. Yet, those same engineers also know the benefits of a lightweight, production ready framework that handles the heavy lifting when it comes to SOTA distributed training features. The Power of Lightning Fabric Lightning Fabric does this heavy lifting... Read more &raquo;","og_url":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/","og_site_name":"Lightning AI","article_published_time":"2023-11-01T19:35:27+00:00","article_modified_time":"2023-11-02T14:10:32+00:00","og_image":[{"width":5560,"height":3920,"url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#article","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/"},"author":{"name":"JP Hennessy","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6"},"headline":"Quickstart to Lightning Fabric","datePublished":"2023-11-01T19:35:27+00:00","dateModified":"2023-11-02T14:10:32+00:00","mainEntityOfPage":{"@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/"},"wordCount":938,"commentCount":0,"publisher":{"@id":"https:\/\/lightning.ai\/pages\/#organization"},"image":{"@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png","articleSection":["Blog","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/","url":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/","name":"Quickstart to Lightning Fabric - Lightning AI","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage"},"image":{"@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png","datePublished":"2023-11-01T19:35:27+00:00","dateModified":"2023-11-02T14:10:32+00:00","breadcrumb":{"@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#primaryimage","url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png","contentUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/11\/Lightning-Quick_Start_to_Lightning_Fabric-3.png","width":5560,"height":3920},{"@type":"BreadcrumbList","@id":"https:\/\/lightning.ai\/pages\/blog\/quickstart-to-lightning-fabric\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lightning.ai\/pages\/"},{"@type":"ListItem","position":2,"name":"Quickstart to Lightning Fabric"}]},{"@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\/5649153"}],"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=5649153"}],"version-history":[{"count":0,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts\/5649153\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media\/5649154"}],"wp:attachment":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media?parent=5649153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/categories?post=5649153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/tags?post=5649153"},{"taxonomy":"glossary","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/glossary?post=5649153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}