Skip to content

Proposal to redefine the platforms to include their virtual packages. #4458

Description

@ruben-arts

Problem description

Pixi only allows users to specify the subdir in a platforms entry. Which sometimes is to limited to create a proper description of the platform you are running on.

We currently solve this by allowing you to define system-requirements. This forces users to create multiple environments to support different machines.

A good example is how Pixi requires you to define multiple environments to have both a gpu and a cpu version of the environment.

Proposal

We allow specifying variants of platforms, which we would call a "subplatform".
Environments are solved for all specified (sub)platforms and when installing/running the first platform from the list is selected that matches your system.
The order in which the platforms are defined is relevant!

[workspace]
platforms = [
    { os = "linux", arch="x86-64-v3", cuda="13" },
    { os = "linux", arch="x86-64-v3", cuda="12.9" },
    { os = "linux", arch="x86-64-v3"},
    { os = "macos", arch="arm64"    },
    { os = "windows", arch="x86-64", windows = "10.9" },
    "linux-64",
]
required-pixi = "0.53.0"
  • On linux x86-64-v3 with cuda==13 it will take the first.
  • On linux x86-64-v3 with cuda==12.* it will take the second.
  • On linux-64 without a specialized arch or cuda it will take the last platform.

Defaults

Non specified virtual packages are defaulted. The default set is defined by the required-pixi version. If no required-pixi is defined we use the oldest set (current).

System-requirements

Subplatforms deprecates [system-requirements] as it will be configurable through the platforms field.

CLI UX

To add the current subplatform you can run:

pixi workspace platform add self

The alias self is TBD!

To add a specific subplatform you can run:

pixi workspace platform add --os linux --arch x86-64-v3 --cuda 12.8

This could also be replaced with pixi lock?

This solves:

The current pixi features, setup of a cuda and non-cuda environment would require the following pixi.toml:

[workspace]
# ...
platforms = ["linux-64"]

[dependencies]
pytorch = "*"

[feature.gpu.system-requirements]
cuda = "12.9"

[environments]
cpu = []
gpu = ["gpu"]

Then on the GPU machine you would always have to run:

pixi shell --environment gpu
pixi shell --environment cpu
# or
pixi run --environment gpu
pixi run --environment cpu

With the features described in this proposal you would be able to do the following:

[workspace]
# ...
platforms = [
{ os = "linux", arch = "x86-64", cuda = "12.9" },
"linux-64"
]

[dependencies]
pytorch = "*"

Pixi will then pick up whether it should use the one with or without cuda.

pixi run
# On a cuda machine it will use the cuda packages in the environment
# On a non-cuda machine it will use non-cuda package in the environment.

Questions

  • What about the "best_platform" logic? e.g. when you're on win-arm64 and have a lockfile for win-64 should you install win-64 or try win-arm64?
  • What should be the default for pixi init?
  • When should we add the native platform to the manifest, and how specific should it be to the platform, e.g. with or without archspec?

Related

This is related to #4457, as it would be great to avoid all of these definitions when you don't care about them in the first place, as a maintainer of a project.

