Skip to content
Scheduler

Scheduler

This page describes the dAIEdge-VLab scheduler and how it works.

The following diagram illustrates the overall architecture of the dAIEdge-VLab and the schedluler component within it. This is a conceptual high-level overview and does not fully represent the actual implementation details.

Scheduler overview

The dAIEdge-VLab Scheduler is a part of the dAIEdge-VLab benchmark API. Conceptually, they are two separate components, but as of now they are implemented in the same codebase. The main reason is that the scheduler is currently fairly simple and closely linked to the API. In the future, if the scheduler becomes more complex, it could be split into a separate service.

Two step orchestration pipeline :

  1. The scheduler receives a request from the user via the dAIEdge-VLab API. The request contains all the information needed to run a benchmark, such as the model, dataset, target device, and runtime environment, and user specific constraints (e.g., user’s priority, budget, time, etc.).
  2. The scheduler processes the request and selects the most appropriate target device based on the provided information and determines the optimal time to run the benchmark. It then creates a Nomad job with the necessary specifications and submits it to the Nomad cluster for execution.

Job descriptions :

  1. The first job description is the one provided by the Benchmark API. It aggregates all the information needed to run a benchmark and the user specific constraints (arrow 2 in the diagram). This job description is referred to as the pre-scheduler job description.
  2. The second job description is the one created by the scheduler. It is a Nomad job description that contains all the information needed to run the benchmark on the selected target device (arrow 3 in the diagram). This job description is referred to as the Nomad job description.

Pre-scheduler job description

The pre-scheduler job description is an object that contains the following fields :

  • Benchmark information :
    • benchmark_id: The unique identifier of the benchmark.
    • model: Model name
    • model_url: The URL to download the model.
    • runtime: The runtime environment to be used for the benchmark.
    • benchmark_type: The type of benchmark to be run. (TYPE1, TYPE2, etc.)
    • dataset: The dataset name to use for the TYPE2 benchmark. (optional)
    • dataset_urls: The list of URL(s) to download the dataset(s). (optional) (used for TYPE2 and TYPE3)
    • odt_config: Configuration file for the on-device training. (optional) (used for TYPE3)
  • Hardware information :
    • target: The targeted device family to run the benchmark on.
    • ram: The minimum amount of RAM required for the benchmark. (this is used to filter out devices that do not have enough RAM)
    • storage: The minimum storage required for the benchmark. (this is used to filter out devices that do not have enough storage)
  • User information :
    • user_id: The unique identifier of the user
    • user_priority: The priority of the user.
    • user_budget: The budget of the user.
    • user_time: The time constraint of the user.
  • Scheduling information :
    • submit_time: The time the benchmark was submitted.
    • deadline: The deadline to complete the benchmark.
    • max_retries: The maximum number of retries in case of failure.
Scheduler : This job description contains metrics that are currently ignored by the scheduler, but could be used in the future to improve the scheduling algorithm. Furthermore, the job description could be extended to include more information if needed.

Nomad job description

The Nomad job description is a HCL file that contains all the information needed to run the benchmark on the selected target device. It is created by the scheduler based on the pre-scheduler job description. The Nomad job can only contain information that is supported by Nomad and the edgedevice plugin (custom plugin developed for allowing edge device capabilities identification and status aggregation).

  • Why HCL and not a Json ? Nomad uses HCL (HashiCorp Configuration Language) for its job specifications. HCL is a human-readable configuration language that is easy to write and understand. This job description is then translated into JSON by the Nomad CLI or API before being submitted to the Nomad server.

The nomad job description can specify the following constraints :

  • The hardware requirements :
    • target: The targeted device family to run the benchmark on.
    • runtime: The runtime environment to be used for the benchmark.
    • benchmark_type: The type of benchmark to be run. (TYPE1, TYPE2, etc.)
    • ram: The minimum amount of RAM required for the benchmark. (this is used to filter out devices that do not have enough RAM)
    • storage: The minimum storage required for the benchmark. (this is used to filter out devices that do not have enough storage)
    • target_uid: The unique identifier of the target device. (This enforces the benchmark to run on a specific device)
  • The scheduling requirements :
    • priority: The priority of the job. (computed by the scheduler based on the user priority and other factors)
    • start_time: The time the job should start. (can be immediate or scheduled for later, can be periodic)
    • max_retries: The maximum number of retries in case of failure.
    • preemptible: Whether the job can be preempted by a higher priority job.
    • job_completion_threshold: Whether the job can preempt a lower priority job that is under a certain completion threshold.
  • The benchmark parameters :
    • nb_inference: The number of inferences to run for the benchmark. (for TYPE1)
    • dataset_filename: The name of the dataset file. (for TYPE2)
    • odt_config_filename: The name of the on-device training configuration file. (for TYPE3)
    • results_pub_url: The URL to upload the results of the benchmark.
  • Any other constraints supported by Nomad and the edgedevice plugin.

Now it appears clear that the Nomad job description can be very loosely constrained (e.g., only target family, runtime, benchmark_type) or very tightly constrained (e.g., specific device UID, start time, etc.) depending on the scheduler algorithm. For loosely constrained jobs, the Nomad orchestrator has more freedom to select the best target device and time to run the benchmark. For tightly constrained jobs, the Nomad orchestrator has less freedom. This allows for a trade-off between flexibility and control, depending on the scheduler algorithm implemented.

Current behavior: The scheduler now always emits the tightly constrained form, and only once a device has already been secured for it (see Device ownership, tracking and preemption below). None of the device-selection constraints described above (family, engine, supported types, RAM, storage, progress, …) are evaluated by Nomad anymore, they are evaluated by the scheduler itself before the job is even submitted. Nomad’s own constraint matching and preemption fields (preemptible, job_completion_threshold, …) become a safety net : they only come into play to arbitrate a conflict if two independent actors happened to request the same device at nearly the same time, not to pick a device on the scheduler’s behalf.

One fair question is :

  • Can the scheduler make aware decisions based on the current load of the devices and the cluster ?

Short answer is yes : the scheduler can access the Nomad API and query the status of the devices in the cluster (more generally it has access to the cluster context), in particular the dynamic attributes advertised by the edgedevice plugin. It uses this information to pick the specific target_uid a job gets constrained to. For example, if a device is currently busy running a benchmark, the scheduler picks another device that is idle instead. This allows optimizing the resource utilization of the cluster and reducing the waiting time for the user. Furthermore, the scheduler can also take into account the historical performance of the devices and the benchmarks to make more informed decisions. For example, if a device has a history of failing benchmarks, the scheduler can choose to avoid scheduling jobs on that device. It can also take into account the average time taken to complete a benchmark on a device to estimate the completion time of the job and schedule it accordingly.

Device ownership, tracking and preemption

Ideally, a single scheduler instance exclusively controls a given set of devices, so that it is the only actor deciding what runs on them. In practice this cannot always be guaranteed, another scheduler instance, or any other system entitled to submit jobs to the same Nomad cluster, may also request one of the devices a scheduler considers part of its own pool. The scheduler is designed to adapt to this rather than assume exclusive ownership :

  • Internal bookkeeping : every time the scheduler assigns a device to a job, it keeps track of it so that it never plans two jobs onto the same device at once.
  • Nomad event stream : the scheduler also listens to the Nomad event stream for allocation events on every device it can place jobs on. This is how it notices that another actor has placed a job on one of “its” devices in the meantime, and keeps its internal bookkeeping consistent with the actual state of the cluster.

This tracking is also what makes preemption possible : the scheduler can stop a job it placed itself to free up a device for a higher priority job, instead of only ever waiting for it to complete or relying on the Nomad orchestrator’s own preemption mechanism.

Concretely, before submitting anything, the scheduler resolves the whole placement decision itself : it checks, using the dynamic attributes described above, whether the device it wants is free. If it is not, it decides whether it is worth stopping the job currently running there based on several factors, including that job’s advertised completion (the ${device.attr.dynamic.progress} dynamic attribute), so that a job close to finishing is left alone (to avoid wasting compute) even if a higher priority job is waiting for that same device. Only once the device is confirmed free, killing the job already there first if needed, does the scheduler submit the new job, strictly constrained to that one target_uid.

Real example of a Nomad job description generated by the scheduler, once a device has already been secured this way :

