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

ollama: smaller cuda plus minor simplifications #324659

Closed
wants to merge 5 commits into from

Conversation

SomeoneSerge
Copy link
Contributor

@SomeoneSerge SomeoneSerge commented Jul 4, 2024

Description of changes

(cf commit messages)

CC @yshui @abysssol

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.

@SomeoneSerge
Copy link
Contributor Author

@ofborg test ollama

@SomeoneSerge SomeoneSerge requested a review from abysssol July 4, 2024 20:21
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abysssol how'd you feel about inlining some of the let-in's as well? And maybe nixfmt-ing the expression?

If you prefer I can leave out the commit that moves the attributes around and you can handle this yourself

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed a few commits, give them a look, tell me what you think.

I don't want to inline vendorHash because I want to keep version, src, vendorHash, and llamacppPatches together to make updating the ollama version easier, and make it harder to forget or miss something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

apple_sdk_11_0

Is it necessary to select the particular release? Iirc the unqualified apple_sdk had some logic that was supposed to make it the safe choice

Copy link
Contributor

Choose a reason for hiding this comment

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

I used apple_sdk_11_0 because of some problem with a missing framework in it, and this comment recommended using apple_sdk_11_0 instead of apple_sdk, which seemed to work.

However, I think this was only a problem on platforms other than darwin, so switching to apple_sdk would probably still work right, though may cause warnings or errors with ofBorg's package evaluation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. If that's causing problems only on some platforms, and especially on non-darwin platforms which should be unaffected - that might be something to bring up with the darwin team. I'll confirm whether there's an issue first though

Comment on lines 159 to 168
] ++ lib.optionals stdenv.isDarwin
metalFrameworks;
];
Copy link
Contributor

@abysssol abysssol Jul 5, 2024

Choose a reason for hiding this comment

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

From what I remember, the metal frameworks needed to be in both nativeBuildInputs and buildInputs for ollama to build right on darwin/macos. See this comment after I tried moving them from nativeBuildInputs to buildInputs.

If you really want to leave this in, we'll need to verify that ollama works right on darwin, but I think this change should be removed.

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 think I should read the whole thread before I move on

@github-actions github-actions bot added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Jul 5, 2024
@ofborg ofborg bot requested a review from abysssol July 5, 2024 10:40
@@ -32,6 +32,7 @@ in
};

cuda = { ... }: {
nixpkgs.config.allowUnfree = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break setups that pass pkgs to lib.nixosSystem. There is an assert in that module that fails in this case. I'd suggest removing this line.

Copy link
Contributor

@abysssol abysssol Jul 9, 2024

Choose a reason for hiding this comment

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

I don't understand why this is a problem. Can you explain in more detail how lib.nixosSystem would fail because a test vm enabled allowUnfree?

There is an assert in that module that fails in this case.

What assert in what module?

Also, why pass pkgs to lib.nixosSystem? I don't see what the purpose of that is, or what that might accomplish.

This line was added to allow ofborg to directly run ollama's nixos test (ie @ofborg test ollama) since it previously failed to evaluate it, complaining about the unfree cuda dependencies. Do you know any way to solve this problem without causing errors when passing pkgs to lib.nixosSystem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will break setups that pass pkgs to lib.nixosSystem.

This is a nixos test, not nixos module, so it itself is responsible for calling nixosSystem?

This line was added to allow ofborg to directly run ollama's nixos test

I'm not sure whether we want the ofborg to test unfree things. I think so far it hasn't (except by accident). That said, we always wanted an ofborg to do that

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure whether we want the ofborg to test unfree things.

Why not?

we always wanted an ofborg to do that

What's wrong with the current ofborg?

Copy link
Contributor

Choose a reason for hiding this comment

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

I overlook the fact that this file is actually a test 🤦

But in the main module that would be a problem. In my config, for example, I instantiate a outer pkgs then pass to all my machines and home-manager. Easier to add stuff that cascades into the machines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's wrong with the current ofborg?

It's just the risk aversity regarding the official infra and the unfree. Another issue might be, ofborg won't be able to substitute cuda stuff using the official cache.

That said, Ofborg's build outputs aren't redistributed, and we could in principle make Ofborg use the nix-community cache, so I'm not sure if there's any policy or decision regarding Ofborg specifically. And eitherways if there is one, now's a good time to reconsider.

But yeah I think this change involves more parties that must be made aware of the change and consulted with...

Copy link
Contributor

Choose a reason for hiding this comment

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

ofborg won't be able to substitute cuda stuff using the official cache.

Again, why not? Not all unfree licenses restrict redistribution of binaries or other build artifacts. Does cuda?

But yeah I think this change involves more parties that must be made aware of the change and consulted with...

Yeah, I agree. I don't actually know who any of those people are, though. Do you?

Copy link
Contributor Author

@SomeoneSerge SomeoneSerge Jul 9, 2024

Choose a reason for hiding this comment

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

Again, why not? Not all unfree licenses restrict redistribution of binaries or other build artifacts. Does cuda?

Ofborg won't be able to substitute because the official hydra doesn't build unfree, and the official hydra doesn't build unfree because last time the proposal met a quite a bit of opposition (e.g. https://discourse.nixos.org/t/petition-to-build-and-cache-unfree-packages-on-cache-nixos-org/, but there were discussions before and after). Not that this is set in stone, but also this is probably OK if we can rely on the nix-community hydra instead. Ofborg and CI are yet to be figured out

Yeah, I agree. I don't actually know who any of those people are, though. Do you?

One could start by (asking, again, advice from the broader contributor community, the infra team, the foundation people, and) posting a proposal on discourse, arguing that there's no legal threat (is there?) in just having Ofborg test the unfree stuff without redistribution (is there?) so why don't we just enable it.

If that meets opposition, we look for an opportunity to run (or co-host) a separate ofborg-like CI instance that could be integrated with github...

Copy link
Contributor

Choose a reason for hiding this comment

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

This all sounds to me like a pretty significant project, and much more of a hassle than I feel like getting into at the moment. I may feel differently at some point in the future, but for now I'll be putting anything related to cuda/unfree licensing on hold.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@github-actions github-actions bot removed the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Jul 15, 2024
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 15, 2024
@abysssol abysssol removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 15, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2024
@drupol
Copy link
Contributor

drupol commented Jan 23, 2025

What's the status of this PR ?

@drupol drupol closed this Jan 30, 2025
@SomeoneSerge
Copy link
Contributor Author

@drupol this was a refactoring but derived from a much older version of the package, I guess you're right to close it

@drupol
Copy link
Contributor

drupol commented Jan 31, 2025

Yes, and since I had no feedback, I closed it.

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