Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.mamba-ssm: init at 2.2.2 #341195

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

cfhammill
Copy link
Contributor

Description of changes

Adds python3Packages.mamba-ssm and its dependency python3Packages.causal-conv1d.

This PR is mostly a proof of concept, I have only tested on python311 with cuda, I have not attempted to figure out rocm, or cpu only execution. Tests green for me after loading with

nix-shell -p '(import <nixpkgs> { config = { cudaSupport = true; cudaCapabilities = [ "8.0" ]; cudaEnableForwardCompat = false; allowUnfreePredicate = p: builtins.all ( license: license.free || builtins.elem license.shortName [ "CUDA EULA" "cuDNN EULA" "cuTENSOR EULA" "NVidia OptiX EULA" ] ) (if builtins.isList p.meta.license then p.meta.license else [ p.meta.license ]); permittedInsecurePackages = [ "electron-24.8.6" "zotero-6.0.27" ]; }; }).python311.withPackages 
  (ps: with ps; [ mamba-ssm causal-conv1d pytest einops ])'

cloning the mamba and causal-conv1d repos and running the test suites.

I'm not interested in being the sole maintainer of this, so if any of the cuda team wants to join and I can add you to the maintainer list.

cc: @ConnorBaker @samuela @SomeoneSerge @bcdarwin

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Copy link
Member

@samuela samuela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff lgtm

@cfhammill
Copy link
Contributor Author

thanks @samuela. I've pushed a few metadata fixes, are you interested in being added as a co-maintainer?

@samuela
Copy link
Member

samuela commented Sep 12, 2024

@cfhammill unfortunately i don't have bandwidth to take on new maintainer duties atm

@cfhammill
Copy link
Contributor Author

ok, no problem, thanks @samuela

pkgs/development/python-modules/causal-conv1d/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/mamba-ssm/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/causal-conv1d/default.nix Outdated Show resolved Hide resolved
];

pythonImportsCheck = [ "causal_conv1d" ];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the most common use case would be to build this with CUDA, I know there has been work done to enable gpu tests but I'm not sure how to do it. As mentioned in the PR description I haven't tested on cpu or with rocm, I would rather mark broken if the user doesn't have cuda enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked, neither introduced packages actually supports cpu only execution, so I've marked the package as broken without CUDA. I'm going to leave tests disabled because I don't have a nixos machine with cuda to experiment on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems fair enough; shall we leave a comment explaining the situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment indicating the tests are disabled.

pkgs/development/python-modules/mamba-ssm/default.nix Outdated Show resolved Hide resolved
} // lib.optionalAttrs cudaSupport { CUDA_HOME = "${lib.getDev cudaPackages.cuda_nvcc}"; };

pythonImportsCheck = [ "mamba_ssm" ];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please enable tests.

pkgs/development/python-modules/mamba-ssm/default.nix Outdated Show resolved Hide resolved
@cfhammill cfhammill force-pushed the init-mamba branch 2 times, most recently from 19c4d66 to 2261a79 Compare September 13, 2024 17:35
};

build-system = [
ninja
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explicitly add setuptools, as this package depends on implicitly propagated setuptools from somewhere?
I'm sorry to say this is also in the future, but please add torch as well since it will not be able to access the runtime dependencies at build time.

These changes will reduce build failures caused by other packages.

If you are interested, the following issue may be helpful. #272178

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added!

Copy link
Contributor

@SomeoneSerge SomeoneSerge Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm out of the loop, how does mamba-ssm use torch at build time? build platform's torch at build time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. I checked, it's just a "normal" cpp_extension and ofc it's doing import torch in setup.py which screws up all of the cross stuff.

Can't judge about semantics yet, but the way we implement build-system (mapping it into nativeBuildInputs) this is obviously not the torch we want to link against, because we want to link torch from buildInputs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: As a matter of fact, semantically, torch from nativeBuildInputs would be correct if we actually made it work like a compiler. Obviously, though, it does not implement the promise

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that build-system is incomplete since it does not support cross compiling.
However, python modules will separate build and runtime dependencies, and dependencies will no longer be available during build.
So, in this case, we need to add torch not only to dependencies but also to build-system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok great, then I think we're good to go.

@cfhammill
Copy link
Contributor Author

Unsuccessful checks look unrelated to this PR. @natsukium and @SomeoneSerge just let me know if we should have torch in build-system or not and I'll make the change.

@cfhammill
Copy link
Contributor Author

Rebased and ready to go @natsukium and @SomeoneSerge

Copy link
Member

@natsukium natsukium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cfhammill
Copy link
Contributor Author

@SomeoneSerge @samuela @natsukium, thanks for the reviews everyone! If someone could pull that would be great.

@natsukium natsukium merged commit 1635ecc into NixOS:master Sep 25, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants