Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ name: Build iPhone IPA
on:
push:
branches:
- main
- "**"
paths:
- ".github/workflows/**"
- "ModelQuantizer/**"
- "ModelQuantizer.xcodeproj/**"
- "README.md"
- "TRIGGER.md"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/**"
- "ModelQuantizer/**"
- "ModelQuantizer.xcodeproj/**"
- "README.md"
- "TRIGGER.md"
workflow_dispatch:

jobs:
build:
runs-on: macos-15
runs-on: macos-14

env:
PROJECT: ModelQuantizer.xcodeproj
Expand All @@ -25,7 +40,7 @@ jobs:
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.4'
xcode-version: '15.4'

- name: Check Xcode and project
shell: bash
Expand Down
44 changes: 32 additions & 12 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@ name: iOS Build and Test

on:
push:
branches: [ main, develop ]
branches: [ "**" ]
paths:
- ".github/workflows/**"
- "ModelQuantizer/**"
- "ModelQuantizer.xcodeproj/**"
- "README.md"
- "TRIGGER.md"
pull_request:
branches: [ main ]
branches: [ "**" ]
paths:
- ".github/workflows/**"
- "ModelQuantizer/**"
- "ModelQuantizer.xcodeproj/**"
- "README.md"
- "TRIGGER.md"

jobs:
build:
Expand All @@ -15,8 +27,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Select Xcode Version
run: sudo xcode-select -s /Applications/Xcode_15.4.app
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'

- name: Show Xcode Version
run: xcodebuild -version
Expand All @@ -35,12 +49,16 @@ jobs:

- name: Run Tests
run: |
xcodebuild test \
-project ModelQuantizer.xcodeproj \
-scheme ModelQuantizer \
-destination 'platform=iOS Simulator,name=iPhone 15' \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO
if xcodebuild -project ModelQuantizer.xcodeproj -list | grep -q "Tests"; then
xcodebuild test \
-project ModelQuantizer.xcodeproj \
-scheme ModelQuantizer \
-destination 'platform=iOS Simulator,name=iPhone 15' \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO
else
echo "No test target found; skipping test step."
fi

- name: Archive Build Logs on Failure
if: failure()
Expand All @@ -59,8 +77,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Select Xcode Version
run: sudo xcode-select -s /Applications/Xcode_15.4.app
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'

- name: Run Static Analysis
run: |
Expand Down
10 changes: 7 additions & 3 deletions ModelQuantizer/Models/ModelTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct HFModel: Identifiable, Codable, Equatable {
architecture: ModelArchitecture,
downloadURL: URL? = nil,
sizeBytes: Int64 = 0,
quantizationOptions: [QuantizationType] = QuantizationType.allCases,
quantizationOptions: [QuantizationType] = QuantizationType.onDeviceSupportedCases,
recommendedContextLength: Int = 4096,
tags: [String] = [],
downloads: Int = 0,
Expand Down Expand Up @@ -67,13 +67,13 @@ enum ModelArchitecture: String, Codable, CaseIterable {
var supportedQuantizations: [QuantizationType] {
switch self {
case .llama, .mistral, .qwen2, .gemma, .phi:
return [.q4_0, .q4_1, .q5_0, .q5_1, .q8_0, .fp16, .fp32]
return QuantizationType.onDeviceSupportedCases
case .falcon, .gpt2:
return [.q4_0, .q4_1, .q8_0, .fp16]
case .bert:
return [.q8_0, .fp16, .fp32]
case .custom:
return QuantizationType.allCases
return QuantizationType.onDeviceSupportedCases
}
}

Expand Down Expand Up @@ -148,6 +148,10 @@ enum QuantizationType: String, Codable, CaseIterable {
return 32.0 / bits
}

static var onDeviceSupportedCases: [QuantizationType] {
[.q4_0, .q4_1, .q8_0, .fp16, .fp32]
}

var ggufFileType: UInt32 {
switch self {
case .fp32: return 0
Expand Down
5 changes: 4 additions & 1 deletion ModelQuantizer/Services/HuggingFaceAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// HuggingFaceAPI.swift
// ModelQuantizer
//
// Real Hugging Face API integration for model search and download.
// Hugging Face API integration for model search and download.
//

import Foundation
Expand Down Expand Up @@ -200,6 +200,9 @@ class HuggingFaceAPI: ObservableObject {
// Remove existing file
try? FileManager.default.removeItem(at: destination)

// Create destination file before opening file handle
_ = FileManager.default.createFile(atPath: destination.path, contents: nil)

// Write file
let fileHandle = try FileHandle(forWritingTo: destination)
defer { try? fileHandle.close() }
Expand Down
Loading
Loading