Skip to content

Environments: matrix of optional variants #32893

@adamjstewart

Description

@adamjstewart

Summary

I would like to be able to create a Spack Environment with all possible values of a set of variants. Not all packages in the environment will have these variants, and some will have these variants recursively. Basically, I want something like:

spack:
  packages:
    all:
      matrix:
        - requires: +A~B
        - requires: ~A+B
        - requires: +A+B
        - requires: ~A~B
  specs:
    - C
    - D
    - E

Where +A and +B will be toggled one and off for C, D, and E, even if those packages don't have those variants, even if their dependencies also have those same variants.

Rationale

I'm working on creating a CI stack for ML packages: #31592

I would like to be able to test at least 3 variations:

  1. ~rocm+cuda cuda_arch=...
  2. ~cuda+rocm amdgpu_target=...
  3. ~cuda~rocm

At the moment, it seems like the only way to do this is to copy-n-paste the entire stack 3 times and change a single line. With this approach, 90% of the packages will be built twice with an identical spec since it isn't possible to reuse installations across stacks.

Description

I would like to be able to do something like:

spack:
  packages:
    all:
      matrix:
        - ~rocm+cuda cuda_arch=...
        - ~cuda+rocm amdgpu_target=...
        - ~cuda~rocm

Alternatively, something like:

spack:
  definitions:
    - packages:
      - py-torch
      - py-tensorflow
    - variants:
      - +cuda
      - +rocm
      - ~cuda~rocm
  specs:
    - matrix:
      - [$packages]
      - [$variants]

However, this doesn't work because not all packages in the list have those variants, and those variants won't be forwarded down the DAG. The only other alternative is to manually concretize every package in each DAG, get a list of all packages with those variants, and manually set the entire dep tree on each line myself. Nothing like a good ol':

spack:
  specs:
    - py-horovod ~rocm+cuda cuda_arch=... ^py-tensorflow ~rocm+cuda cuda_arch=... ^py-torch ~rocm+cuda cuda_arch=... ...
    - py-horovod ~cuda+rocm amdgpu_target=... ^py-tensorflow ~cuda+rocm amdgpu_target=... ^py-torch ~cuda+rocm amdgpu_target=... ...
    - py-horovod ~cuda~rocm ^py-tensorflow ~cuda~rocm ^py-torch ~cuda~rocm ...
    ...

Additional information

@becker33 @alalazo @scheibelp

General information

  • I have run spack --version and reported the version of Spack
  • I have searched the issues of this repo and believe this is not a duplicate

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions