Skip to content

Rename service replica groups to groups and support IP interpolation - #4177

Open
Bihan wants to merge 1 commit into
dstackai:masterfrom
Bihan:pr_service_groups_interpolation
Open

Rename service replica groups to groups and support IP interpolation#4177
Bihan wants to merge 1 commit into
dstackai:masterfrom
Bihan:pr_service_groups_interpolation

Conversation

@Bihan

@Bihan Bihan commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Services can now use the same groups: layout as tasks, and service commands can reference other replicas by IP with ${{ groups[i].replicas[j].IP_ADDRESS }}.

Previously, heterogeneous services used a list under replicas with count. That is renamed to groups with replicas (matching tasks’ groups / nodes). Old YAML still works; saved configs still use the old replicas: [{count}] layout.

A follow-up PR can deprecate that layout and save as groups instead.

Key changes

  1. Both layouts work

Old

replicas:
  - count: 1
    commands: [...]

New

groups:
  - replicas: 1
    commands: [...]

Saved configs still use the old replicas layout, not groups.

  1. Interpolation rules
    You can only reference replicas that are guaranteed at start:
- replicas: 2 → slots 0 and 1 are OK

- replicas: 1..4 → only slot 0 is OK

- replicas: 0..4 → no IP refs allowed
  1. Preset fix
    Preset build had a helper that assumed service.replicas is a list of groups, but that list shape no longer exists in memory after this PR.

Before

resources = (
    service.replicas[group_num].resources
    if isinstance(service.replicas, list)
    else service.resources
)

After

for group in service.replica_groups:
    resources = group.resources
    resources.gpu.vendor = verification_vendor

This does not change behavior for presets that were already saved. Existing presets load as-is; this logic only runs when building a new preset.

Next: Separate PR for Docs

@Bihan
Bihan requested a review from r4victor August 20, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant