Skip to content

Feat: Improve Model Tier Recommendation for Apple Silicon#1299

Open
rohan-pandeyy wants to merge 3 commits into
AOSSIE-Org:mainfrom
rohan-pandeyy:feat/model-tier-recommendation-for-apple-silicon
Open

Feat: Improve Model Tier Recommendation for Apple Silicon#1299
rohan-pandeyy wants to merge 3 commits into
AOSSIE-Org:mainfrom
rohan-pandeyy:feat/model-tier-recommendation-for-apple-silicon

Conversation

@rohan-pandeyy
Copy link
Copy Markdown
Contributor

@rohan-pandeyy rohan-pandeyy commented May 30, 2026

Closes #1292

This pull request adds improved detection and reporting of Apple Silicon hardware in both the backend and frontend. The main changes include new utility functions to detect Apple Silicon and its performance tier, updating the hardware info API to include this data, and adjusting the frontend to display Apple Silicon chip names when present.

Apple Silicon Detection and Tiering:

  • Added detect_apple_silicon() and detect_apple_silicon_tier() functions to identify Apple Silicon chips and classify them as "small" (base M1/M2) or "medium" (Pro/Max/Ultra, M3+, or future chips) in hardware_detect.py.
  • Updated detect_hardware_tier() to return the Apple Silicon tier if detected, improving model recommendations for Mac users.

Backend API Enhancements:

  • Modified get_hardware_info() to include an apple_silicon field in the returned dictionary, exposing chip information to the frontend.

Frontend and Type Updates:

  • Updated the HardwareInfo TypeScript interface to include the new apple_silicon field.
  • Changed the hardware display in AIModelSetupStep.tsx to show the Apple Silicon chip name (if present) instead of GPU info, improving clarity for Mac users.

Screenshots/Recordings:

image

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: Claude, Gemini

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

New Features

  • Added automated Apple Silicon hardware detection and diagnostics reporting
  • Enhanced hardware tier classification system with improved support for Apple Silicon-based devices
  • Hardware information display now includes Apple Silicon identification alongside GPU specifications for better system profiling

Review Change Stack

@github-actions github-actions Bot added GSoC 2026 backend enhancement New feature or request labels May 30, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Walkthrough

This PR adds Apple Silicon hardware detection to improve model tier recommendations on Apple Silicon Macs. The backend now detects Apple Silicon chips, determines appropriate hardware tiers (small/medium), and exposes chip information. The frontend displays the detected chip name in the onboarding UI hardware summary.

Changes

Apple Silicon Detection Integration

Layer / File(s) Summary
Backend Apple Silicon Detection Helpers
backend/app/utils/hardware_detect.py
Imports platform and introduces detect_apple_silicon() to identify Apple Silicon chips via sysctl, and detect_apple_silicon_tier() to map chip families to hardware tiers; integrates Apple tier detection into detect_hardware_tier() with early return before RAM/GPU fallback.
Backend Hardware Info Exposure
backend/app/utils/hardware_detect.py
Updates get_hardware_info() to include "apple_silicon" field in the returned diagnostics dictionary.
Frontend Type and UI Integration
frontend/src/types/models.ts, frontend/src/components/OnboardingSteps/AIModelSetupStep.tsx
Adds `apple_silicon: string

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Python, TypeScript/JavaScript

Poem

🐰 Silicon Apple trees now in sight,
From M-chips bright to tier just right,
Detect and display with grace untold,
A Mac recommendation worth its gold! 🍎

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding Apple Silicon detection to improve model tier recommendations.
Linked Issues check ✅ Passed All requirements from issue #1292 are met: detect_apple_silicon() and detect_apple_silicon_tier() functions added with correct mappings, detect_hardware_tier() updated to prioritize Apple Silicon tiering, get_hardware_info() exposes apple_silicon field, and frontend displays chip information.
Out of Scope Changes check ✅ Passed All changes are directly related to Apple Silicon detection and tier recommendations as specified in issue #1292; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rohan-pandeyy rohan-pandeyy changed the title Feat/model tier recommendation for apple silicon Feat: Improve Model Tier Recommendation for Apple Silicon May 30, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/app/utils/hardware_detect.py`:
- Around line 1-6: This module uses PEP 604 union syntax (e.g., annotations like
"str | None") but lacks the compatibility import; add "from __future__ import
annotations" as the very first line of backend/app/utils/hardware_detect.py
(before any other imports such as shutil, subprocess, platform, onnxruntime or
psutil) so functions and type hints in this file (e.g., any that use "|" unions)
work on Python 3.9.
- Around line 68-81: The function detect_apple_silicon_tier currently returns
"medium" by default for any Apple Silicon not matched as base M1/M2 small, which
contradicts issue `#1292`; update detect_apple_silicon_tier (using the chip
variable from detect_apple_silicon()) so that the final/default return is
"small" instead of "medium" while keeping existing logic that explicitly
classifies Pro/Max/Ultra as non-small.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 74b81545-d40a-4ea0-9ee8-f3535db5b6fd

📥 Commits

Reviewing files that changed from the base of the PR and between 27a9c6a and adbbb72.

📒 Files selected for processing (3)
  • backend/app/utils/hardware_detect.py
  • frontend/src/components/OnboardingSteps/AIModelSetupStep.tsx
  • frontend/src/types/models.ts

Comment on lines 1 to 6
import shutil
import subprocess
import platform

import onnxruntime as ort
import psutil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add from __future__ import annotations for Python 3.9 compatibility.

The file uses PEP 604 union syntax (str | None) in type hints but is missing the required future import for Python 3.9 compatibility. Based on learnings, this repo targets Python 3.9 minimum and requires from __future__ import annotations when using X | Y syntax.

🔧 Proposed fix
+from __future__ import annotations
+
 import shutil
 import subprocess
 import platform
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import shutil
import subprocess
import platform
import onnxruntime as ort
import psutil
from __future__ import annotations
import shutil
import subprocess
import platform
import onnxruntime as ort
import psutil
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/utils/hardware_detect.py` around lines 1 - 6, This module uses
PEP 604 union syntax (e.g., annotations like "str | None") but lacks the
compatibility import; add "from __future__ import annotations" as the very first
line of backend/app/utils/hardware_detect.py (before any other imports such as
shutil, subprocess, platform, onnxruntime or psutil) so functions and type hints
in this file (e.g., any that use "|" unions) work on Python 3.9.

Comment on lines +68 to +81
def detect_apple_silicon_tier() -> str | None:
chip = detect_apple_silicon()
if chip is None:
return None

chip_lower = chip.lower()

# Base M1 and M2 chips (without Pro/Max/Ultra modifiers) are "small"
if any(base in chip_lower for base in ["m1", "m2"]):
if not any(mod in chip_lower for mod in ["pro", "max", "ultra"]):
return "small"

# Default to medium for all other Apple Silicon (Pro/Max/Ultra, M3+, and future chips)
return "medium"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Default tier for unknown Apple Silicon contradicts requirements.

Line 81 defaults unknown Apple Silicon chips to "medium", but issue #1292 explicitly requires unknown Apple Silicon to default to "small". This could lead to over-recommending model sizes for future or unrecognized chips.

📝 Proposed fix to match requirements
-    # Default to medium for all other Apple Silicon (Pro/Max/Ultra, M3+, and future chips)
-    return "medium"
+    # M3+, Pro/Max/Ultra variants are medium
+    # M3, M4, and newer chips (with or without modifiers) should be medium
+    if any(chip in chip_lower for chip in ["m3", "m4", "m5", "m6", "m7", "m8", "m9"]):
+        return "medium"
+    if any(mod in chip_lower for mod in ["pro", "max", "ultra"]):
+        return "medium"
+    
+    # Default to small for unknown Apple Silicon chips
+    return "small"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def detect_apple_silicon_tier() -> str | None:
chip = detect_apple_silicon()
if chip is None:
return None
chip_lower = chip.lower()
# Base M1 and M2 chips (without Pro/Max/Ultra modifiers) are "small"
if any(base in chip_lower for base in ["m1", "m2"]):
if not any(mod in chip_lower for mod in ["pro", "max", "ultra"]):
return "small"
# Default to medium for all other Apple Silicon (Pro/Max/Ultra, M3+, and future chips)
return "medium"
def detect_apple_silicon_tier() -> str | None:
chip = detect_apple_silicon()
if chip is None:
return None
chip_lower = chip.lower()
# Base M1 and M2 chips (without Pro/Max/Ultra modifiers) are "small"
if any(base in chip_lower for base in ["m1", "m2"]):
if not any(mod in chip_lower for mod in ["pro", "max", "ultra"]):
return "small"
# M3+, Pro/Max/Ultra variants are medium
# M3, M4, and newer chips (with or without modifiers) should be medium
if any(chip in chip_lower for chip in ["m3", "m4", "m5", "m6", "m7", "m8", "m9"]):
return "medium"
if any(mod in chip_lower for mod in ["pro", "max", "ultra"]):
return "medium"
# Default to small for unknown Apple Silicon chips
return "small"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/utils/hardware_detect.py` around lines 68 - 81, The function
detect_apple_silicon_tier currently returns "medium" by default for any Apple
Silicon not matched as base M1/M2 small, which contradicts issue `#1292`; update
detect_apple_silicon_tier (using the chip variable from detect_apple_silicon())
so that the final/default return is "small" instead of "medium" while keeping
existing logic that explicitly classifies Pro/Max/Ultra as non-small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Model Tier Recommendation for Apple Silicon

1 participant