Activity

  1. added
    enhancement
    configuration
    UX
    on Aug 28, 2025
  2. geoHeil commented on Aug 30, 2025

    @geoHeil

    It would be neat if lets say ARM osx can resolve package for a different platform such as linux x86.

  3. baszalmstra commented on Aug 30, 2025

    @baszalmstra
    Contributor

    Maybe I dont understand but is that not already the case?

  4. matthewfeickert commented on Aug 30, 2025

    @matthewfeickert
    Contributor

    I guess this is mostly a convenience factor (?), but I don't feel very limited by the issues of different virtual packages (e.g. cuda) for the most part. Though perhaps the following is an explicit use case motivated by carpentries-incubator/reproducible-ml-workflows#57 and carpentries-incubator/reproducible-ml-workflows#27:

    You have a hardware accelerated problem that you would like to address through scaling out across a high throughput computing workflow (e.g. using HTCondor). The machines in your compute pool are heterogeneous and can have various CUDA compute capability scores, and so will have different NVIDIA driver versions, resulting in different maximum supported CUDA versions, and so will be able to support different versions of CUDA accelerated software (e.g. PyTorch versions). To still use all the compute resources in your pool, and not remove some of them that might be older, you would need to currently create a Pixi workspace for each targeted maximum supported CUDA version as a system-requirement and label the environment as such.

    Explicit example workspace:
    pixi init example && cd example
    pixi workspace platform add linux-64 osx-arm64 win-64
    pixi add --feature cpu python pytorch-cpu torchvision
    pixi workspace environment add --feature cpu cpu
    pixi upgrade --feature cpu
    pixi workspace system-requirements add --feature gpu-cuda-11 cuda 11.8
    pixi workspace environment add --feature gpu-cuda-11 gpu-cuda-11
    pixi add --feature gpu-cuda-11 --platform linux-64 pytorch-gpu torchvision 'cuda-version 11.8.*'
    pixi workspace system-requirements add --feature gpu-cuda-12 cuda 12.6
    pixi workspace environment add --feature gpu-cuda-12 gpu-cuda-12
    pixi add --feature gpu-cuda-12 --platform linux-64 --platform win-64 pytorch-gpu torchvision 'cuda-version 12.6.*'
    

    which generates this Pixi manifest pixi.toml:

    [workspace]
    channels = ["conda-forge"]
    name = "example"
    platforms = ["linux-64", "osx-arm64", "win-64"]
    version = "0.1.0"
    
    [tasks]
    
    [dependencies]
    
    [feature.cpu.dependencies]
    python = ">=3.13.5,<3.14"
    pytorch-cpu = ">=2.7.1,<3"
    torchvision = ">=0.22.0,<0.23"
    
    [feature.gpu-cuda-11.system-requirements]
    cuda = "11.8"
    
    [feature.gpu-cuda-11.target.linux-64.dependencies]
    pytorch-gpu = ">=2.5.1,<3"
    torchvision = ">=0.20.1,<0.21"
    cuda-version = "11.8.*"
    
    [feature.gpu-cuda-12.system-requirements]
    cuda = "12.6"
    
    [feature.gpu-cuda-12.target.linux-64.dependencies]
    pytorch-gpu = ">=2.7.1,<3"
    torchvision = ">=0.22.0,<0.23"
    cuda-version = "12.6.*"
    
    [feature.gpu-cuda-12.target.win-64.dependencies]
    pytorch-gpu = ">=2.7.1,<3"
    torchvision = ">=0.22.0,<0.23"
    cuda-version = "12.6.*"
    
    [environments]
    cpu = ["cpu"]
    gpu-cuda-11 = ["gpu-cuda-11"]
    gpu-cuda-12 = ["gpu-cuda-12"]

    (The example is about to break down as you would still want to use containerized deployments of your environment as HTCondor doesn't use a shared file system, but whatever, imagine that you did, or that this is some SLURM variation of the problem where you do have a shared file system.) As of now, to know what environment you would want to execute your code in, you would need to do some custom detection to know what machine that you landed on so that you could know to run

    pixi run --environment gpu-cuda-11 ...
    

    or

    pixi run --environment gpu-cuda-12 ...
    

    If I understand it correctly, the result of this proposal would mean that you could instead use

    [workspace]
    platforms = [
        { os = "linux", arch="x86-64-v3", cuda="11.8" },
        { os = "linux", arch="x86-64-v3", cuda="12.6" },
        { os = "linux", arch="x86-64-v3"},
        { os = "macos", arch="arm64" },
        { os = "windows", arch="x86-64", windows = "10.9", cuda="12.6" },
        { os = "windows", arch="x86-64", windows = "10.9" },
        "linux-64",
    ]

    and then just define a gpu environment (with * for dependency versions in the feature) and then regardless of what machine you landed on running

    pixi run --environment gpu ...
    

    would be able to resolve the correct environment from the cuda virtual package. Is that correct?

    • What about the "best_platform" logic? e.g. when you're on win-arm64 and have a lockfile for win-64 should you install win-64 or try win-arm64?

    I think I'm missing something, but it seems to me that if you don't provide further clarification that current machine's platform is targeted. So in this question example, the manifest and lockfile have both win-64 and win-arm64? So shouldn't win-arm64 get installed?

    • What should be the default for pixi init?

    I would say the same as it is now. Just the most generic match to the host machine's platform.

    • When should we add the native platform to the manifest, and how specific should it be to the platform, e.g. with or without archspec?

    I would assume without(?). I haven't thought much on this though.

  5. ruben-arts commented on Aug 30, 2025

    @ruben-arts
    ContributorAuthor

    Thank you for the review @matthewfeickert!

    would be able to resolve the correct environment from the cuda virtual package. Is that correct?

    Indeed, with the proposed implementation, Pixi would pick the first in the list of platforms that best your machine. Assuming the list is set up to be "best option first".

    To give an example why we would want to make the list be prioritized on index is because of the option to choose between GPU and CPU optimization. e.g.:

    [workspace]
    platforms = [
    	{ os = "linux", arch="x86-64", cuda="13" }, 
        { os = "linux", arch="x86-64-v3", cuda="12" },
    ]

    In the above example, I tell Pixi that I find the GPU version is more important than the CPU arch. So If there is a cuda13 available, choose the environment with the higher version GPU vs the environment with the better CPU. Not sure if in practice this matters much, but it allows us to not make this guess for the user.


    About the best_platform logic the issue is that it will now choose the "best fit" meaning osx-arm64 and osx-64 can both be run on osx-arm64 due to Rosetta, but if it's not defined for the osx-arm64 the current proposal says it will try to install it as native, but it might not be able to solve for that platform. How should we deal with this? (Same goes for win-arm64 and win-64.

  6. ruben-arts commented on Aug 30, 2025

    @ruben-arts
    ContributorAuthor

    @baszalmstra

    Maybe I dont understand but is that not already the case?

    We can't solve a linux-64 only workspace on osx when we don't support that in the platforms, if it needs a conda prefix to solve the pypi packages with.

    @geoHeil While this proposal doesn't directly solve that issue, it might kickstart more opportunities to solve that problem.

  7. geoHeil commented on Aug 30, 2025

    @geoHeil

    @ruben-arts but could a workspace like:

    [workspace]
    platforms = [
        { os = "linux", arch="x86-64-v3", cuda="11.8" },
        { os = "macos", arch="arm64" },
    ]
    

    be resolved? i.e. one which has both OS present?

  8. ruben-arts commented on Aug 30, 2025

    @ruben-arts
    ContributorAuthor

    @ruben-arts but could a workspace like:

    [workspace]
    platforms = [
        { os = "linux", arch="x86-64-v3", cuda="11.8" },
        { os = "macos", arch="arm64" },
    ]
    

    be resolved? i.e. one which has both OS present?

    Yes this would behave the exact same way as it does right now.

  9. hameerabbasi commented on Mar 10, 2026

    @hameerabbasi
    Contributor

    One little issue I see here is that one can do

    [feature.x.platform.y.dependencies]
    ...

    How would the platform name y be specified in this case? I guess one can do the following: As platform-{{ some_uint }} wasn't a valid platform before, one can do platform-{{ index }}. Another option is to add a name arg, and allow one to use that instead, with name being set by default only for platforms that are simple OS strings.

  10. ruben-arts commented on Mar 31, 2026

    @ruben-arts
    ContributorAuthor

    @hameerabbasi I like your ideas. I think we should have a way to name the platforms indeed. Probably also support a default naming scheme, e.g. linux-aarc64-cuda-13-libc-2_34 which then could be renamed to jetson-nano.

    The index would be more prone to unexpected behavior due to modifications to the toml so I would like to avoid that.

  11. 8 remaining items

  12. hameerabbasi commented on May 22, 2026

    @hameerabbasi
    Contributor

    I wouldn't be opposed to a general pixi migrate command that rewrites most old versions; even [workspace] vs [project].

    However; I do think it's a separate issue.

    And I believe we shouldn't allow them in the same pixi.toml; perhaps pointing people to migrate.

  13. hunger commented on Jun 3, 2026

    @hunger
    Contributor

    The migration story in the PR I made is like this: Pixi will migrate generate rich platforms from the "poor" platforms in pixi.toml and the system-requirements it finds, but will not change the pixi.toml file.

    Whenever you edit a platform to become a "rich" platform, pixi will write that into pixi.toml and switch the entire file over to rich platforms, removing any mention of system-requirements. From that point on it is a hard error to add system-requirements back in.

    So basically you have either "poor" platforms only in pixi.toml (which serialize/deserialize into a string just as platforms always did) and may then have system-requirements, or you have at least one "rich" platform (which serializes/deserializes into a dictionary) and then may not have system-requirements. Update happens only when you explicitly add a rich platform.

    I think this should work quite well in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

UXconfigurationenhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions