<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Distributed Model Exploration with EMEWS</title></titleStmt>
			<publicationStmt>
				<publisher>IEEE</publisher>
				<date>12/15/2024</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10568095</idno>
					<idno type="doi">10.1109/WSC63780.2024.10838848</idno>
					
					<author>Nicholson Collier</author><author>Justin M Wozniak</author><author>Arindam Fadikar</author><author>Abby Stevens</author><author>Jonathan Ozik</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[As high-performance computing resources have become increasingly available, new modes of applying and experimenting with simulation and other computational tools have become possible. This tutorial presents recent advancements to the Extreme-scale Model Exploration with Swift (EMEWS) framework. EMEWS is a high-performance computing (HPC) model exploration (ME) framework, developed for large-scale analyses (e.g., calibration, optimization) of computational models. We focus on three new use-inspired EMEWS capabilities, improved accessibility through binary installation, a new decoupled architecture (EMEWS DB) and task API for distributing workflows on heterogeneous compute resources, and improved EMEWS project creation capabilities. We present a complete worked example where EMEWS DB is used to connect a Python Bayesian optimization algorithm to worker pools running both locally and on remote compute resources. The example, including an R version, and additional details on EMEWS are made available on a public website.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>The Extreme-scale Model Exploration with Swift (EMEWS) framework is a high-performance computing (HPC) model exploration (ME) framework, developed for large-scale analyses of computational models that require the use of approximate, heuristic ME methods, such as calibration or Bayesian optimization, involving large ensembles. EMEWS was introduced to Winter Simulation Conference attendees through a previous advanced tutorial <ref type="bibr">(Ozik et al. 2016)</ref>. Since that time, the importance and complexity of computational studies for advancing scientific insight and supporting decision making has only increased. Our research group has been applying and evolving EMEWS to adapt to changing requirements related to ease of deployment, robustness, scalability, and heterogeneous computing resources. EMEWS has been used across many computational methods and applications, including agent-based models (ABMs) of infectious diseases <ref type="bibr">(Ozik et al. 2018;</ref><ref type="bibr">Tatara et al. 2019)</ref>, ABMs of information diffusion <ref type="bibr">(Kaligotla et al. 2020;</ref><ref type="bibr">Lindau et al. 2021)</ref>, ABMs of molecular systems <ref type="bibr">(Ozik et al. 2019)</ref>, deep learning for cancer <ref type="bibr">(Wozniak et al. 2018)</ref>, and microsimulations in cancer <ref type="bibr">(Rutter et al. 2019;</ref><ref type="bibr">Nascimento de Lima et al. 2023)</ref>.</p><p>EMEWS has also been used to support the COVID-19 response in Chicago and Illinois <ref type="bibr">(Ozik et al. 2021)</ref>. Informed by this experience in time-critical computing, a set of requirements for an open science platform for robust epidemic analysis emerged <ref type="bibr">(Collier et al. 2023)</ref>. These needs, which include support for very large number of tasks, analyses that extend beyond resource wall times, analysis persistence of data and metadata across computational campaigns, and coordinating tasks across distributed HPC resources, with robust, secure and automated access to each of the resources, guided the development of the new capabilities in EMEWS. In the same pandemic response context, EMEWS has enabled the development of new, fast time-to-solution, large-scale ME algorithms, that can exploit the concurrency provided by HPC systems. These include trajectory-oriented <ref type="bibr">(Fadikar et al. 2023;</ref><ref type="bibr">Fadikar et al. 2024</ref>) and large-batch Bayesian optimization <ref type="bibr">(Binois et al. 2021)</ref> approaches. <ref type="bibr">Collier, Wozniak, Fadikar, Stevens, and Ozik</ref> Through this tutorial paper we present the latest advances to the EMEWS framework, with a focus on demonstrating 1) a new software installation approach for ease of deployment, 2) a new decoupled architecture and task API for distributed workflows, and 3) new EMEWS project creation capabilities. These are use-inspired advancements to the EMEWS framework that together enable new and powerful modes of using computational studies in support of advancing science and improving support for evidence based decision making. These and other capabilities can be further explored on the EMEWS Project (2024a) site.</p><p>The remainder of this paper is organized as follows. In Section 2, we describe related HPC workflow systems, including how EMEWS expands on existing capabilities. In Section 3, we present the expanded EMEWS capabilities: binary installations, EMEWS DB, and the EMEWS project creator. In Section 4, we provide a complete worked example showing EMEWS DB in both a local and remote configuration, running Python and R ME algorithms. We summarize our contributions and discuss future directions in Section 5.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">RELATED WORK</head><p>Workflow management systems that coordinate tasks on HPC or cloud resources have gained in popularity as many-task computing has played an increasingly central role across scientific domains, with many open source systems being under active development (Workflows Community Initiative 2024). These systems can be thought of as divided between declarative and programmatically defined workflow systems. Merlin <ref type="bibr">(Peterson et al. 2022</ref>) is in the first category of systems where a specification, in the form of a directed acyclic graph (DAG), defines all task dependencies and the system is charged with coordinating the necessary steps to complete the set of tasks. Systems like Swift/T <ref type="bibr">(Wozniak et al. 2013)</ref> and Parsl <ref type="bibr">(Babuji et al. 2019)</ref>, on the other hand, use code and code analysis to determine inter-task dependencies. Both approaches have their advantages, including simplifying the workflow description interface for the declarative systems, and enabling more fine-grained control of workflows with the programmatic approach. The EMEWS framework has been built on the Swift/T workflow system (hereafter Swift), which provides flexibility in incorporating multiple programming languages within workflows <ref type="bibr">(Wozniak et al. 2015)</ref>, and through message passing, compiler techniques <ref type="bibr">(Armstrong et al. 2014)</ref>, and work stealing capabilities <ref type="bibr">(Lusk et al. 2010)</ref>, enables EMEWS workflows to efficiently scale to the largest computing resources <ref type="bibr">(Ozik et al. 2021)</ref>.</p><p>Building on the proliferation of workflow systems, there has been an emergence of approaches to allow increasingly complex algorithms to control the overall workflow logic. Two such examples are the Python libraries Colmena <ref type="bibr">(Ward et al. 2021</ref>) and libEnsemble <ref type="bibr">(Hudson et al. 2022)</ref>, where the logic of producing additional tasks based on the results of earlier tasks are encapsulated in Python code called "thinkers" in the former and "generators" in the latter. This inversion of control <ref type="bibr">(Ozik et al. 2015)</ref> pattern delegates the workflow progression logic to something outside of the workflow system itself and allows for arbitrarily complicated logic that can be defined using, in this case Python-based, scripts and 3rd party libraries for, e.g., statistical or machine learning based decisions on task generation. EMEWS, through the use of general task queues, provides the ability to define such control algorithms, also referred to as model exploration (ME) algorithms, in multiple languages, with a primary focus on Python and R. This extends the utility of EMEWS beyond the Python ecosystem <ref type="bibr">(Wozniak et al. 2018;</ref><ref type="bibr">Rutter et al. 2019;</ref><ref type="bibr">Ozik et al. 2021)</ref>.</p><p>Another trend for workflow systems is distributing them across multiple resources. This can provide bursting capabilities when demand for specific tasks within a workflow spike and also can align tasks with their optimal resource configurations. In this space, Globus Compute (formerly funcX) <ref type="bibr">(Chard et al. 2020)</ref> has been used by Colmena <ref type="bibr">(Ward et al. 2023</ref>) and libEnsemble <ref type="bibr">(Hudson et al. 2024)</ref> to securely enable the execution of tasks on a mix of distributed resources, e.g., sending simulation tasks to CPU resources and AI/machine learning tasks to GPU resources. Balsam <ref type="bibr">(Salim et al. 2019</ref>) is a Python-based workflow manager that provides centralized access to a number of existing HPC resources, including those at the Argonne and Oak Ridge Leaderships Computing Facilities (ALCF/OLCF) and the National Energy Research Scientific Computing Center (NERSC). Currently, access to the Balsam service is not public but Collier, Wozniak, Fadikar, Stevens, and Ozik is administered by the ALCF. With its latest capability enhancements, EMEWS, through the EMEWS DB queues discussed below, leverages Globus Compute to coordinate tasks across federated HPC resources, with robust, secure, and automated access to each of the resources. What is unique about EMEWS is that rather than employ a global task queue, each resource is provided with a local queue, which is located within the security cordon of the resource. This ensures alignment with the diverse authentication requirements of each HPC facility. Furthermore, these capabilities are available to anyone with a free Globus account.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">EXPANDED EMEWS CAPABILITIES</head><p>This section presents new capabilities in the EMEWS framework, including easy-to-install EMEWS binaries ( &#167;3.1), the new EMEWS DB decoupled architecture and associated task API for distributing workflows on heterogeneous compute resources ( &#167;3.2), and the improved EMEWS project creator ( &#167;3.3). Further details on these are found on the EMEWS Project (2024a) site.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">The EMEWS Anaconda Installer</head><p>Modern high-level scientific computing environments are used by researchers focused primarily on scientific results, and less focused on computing internals. These can include web or shell-based environments, with scientific tools and libraries that are easy to find, install, and incorporate into workflows. EMEWS is designed as a workflow system that provides access to such scientific resources, but is also intended to be scalable to exotic computing environments in which computing internals are exposed to the user.</p><p>To address this deployment challenge, we developed the EMEWS Anaconda Installer, which provides prebuilt binaries that can be quickly and seamlessly installed across platforms. This is built on Anaconda-based installations of core EMEWS components, including Swift (Wozniak 2024a), R, Python, and PostgreSQL, and provides further access to Anaconda packages for Python, R, etc., for the user.</p><p>The binary installation approach has software engineering trade-offs in terms of maintainability, and strengths and weaknesses from a user perspective, when compared against the alternative, a source-based installation process. The main complexity is that the underlying workflow engine is built on a scalable, MPI and C -based system <ref type="bibr">(Lusk et al. 2010</ref>). Compiling this system can produce errors that are unfamiliar to users new to this type of programming. Primarily, this approach pushes the ownership of such issues to the EMEWS team, and decreases the likelihood that end users will see them. This incurs costs on the EMEWS team, as we must maintain binary packages for a range of OS and hardware configurations (currently 4), with associated testing and development workloads.</p><p>The strength of this approach is that users can generally get up to speed with EMEWS on a local system as quickly as with other Anaconda-based packages. The potential weakness of the approach is that the user is essentially locked into Anaconda as an "OS." Swift will use the MPI and C language runtime in Anaconda, and other such resources, rather than those that might be available on an exotic computing system such as a tuned vendor-provided MPI installation. However, the binary installation allows for quick and painless startup for experimenting with EMEWS and developing workflows that can be deployed on larger systems with more bespoke software stacks, where a source-based installation of EMEWS may already exist, HPC facility support for installation can be requested, or the user has assessed the utility of EMEWS such that investing in learning about source installations makes sense.</p><p>In summary, the EMEWS Anaconda Installer offers a first step for scientific users that desire to quickly access EMEWS capabilities on small-scale resources, in an environment familiar to users of highlevel programming environments. Once "hooked" on EMEWS workflows, the user can then progress to larger-scale runs on supercomputing systems supported by the traditional source-based EMEWS installers.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">EMEWS DB</head><p>EMEWS DB builds on our earlier queue-like workflow interfaces: EMEWS Queues for Python (EQ/Py) and R (EQ/R) <ref type="bibr">(Ozik et al. 2016)</ref>. There, the main user interface is a Swift script, a high-level program Collier, Wozniak, Fadikar, Stevens, and Ozik that starts the ME algorithm which then provides tasks for evaluation to the Swift script via an in memory output queue. The tasks are distributed by the Swift runtime over a potentially large computer system where they are evaluated, and the results are returned to the ME via an in memory input queue. The two components here, the Swift script and the ME algorithm are tightly coupled. They both run as part of the same HPC job and typically with the same node configuration.</p><p>EMEWS DB loosens this tight coupling by separating the execution of the Swift script from that of the ME. A PostgreSQL database serves as a mediator between the two. The ME submits tasks to the EMEWS task database ( &#167;3.2.1). A Swift worker pool ( &#167;3.2.2) retrieves tasks from the database for evaluation, and returns the results to the database where they are retrieved by the ME. The communication of tasks, their status, and evaluation results are all done through the EMEWS task queue API ( &#167;3.2.3). Figure <ref type="figure">1</ref> illustrates the main components of EMEWS DB. While the decoupled nature of EMEWS DB queues adds complexity compared to the existing EQ/R and EQ/Py queues, there are many benefits. These include the ability to run long computational campaigns with very large number of tasks and analyses that extend beyond resource wall times. The more monolithic EQ/R and EQ/Py approaches, while convenient, are limited to the maximum length of time available for individual HPC jobs. In addition, the mediating database better supports the persistence of data and metadata during and across computational campaigns, enabling progress-monitoring tools to access the database, and provides the ability to restart and/or share partial results. Another benefit is that, with increasing levels of heterogeneity and specialization in current and upcoming computing infrastructure, EMEWS DB can enable the execution of different types of work on different hardware resources. For example, ML algorithms are best executed on GPUs or other accelerators, while simulations might better utilize CPU resources. EMEWS DB enables robust, secure, and automated simultaneous access to multiple distributed compute resources, providing the ability to create integrated, multi-resource computational workflows.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2.1">EMEWS Task Database</head><p>The EMEWS Task Database is a resource local SQL database, consisting of tables and SQL code that implement the task input and output queues, a tasks table (one row for each task), and tables for associated metadata. The tasks table contains the data associated with each task: a unique task identifier; current status (queued, running, completed, or canceled); a task work type; the input payload (e.g., simulation</p><p>Collier, Wozniak, Fadikar, Stevens, and Ozik input parameters); the result payload; the identifier of the worker pool running the task; the time the task was created; the task execution start time; and the task execution stop time.</p><p>When a task is submitted to the database, an entry for it is created in the tasks table -including the unique id for that task -and the creation time is recorded. Concomitantly, an entry for the task is created in the output queue table. When that task is popped off the output queue table, the task's table entry is updated to tag it as running, and the start time is recorded. When the task has finished and its result is returned to the database, the task's table entry is updated with the result. It is also tagged as completed or canceled, and the stop time is recorded. An entry for the task in the input queue is then created. The task database persists regardless of the state of the worker pool, or ME. For example, an ME can submit tasks, and stop execution. Then when restarted, it can query for the results. Similarly, if a worker pool fails, the task database can be queried to determine the unevaluated tasks, e.g., incomplete tasks due to the worker pool failing, and those can be resubmitted.</p><p>Using the Task Queue API ( &#167;3.2.3), an ME submits tasks to the database, pushing them on to the output queue, and waits for some number to complete, popping them off the input queue as they become available. Meanwhile, a Swift worker pool also using the Task Queue API, pops tasks off the output queue, evaluates them, and pushes the results back to the input queue. As resource local the expectation is that the database will be run on the same resource as the worker pool. This is both to avoid communication overhead between the worker pool, which may be querying the database for 1000's of tasks at a time, and to avoid any security concerns with HPC compute nodes networking with remote databases. EMEWS DB includes an API (the eqsql.db_tools module) for starting, stopping and creating the EMEWS task database. This can be used as-is when executed on the resource running the database, or via Globus Compute when the database is on a remote resource. For a more in-depth description of the EMEWS task database, see <ref type="bibr">(Collier et al. 2023)</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2.2">Swift Heterogeneous Worker Pools</head><p>Worker pools are responsible for querying the database via the output queue for submitted tasks, executing them, and then reporting the results of those tasks back to the database where the ME algorithm can retrieve them via the input queue. Our canonical worker pool implementation is a Swift application written using the Swift language and Python, running on a HPC resource (or locally for smaller prototype or debugging runs) as a pilot job. Our worker pool implementation leverages the ability of Swift to distribute work across compute processes and execute that work concurrently, to evaluate as many submitted tasks in parallel as possible. Worker pools can run a variety of task application types using Swift's Python and R interfaces as well as command line executables, including MPI applications, via its app function type, and @par keyword <ref type="bibr">(Wozniak 2024b)</ref>.</p><p>Worker pools can be matched to those HPC resources configured to most efficiently execute their work type by specifying a work type for each task, such that a worker pool only pops tasks of that type off the output queue. In this way, a worker pool configured to run a multi-process MPI application can retrieve work of that type via an associated work type id versus another work type associated with a single process GPU enabled application, for example. Consequently, the tasks generated by an ME need not be served by a single worker pool, but can leverage increasingly common heterogeneous HPC architectures through differently configured worker pools. EMEWS DB includes a worker pool API (the eqsql.worker_pool module) for starting and stopping worker pools both locally and on remote resources.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2.3">Task Queue API</head><p>The EMEWS DB Task Queue API is implemented in Python in our eqsql package, and in R. The R package implementation is essentially a wrapper around the Python code, using Reticulate (Ushey, Allaire, and Tang 2024) together with some bespoke R functions. The core task queue API is defined in a TaskQueue Python protocol containing methods for submitting tasks, retrieving results, and for manipulating submitted Collier, Wozniak, Fadikar, Stevens, and Ozik tasks (canceling and changing priority). The methods signatures for submitting tasks can be seen in Figure <ref type="figure">2</ref> for both individual and lists of tasks. Tasks are submitted with an experiment id (the exp_id argument), identifying the experiment workflow associated with the task, the work type of task (eq_type), matching it with a worker pool, a payload string (payload), a priority (priority), and an optional metadata tag (tag). The payload is typically a JSON string containing the input parameters for the task execution. When a task is submitted, an entry is created in the EMEWS database as described in &#167;3.2.1. Task submission returns an instance of an eqsql.core.Future or a list of eqsql.core.Futures. A Future encapsulates the asynchronous execution of a task, and is implemented as a Python class. Future class methods allow ME algorithm code to query the status (running, finished, etc.) and check for a result of the encapsulated task without waiting for it to finish. Other methods provide the ability to cancel and reprioritize the task with respect to other tasks in the output queue.</p><p>Typically an ME algorithm will submit a number of tasks, wait for some number of results, either all of them in the case of an iterative batch algorithm or some subset of the total in the case of an asynchronous algorithm, and then process the results of the task evaluations. The core Task API's as_completed method (see Figure <ref type="figure">3</ref>) allows an ME author to easily implement this pattern.  as_completed takes a Python list of Futures and returns a Python generator, allowing client code to iterate over the Future tasks as they complete. The pop argument, when true, will pop any completed tasks off the list of passed in Futures. By default, as_completed will loop until all the passed-in tasks have completed. The n argument overrides this such that the loop will return that number of completed tasks. The remaining arguments control aspects of the loop iteration, timeout after timeout seconds, pause sleep amount between querying all the passed in Futures for results, and gather batch_size number of results before yielding in the generator. Figure <ref type="figure">4</ref> illustrates an example of an asynchronous ME using the Task Queue API. Here, line 6 initializes a local task queue (for more on task queue types, see below). Line 9 creates a list of payloads from 2000 random samples and line 10 submits the payloads for execution. Line 11 creates a results dictionary that holds the payload, and result (initially None) for each task. This allows the ME to assign the input (a particular task payload) to its evaluation. Then the algorithm iterates for max_steps number of iterations, using as_completed to retrieve results, popping the completed futures off the list of futures (line 14). The results dictionary is updated in line 16 with the new results, and a new set of payloads is created from the updated results in line 18. In lines 19 -22, the task payloads are submitted, the results dictionary is updated, and the new list of Futures is added to the existing list passed to as_completed in the subsequent step.</p><p>Collier, Wozniak, Fadikar, Stevens, and Ozik import numpy as np import json from eqsql.task_queues import local_queue task_queue = local_queue.init_task_queue(...) rng = np.random.default_rng() payloads = [json.dumps({'x': for x in rng.random(2000)})] _, fts = task_queue.submit_tasks(exp_id, task_type, payloads) results = {ft.eq_task_id: [payloads[i], None] for i, ft in enumerate(fts)} for step in range(max_steps): for ft in task_queue.as_completed(fts, pop=True, n=100): result = ft.result() results[ft.eq_task_id][1] = result payloads = create_payloads(results) new_fts = task_queue.submit_tasks(exp_id, task_type, payloads) for i, ft in enumerate(new_fts): results[ft.eq_task_id] = [payloads[i], None] fts += new_fts The Task Queue API provides three task queue implementations: one local and two remote. Here local implies that the ME using the task queue code is running on the same resource as the database. The remote task queues use a mediating technology to transfer the payloads and results between the resource where the task queue is executing and the database running on an HPC resource. Both remote task queues ultimately call Python functions on the HPC resource which itself uses a local task queue to submit tasks and retrieve results. The Globus Compute task queue uses Globus Compute <ref type="bibr">(Chard et al. 2020)</ref>, formerly known as funcX, to execute these remote function calls, and the EMEWS Service task queue uses JSON messages and a RESTful web service (the EMEWS service) running on the HPC resource that then executes these functions. Regardless of whether the task queue is local or remote, they are all decoupled from worker pool execution such that they can run on a different hardware resource, or with a different configuration.</p><p>Local task queues offer many different types of EMEWS DB usage patterns. For example, HPC resources increasingly offer Jupyter notebook servers on which an ME using a local task queue can run, submitting work to a worker pool running on the resource. In addition, HPC job schedulers, such as slurm and PBS, support running a job with different applications and different arguments for each application. In this way, a local ME, using a local task queue, and a worker pool can run as part of the same job, but use different hardware configurations. As for the remote queues, the ME can run on hardware entirely separate from the worker pool(s), in a Jupyter notebook running on a laptop, or on some other hardware resource best suited for the ME, for example, while the worker pools run on more traditional HPC systems.</p><p>The above has focused on how an ME uses the Task Queue API to push tasks to the output queue. However, the local queue also contains functionality for popping tasks off the output queue for execution and for pushing the results of executed tasks on to the input queue. This functionality is used by our canonical Swift worker pool implementation to get tasks, execute them concurrently, and push the results back. This capability is implemented only in the local task queue as the EMEWS DB is intended to run locally on the worker pool resource for security and performance as described earlier in &#167;3.2.1. The method signatures for the functionality used by the worker pool can be seen in Figure <ref type="figure">5</ref>.</p><p>query_more_tasks is an output queue task query, customized for worker pools. This call allows a worker pool to request up to batch_size tasks to consume at a time, while accounting for the number of tasks a worker pool has obtained already but has not completed. So, for example, if a worker pool is  configured to possess 33 tasks at a time, and if it owns 30 uncompleted tasks when querying the output queue, it will only obtain 3 additional tasks. The eq_task_ids argument tracks the tasks currently owned by the worker pool. The task request can be modified using a threshold value that specifies how large the deficit between requested tasks and owned tasks must be before more tasks are obtained. Querying for tasks in this way allows a worker pool to tune its query to the number of available workers such that all its workers are busy while equitably sharing work among multiple worker pools. This prevents any one worker pool from obtaining more tasks than it can reasonably execute while potentially leaving other pools starved of work. The remaining query_more_tasks arguments allow a worker pool to query for tasks of a particular type (eq_type), tag the task as retrieved by the named worker pool using the worker_pool argument, specify the number of seconds to delay when polling the EMEWS DB, and a timeout value after which the query will timeout. query_more_tasks returns a Python Tuple containing a list of the ids of the tasks owned by the worker pool (i.e., those currently running, and any new ones returned by the query), and a list of Python Dictionaries containing the task payloads and query metadata.</p><p>The report_task method is simple in comparison, and is used to push the result of a task's evaluation to the input queue where it can be retrieved by an ME. The eq_task_id is the id of the completed task, eq_type the work type , and result the result of the task evaluation.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">EMEWS Creator</head><p>Implementing an EMEWS workflow can involve writing some amount of boilerplate code, including model and worker pool submission scripts, and ME task submission and retrieval. EMEWS Creator, a Python command line application for creating EMEWS workflow projects, automates the creation of this boiler plate code for input parameter sweep, EQ/Py, EQ/R, and EMEWS DB projects. It can also be used to initialize an EMEWS task database. As a Python package, it can be installed from PyPI using pip install emewscreator.</p><p>The emewscreator command line application takes five commands: 1) eqpy, which creates an EQ/Py workflow project; 2) eqr, which creates an EQ/R workflow project; 3) sweep, which creates a sweep workflow project; 4) eqsql, which creates an EMEWS DB workflow project; and 5) initdb, which initializes an EMEWS task database. Each of the project commands can be configured using a yaml format file or through command line arguments. To create an EMEWS DB project, for example, configured by a "my_cfg.yaml" file in an "emews" directory, the command line would look like:</p><p>emewscreator -o emews eqsql -c my_cfg.yaml Example configuration files can be found on the EMEWS Creator repository (EMEWS Project 2024c).</p><p>Running emewscreator creates a canonical project directory tree containing Python, R, and Swift code, as well as bash scripts for running a model, and submitting Swift workflows to local and HPC resources. For example, creating an EMEWS DB project will produce Python and R prototype ME code, and a Swift worker pool implementation, together with other required files (Swift extensions, and submission scripts). The Python and R prototype code includes boiler plate for starting the EMEWS task database, initializing the task queue, checking for a coherent input and output queue state, and starting a worker pool. Sections marked with TODO contain examples of the Task API ( &#167;3.2.3) for creating task payloads, submitting those payloads, and retrieving results. Other files also include TODO sections, but much of the customization is achieved using yaml format configuration files, prototypes of which are also produced by <ref type="bibr">Collier, Wozniak, Fadikar, Stevens, and Ozik EMEWS Creator.</ref> A much more thorough discussion of EMEWS Creator and all its options can be found in the EMEWS Tutorial at the EMEWS Project (2024a) site.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">EMEWS DB WORKED EXAMPLE</head><p>In order to showcase the various elements of EMEWS DB, we provide a complete worked example where we use a simple simulation model and an ME algorithm to optimize it. We first present the details of the simulation model and ME algorithm ( &#167;4.1) and then demonstrate how to use the capabilities of EMEWS DB to create local and remote Bayesian optimization EMEWS workflows ( &#167;4.2).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Simulation Model and ME Algorithm</head><p>For this example, we have adapted the Zombies demonstration model distributed with Repast4Py <ref type="bibr">(Collier and Ozik 2022</ref>). The Zombies model involves two agent types, Zombies and Humans, where the Zombies pursue Humans, seeking to infect them. Once a Human agent is infected it is transformed into a Zombie agent after an incubation period lasting a number of time steps. Each time step, each Zombie and Human examines their local Moore neighborhood and moves towards the location with the most Humans or fewest Zombies, respectively. In this adaptation, we have introduced a varying movement step size for each of the agent types. The original model had Zombies move in fixed steps of length 0.25 (in units of the model space) and Humans in steps of length 0.5. The present model encapsulates these two values in two float type parameters zombie_step_size and human_step_size.</p><p>The value to optimize in this example is the remaining number of Humans at a specific simulation time step, where we deem more surviving Humans as a better outcome. Since this is a stochastic model, we run each parameter combination (zombie_step_size, human_step_size) five times, varying the random seed for each, and the remaining number of Humans is averaged to yield the final number of survivors. The adaptive parameter search algorithm we used is Thompson sampling (TS). TS <ref type="bibr">(Thompson 1933;</ref><ref type="bibr">Thompson 1935</ref>) is a probabilistic approach used in decision-making under uncertainty, particularly in the context of sequential decision problems like reinforcement learning <ref type="bibr">(Russo et al. 2018)</ref>, multi-armed bandit problems <ref type="bibr">(Agrawal and Goyal 2012)</ref>, and Bayesian optimization <ref type="bibr">(Fadikar et al. 2023)</ref>. In TS, decisions are made by sampling from the posterior distribution of the unknown parameters in the problem space. In the Zombies model, this distribution represents the expected number of surviving Humans based on different step sizes taken by Humans and Zombies. The key idea is to balance exploration (trying new options) and exploitation (leveraging current knowledge) for making optimal decisions by sampling from the posterior distribution of the simulation input at untested settings. Here we integrate the TS algorithm with a Gaussian process (GP) <ref type="bibr">(Williams and Rasmussen 2006)</ref> surrogate, providing a non-parametric regression model to anticipate simulation results at unexplored configurations with probabilistic uncertainty, and a method to efficiently sample multiple parameters at a time (TS). To start with, a GP model is trained on an initial batch of simulations and subsequently updated as the simulation dataset expands during optimization. At each iteration, samples are drawn from the fitted GP's predictive surface to identify the next batch of parameter combinations for conducting new simulations. The pseudo-code for the ME can be seen in Algorithm 1.</p><p>Figure <ref type="figure">6</ref> demonstrates that the TS procedure is able to find an optimal parameter configuration after just two iterations. We first fit a GP using an evenly spaced initial design of size 5. The resulting predictive surface suggests that higher values (i.e., the maximum number of surviving Humans) are more likely at parameters near the origin (bottom left corner). The TS procedure then samples new points close to the origin. We fit another GP and notice that the surface is smoother, especially for smaller Zombie step sizes. We perform one more TS iteration and only find a few additional points, evidence that the first iteration managed to characterize the parameter space quite well already. The results confirm that, for Humans to have the best chance of survival, Zombies should move as slowly as possible while Humans must move faster but not too much faster, staying within their examined local neighborhood and not running into unseen areas where Zombies might exist. Re-sample using TS 7:</p><p>Submit the samples for evaluation by Zombies model 8:</p><p>Wait for results (average number of Humans)</p><p>9:</p><p>Update the GP surrogate with the results 10: end for </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">EMEWS DB Example Workflows</head><p>The pseudo-code from Algorithm 1 is implemented in Python in a Jupyter notebook, which can be found in the tutorial example repository (EMEWS Project 2024b). Leaving aside the specifics of the TS implementation and the plotting code used to produce Figure <ref type="figure">6</ref>, the following will focus on the EMEWS DB specific parts of the notebook implementation. This first example uses a local task queue ( &#167;3.2.3) and subsequently we demonstrate how to extend it to a Globus Compute remote task queue where tasks are run on a remote HPC resource. Figure <ref type="figure">7</ref> begins with the initialization of the various EMEWS DB components.</p><p>Here params is a Python dictionary containing the configuration parameters for the ME. This is typically loaded from a yaml format file created using EMEWS Creator ( &#167;3.3). The initialization begins by starting the database (line 4) and initializing a local task queue (line 5) using the EMEWS DB eqsql package imported in lines 1 and 2. The task_queue will submit tasks and retrieve results for the queues in that database. In line 7 we check if the input and output database queues are empty and, if not, we abort the run, ensuring that only tasks produced in this run are submitted and retrieved. Having confirmed that the input and output queues are in a coherent state, a Swift worker pool is started, again using a Python module from the eqsql packages. In this case, a local pool is started, where local indicates that the pool runs on the same resource as the ME (i.e., the one running the notebook). Whether local or remote, the pool</p></div></body>
		</text>
</TEI>
