<?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[Stories by DVC on Medium]]></title>
        <description><![CDATA[Stories by DVC on Medium]]></description>
        <link>https://medium.com/@dvc-ai?source=rss-5b39037d735b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*P7aJOXwwdAwiq00HGK35tw.png</url>
            <title>Stories by DVC on Medium</title>
            <link>https://medium.com/@dvc-ai?source=rss-5b39037d735b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:05:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dvc-ai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Announcing DataChain]]></title>
            <link>https://medium.com/dvc-data-version-control/announcing-datachain-4cf9c38d7ce8?source=rss-5b39037d735b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cf9c38d7ce8</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[unstructured-data]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[multimodal]]></category>
            <dc:creator><![CDATA[DVC]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 00:00:50 GMT</pubDate>
            <atom:updated>2024-07-24T19:40:42.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3IucVmZC2WO83y1i.png" /><figcaption><em>DataChain: ⭐ the repo at </em><a href="https://github.com/iterative/datachain"><em>https://github.com/iterative/datachain</em></a></figcaption></figure><p>Author: <a href="https://www.linkedin.com/in/dmitryleopetrov/">Dmitry Petrov</a></p><p>As a DVC team, we are fortunate to have witnessed the recent transformations in ML and AI firsthand and admire the rise of unstructured data together with great libraries to handle it.</p><p>The tidal wave of new applications demanding access to images, video, audio, text, PDF documents, MRI scans, and other media types introduces a new challenge — unstructured data preparation and curation. It is no longer enough to designate and version a file folder as a dataset; the modern data stack demands the use of AI to create features and annotations and start the dataset formation from these features.</p><h3>AI’s new appetite for data</h3><p>While data has long been touted to be in the critical path for building AI, below are the novel requirements that we believe are here to stay:</p><p>🤖 <strong>AI-Driven Data Curation:</strong> There is a rapidly growing interest in data curation assisted with AI models. Technologies like LLMs judging their own outputs, or OpenAI’s DALL-E3 curating its own dataset are becoming a common practice, and frequently separate the good products from the great products.</p><p>🚀 <strong>Dataset scaling:</strong> In many GenAI use cases, millions and billions of images or text snippets are becoming routine. Wrangling and versioning the GenAI-era datasets takes an entirely new approach at the backend.</p><p>🐍 <strong>Python ubiquity:</strong> As Python emerged as a clear language of choice for AI workloads, it became painfully obvious that Python objects must be treated as 1st class citizens in the AI datasets. Using JSON to store every possible feature just no longer cuts it.</p><h3>What DataChain can do for you.</h3><p>We created DataChain to answer these challenges. Our high-level vision of serving the modern AI data stack drives the key product capabilities:</p><ol><li>Read data from cloud S3/GCS/Azure (or locally) and create persistent and versioned datasets with samples defined as sparse references to files or objects inside files. Examples are features within parquet or .tar archives, tiles within the bounding boxes in images, snippets within text blobs, etc.</li><li>Define data models in Python using <a href="https://docs.pydantic.dev/latest/">Pydantic</a> and store features as validated data objects with automatic serialization/deserialization.</li><li>Apply transformations to data using local ML models, external LLM calls, or custom Python code coupled with the ability to chain and optimize stages for execution.</li><li>Run inference code efficiently in parallel and out-of-memory, handling millions of files even on a laptop.</li><li>Use embedded databases under the hood (<a href="https://www.sqlite.org/">SQLite</a> in open-source version) to efficiently store Python objects and execute vectorized operations (such as similarity search) and analytical calls. DataChain hides all the complexity of dealing with databases.</li></ol><p>The result is a modern, Python-friendly, data-wrangling abstraction that can compose actions like AI inferences and metric computations at scale, and doubles as a building block to your data curation routine, or as a way to evaluate an existing AI application.</p><p>We believe that DataChain will serve as a solid foundation for new and upcoming unstructured data-wrangling libraries, as well as custom AI-driven curation solutions.</p><h3>Typical use examples</h3><pre>$ pip install datachain</pre><h3>LLM judging LLMs dialogues</h3><pre>from mistralai.client import MistralClient<br>from mistralai.models.chat_completion import ChatCompletionResponse, ChatMessage<br>from datachain import File, DataChain<br><br>PROMPT = &quot;Was this dialog successful? Answer in a single word: Success or Failure.&quot;<br><br>def eval_dialogue(file: File) -&gt; ChatCompletionResponse:<br>     client = MistralClient()<br>     return client.chat(<br>         model=&quot;open-mixtral-8x22b&quot;,<br>         messages=[ChatMessage(role=&quot;system&quot;, content=PROMPT),<br>                   ChatMessage(role=&quot;user&quot;, content=file.read())])<br><br>chain = (<br>   DataChain.from_storage(&quot;gs://datachain-demo/chatbot-KiT/&quot;, object_name=&quot;file&quot;)<br>   .map(response=eval_dialogue)<br>   .save(&quot;mistral_dataset&quot;)<br>)</pre><h3>Auto-deserializing LLM-responses to Pydantic</h3><pre>from datachain import DataChain, DataModel<br>from mistralai.models.chat_completion import ChatCompletionResponse<br><br>DataModel.register(ChatCompletionResponse)<br>chain = DataChain.from_dataset(&quot;mistral_dataset&quot;)<br><br># Iterating one-by-one: out of memory<br>for file, response in chain.iterate(&quot;file&quot;, &quot;response&quot;):<br>    # You work with Python objects<br>    assert isinstance(response, ChatCompletionResponse)<br><br>    status = response.choices[0].message.content<br>    print(f&quot;{file.get_uri()}: {status}&quot;)</pre><p>Output:</p><pre>gs://datachain-demo/chatbot-KiT/1.txt: Success <br>gs://datachain-demo/chatbot-KiT/10.txt: Success <br>gs://datachain-demo/chatbot-KiT/11.txt: Failure <br>...</pre><h3>Vectorized operations over Pydantic data fields</h3><p>In some cases, deserialization into a Python object can be skipped, and the computation can be executed directly within the underlying database.</p><pre># input tokens price: $2 per 1M tokens<br># output tokens proce: $6 per 1M tokens<br>cost = chain.sum(&quot;response.usage.prompt_tokens&quot;)*0.000002 \<br>      + chain.sum(&quot;response.usage.completion_tokens&quot;)*0.000006<br><br>print(f&quot;Spent ${cost:.2f} on {chain.count()} calls&quot;)</pre><p>Output:</p><pre>Spent $0.08 on 50 calls</pre><h3>Annotating cloud images with a local model</h3><p>Computer Vision use cases are especially sensitive to high-performance data downloads.</p><pre>import io<br>from PIL import Image<br>from datachain import DataChain<br>from transformers import PaliGemmaForConditionalGeneration, AutoProcessor<br><br>model = PaliGemmaForConditionalGeneration.from_pretrained(&quot;google/paligemma-3b-mix-224&quot;)<br>processor = AutoProcessor.from_pretrained(&quot;google/paligemma-3b-mix-224&quot;)<br><br>def process_image(file) -&gt; str:<br>   image = Image.open(io.BytesIO(file.read())).convert(&quot;RGB&quot;)<br>   inputs = processor(text=&quot;caption&quot;, images=image, return_tensors=&quot;pt&quot;)<br>   generate_ids = model.generate(**inputs, max_new_tokens=100)<br>   return processor.batch_decode(generate_ids, skip_special_tokens=True,<br>                                 clean_up_tokenization_spaces=False)[0]<br><br>chain = (<br>      DataChain.from_storage(&quot;gs://datachain-demo/newyorker_caption_contest/images&quot;)<br>      .limit(5)<br>      .map(scene=process_image)<br>      .save(&quot;image_captions&quot;)<br>)</pre><h3>Optimizations: parallelization and data caching</h3><p>Parallel execution and data caching play a critical role in the efficient data curation process.</p><pre>chain = (<br>   DataChain.from_storage(&quot;gs://datachain-demo/chatbot-KiT/&quot;,<br>                          object_name=&quot;file&quot;)<br>   .settings(parallel=4, cache=True)<br>   .limit(5)<br>   .map(response=eval_dialogue)<br>   .save(&quot;mistral_dataset&quot;)<br>)</pre><h3>DataChain needs your feedback!</h3><p>As usual in the open-source, we are providing this software for free, but we are also dependent on help from our community.</p><p><strong>First and foremost</strong>, we want you to try the product, let us know if it fits your data routine, and report any bugs or deficiencies that you may have seen. DataChain is still early in its lifecycle, so your feedback is crucial to the future of this product.</p><p><strong>Second</strong>, we need contributors! If you see a missing feature or an application for DataChain that could be built as an extension, we would be happy to see a pull request from you.</p><p><strong>Last, but not least</strong> — if you find DataChain useful, give us a star ⭐ It goes a long way for us.</p><p>⭐️ <a href="https://github.com/iterative/datachain">Star the repo!</a> ⭐️</p><p><em>Originally published at </em><a href="https://dvc.ai/blog/datachain-release"><em>https://dvc.ai</em></a><em> on July 23, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cf9c38d7ce8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dvc-data-version-control/announcing-datachain-4cf9c38d7ce8">Announcing DataChain</a> was originally published in <a href="https://medium.com/dvc-data-version-control">DVC — Data Version Control</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Announcing DataChain]]></title>
            <link>https://medium.com/@dvc-ai/announcing-datachain-90bed43ff1ea?source=rss-5b39037d735b------2</link>
            <guid isPermaLink="false">https://medium.com/p/90bed43ff1ea</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[multimodal]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[unstructured-data]]></category>
            <dc:creator><![CDATA[DVC]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 00:00:08 GMT</pubDate>
            <atom:updated>2024-09-13T14:34:55.587Z</atom:updated>
            <content:encoded><![CDATA[<h3>Announcing DataChain!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XIzhQzZtXYhXkmYD.png" /></figure><p>As a DVC team, we are fortunate to have witnessed the recent transformations in ML and AI firsthand and admire the rise of unstructured data together with great libraries to handle it.</p><p>The tidal wave of new applications demanding access to images, video, audio, text, PDF documents, MRI scans, and other media types introduces a new challenge — unstructured data preparation and curation. It is no longer enough to designate and version a file folder as a dataset; the modern data stack demands the use of AI to create features and annotations and start the dataset formation from these features.</p><h3>AI’s new appetite for data</h3><p>While data has long been touted to be in the critical path for building AI, below are the novel requirements that we believe are here to stay:</p><p>🤖 <strong>AI-Driven Data Curation:</strong> There is a rapidly growing interest in data curation assisted with AI models. Technologies like LLMs judging their own outputs, or OpenAI’s DALL-E3 curating its own dataset are becoming a common practice, and frequently separate the good products from the great products.</p><p>🚀 <strong>Dataset scaling:</strong> In many GenAI use cases, millions and billions of images or text snippets are becoming routine. Wrangling and versioning the GenAI-era datasets takes an entirely new approach at the backend.</p><p>🐍 <strong>Python ubiquity:</strong> As Python emerged as a clear language of choice for AI workloads, it became painfully obvious that Python objects must be treated as 1st class citizens in the AI datasets. Using JSON to store every possible feature just no longer cuts it.</p><h3>What DataChain can do for you.</h3><p>We created DataChain to answer these challenges. Our high-level vision of serving the modern AI data stack drives the key product capabilities:</p><ol><li>Read data from cloud S3/GCS/Azure (or locally) and create persistent and versioned datasets with samples defined as sparse references to files or objects inside files. Examples are features within parquet or .tar archives, tiles within the bounding boxes in images, snippets within text blobs, etc.</li><li>Define data models in Python using Pydantic and store features as validated data objects with automatic serialization/deserialization.</li><li>Apply transformations to data using local ML models, external LLM calls, or custom Python code coupled with ability to chain and optimize stages for execution.</li><li>Run inference code efficiently in parallel and out-of-memory, handling millions of files even in a laptop.</li><li>Use embedded databases under the hood (SQLite in open-source version) to efficiently store Python objects and execute vectorized operations (such as similarity search) and analytical calls. DataChain hides all the complexity of dealing with databases.</li></ol><p>The result is a modern, Python-friendly, data-wrangling abstraction that can compose actions like AI inferences and metric computations at scale, and doubles as a building block to your data curation routine, or as a way to evaluate an existing AI application.</p><p>We believe that DataChain will serve as a solid foundation for new and upcoming unstructured data-wrangling libraries, as well as custom AI-driven curation solutions.</p><h3>Typical use examples</h3><pre>pip install datachain</pre><h3>LLM judging LLMs dialogues</h3><pre>from mistralai.client import MistralClient<br>from mistralai.models.chat_completion import ChatCompletionResponse, ChatMessage<br>from datachain import File, DataChain<br><br>PROMPT = &quot;Was this dialog successful? Answer in a single word: Success or Failure.&quot;<br><br>def eval_dialogue(file: File) -&gt; ChatCompletionResponse:<br>     client = MistralClient()<br>     return client.chat(<br>         model=&quot;open-mixtral-8x22b&quot;,<br>         messages=[ChatMessage(role=&quot;system&quot;, content=PROMPT),<br>                   ChatMessage(role=&quot;user&quot;, content=file.read())])<br><br>chain = (<br>   DataChain.from_storage(&quot;gs://datachain-demo/chatbot-KiT/&quot;, object_name=&quot;file&quot;)<br>   .map(response=eval_dialogue)<br>   .save(&quot;mistral_dataset&quot;)<br>)</pre><h3>Auto-deserializing LLM-responses to Pydantic</h3><pre>from datachain import DataChain, DataModel<br>from mistralai.models.chat_completion import ChatCompletionResponse<br><br>DataModel.register(ChatCompletionResponse)<br>chain = DataChain.from_dataset(&quot;mistral_dataset&quot;)<br><br># Iterating one-by-one: out of memory<br>for file, response in chain.iterate(&quot;file&quot;, &quot;response&quot;):<br>    # You work with Python objects<br>    assert isinstance(response, ChatCompletionResponse)<br><br>    status = response.choices[0].message.content<br>    print(f&quot;{file.get_uri()}: {status}&quot;)</pre><p>Output:</p><pre>gs://datachain-demo/chatbot-KiT/1.txt: Success<br>gs://datachain-demo/chatbot-KiT/10.txt: Success<br>gs://datachain-demo/chatbot-KiT/11.txt: Failure<br>...</pre><h3>Vectorized operations over Pydantic data fields</h3><p>In some cases, deserialization into a Python object can be skipped, and the computation can be executed directly within the underlying database.</p><pre># input tokens price: $2 per 1M tokens<br># output tokens proce: $6 per 1M tokens<br>cost = chain.sum(&quot;response.usage.prompt_tokens&quot;)*0.000002 \<br>      + chain.sum(&quot;response.usage.completion_tokens&quot;)*0.000006<br><br>print(f&quot;Spent ${cost:.2f} on {chain.count()} calls&quot;)</pre><p>Output:</p><pre>Spent $0.08 on 50 calls</pre><h3>Annotating cloud images with a local model</h3><p>Computer Vision use cases are especially sensitive to high performance data downloads.</p><pre>import io<br>from PIL import Image<br>from datachain import DataChain<br>from transformers import PaliGemmaForConditionalGeneration, AutoProcessor<br><br>model = PaliGemmaForConditionalGeneration.from_pretrained(&quot;google/paligemma-3b-mix-224&quot;)<br>processor = AutoProcessor.from_pretrained(&quot;google/paligemma-3b-mix-224&quot;)<br><br>def process_image(file) -&gt; str:<br>   image = Image.open(io.BytesIO(file.read())).convert(&quot;RGB&quot;)<br>   inputs = processor(text=&quot;caption&quot;, images=image, return_tensors=&quot;pt&quot;)<br>   generate_ids = model.generate(**inputs, max_new_tokens=100)<br>   return processor.batch_decode(generate_ids, skip_special_tokens=True,<br>                                 clean_up_tokenization_spaces=False)[0]<br><br>chain = (<br>      DataChain.from_storage(&quot;gs://datachain-demo/newyorker_caption_contest/images&quot;)<br>      .limit(5)<br>      .map(scene=process_image)<br>      .save(&quot;image_captions&quot;)<br>)</pre><h3>Optimizations: parallelization and data caching</h3><p>Parallel execution and data caching plays a critical role in the efficient data curation process.</p><pre>chain = (<br>   DataChain.from_storage(&quot;gs://datachain-demo/chatbot-KiT/&quot;,<br>                          object_name=&quot;file&quot;)<br>   .settings(parallel=4, cache=True)<br>   .limit(5)<br>   .map(response=eval_dialogue)<br>   .save(&quot;mistral_dataset&quot;)<br>)</pre><h3>DataChain needs your feedback!</h3><p>As usual in the open-source, we are providing this software for free, but we are also dependent on help from our community.</p><p><strong>First and foremost</strong>, we want you to try the product, let us know if it fits your data routine, and report any bugs or deficiencies that you may have seen. DataChain is still early in its lifecycle, so your feedback is crucial to the future of this product.</p><p><strong>Second</strong>, we need contributors! If you see a missing feature or an application for DataChain that could be built as an extension, we would be happy to see a pull request from you.</p><p><strong>Last, but not least</strong> — if you find DataChain useful, <a href="https://github.com/iterative/datachain">give us a star</a> ⭐ It goes a long way for us.</p><p><em>Originally published by </em><a href="https://twitter.com/FullStackML"><em>Dmitry Petrov</em></a><em> at </em><a href="https://datachain.ai/blog/datachain-release"><em>https://datachain.ai</em></a><em> on July 23, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90bed43ff1ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running DVC on a SLURM cluster]]></title>
            <link>https://medium.com/dvc-data-version-control/running-dvc-on-a-slurm-cluster-9aa47ca8f58d?source=rss-5b39037d735b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aa47ca8f58d</guid>
            <category><![CDATA[biotechnology]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[data-version-control]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[slurm]]></category>
            <dc:creator><![CDATA[DVC]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 00:00:26 GMT</pubDate>
            <atom:updated>2024-03-21T14:57:33.514Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="DVC and SLURM integration" src="https://cdn-images-1.medium.com/max/1024/1*8nP_lnee1XhgLAgbPz64CQ.png" /><figcaption>Exscientia’s Dom Miketa and Luis Yanes solution for integrating DVC and SLURM</figcaption></figure><h3>Introduction</h3><p>For many ML projects, there comes a point when local development hits the wall and we need to scale up the underlying compute resources. Maybe the dataset grows too large for your primary workstation or the deep learning model requires several high-end GPUs. This should be a routine transition for ML developers, and one to which they shouldn’t have to give much thought. In this blog post, we’ll explain our approach to remote DVC experiments on a SLURM cluster and share some code to get you started.</p><p>We work at an AI-driven precision medicine company called <a href="https://www.exscientia.ai/">Exscientia</a>. Our goal is to change the way the world discovers and develops new medicines. The company is roughly evenly split between biologists and chemists on one side and technologists on the other, with your two authors belonging to the latter group; Dom is an AI research scientist and Luis is an engineer. This context is important to understand why we gravitated towards DVC in the first place, and why we scaled it up the way we did.</p><h3>Why DVC on SLURM?</h3><p>As demonstrated in <a href="https://en.wikipedia.org/wiki/Accelerate_(book)">research undertaken by the DevOps movement</a>, it’s hard to maintain consistent software delivery without well-designed tooling (like CI/CD) and a conducive developer culture (like PRs or working in small batches). Our domain is highly specific, but the same principles apply: to move fast while maintaining high quality, reliability and reproducibility, we need to adopt best DevOps practices. There are only so many hours in a day and you want to spend all of them on trying out new ideas and ideally none on setting up infrastructure. Good tooling optimises scientists’ efficiency and lets them run more experiments, each more thorough and exhaustive than would otherwise have been possible — all this while maintaining control over research code bases which can, if left unchecked, turn into precarious Jenga towers. Predictable code with clear standards also eases collaboration, the lifeblood of science. Consequently it’s much more important to pick an arbitrary standard than to obsess over any particular detail.</p><p>At Exscientia we provide researchers with project templates that automatically set up version control and CI/CD as well as QA tooling like Black, Ruff and Mypy. To coherently extend this setup to the joint realms of data science and ML, we integrated DVC. Our scientists can set up a fresh DVC-enabled repository with all the productivity tooling in just a few keystrokes and start experimenting right away. And because DVC transparently extends Git, there is less tool-induced context switching: users are always dealing with Git in some shape or form, rather than Git (for the code) and a database hidden behind a web service (for all the rest of it). Less context switching translates to less frustration and more flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*iD6UQMARf2c9tZCc.png" /></figure><p>To maintain a frictionless developer experience even as model sizes grow beyond the means of the humble laptop, we surveyed the organisation’s entire computational estate with a view towards designing an effective developer experience. Our platforms must support a number of teams with on-demand Jupyter or RStudio instances as well as workflow orchestration engines. We need to run large unsupervised jobs, interactive analyses and development sessions across many domains and technologies: data processing, ML model training and chemical simulations, each with different resource requirements. Finally, submitting a large workload should be a smooth and routine experience.</p><p>In the end, a cloud-deployed SLURM cluster fit the bill. It can efficiently scale compute resources while maintaining a user-friendly interface for job submission. As a bonus, many of our users are already familiar with SLURM from their past lives in academia. The principal mode of interaction is very simple: the user submits a Bash script describing exactly what they want to happen, including the exact resources required. SLURM will wait until such resources are available and then execute the job as instructed. Thanks to this highly general interface, the same computational resource, and its administrators, can support very diverse groups of users at the same time, reducing infrastructural complexity across the organisation.</p><h3>A sample project</h3><p>We’ll set up a <a href="https://github.com/Exscientia/rdvc-demo-project">basic project</a> for this demo and, to keep with the drug discovery theme, we will be predicting solubility of chemical compounds in water using only our recently open-sourced framework MolFlux.</p><p>The DVC pipeline consists of a featurisation stage, which loads the “ESOL” dataset consisting of pairs of molecules and their aqueous solubilities — how easily a molecule dissolves in water.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*1Q-eBrCUYx6L7McH.png" /></figure><p>A few words about molecules and neural networks. Cheminformatics typically represents molecules as graphs, with atoms acting as the nodes and chemical bonds as the edges. There are several ways to feed molecular data to neural networks, each with its own pros and cons. GNNs can act directly on the molecular graph. You can also represent the graph as a string (most commonly using the SMILES format) and feed it to any sequence model such as a transformer.</p><p>In this example we’ll use a classic cheminformatics transformation called ECFP, or <a href="https://pubs.acs.org/doi/10.1021/ci100050t">extended connectivity fingerprint</a>. It’s essentially analogous to n-grams in NLP, which track whether a particular sequence of tokens appears in a text document. For example, does the 3-letter sequence “wea” appear in the Wikipedia article on blazers? Indeed it does, as part of “wear”.</p><p>Returning to ECFPs defined on molecular graphs, each “n-gram” is an atom and its immediate (e.g. 2-hop) neighbourhood. Since the “vocabulary” of all possible “n-grams” is finite, we can associate to each molecule a finite bit-vector (of the same length as the vocabulary) such that the choice of 0 or 1 indicates whether the corresponding “n-gram” is present in the molecule. This bit-vector is the ECFP fingerprint. And since it has a constant length, we can feed it into a large variety of ML algorithms, such as the MLP in the training stage.</p><p>We use DVC to configure and run the pipeline, decoupling the data featurisation step (where we convert molecules to ECFPs) from the model training step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*GsYNux4FrVWy5ipm.png" /></figure><p>DVC pipelines are useful to organise projects. As they are versioned in Git, you can reproduce complete workflows and results. Running a new experiment is a command away:</p><pre>dvc exp run</pre><p>This executes and tracks experiments in your repository without polluting it with unnecessary Git commits, branches, directories, etc. For more information and examples, see the <a href="https://dvc.org/doc/command-reference/exp/run">DVC documentation</a>.</p><p>It may not be immediately obvious, but our setup is highly modular. Head over to src/rdvc_demo_project/config/main.yaml to see just an example of configuration options we can tweak for each individual experiment. To start a much longer training run, execute</p><pre>dvc exp run -S model.config.trainer.max_epochs=100</pre><p>MolFlux was built to be explicitly config-driven and DVC’s <a href="https://dvc.org/doc/user-guide/experiment-management/hydra-composition">Hydra integration</a> exposes all of that flexibility out of the box.</p><h3>In the cloud</h3><p>Now that DVC experiments run on our local machine, we’d like to move them to the SLURM cluster. In this second repository, we share the source code to an internal tool we call <a href="https://github.com/exs-dmiketa/rdvc">rDVC</a> (for <em>remote</em> DVC). It is, by design, a very thin layer around dvc exp run and accepts all of its options and arguments. But on top of that it also recognises many of<a href="https://slurm.schedmd.com/sbatch.html">sbatch arguments and flags</a>, allowing it to control which computational resource inside the cluster will be used and for how long. For a full list of options consult rdvc run -help.</p><p>Let’s demonstrate how it works.</p><p>On its own, DVC knows nothing about your remote cluster, so we’ll need to start with a small amount of setup. Make sure you have cloned the sample project repo and installed the Python virtual environment using init_python_venv.sh. You will initialise your local rDVC config with</p><pre>rdvc init project</pre><p>Follow the wizard to set up default options for this project’s remote runs; they will be found in .rdvc/config.toml inside of the project repository. Depending on the cluster&#39;s setup, you may be able to choose the <em>instance type</em> allocated to your job. For the demo we have configured the cluster with t3.xlarge, g5.xlarge and g5.12xlarge. Our internal version of rDVC supports many more instance types and we encourage you to fork rDVC, redefine supported instance types and make the tool your own. For this demo, we pick g5.xlarge as the default instance as we want access to the GPU. But let&#39;s continue with the demo. To point rDVC at your SLURM cluster, we&#39;ll run the global initialisation script next:</p><pre>rdvc init global</pre><p>rDVC now knows how to contact SLURM, so let’s finish with configuration of the remote server:</p><pre>rdvc init remote</pre><p>Nothing stands between us and a remote GPU-powered experiment! Since rDVC is in many ways just a wrapper around dvc exp run, we can easily set off a run with modified parameters as</p><pre>rdvc run -S fabric=gpu</pre><p>When your run is finished you can pull it to your local repository with</p><pre>dvc exp pull origin</pre><p>and look at the results.</p><h3>Behind the scenes</h3><p>rDVC compiled a SLURM batch (or “sbatch”) script containing these instructions:</p><ol><li>Clone the project repo</li></ol><pre>#!/bin/bash<br><br>#SBATCH --output=&quot;.rdvc/logs/slurm-%j.out&quot;<br>#SBATCH --job-name=rdvc-run:rdvc-demo-project:main<br>#SBATCH --wckey=rdvc-demo-project<br>#SBATCH --mail-type=END,FAIL<br>#SBATCH --mail-user=&lt;email.address@domain.com&gt;<br>#SBATCH --constraint=t3.xlarge<br>#SBATCH --cpus-per-task=2<br>#SBATCH --nodes=1<br>#SBATCH --exclusive<br># Ensure bashrc is loaded<br>source &quot;${HOME}/.bashrc&quot;<br><br># Exit on failure http://redsymbol.net/articles/unofficial-bash-strict-mode/<br>set -euxo pipefail<br>IFS=$&#39;\n\t&#39;<br><br>export RDVC_JOB_REPO_NAME=&quot;rdvc-demo-project&quot;<br>export RDVC_JOB_REPO_URL=&quot;git@github.com:&lt;user&gt;/rdvc-demo-project.git&quot;<br>export RDVC_JOB_REPO_BRANCH=&quot;main&quot;<br>export RDVC_JOB_REPO_REV=&quot;&lt;git_hash&gt;&quot;<br><br>export RDVC_DIR=&quot;${RDVC_DIR:-${HOME}/.rdvc}&quot;<br><br># Prepare a directory for the current job<br>export RDVC_JOB_WORKSPACE_DIR=&quot;/tmp/rdvc-${SLURM_JOB_ID}&quot;<br>mkdir -p &quot;${RDVC_JOB_WORKSPACE_DIR}&quot;<br><br># Ensure cleanup after job finishes, regardless of exit status<br>function cleanup_job_dir(){<br>  echo &quot;Cleaning up the job directory.&quot;<br>  rm -rf &quot;${RDVC_JOB_WORKSPACE_DIR}&quot;<br>}<br><br>trap cleanup_job_dir EXIT<br><br># Create an insulated Git workspace for the current job<br>echo &quot;Creating Git workspace.&quot;<br>export RDVC_JOB_REPO_DIR=&quot;${RDVC_JOB_WORKSPACE_DIR}/${RDVC_JOB_REPO_NAME}&quot;<br>git clone --branch &quot;${RDVC_JOB_REPO_BRANCH}&quot; &quot;${RDVC_JOB_REPO_URL}&quot; &quot;${RDVC_JOB_REPO_DIR}&quot;<br>cd &quot;${RDVC_JOB_REPO_DIR}&quot; || exit<br><br># Ensure the job runs on the same revision as was submitted (even if the branch has moved on in the meantime)<br>git checkout &quot;${RDVC_JOB_REPO_REV}&quot;</pre><p>2. Install the Python virtual environment with init_python_venv.sh</p><pre># Install Python environment<br>echo &quot;Install Python environment.&quot;<br>./init_python_venv.sh<br><br>echo &quot;Activate Python environment.&quot;<br>source ./.venv/bin/activate<br><br># Setup links for the DVC cache shared among jobs and projects<br>dvc config --local cache.type hardlink,symlink,copy<br><br># Push results of experiments even if job fails<br>function cleanup_dvc(){<br> if [ &quot;$1&quot; != &quot;0&quot; ]; then<br>     # Push cache of all runs, including failed<br>     echo &quot;Job failed. Pushing run cache.&quot;<br>     dvc push --run-cache<br> else<br>     echo &quot;Job successfully finished.&quot;<br> fi<br><br> deactivate<br> cleanup_job_dir<br>}<br><br>trap &#39;cleanup_dvc $?&#39; EXIT</pre><p>3. Execute dvc exp run -S fabric=gpu</p><pre>export RDVC_JOB_EXP_RUN_OPTIONS_STRING=&quot;-S fabric=gpu&quot;<br>echo &quot;Executing DVC experiment.&quot;<br>eval &quot;dvc exp run --pull --allow-missing ${RDVC_JOB_EXP_RUN_OPTIONS_STRING}&quot;</pre><p>4. Push the experiment to the remote</p><pre># Push experiment to the remote and update the repository<br>echo &quot;Pushing DVC experiment to Git and DVC remotes.&quot;<br>dvc exp push $RDVC_JOB_REPO_URL</pre><p>This script is submitted to the cluster over SSH. You can view it in ~/.rdvc/submissions.</p><p>And that’s it! It’s so simple you could do it manually in an interactive SLURM session — and that happens to be a good way to debug issues. If your job fails, first consult its log over at ~/.rdvc/logs and then try to reproduce the submission script from an interactive session.</p><h3>Conclusion</h3><p>We shared two repositories: a simple DVC project and a tool for remote execution on SLURM clusters. The latter is universal — it knows nothing about the project! — and easily hackable. We highly recommend to fork and customise it to your team’s needs.</p><p><em>Originally published at </em><a href="https://dvc.ai/blog/dvc-slurm-cluster-exscientia"><em>https://dvc.ai</em></a><em> on March 11, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aa47ca8f58d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dvc-data-version-control/running-dvc-on-a-slurm-cluster-9aa47ca8f58d">Running DVC on a SLURM cluster</a> was originally published in <a href="https://medium.com/dvc-data-version-control">DVC — Data Version Control</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>