Skip to main content

Concurrency

Concurrency control prevents multiple workflow instances from running simultaneously. Use this feature to protect shared resources and prevent conflicts.

Fields

group (required)

Concurrency group identifier. Workflows with the same group cannot run concurrently.

Type: string (non-empty)

Supports expressions: Yes

Example:

concurrency:
group: production-deploy

With expressions:

concurrency:
group: train-${{ .inputs.model_type }}

cancel_in_progress (optional)

Controls behavior when a new workflow arrives while another is running in the same group.

Type: bool

Default: false

ValueBehavior
trueCancel the running workflow and start the new one immediately
falseQueue the new workflow (maximum 1 running + 1 pending; newer replaces pending)

Example:

concurrency:
group: model-training
cancel_in_progress: true

Behavior

Queue mode (cancel_in_progress: false)

  • Maximum: 1 running + 1 pending workflow
  • New arrivals replace the pending workflow (keeps newest)
  • When the running workflow completes, the pending one starts

Cancel mode (cancel_in_progress: true)

  • New workflow cancels the running workflow
  • No queue: the newest workflow always runs

Examples

Model deployment

Ensure only one model deployment runs at a time:

id: deploy-model

concurrency:
group: production-deploy

jobs:
deploy:
steps:
- run: python deploy_model.py --env production

Per-model training

Allow concurrent training of different models, but serialize same-model training:

id: train-model

inputs:
model_type:
type: string
required: true

concurrency:
group: train-${{ .inputs.model_type }}

jobs:
train:
steps:
- run: python train.py --model ${{ .inputs.model_type }}

Experiment with cancel

For experiments where only the latest hyperparameters matter:

id: hyperparameter-tuning

inputs:
experiment_id:
type: string

concurrency:
group: experiment-${{ .inputs.experiment_id }}
cancel_in_progress: true

jobs:
tune:
steps:
- run: python tune.py --experiment ${{ .inputs.experiment_id }}

Interaction with other features

cancel_on_failure

Concurrency cancellations have state cancelled (not failed), so they don't trigger cancel_on_failure in other workflows.

Expressions

Concurrency groups support the same expression contexts as other fields: .inputs, .secrets, and .env.


Feedback