Skip to content

feat(react-native): added model compatibility checks to React Native SDK#318

Open
JoshuaChil wants to merge 2 commits intoRunanywhereAI:mainfrom
JoshuaChil:feat/model-compatibility-check
Open

feat(react-native): added model compatibility checks to React Native SDK#318
JoshuaChil wants to merge 2 commits intoRunanywhereAI:mainfrom
JoshuaChil:feat/model-compatibility-check

Conversation

@JoshuaChil
Copy link

@JoshuaChil JoshuaChil commented Feb 1, 2026

Description

Adds model compatibility checking API to the React Native SDK, enabling apps to determine if a model can run on the current device before downloading or loading it.

Motivation

Whereas portions of other SDK's have functions, such as those for checking sufficient memory, React Native SDK lacks compatibility check functions to simplify for developers. I started with React Native due to higher TypeScript familiarity, but this could fill a gap if implemented across other SDK's as well.

Changes

New Features

  • checkModelCompatibility(modelId) - Check if a single model can run on the device
  • checkModelsCompatibility(modelIds[]) - Batch check multiple models
  • getDeviceCapabilities() - Get device hardware info (RAM, storage, CPU, GPU, NPU, chip)

Implementation

  • Created CompatibilityTypes.ts with ModelCompatibilityResult and DeviceCapabilities interfaces
  • Created RunAnywhere+Compatibility.ts with compatibility checking logic
  • Integrated into main SDK via RunAnywhere.ts
  • Uses native RunAnywhereDeviceInfo module for accurate hardware detection

Files Changed

  • sdk/runanywhere-react-native/packages/core/src/types/CompatibilityTypes.ts (new)
  • sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts (new)
  • sdk/runanywhere-react-native/packages/core/src/types/index.ts (exports)
  • sdk/runanywhere-react-native/packages/core/src/Public/Extensions/index.ts (exports)
  • sdk/runanywhere-react-native/packages/core/src/Public/RunAnywhere.ts (integration)
  • sdk/runanywhere-react-native/packages/core/README.md (documentation)

Important Notes/Considerations

  • Currently, compatibility check assumes arbitrary overheads. Assumes requirement of 1.5x model RAM and 1.2x storage. These are arbitrarily chosen values. I believe they could either be removed, or if maintainers have more informed estimates to choose, that change would be deeply appreciated.
  • During testing, I noticed llama-2-7b-chat-q4_k_m and mistral-7b-instruct-q4_k_m returned 0 values for required RAM and Storage. I believe this may be an error in the back-end API storing Model Info? If not, please let me know, I will see if it is an error in my implementation again.

Thank you! This is my first OSS PR, apologies if any mistakes are present. Would deeply appreciate feedback.

Additional Commit

  • Fixed formatting errors found by AI code review. Chose to ignore critical error regarding fallback for models returning 0 storage/RAM; I would like to wait for opinion of maintainers on next best steps to take given fallback handling.

Summary by CodeRabbit

  • New Features
    • Check whether a single or multiple AI models are compatible with your device
    • Retrieve detailed device capabilities including total/available memory and storage, CPU cores, GPU/NPU presence, chip name, and device model
    • Graceful error handling for batch compatibility assessments across multiple models

✏️ Tip: You can customize this high-level summary in your review settings.

Greptile Overview

Greptile Summary

This PR adds model compatibility checking functionality to the React Native SDK, enabling developers to verify if models can run on devices before downloading. The implementation follows the SDK's extension pattern and integrates cleanly with existing services.

Key Changes:

  • New checkModelCompatibility() and checkModelsCompatibility() functions to verify model-device compatibility
  • New getDeviceCapabilities() function to retrieve device hardware information
  • Uses 1.5x memory multiplier and 1.2x storage multiplier with 500MB RAM and 100MB storage overheads
  • Leverages existing RunAnywhereDeviceInfo native module and ModelRegistry for data

Issues Found:

  • Critical: Models with zero memoryRequired and downloadSize will silently return 0 for required resources, causing incorrect compatibility checks (affects llama-2-7b-chat-q4_k_m and mistral-7b-instruct-q4_k_m mentioned by author)
  • Minor: Missing semicolons in two export statements
  • Minor: Inconsistent indentation and formatting issues

Recommendations:

  • Fix the zero-value handling in calculateRequiredMemory() and calculateRequiredStorage() to warn or fail gracefully
  • Address formatting issues (semicolons, indentation, blank lines)
  • Consider whether the arbitrary multipliers need maintainer validation or should be configurable

Confidence Score: 3/5

  • PR has one critical logic issue with zero-value models but is otherwise well-implemented
  • Score reflects the critical bug where models with zero memory/size data will return incorrect compatibility results. This directly addresses the author's concern about llama-2-7b-chat-q4_k_m and mistral-7b-instruct-q4_k_m returning 0 values. The rest of the implementation is sound and follows SDK patterns, but this issue must be fixed before merging.
  • Pay close attention to RunAnywhere+Compatibility.ts lines 232-243 where zero-value models will cause incorrect compatibility checks

Important Files Changed

Filename Overview
sdk/runanywhere-react-native/packages/core/src/types/CompatibilityTypes.ts new TypeScript interfaces for compatibility checking - minor formatting issues (blank lines, missing semicolon)
sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts implements compatibility checking logic - has critical issue with models returning zero memory/size values, plus minor formatting issues
sdk/runanywhere-react-native/packages/core/src/Public/RunAnywhere.ts integrates compatibility methods into main SDK - inconsistent indentation on new methods

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant RA as RunAnywhere
    participant Compat as Compatibility Extension
    participant MR as ModelRegistry
    participant DI as DeviceInfoModule
    participant FS as FileSystem

    App->>RA: checkModelCompatibility(modelId)
    RA->>Compat: checkModelCompatibility(modelId)
    
    Compat->>MR: getModel(modelId)
    MR-->>Compat: ModelInfo
    
    Compat->>Compat: getDeviceCapabilities()
    Compat->>DI: Promise.all([getTotalRAM(), getAvailableRAM(), ...])
    Compat->>FS: Promise.all([getTotalDiskSpace(), getAvailableDiskSpace()])
    DI-->>Compat: RAM, CPU, GPU, NPU, chip info
    FS-->>Compat: Storage info
    Compat->>Compat: Construct DeviceCapabilities
    
    Compat->>Compat: performCompatibilityCheck(model, device)
    Compat->>Compat: calculateRequiredMemory(model)
    Compat->>Compat: calculateRequiredStorage(model)
    Compat->>Compat: Check canRun (memory check)
    Compat->>Compat: Check canFit (storage check)
    Compat->>Compat: Determine isCompatible
    
    Compat-->>RA: ModelCompatibilityResult
    RA-->>App: ModelCompatibilityResult
    
    Note over App,FS: Batch Check Flow
    
    App->>RA: checkModelsCompatibility([modelIds])
    RA->>Compat: checkModelsCompatibility([modelIds])
    Compat->>Compat: getDeviceCapabilities() (once)
    
    loop For each modelId
        Compat->>MR: getModel(modelId)
        MR-->>Compat: ModelInfo
        Compat->>Compat: performCompatibilityCheck(model, device)
    end
    
    Compat-->>RA: Record<modelId, ModelCompatibilityResult>
    RA-->>App: Record<modelId, ModelCompatibilityResult>
Loading

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

Copilot AI review requested due to automatic review settings February 1, 2026 01:00
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 335d4c6 in 10 seconds. Click for details.
  • Reviewed 447 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_nCYCfx4Njcr78jtM

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

Adds a model compatibility feature to the RunAnywhere SDK: three new public APIs (checkModelCompatibility, checkModelsCompatibility, getDeviceCapabilities), supporting types, core implementation, re-exports, and README docs for usage examples.

Changes

Cohort / File(s) Summary
Core Implementation
sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts
New module implementing device capability retrieval and model compatibility checks, batch checking, internal helpers performCompatibilityCheck, calculateRequiredMemory, calculateRequiredStorage, and constants (MEMORY_MULTIPLIER 1.5, STORAGE_MULTIPLIER 1.2, MIN_RAM_OVERHEAD 500MB, MIN_STORAGE_OVERHEAD 100MB).
Public API Wiring
sdk/runanywhere-react-native/packages/core/src/Public/RunAnywhere.ts, sdk/runanywhere-react-native/packages/core/src/Public/Extensions/index.ts
Imported and re-exported compatibility extension; added RunAnywhere methods that delegate to the new compatibility functions.
Types
sdk/runanywhere-react-native/packages/core/src/types/CompatibilityTypes.ts, sdk/runanywhere-react-native/packages/core/src/types/index.ts
New exported interfaces: ModelCompatibilityResult (canRun, canFit, isCompatible, required/available memory & storage) and DeviceCapabilities (total/available memory & storage, cpuCores, hasGPU, hasNPU, chipName, deviceModel, platform).
Documentation
sdk/runanywhere-react-native/packages/core/README.md
Added "Model Compatibility" section documenting three new public APIs with single-model, multi-model, and device capability examples and sample console outputs.

Sequence Diagram(s)

sequenceDiagram
  actor Client
  participant RunAnywhere
  participant CompatibilityExtension as Compatibility
  participant ModelRegistry
  participant NativeCore as NativeCore
  participant FileSystem

  Client->>RunAnywhere: checkModelsCompatibility([modelIds])
  RunAnywhere->>Compatibility: checkModelsCompatibility(models)
  Compatibility->>NativeCore: getDeviceInfo()
  NativeCore-->>Compatibility: device specs (memory, cpu, chip, gpu/npu)
  Compatibility->>FileSystem: getStorageInfo()
  FileSystem-->>Compatibility: storage stats
  Compatibility->>ModelRegistry: resolve model info (for each modelId)
  ModelRegistry-->>Compatibility: ModelInfo
  Compatibility->>Compatibility: performCompatibilityCheck(model, device)
  Compatibility-->>RunAnywhere: aggregated results
  RunAnywhere-->>Client: Promise resolves with compatibility map
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A pocket of bytes and a curious twitch,
I sniff the RAM, the storage—every niche,
Models line up, I peer and decide,
"Fit" or "needs more"—I skip, I stride,
Hopping home happy with compatibility pride.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description covers objectives, changes, files modified, and implementation details. However, it lacks required testing checklist items and platform-specific testing confirmations. Complete the Testing section with checkmarks for lint, tests, and platform-specific testing (iOS/Android for React Native). Clarify if testing was performed and what the results were.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding model compatibility checks to the React Native SDK, which aligns with the substantial new API surface being introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 7 comments

Edit Code Review Agent Settings | Greptile

export type {
ModelCompatibilityResult,
DeviceCapabilities,
} from './CompatibilityTypes' No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

missing semicolon at end of export statement

Suggested change
} from './CompatibilityTypes'
} from './CompatibilityTypes';

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: sdk/runanywhere-react-native/packages/core/src/types/index.ts
Line: 152:152

Comment:
missing semicolon at end of export statement

```suggestion
} from './CompatibilityTypes';
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

checkModelCompatibility,
checkModelsCompatibility,
getDeviceCapabilities,
} from './RunAnywhere+Compatibility'; No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

missing semicolon at end of export statement

Suggested change
} from './RunAnywhere+Compatibility';
} from './RunAnywhere+Compatibility';

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: sdk/runanywhere-react-native/packages/core/src/Public/Extensions/index.ts
Line: 158:158

Comment:
missing semicolon at end of export statement

```suggestion
} from './RunAnywhere+Compatibility';
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 1 to 2


Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary blank lines at start of file - remove for consistency with other SDK files

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: sdk/runanywhere-react-native/packages/core/src/types/CompatibilityTypes.ts
Line: 1:2

Comment:
unnecessary blank lines at start of file - remove for consistency with other SDK files

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

function calculateRequiredStorage(model: ModelInfo): number {
const baseStorage = model.downloadSize || model.memoryRequired || 0;
return Math.ceil(baseStorage * STORAGE_MULTIPLIER);
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

missing newline at end of file

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts
Line: 244:244

Comment:
missing newline at end of file

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +232 to +235
function calculateRequiredMemory(model: ModelInfo): number {
// Use memoryRequired if available, otherwise estimate from download size
const baseMemory = model.memoryRequired || model.downloadSize || 0;
return Math.ceil(baseMemory * MEMORY_MULTIPLIER);
Copy link
Contributor

Choose a reason for hiding this comment

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

models with zero memoryRequired and downloadSize will return 0, causing incorrect compatibility checks - add validation or fallback

function calculateRequiredMemory(model: ModelInfo): number {
    const baseMemory = model.memoryRequired || model.downloadSize || 0;
    if (baseMemory === 0) {
        logger.warning(`Model ${model.id} has no memory/size data - cannot check compatibility`);
    }
    return Math.ceil(baseMemory * MEMORY_MULTIPLIER);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts
Line: 232:235

Comment:
models with zero `memoryRequired` and `downloadSize` will return 0, causing incorrect compatibility checks - add validation or fallback

```typescript
function calculateRequiredMemory(model: ModelInfo): number {
    const baseMemory = model.memoryRequired || model.downloadSize || 0;
    if (baseMemory === 0) {
        logger.warning(`Model ${model.id} has no memory/size data - cannot check compatibility`);
    }
    return Math.ceil(baseMemory * MEMORY_MULTIPLIER);
}
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 708 to 710
checkModelCompatibility: Compatibility.checkModelCompatibility,
checkModelsCompatibility: Compatibility.checkModelsCompatibility,
getDeviceCapabilities: Compatibility.getDeviceCapabilities,
Copy link
Contributor

Choose a reason for hiding this comment

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

inconsistent indentation - uses 4 spaces instead of 2 spaces like rest of file

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: sdk/runanywhere-react-native/packages/core/src/Public/RunAnywhere.ts
Line: 708:710

Comment:
inconsistent indentation - uses 4 spaces instead of 2 spaces like rest of file

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 33 to 37
/** Memory multiplier for model loading (typically 1.5x model size) */
const MEMORY_MULTIPLIER = 1.5;

/** Storage multiplier for extraction/temp files (1.2x download size) */
const STORAGE_MULTIPLIER = 1.2;
Copy link
Contributor

Choose a reason for hiding this comment

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

arbitrary multipliers (1.5x memory, 1.2x storage) noted by author - consider making these configurable or adding TODO comment explaining they need validation from maintainers

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts
Line: 33:37

Comment:
arbitrary multipliers (1.5x memory, 1.2x storage) noted by author - consider making these configurable or adding TODO comment explaining they need validation from maintainers

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Copy link

@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: 1

🤖 Fix all issues with AI agents
In
`@sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere`+Compatibility.ts:
- Around line 200-226: performCompatibilityCheck currently treats zero/absent
resource metadata as compatible; update it to "fail closed" by detecting when
calculateRequiredMemory(model) <= 0 or calculateRequiredStorage(model) <= 0 and
treating those cases as incompatible: set canRun = false and/or canFit = false,
ensure isCompatible = false, and return the computed
requiredMemory/requiredStorage and available values so callers can surface an
error; use the existing symbols calculateRequiredMemory,
calculateRequiredStorage, MIN_RAM_OVERHEAD_BYTES, MIN_STORAGE_OVERHEAD_BYTES and
ensure any existing logic that compares device.availableMemory/availableStorage
only runs when required values are > 0 (or short-circuit earlier) to avoid false
positives.
🧹 Nitpick comments (2)
sdk/runanywhere-react-native/packages/core/README.md (1)

144-173: Clarify the batch return shape in the docs.
checkModelsCompatibility returns a map keyed by model ID in the implementation, but the example doesn’t show how to consume that shape. Consider adding a short snippet using Object.entries(results) to make it explicit.

sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts (1)

178-187: Batch API drops errored/missing models silently.
Right now, failures are only logged and the entry is omitted, which makes it impossible for callers to distinguish “missing model” from “not checked.” Consider returning an explicit entry (or a separate error map) so consumers can handle failures deterministically.

Comment on lines +200 to +226
function performCompatibilityCheck(
model: ModelInfo,
device: DeviceCapabilities
): ModelCompatibilityResult {
// Calculate required resources
const requiredMemory = calculateRequiredMemory(model);
const requiredStorage = calculateRequiredStorage(model);

// Check memory compatibility
const canRun = device.availableMemory >= requiredMemory + MIN_RAM_OVERHEAD_BYTES;

// Check storage compatibility
const canFit =
device.availableStorage >= requiredStorage + MIN_STORAGE_OVERHEAD_BYTES;

// Overall compatibility
const isCompatible = canRun && canFit;

return {
canRun,
canFit,
isCompatible,
requiredMemory,
availableMemory: device.availableMemory,
requiredStorage,
availableStorage: device.availableStorage,
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Guard against missing/zero model resource metadata to avoid false positives.
If requiredMemory or requiredStorage resolves to 0, the check can incorrectly mark large models as compatible. This is already happening per the PR notes. Consider treating unknown/zero metadata as incompatible (or surface an error).

🛡️ Proposed fix (fail closed on missing metadata)
 function performCompatibilityCheck(
     model: ModelInfo,
     device: DeviceCapabilities
 ): ModelCompatibilityResult {
     // Calculate required resources
     const requiredMemory = calculateRequiredMemory(model);
     const requiredStorage = calculateRequiredStorage(model);
+
+    if (requiredMemory <= 0 || requiredStorage <= 0) {
+        logger.warning('Model resource metadata missing/invalid', {
+            model: model.id,
+            requiredMemory,
+            requiredStorage,
+        });
+        return {
+            canRun: false,
+            canFit: false,
+            isCompatible: false,
+            requiredMemory,
+            availableMemory: device.availableMemory,
+            requiredStorage,
+            availableStorage: device.availableStorage,
+        };
+    }

     // Check memory compatibility
     const canRun = device.availableMemory >= requiredMemory + MIN_RAM_OVERHEAD_BYTES;
🤖 Prompt for AI Agents
In
`@sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere`+Compatibility.ts
around lines 200 - 226, performCompatibilityCheck currently treats zero/absent
resource metadata as compatible; update it to "fail closed" by detecting when
calculateRequiredMemory(model) <= 0 or calculateRequiredStorage(model) <= 0 and
treating those cases as incompatible: set canRun = false and/or canFit = false,
ensure isCompatible = false, and return the computed
requiredMemory/requiredStorage and available values so callers can surface an
error; use the existing symbols calculateRequiredMemory,
calculateRequiredStorage, MIN_RAM_OVERHEAD_BYTES, MIN_STORAGE_OVERHEAD_BYTES and
ensure any existing logic that compares device.availableMemory/availableStorage
only runs when required values are > 0 (or short-circuit earlier) to avoid false
positives.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds model compatibility checking functionality to the React Native SDK, enabling developers to determine if a model can run on their device before downloading or loading it. This addresses a gap in the React Native SDK compared to other platform SDKs.

Changes:

  • Added three new public API functions: checkModelCompatibility(), checkModelsCompatibility(), and getDeviceCapabilities()
  • Implemented compatibility checking logic based on device RAM, storage, and model requirements
  • Added comprehensive TypeScript type definitions for compatibility results and device capabilities

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
sdk/runanywhere-react-native/packages/core/src/types/CompatibilityTypes.ts New type definitions for ModelCompatibilityResult and DeviceCapabilities interfaces
sdk/runanywhere-react-native/packages/core/src/Public/Extensions/RunAnywhere+Compatibility.ts Core implementation of compatibility checking with device info retrieval and requirement calculations
sdk/runanywhere-react-native/packages/core/src/types/index.ts Export statements for new compatibility types
sdk/runanywhere-react-native/packages/core/src/Public/Extensions/index.ts Export statements for new compatibility functions
sdk/runanywhere-react-native/packages/core/src/Public/RunAnywhere.ts Integration of compatibility functions into main SDK object, plus minor indentation formatting fixes
sdk/runanywhere-react-native/packages/core/README.md Added documentation and usage examples for the new compatibility API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import * as VoiceSession from './Extensions/RunAnywhere+VoiceSession';
import * as StructuredOutput from './Extensions/RunAnywhere+StructuredOutput';
import * as Audio from './Extensions/RunAnywhere+Audio';
import * as Compatibility from './Extensions/RunAnywhere+Compatibility'
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

Missing semicolon at the end of the import statement. All other import statements in this file end with a semicolon (see lines 47, 48, 49).

Suggested change
import * as Compatibility from './Extensions/RunAnywhere+Compatibility'
import * as Compatibility from './Extensions/RunAnywhere+Compatibility';

Copilot uses AI. Check for mistakes.
hasNPU,
chipName,
deviceModel,
platform: Platform.OS
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

Missing semicolon at the end of the statement. The codebase consistently uses semicolons at the end of statements (see lines 139-147 in this file).

Copilot uses AI. Check for mistakes.
deviceModel: string;

/** Device Platform */
platform: 'ios' | 'android' | 'windows' | 'macos' | 'web';
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The platform type definition includes 'windows', 'macos', and 'web', but React Native's Platform.OS only returns 'ios' or 'android' (and potentially 'windows', 'macos', 'web' for React Native for Web/Desktop, but these are not widely used in typical React Native apps). This type mismatch could lead to TypeScript accepting invalid platform values. Consider restricting the type to match the actual React Native platforms: 'ios' | 'android', or if the SDK plans to support other platforms in the future, document this explicitly.

Suggested change
platform: 'ios' | 'android' | 'windows' | 'macos' | 'web';
platform: 'ios' | 'android';

Copilot uses AI. Check for mistakes.
Comment on lines +232 to +236
function calculateRequiredMemory(model: ModelInfo): number {
// Use memoryRequired if available, otherwise estimate from download size
const baseMemory = model.memoryRequired || model.downloadSize || 0;
return Math.ceil(baseMemory * MEMORY_MULTIPLIER);
}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

When both model.memoryRequired and model.downloadSize are 0 or undefined (as noted in the PR description for some models like llama-2-7b-chat-q4_k_m), the calculated required memory and storage will be 0. This could lead to misleading compatibility results where a model appears compatible when the actual resource requirements are unknown. Consider adding validation to detect this case and either log a warning, throw an error, or return a special compatibility result indicating that requirements are unknown.

Copilot uses AI. Check for mistakes.
console.log(`RAM: ${(caps.availableMemory / 1e9).toFixed(1)} / ${(caps.totalMemory / 1e9).toFixed(1)} GB`);
console.log(`Storage: ${(caps.availableStorage / 1e9).toFixed(1)} / ${(caps.totalStorage / 1e9).toFixed(1)} GB`);
console.log(`CPU: ${caps.cpuCores} cores, GPU: ${caps.hasGPU}, NPU: ${caps.hasNPU}`);

Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

Missing closing triple backticks for the code block that starts at line 146. The code block should be closed before the markdown separator on line 174. Add ``` at the end of line 173 to properly close the code block.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines 708 to 710
checkModelCompatibility: Compatibility.checkModelCompatibility,
checkModelsCompatibility: Compatibility.checkModelsCompatibility,
getDeviceCapabilities: Compatibility.getDeviceCapabilities,
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation: these lines have 4 spaces of indentation while other properties at the same level (e.g., Audio section on lines 687-702) use 2 spaces. Adjust to use 2 spaces for consistency with the rest of the object.

Suggested change
checkModelCompatibility: Compatibility.checkModelCompatibility,
checkModelsCompatibility: Compatibility.checkModelsCompatibility,
getDeviceCapabilities: Compatibility.getDeviceCapabilities,
checkModelCompatibility: Compatibility.checkModelCompatibility,
checkModelsCompatibility: Compatibility.checkModelsCompatibility,
getDeviceCapabilities: Compatibility.getDeviceCapabilities,

Copilot uses AI. Check for mistakes.
export type {
ModelCompatibilityResult,
DeviceCapabilities,
} from './CompatibilityTypes' No newline at end of file
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

Missing semicolon at the end of the export statement. All other export type statements in this file end with a semicolon (see lines 101, 111, 123, 135, 146).

Suggested change
} from './CompatibilityTypes'
} from './CompatibilityTypes';

Copilot uses AI. Check for mistakes.
@shubhammalhotra28
Copy link
Contributor

Hi Joshua,
Thanks for the PR. Can we move the business logic to the CPP layer, since then we can call it from all the other SDK's - since that's how we're doing which also makes sure that CPP (common) is the source of truth for all the 4 SDK's we have. Let me know if you've any questions

@shubhammalhotra28
Copy link
Contributor

@JoshuaChil Let me know if you've any questions. Once you're having the CPP changes - you can connect it via the react native SDK.

@JoshuaChil
Copy link
Author

@shubhammalhotra28 , thank you so much for feedback! I will get on making change asap. Two quick questions:

  1. Should I create a new feature branch/pr or just commit my changes to this branch
  2. Is there a preference for how I should handle fallbacks for models that are currently returning 0 required RAM / storage.

@shubhammalhotra28
Copy link
Contributor

@JoshuaChil
No worries, thanks for contributing to it !!

  1. Just use the same branch, will keep an eye on to it and can review as soon as you're done with the changes.
  2. I believe for this we could do something like return compatible = True and then have another boolean for metadata (completeMetaData which could be False). Also, we should not block the downloads in case completeMetaData = False, just log it and let it flow.

Let me know if you've any other questions :)

@shubhammalhotra28
Copy link
Contributor

Hi @JoshuaChil - any updates on this ? Or stuck with anything ?

@JoshuaChil
Copy link
Author

JoshuaChil commented Feb 10, 2026

Hi @JoshuaChil - any updates on this ? Or stuck with anything ?

Hey @shubhammalhotra28 , worked on it for quite a bit, took some time since I'm getting familiar with C++. Was running into some issues/errors, but wanted to give myself a bit more time to fully understand the feature and build out. I will keep trying until Thursday night, and if not able to complete feature will commit what I have and maybe reach out to see if we can fix the errors together. If any issues there please let me know. Thanks!

Edit: Sorry for delays! Schedule got a bit packed this week. I will PR on Saturday.

@JoshuaChil
Copy link
Author

Hi @JoshuaChil - any updates on this ? Or stuck with anything ?

@shubhammalhotra28, I re-opened this in a new PR since I have made significant changes. Struggled with implementation (I think I am just new to C++, and this has definitely been a skill jump, but great learning experience!) Would deeply appreciate feedback, I feel my current approach is not in alignment with style guide architectures, and would love any advice. I will continue to work on iterations as needed.

Also - currently I have attempted to implement using downloadSize from model registry, but seem to be returning 0 for all models . I don't believe I had this issue earlier and think it may be an issue in the backend? After receiving feedback I will also work to implement fallbacks for compatibility checks in cases where there is missing metadata.

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.

3 participants

Comments