Repository navigation
Description
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
linuxx86-64-v3withcuda==13it will take the first. - On
linuxx86-64-v3withcuda==12.*it will take the second. - On
linux-64without a specializedarchorcudait 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 cpuWith 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-arm64and have a lockfile forwin-64should you installwin-64or trywin-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
geoHeil commentedon Aug 30, 2025
It would be neat if lets say ARM osx can resolve package for a different platform such as linux x86.
baszalmstra commentedon Aug 30, 2025
Maybe I dont understand but is that not already the case?
matthewfeickert commentedon Aug 30, 2025
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-requirementand label the environment as such.Explicit example workspace:
which generates this Pixi manifest
pixi.toml:(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
or
If I understand it correctly, the result of this proposal would mean that you could instead use
and then just define a
gpuenvironment (with*fordependencyversions in the feature) and then regardless of what machine you landed on runningwould be able to resolve the correct environment from the
cudavirtual package. Is that correct?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-64andwin-arm64? So shouldn'twin-arm64get installed?I would say the same as it is now. Just the most generic match to the host machine's platform.
I would assume without(?). I haven't thought much on this though.
ruben-arts commentedon Aug 30, 2025
Thank you for the review @matthewfeickert!
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.:
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_platformlogic the issue is that it will now choose the "best fit" meaningosx-arm64andosx-64can both be run onosx-arm64due to Rosetta, but if it's not defined for theosx-arm64the 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 forwin-arm64andwin-64.ruben-arts commentedon Aug 30, 2025
@baszalmstra
We can't solve a
linux-64only workspace onosxwhen 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.
geoHeil commentedon Aug 30, 2025
@ruben-arts but could a workspace like:
be resolved? i.e. one which has both OS present?
ruben-arts commentedon Aug 30, 2025
Yes this would behave the exact same way as it does right now.
hameerabbasi commentedon Mar 10, 2026
One little issue I see here is that one can do
How would the platform name
ybe specified in this case? I guess one can do the following: Asplatform-{{ some_uint }}wasn't a valid platform before, one can doplatform-{{ index }}. Another option is to add anamearg, and allow one to use that instead, withnamebeing set by default only for platforms that are simple OS strings.ruben-arts commentedon Mar 31, 2026
@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_34which then could be renamed tojetson-nano.The index would be more prone to unexpected behavior due to modifications to the toml so I would like to avoid that.
8 remaining items
hameerabbasi commentedon May 22, 2026
I wouldn't be opposed to a general
pixi migratecommand 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.feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
hunger commentedon Jun 3, 2026
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.tomlfile.Whenever you edit a platform to become a "rich" platform, pixi will write that into
pixi.tomland 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.
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…
feat(manifest): switch workspace platform TOML to per-virtual-package…