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

Make the default of ngl be -1 #707

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Make the default of ngl be -1 #707

wants to merge 1 commit into from

Conversation

ericcurtin
Copy link
Collaborator

@ericcurtin ericcurtin commented Feb 2, 2025

This means automatically assign a value, which may be 999 or 0 depending on hardware.

Summary by Sourcery

Documentation:

  • Update documentation to reflect the new default value of -1 for the number of GPU layers (ngl).

This means automatically assign a value, which may be 999 or 0
depending on hardware.

Signed-off-by: Eric Curtin <[email protected]>
Copy link
Contributor

sourcery-ai bot commented Feb 2, 2025

Reviewer's Guide by Sourcery

The pull request changes the default value of the ngl parameter to -1. This change affects the default number of layers offloaded to the GPU, which will now be automatically assigned based on the hardware.

State diagram for GPU layer configuration

stateDiagram-v2
    [*] --> CheckNGL
    CheckNGL --> AutoAssign: ngl = -1
    CheckNGL --> ManualConfig: ngl specified
    AutoAssign --> HardwareDetection
    HardwareDetection --> CUDA: CUDA/HIP detected
    HardwareDetection --> Other: Other GPU
    CUDA --> [*]: Set 999 layers
    Other --> [*]: Set 0 layers
    ManualConfig --> [*]: Use specified value
Loading

Flow diagram for GPU layer assignment logic

graph TD
    A[Start] --> B{ngl = -1?}
    B -->|Yes| C[Auto-assign GPU layers]
    C --> D{Hardware Type}
    D -->|CUDA/HIP| E[Set to 999 layers]
    D -->|Other GPU| F[Set to 0 layers]
    B -->|No| G[Use specified ngl value]
    E --> H[End]
    F --> H
    G --> H
Loading

File-Level Changes

Change Details Files
Changed the default value of the ngl parameter to -1.
  • Updated the default value in the documentation.
  • Updated the default value in the configuration file.
  • Updated the default value in the command line interface.
docs/ramalama.1.md
docs/ramalama.conf
docs/ramalama.conf.5.md
ramalama/cli.py
Modified the condition for enabling GPU usage.
  • The condition to enable GPU usage now checks if args.gpu is greater than 0 instead of just if args.gpu is truthy.
ramalama/model.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ericcurtin - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please document the valid values for the gpu parameter and what each value means (especially -1, 0, and positive values)
  • The change from args.gpu to args.gpu > 0 in gpu_args() could be a breaking change. Please explain the rationale and document the behavior change
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 115 to +118
Needed to access the gpu on some systems, but has an impact on security, use with caution.

#### **--ngl**
number of gpu layers (default: 999)
number of gpu layers (default: -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Clarify the meaning of -1 for ngl.

The documentation should explicitly state what a value of -1 means for the number of GPU layers. Does it mean "use all available layers" or something else? Also, "gpu" should be "GPU".

Suggested change
Needed to access the gpu on some systems, but has an impact on security, use with caution.
#### **--ngl**
number of gpu layers (default: 999)
number of gpu layers (default: -1)
Needed to access the GPU on some systems, but has an impact on security, use with caution.
#### **--ngl**
number of GPU layers (default: -1). A value of -1 means use all available GPU layers

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 with sorcery, you need to explain the value of -1?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @rhatdan! I'm glad you agree. @, it's important to make this clear in the documentation so users understand how to use this option. Please update the documentation to explain the meaning of -1, as suggested in my previous comment. Let me know if you have any questions about how to best phrase this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 magic numbers are bad.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for your feedback, we will generate more comments like this in the future.

@@ -51,7 +51,7 @@

# Default number of layers offloaded to the gpu
#
#ngl = 999
#ngl = -1
Copy link
Member

Choose a reason for hiding this comment

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

Explain -1 above

@@ -92,7 +92,7 @@ RAMALAMA_IMAGE environment variable overrides this field.
Pass `--group-add keep-groups` to podman, when using podman.
In some cases this is needed to access the gpu from a rootless container

**ngl**=999
**ngl**=-1
Copy link
Member

Choose a reason for hiding this comment

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

Please explain the meaning of -1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants