<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Latent Space - Medium]]></title>
        <description><![CDATA[Building the next wave of generative models for businesses and creatives. - Medium]]></description>
        <link>https://medium.com/latentspace?source=rss----76ed7d9c1dc8---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Latent Space - Medium</title>
            <link>https://medium.com/latentspace?source=rss----76ed7d9c1dc8---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:52:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/latentspace" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Scaling Up and Down: Why we moved to  PyTorch-Lightning]]></title>
            <link>https://medium.com/latentspace/scaling-up-and-down-why-we-moved-to-pytorch-lightning-54332204de12?source=rss----76ed7d9c1dc8---4</link>
            <guid isPermaLink="false">https://medium.com/p/54332204de12</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[pytorch]]></category>
            <dc:creator><![CDATA[Jeff Ling]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 13:16:03 GMT</pubDate>
            <atom:updated>2019-10-10T13:16:02.948Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8eLEfwoT7wBugiYoHbdHg.png" /><figcaption>yes</figcaption></figure><h3>Scaling Up and Down: Why we moved to PyTorch Lightning</h3><h3>Engineering Modular Neural Networks</h3><p>co-authored with <a href="https://medium.com/u/c9d4f242a2cb">Sarah Jane Hong</a> and <a href="https://medium.com/u/9ec7f9bd62d3">Darryl Barnhart</a></p><p>Creating and training a model at scale has its challenges. Starting with a single model is easy enough. But as you scale your model up, you’ll need features like gradient accumulation, mixed precision, and hyperparameter scheduling. Then, as you want to scale out, you need to worry about all the details on how to setup a proper distributed training environment.</p><p>With all that, you still want to make sure you maintain a fast feedback loop as you try out new ideas, so you’re constantly having to scale up and down. Maintaining all those features take a lot of work, and it’s easy for modern deep learning code-bases to grow to be overly complex.</p><p>At <a href="https://www.latentspace.co/">Latent Space</a>, we’re trying to push the state of the art in generative modelling while improving on metrics as wide ranging as disentanglement, model distillation, and temporal consistency. To help us iterate quickly, we created a framework internally called Lab to dynamically build models and track experiments.</p><p>The purpose of Lab is to make it incredibly easy to test different model configurations and architectures quickly. It can:</p><ul><li>dynamically compose models from different blocks by swapping them in and out using <a href="https://github.com/google/gin-config">gin</a> configurations</li><li><a href="https://arxiv.org/abs/1802.03268">sweep over different model architectures</a>, also using <a href="https://github.com/google/gin-config">gin</a>.</li><li>train models on the cloud by spinning up instances, provisioning, and running them on one or many GPUs/TPUs, including multi-node scenarios.</li><li>generate synthetic datasets to overcome the limitations of current academic datasets.</li></ul><p>Using Lab, we’ve been able to create and continually iterate on a complex models and datasets, but we started running into some issues.</p><h3>Why Lightning</h3><p>Lab was very home-grown; we built it as we needed each feature. We didn’t always have time to focus on our framework’s structure and keep it up to date as we upgraded.</p><p>We started spending the majority of our time making sure our framework did not break as we tried to develop our model architecture further. As we tried to push the envelope on our model, we wanted to spend more time focusing on algorithmic correctness over mechanical correctness.</p><p><a href="https://github.com/williamFalcon/pytorch-lightning">Lightning</a> is a framework that aimed at reducing boilerplate and enabling researchers to focus on their research code. It covers difficult-to-maintain features that become important when training at scale, like distributed training, mixed precision, and gradient accumulation.</p><p>Lab already supported all of those features, but the attraction of being able to use all these features and remove our maintenance cost started outweighing the migration cost.</p><p>We were also impressed by the development of Lightning — the design principles were clearly laid out, the creator, <a href="https://medium.com/u/8536ebfbc90b">William Falcon</a>, was very active and responsive to questions, and the features were well-designed and well-tested.</p><h3>The Migration</h3><p>For us, moving to Lightning meant moving over all our existing features and models. Lightning modules inherit off PyTorch modules and include a set of methods and hooks meant to be overridden. Luckily, the way Lightning is designed is pretty agnostic — as long as we replace our entry-point with their top-level entry-point, we got most of the advantages right away.</p><p>The main work involved was moving our configuration and model construction system into Lightning. The Lab model construction system allows us to build our models using ‘blocks’. As an example, one block might contain the logic for self-attention, and another block will handle logic for <a href="https://distill.pub/2018/feature-wise-transformations/">modulation</a>.</p><p>Integrating the configuration and model construction system into Lightning took a lot of care and planning, as we wanted to maintain our existing feature-set and reduce disruption to our team. The bulk of the work was friction-less due to the simplicity of the Lightning API. We got away with writing a few top-level adapters to decouple our code with some of the assumptions in the way our dataloaders and optimizers worked.</p><p>We were surprised by how easy it was to get running with the framework given the sheer size of our code-base. With a smaller or medium-sized research code-base, I would expect the move to be even easier.</p><h3>Reaping the Benefits</h3><p>Lab is now built on top of Lightning. We were able to remove historic, home-grown code and replaced it with Lightning’s strongly-tested feature-set. We extracted out the best parts of our old framework (like our composable model builder) into libraries and continued using them with our new hybrid framework.</p><p>There are a still few things that the pre-migration Lab does that we still need to keep at the framework-level, but in the future, we hope to merge some of the more useful features upstream and contribute to the framework.</p><p>Looking at the roadmap for the future post-migration, we hope to spend a lot less time dealing with how the model runs and more time with how the model learns.</p><p>We will be writing a lot more about best practices in engineering deep learning models, so stay tuned for more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54332204de12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/latentspace/scaling-up-and-down-why-we-moved-to-pytorch-lightning-54332204de12">Scaling Up and Down: Why we moved to  PyTorch-Lightning</a> was originally published in <a href="https://medium.com/latentspace">Latent Space</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ML Best Practices: Test Driven Development at Latent Space]]></title>
            <link>https://medium.com/latentspace/ml-best-practices-test-driven-development-at-latent-space-13fb3edf8fd0?source=rss----76ed7d9c1dc8---4</link>
            <guid isPermaLink="false">https://medium.com/p/13fb3edf8fd0</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[generative-model]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Jeff Ling]]></dc:creator>
            <pubDate>Wed, 04 Sep 2019 21:03:07 GMT</pubDate>
            <atom:updated>2019-09-04T21:03:07.249Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.wandb.com/articles/ml-best-practices-test-driven-development"><strong><em>This interview originally appeared on the Weights &amp; Biases blog.</em></strong></a></p><p>I sat down with the <a href="https://www.latentspace.co/">Latent Space</a> team to talk about best practices around collaboration and managing model iteration. In machine learning, bugs may affect the distribution of possible models more than any particular instance, making traditional deterministic tests misleading. Because of this, a test-driven development framework for large ML models must account for the statistical nature of training. This is especially crucial when multiple researchers and engineers are contributing to the same model, as it’s easy to silently introduce regressions into a codebase. Here, the team shares some insights about how this new form of test-driven development has been the key to moving quickly on a large-scale collaborative project.</p><p>Latent Space is democratizing creativity through AI. They are making the first fully AI-rendered 3D engine, where users create the world itself and objects in it. Creation is as easy as uploading a picture to Instagram. But when you upload in Latent Space, you see it come to life in 3D. Bring your family car or the Millennium Falcon into a shared world that could look like anything from the Taj Mahal to Winterfell. This new level of self expression enables greater diversity in 3D content, tackling one of the largest problems in the games industry.</p><h3>Process in a nutshell</h3><p>To iterate quickly and with confidence on cutting-edge generative models with a team, Latent Space has found two crucial strategies:</p><ol><li>Fully modular models.</li><li>Testing with rigor.</li></ol><h3>Fully Modular Models</h3><p>Latent Space built what they call the “block system” combined with<a href="https://github.com/google/gin-config"> the gin configuration framework</a> to allow them to create new generators, discriminators, encoders, arbitrary skip connections, or tuning parameters in a high-level configuration file. The name was inspired by<a href="https://github.com/mila-iqia/blocks"> MILA’s old Theano “Blocks” system</a>.<a href="https://www.linkedin.com/in/darrylbarnhart/"> Darryl Barnhart</a>, architect of the block system, describes its benefits:</p><ol><li><em>Clarity of abstraction. By separating hyperparameters from the business logic of forward passes and model construction, configs become a higher level way to design a model.</em></li><li><em>Ease of ablation. Comparing two variants of a model is as easy as changing a few parameters in a config, lowering the barrier to experimentation significantly.</em></li><li><em>Ease of hyperparameter search. They use</em><a href="https://docs.wandb.com/docs/sweep.html"><em> W&amp;B’s sweep feature</em></a><em> to run thousands of variations of a model to find the best setup. (An even more extreme extension of this is</em><a href="https://arxiv.org/abs/1802.03268"><em> Neural Architecture Search</em></a><em> where an ML model drives architecture selection with even finer granularity.)</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9WZ7vreC06h-7_HQ" /></figure><p><em>A W&amp;B “parallel coordinates” visualization of sweep results over learning rate, batch size and optimizer type, with the best performing runs interactively highlighted</em></p><p>Their config structure is hierarchical. They have one HEAD model that represents the latest and most effective changes. Everything else is a ‘child’ configuration. This makes ablations (A/B tests of changes) clear: inherit from the HEAD model, change the settings that are different/new and run that new config. Each config is essentially a model definition, and in W&amp;B each config gets its own tag.</p><p>Here’s an example gin config:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/0*WDueoCn-n_jNWegB" /></figure><p><a href="https://www.linkedin.com/in/chase-basich-658a46107/">Chase Basich</a> on the config system:</p><p><em>One thing about our config system that has been very helpful is the checkpoint-like nature of the system. For any feature, we can easily find the config that first introduced that feature to see a canonical example of how it was setup and then run that config. We can then use that config to find the corresponding W&amp;B runs and reports. For example, I was recently investigating a regression and this provided a quick way to re-run the ablations and compare the new and old W&amp;B data.</em></p><h3>Testing with Rigor</h3><h4>Finding the new SOTA</h4><p>One of the things that initially attracted them to W&amp;B was how shareable W&amp;B reports are. They loved the idea of associating reports with pull requests. Pull requests happen when code is merging into their develop branch, and when they are changing their HEAD model configs. To have stats to prove a set of changes are an improvement to their model was very enticing.</p><p>Initially, they compared the average and min/max of a few runs from a branch vs HEAD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IGefzP2lF3YH_jI8" /></figure><p><em>Two ablations (orange and red) compared with one of their HEAD models over the course of training in W&amp;B. Each config is comprised of 5–10 separate runs. The solid lines indicate mean and the vertical bands indicate min/max values at a given iteration.</em></p><p>If you run the same config many times, you’ll get different results depending on model initialization, randomized shuffled data-loader reads, or the parallel nature of GPU operations. Moreover, they realized they don’t just care about improving the average, or even the min/max. If a change didn’t affect the mean/min/max, but the variance significantly reduced, it would be a win. These kinds of changes make the signal much clearer and reduce the number of runs needed.</p><p>Even during development, the team triggers a training run over 10 times for each of their changes. Using an in-house cloud setup, they can run them all in parallel, then analyze their changes in W&amp;B.</p><p>To communicate how changes improve their models, all their code pull requests use the following template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/0*iE_trhg_q3OC-cpg" /></figure><p>They use one or more W&amp;B tags per config, and then use different run sets (with their corresponding tags) in the same section of a report to pull the different arms of the experiment together.</p><p>Tips from<a href="https://www.linkedin.com/in/jefftyling/"> Jeff Ling</a><em>:</em></p><p><em>In W&amp;B, each of our configs is mapped to one or many tags. That’s how we find relevant runs. We use tags with reports to show the A/B comparison of a config change. For example, if I’m testing the effects of a new feature, I would find the head cloud model and the config with the feature, and put the same tag in both. When I run both, it appears in my report.</em></p><h4>Preventing Regressions</h4><p>According to<a href="https://twitter.com/latentcodes"> Sarah Jane Hong</a>,</p><p><em>ML models are difficult to debug due to their adaptive nature; if you have a bug (or many!) the model can still perform adequately. The most insidious forms of bugs are the ones that “fail” silently. It can range from something unintended such as</em><a href="https://twitter.com/karpathy/status/1013244313327681536?s=21"><em> passing in softmax outputs to a loss that expects raw logits</em></a><em>, or as subtle as accidentally broadcasting a tensor somewhere in your model.</em></p><p>They have hourly, nightly, and weekly integration tests, and unit tests on every PR. The tests are used to ensure that their models won’t perform worse as new changes come in. The more frequent the integration test, the shorter the duration of the run. Runs have several key metrics (for them this includes<a href="https://arxiv.org/pdf/1706.08500.pdf"> Fréchet Inception Distance</a>), and any of these can be compared to a distribution of baseline runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*46R77QM803AXFfHa" /></figure><p><em>They use a W&amp;B report to track all their hourly integration test results over time. Each data point is the final score from a test (lower is better). Notice around 19–07–24 13:26 a bug results in spikes across all metrics for several runs, followed by a lasting improvement.</em></p><p>Getting fast <em>and</em> confident feedback on new features is central to Latent Space’s automated testing. They use a mixture of frequentist and Bayesian methods to compare the old and new distributions, but have increasingly relied on Bayesian approaches to more quickly update their beliefs based on new evidence (each run and sub-metrics within a run representing new evidence). Most tests involve comparing two distributions: a previous distribution from an earlier config/commit, and a new distribution for the integration test, PR, or ablation/sweep being run. As Latent Space has scaled their generative models, better automated statistical analysis has become increasingly beneficial the larger their training regime becomes. It creates a fast feedback loop for adding new features and understanding their effect at scale at minimal cost.</p><p>They also treat extremely out of distribution “good” results as a failure. If they were expected, they should have come in with a PR and established new baseline runs. If unexpected, likely there’s a new bug in how the metric is calculated and it’s not actually improved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/0*KKa4dbvikW3zo0m3" /></figure><p><em>Slack tells them when integration tests pass or fail and posts links to W&amp;B runs.</em></p><p>Finally, they have Unit Tests that run via <a href="https://circleci.com/">CircleCI</a> on every PR to ensure the model can still mechanically train and key functionality always works as expected.</p><h3>Conclusion</h3><p>Latent Space’s meticulous approach to coordinating model improvements stood out to me as an example of a thoughtful and repeatable structure for pushing the envelope of best practices in the industry.</p><p>One of the most interesting parts of Latent Space’s system is their use of composable blocks. They’ll dive into more detail on that subject in a future post. Get ready to learn about how this design choice allows the team to sweep through different architectures instead of just tweaking hyperparameters!</p><p>Learn more about Latent Space <a href="http://latentspace.co/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13fb3edf8fd0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/latentspace/ml-best-practices-test-driven-development-at-latent-space-13fb3edf8fd0">ML Best Practices: Test Driven Development at Latent Space</a> was originally published in <a href="https://medium.com/latentspace">Latent Space</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>