job "benchmark-rpi4b-ort-20250813091714" {

  # Computed priority, Scheduler decision
  priority = 80

  # Cluster and type of job (never change)
  datacenters = ["dc1"]
  type        = "batch"

  # Planned execution time 
  # Can be immediate if this constraint is removed
  # or scheduled for later with a cron syntax
  # Scheduler decision
  periodic {
    crons             = ["30 17 7 13 8 * 2025"] # sec min hour day month dow year
    prohibit_overlap  = true
    enabled           = true
  }

  group "bootstrap-group" {
    # Only one instance of the job (benchmark job usually only need one instance)
    count = 1

    task "bootstrap-job" {
      driver = "docker"

      # Artifacts to download before starting the job
      # Download model from the API server 
      artifact {
        source      = "http://10.200.0.1:42777/download/small_model.onnx"
        destination = "local/"
      }

      # Image docker to run the job (common to all benchmarks)
      # The plugin selects the final image based on the target device
      # The image name and access rights never leaves the Host side
      config {
        image = "daiedge-vlab-bootstrap"
        network_mode = "host"
        auth {
            username = "******"
            password = "******"
        }
        privileged = true
      }

      # Setting environment variables for the job execution.
      # Follows the convention for the target repository. 
      env {
        NOMAD_ALLOC_ID   = "${NOMAD_ALLOC_ID}"
        NOMAD_NODE_ID   = "${node.unique.id}"
        TARGET  = "rpi4b"
        RUNTIME = "ort"
        VERSION_TAG = ""
        NB_INFERENCE = 20
        BENCHMARK_TYPE = "TYPE1"
        MODEL_FILENAME = "small_model.onnx"
        DATASET_FILENAME = ""
        ODT_CONFIG_FILENAME = ""
        RESULTS_PUB_URL = "http://10.200.0.1:42777/upload/rpi4b-ort-20250813091714/"
      }

      # Resource allocation for the job
      resources {
          device "daiedge/edgedevice" { #  Identify the device plugin
          count = 1                     #  how many boards the task needs, normally 1

          # Pick the exact board to run the benchmark on.
          # Family, engine, benchmark type, progress and available resources were
          # already checked by the scheduler itself before this job was submitted,
          # they are not repeated here as constraints.
          constraint {
            attribute = "${device.attr.target_uid}"
            operator  = "="
            value     = "rpi4b-0001-0001"     # Scheduler decision, the device it already secured
          }
        }
      }
    }
  }
}

With a single target_uid constraint, the Nomad orchestrator has no choice but to run the job on the specified device. Since the scheduler only submits it after confirming (or making) that device free, this is expected to always succeed, Nomad’s constraint matching only really matters as a last line of defense in case another actor raced for the same device in the short window between the scheduler’s check and the job submission. Should that happen, the scheduler must still be able to handle the resulting failure and either reschedule the job or notify the user.

Cluster Context

The cluster context is an important aspect to design the scheduler algorithm. The cluster is composed of a set of hosts each containing their set of edge devices that are registered to the Nomad orchestrator via the edgedevice plugin. Each device has a set of attributes that describe its capabilities and status (dynamic attributes). The scheduler can use these attributes to make informed decisions when selecting a target device and scheduling the job. Furthermore, the cluster can be dynamic, with devices being added or removed at any time. The scheduler must be able to handle such situations and adapt its scheduling algorithm accordingly.

The cluster context also includes the list of expected devices (including offline devices). This information can be used by the scheduler to avoid scheduling jobs on unknown devices. An unknown device is a device that is not registered to the blockchain and therefore not expected to be part of the cluster. The scheduler can use this information to avoid scheduling jobs on unknown devices and therefore avoid potential failures. This is a mechanism part of the trustworthiness of the dAIEdge-VLab (not deployed yet).

Nomad API

The nomad API can be queried to get the full list of nodes in the cluster with their attributes and associated resources. This information can be used by the scheduler to make informed decisions when selecting a target device and scheduling the job. The following endpoint can be used to get the list of devices in the cluster :

nomad operator api -X GET "/v1/nodes?resources=true"

Here is an example for the output of this command :

To get only the resources part of the output, you can use the following command :

nomad operator api -X GET "/v1/nodes?resources=true" | jq '[ .[] as $n
       | (($n.NodeResources // {}).Devices // [])
       | {id:$n.ID, name:$n.Name, devices:.} ]'

Here is an example of the output of this command :

List of edge nodes

The list of edge nodes is stored in a JSON file that is currently hardcoded in the scheduler. This file contains the list of expected devices in the cluster with their static attributes. The scheduler can use this information to avoid scheduling jobs on unknown devices. In the future this list will be provided by the blockchain. The following is an example of the list of edge nodes file :

This file is subject to change with the integration of the blockchain for user management.

Scheduling algorithm

The scheduler does the following :

  1. Receives the pre-scheduler job description from the Benchmark API.
  2. Computes the job priority based on its type (e.g., TYPE1, TYPE2, etc.) and the user priority.
  3. Queries the dynamic attributes of the available edge devices (see Cluster Context) and cross-checks them against its own bookkeeping of already-assigned devices, to pick one specific, currently free target_uid.
  4. Creates the Nomad job description constrained to that exact target_uid, together with the computed priority.
  5. Adds to the job description all the parameters needed to run the benchmark (model URL, dataset URL, number of inferences, etc.).
  6. Submits the Nomad job to the Nomad cluster for execution.
  7. Monitors the job status, and the Nomad event stream for the devices it manages, updating the Benchmark API with the job status (pending, running, completed, failed, etc.). If a higher priority job needs an already assigned device, the scheduler can stop the job it previously placed there itself, gated on the device’s advertised completion, to free it up. It doesn’t do any other rescheduling or advanced handling of failed jobs yet.

The Benchmark API is responsible for serving the different files needed to run the benchmark (model, dataset, on-device training config, etc.) and for receiving the results of the benchmark.