-
Notifications
You must be signed in to change notification settings - Fork 94
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
We are displaying display driver info, scope creep #710
Conversation
We have to be mindful of maintenance of the codebase. Display drivers have nothing to do with AI acceleration. Don't show display info such as "Color LCD" : { "Engine": { "Name": null }, "GPUs": { "Detected GPUs": [ { "Cores": "18", "GPU": "Apple M3 Pro", "Metal": "Metal 3", "Vendor": "Apple (0x106b)" }, { "GPU": "Color LCD" } ], "INFO": "No errors" }, "Image": "quay.io/ramalama/ramalama", "Runtime": "llama.cpp", "Store": "/Users/ecurtin/.local/share/ramalama", "UseContainer": false, "Version": "0.0.19" } Not sure about the "macOS detection covers AMD GPUs" code. We could have external GPUs potentially on macOS but even in that case the code seems illogical. Signed-off-by: Eric Curtin <[email protected]>
Reviewer's Guide by SourceryThis pull request refactors the GPU detection logic to remove display driver information and correct macOS GPU detection. The changes ensure that only relevant GPU information is included, and the macOS detection logic is more robust. Sequence diagram for macOS GPU detection flowsequenceDiagram
participant C as CLI
participant D as GPUDetector
participant S as system_profiler
C->>D: get_macos_gpu()
D->>S: system_profiler SPDisplaysDataType
S-->>D: Raw GPU information
Note over D: Parse GPU info:
Note over D: - Chipset Model
Note over D: - Cores
Note over D: - Vendor
Note over D: - Metal Support
D-->>C: Filtered GPU information
Class diagram for GPUDetector changesclassDiagram
class GPUDetector {
+get_nvidia_gpu()
+get_amd_gpu()
+get_intel_gpu()
+get_macos_gpu()
+detect_best_gpu(gpu_template)
-_read_gpu_memory(path_pattern, gpu_name, env_var)
}
note for GPUDetector "Simplified macOS GPU detection
Removed display info parsing"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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 and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -304,7 +304,7 @@ def show_gpus_available_cli(args): | |||
|
|||
return { | |||
"Detected GPUs": gpu_info if gpu_info else [{"GPU": "None", "VRAM": "N/A", "INFO": "No GPUs detected"}], | |||
"INFO": errors if errors else "No errors" | |||
"INFO": errors if errors else "No errors", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Replace if-expression with or
(or-if-exp-identity
)
"INFO": errors if errors else "No errors", | |
"INFO": errors or "No errors", |
Explanation
Here we find ourselves setting a value if it evaluates toTrue
, and otherwiseusing a default.
The 'After' case is a bit easier to read and avoids the duplication of
input_currency
.
It works because the left-hand side is evaluated first. If it evaluates to
true then currency
will be set to this and the right-hand side will not be
evaluated. If it evaluates to false the right-hand side will be evaluated and
currency
will be set to DEFAULT_CURRENCY
.
@@ -46,7 +43,9 @@ def get_nvidia_gpu(self): | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Explicitly raise from a previous error [×3] (raise-from-previous-error
)
output = subprocess.check_output( | ||
["system_profiler", "SPDisplaysDataType"], text=True | ||
) | ||
output = subprocess.check_output(["system_profiler", "SPDisplaysDataType"], text=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Extract code out into method (extract-method
)
@@ -157,7 +142,6 @@ def get_macos_gpu(self): | |||
logging.error(f"Unexpected error while detecting macOS GPU: {e}") | |||
return [{"GPU": "Unknown", "Error": str(e)}] | |||
|
|||
|
|||
def detect_best_gpu(self, gpu_template): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Low code quality found in GPUDetector.detect_best_gpu - 24% (low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
I ran "make lint" on the codebase and it auto-formatted. A lot of non-functional changes that the AI bot commented on as low quality, some are debatable as they are style-based. |
LGTM |
We have to be mindful of maintenance of the codebase. Display drivers have nothing to do with AI acceleration. Don't show display info such as "Color LCD" :
{
"Engine": {
"Name": null
},
"GPUs": {
"Detected GPUs": [
{
"Cores": "18",
"GPU": "Apple M3 Pro",
"Metal": "Metal 3",
"Vendor": "Apple (0x106b)"
},
{
"GPU": "Color LCD"
}
],
"INFO": "No errors"
},
"Image": "quay.io/ramalama/ramalama",
"Runtime": "llama.cpp",
"Store": "/Users/ecurtin/.local/share/ramalama",
"UseContainer": false,
"Version": "0.0.19"
}
Not sure about the "macOS detection covers AMD GPUs" code. We could have external GPUs potentially on macOS but even in that case the code seems illogical.
Summary by Sourcery
Refine GPU detection and logging to exclude display adapters and streamline logging setup.
Bug Fixes:
Enhancements: