Dflow, a Python framework for constructing cloud-native AI-for-Science workflows

Xinzijian Liu, Yanbo Han, Zhuoyuan Li, Jiahao Fan, Chengqian Zhang, Jinzhe Zeng, Yifan Shan, Yannan Yuan, Weihong Xu, Yun‐Pei Liu, Yuzhi Zhang, Tongqi Wen, Darrin M. York, Zhicheng Zhong, Hang Zheng, Jun Cheng, Linfeng Zhang, Han Wang · DOI

Abstract

In the AI-for-science era, scientific computing scenarios such as concurrent learning and high-throughput computing demand a new generation of infrastructure that supports scalable computing resources and automated workflow management on both cloud and high-performance supercomputers. Here we introduce Dflow, an open-source Python toolkit designed for scientists to construct workflows with simple programming interfaces. It enables complex process control and task scheduling across a distributed, heterogeneous infrastructure, leveraging containers and Kubernetes for flexibility. Dflow is highly observable and can scale to thousands of concurrent nodes per workflow, enhancing the efficiency of complex scientific computing tasks. The basic unit in Dflow, known as an Operation (OP), is reusable and independent of the underlying infrastructure or context. Dozens of workflow projects have been developed based on Dflow, spanning a wide range of projects. We anticipate that the reusability of Dflow and its components will encourage more scientists to publish their workflows and OP components. These components, in turn, can be adapted and reused in various contexts, fostering greater collaboration and innovation in the scientific community.

Introduction

The "AI-for-Science" era demands massive computational throughput. Tasks like active learning for interatomic potentials or high-throughput drug screening require iterative, complex workflows that are notoriously difficult to manage. Traditionally, scientists have relied on manual task submission or brittle, hard-to-maintain scripts on supercomputers. While general-purpose workflow tools exist, they often suffer from steep learning curves or an inability to handle the recursive logic common in scientific computing.

Dflow addresses this "valley of death" between a conceptual algorithm and its practical implementation by providing a developer-friendly, Pythonic interface for cloud-native orchestration. By leveraging Kubernetes and Argo Workflows, it allows researchers to construct modular workflows that can scale to thousands of concurrent nodes across heterogeneous environments, from local workstations to massive high-performance computing (HPC) clusters.

Architecture and Methodology

Dflow’s architecture is built on top of Argo Workflows and Kubernetes, providing a robust engine for containerized task execution. A key strength of the framework is its infrastructure agnosticism; a researcher can develop and debug a workflow on a local workstation and deploy the exact same code to a cloud cluster or an HPC environment without modification.

A schematic graph of Dflow within the AI-for-science computing framework, illustrating the layers from application to infrastructure.

Core Technical Components

  • Operations (OPs): The fundamental unit of Dflow. An OP encapsulates a specific task (e.g., running a DFT calculation) as a standard Python class or function. OPs are designed to be reusable and independent of the underlying infrastructure.
  • Workflow Control: Dflow supports sequential steps, Directed Acyclic Graphs (DAGs), and recursive loops. It also introduces "Super OPs"—nested workflows that can be treated as a single building block.
  • Parallelization via Slices: A built-in "map-reduce" mechanism automatically parallelizes tasks across a list of inputs and collects the results.
  • Executor Plugins: Through the DispatcherExecutor, Dflow can dispatch tasks to traditional HPC schedulers like Slurm, PBS, or LSF, effectively treating a supercomputer as a resource within a cloud-native workflow.

Applications and Results

Dflow has demonstrated its utility across several high-impact scientific domains, showcasing significant scalability and resilience. The framework has been used to manage workflows with approximately 1,500 OPs and has achieved concurrency levels of over 1,200 GPU nodes.

Alloy Property EXplorer (APEX)

One prominent application is APEX, a Dflow-based tool that automates the evaluation of interatomic potentials. It handles the entire pipeline from structure relaxation to calculating elastic constants, phonon spectra, and other material properties.

The overall architecture of the APEX tool, demonstrating the transition from relaxation workflows to parallel property evaluations.

Other High-Impact Workflows

  • Virtual Screening: In drug design, Dflow was used to segment massive molecular libraries into manageable units, ensuring that computational loads on any given node were completed within a predictable window, significantly enhancing throughput.
  • TESLA: A workflow for training machine learning potentials using iterative active learning, which utilizes Dflow's ability to handle complex, looping logic.

Discussion and Conclusion

Dflow's "Lego" philosophy encourages a modular ecosystem. By standardizing the "Operation," the framework fosters collaboration, as community-contributed OPs for specific simulation packages can be dropped into entirely different projects. Furthermore, Dflow implements sophisticated fault tolerance, such as the continue_on_success_ratio, which allows massive parallel jobs to proceed even if a small percentage of nodes fail.

While maximizing reusability requires careful design of OPs to abstract input/output formats, Dflow provides a powerful abstraction layer for the AI-for-Science era. Future work focuses on expanding the ecosystem of reusable components, moving toward a future where complex scientific workflows can be assembled rapidly from a library of pre-validated, standardized parts.

Summary updated

BibTeX
@misc{liu2024dflow,
  author = {Xinzijian Liu and Yanbo Han and Zhuoyuan Li and Jiahao Fan and Chengqian Zhang and Jinzhe Zeng and Yifan Shan and Yannan Yuan and Weihong Xu and Yun‐Pei Liu and Yuzhi Zhang and Tongqi Wen and Darrin M. York and Zhicheng Zhong and Hang Zheng and Jun Cheng and Linfeng Zhang and Han Wang},
  title = {{Dflow, a Python framework for constructing cloud-native AI-for-Science workflows}},
  year = {2024},
  eprint = {2404.18392},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.18392},
}
Figure