Repository navigation
Expand file tree
/
Copy pathPackage.swift
More file actions
148 lines (147 loc) · 7.9 KB
/
Copy pathPackage.swift
File metadata and controls
148 lines (147 loc) · 7.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "coreai-kit",
platforms: [.macOS("26.0"), .iOS("26.0")],
products: [
// LLM: ModelStore + ChatSession + FoundationModels provider (tool calling).
.library(name: "CoreAIKit", targets: ["CoreAIKit"]),
// CV: generic graph runner + typed pipelines (CLIP, depth, camera). Links only
// the system CoreAI framework — no LLM runtime is pulled in.
.library(name: "CoreAIKitVision", targets: ["CoreAIKitVision"]),
// Text embeddings for on-device retrieval/RAG (EmbeddingGemma).
.library(name: "CoreAIKitEmbeddings", targets: ["CoreAIKitEmbeddings"]),
// SwiftUI components: model picker, chat transcript, stats bar.
.library(name: "CoreAIKitUI", targets: ["CoreAIKitUI"]),
// Anchored task ops (text, image, audio, video, search, forecast) over catalog
// models — the stable task-level API. Re-exports the model layer, so this one
// product + `import CoreAIOps` is the whole quick path.
.library(name: "CoreAIOps", targets: ["CoreAIOps"]),
// Answers "what will this app download" before someone has to answer it in a meeting.
// An executable, so linking the libraries never drags it in.
.executable(name: "coreai-doctor", targets: ["coreai-doctor"]),
// System One on this machine without a Swift toolchain: `systemone serve` is the
// /v1/systemone endpoint over a catalog model, `ask` one decision from the shell,
// `models` what can decide. Built, signed and notarized by the release workflow and
// installed with `brew install john-rocky/tap/systemone`.
.executable(name: "systemone", targets: ["systemone"]),
],
traits: [
// Off by default. Enable it to download large files over Xet; swift-xet and its
// dependencies are compiled only then. Forwards to swift-huggingface's trait.
.trait(name: "Xet", description: "Enable Xet transport for model downloads.")
],
dependencies: [
// Community fork of apple/coreai-models (unaffiliated with Apple). 0.2.8-zoo is
// 0.2.7-zoo with upstream's x86_64 guard on the Float16 code of three files: 0.2.6-zoo's
// macOS 26 floor makes a Release (universal) app build compile the fork for x86_64,
// which has no Float16, and those files failed there (the arm64 code is unchanged).
// 0.2.7-zoo adds a
// checkpoint of a hybrid model's recurrent state to the sequential engine
// (InferenceEngine.checkpoint()): TypedDecisions checkpoints after a state's prefix
// and each later question restores it instead of re-prefilling the whole prompt
// (4.4-5.9x per decision on three hybrid decision models, macOS; iOS not measured).
// The move from 0.2.4-zoo also brings 0.2.5-zoo (the engine stops at a stop sequence
// instead of decoding to maxTokens) and 0.2.6-zoo (a macOS 26 / iOS 26 floor with
// @available(macOS 27, iOS 27, *) on everything that touches Core AI; this package
// does the same). 0.2.4-zoo is
// upstream main through #207 (2026-08-28) plus the zoo patches to the pipelined
// engine: hybrid/SSM extra states so Qwen3.5/3.6, LFM2.5 and Granite 4 load,
// chunked prefill via a static-chunk "prefill" function, per-token/static inputs,
// decode-only S=1 bundles (apple/coreai-models#212), the iOS dynamic-KV capacity
// guard (apple/coreai-models#124), and EOS stop when the consumer breaks the
// stream. Everything else is byte-for-byte upstream. See
// https://github.com/john-rocky/coreai-models.
// 0.2.4-zoo drops the fork's sampler-ordering drain, which upstream #121 made
// redundant: macOS decode +43-52% (qwen3-0.6b, drain vs. none); iOS not measured.
// 0.2.2-zoo and earlier predate upstream #121 (per-call sampler execution
// descriptor; garbled text at temperature > 0 under pipelined decode).
// For local engine work swap in .package(path: "../coreai-models") — branch
// zoo-0.4 matches this tag.
.package(url: "https://github.com/john-rocky/coreai-models", exact: "0.2.8-zoo"),
.package(url: "https://github.com/huggingface/swift-transformers", from: "1.1.0"),
.package(
url: "https://github.com/huggingface/swift-huggingface.git",
from: "0.11.0",
traits: [
.defaults,
.trait(name: "Xet", condition: .when(traits: ["Xet"])),
]
),
],
targets: [
// Shared base: model identity + Hugging Face download/cache. No inference runtime.
.target(
name: "CoreAIKitCore",
dependencies: [.product(name: "HuggingFace", package: "swift-huggingface")]
),
// d1-3B's readout products in float64 through the BLAS calls NumPy makes for `E @ h` (Accelerate's new
// interface, 64-bit integers), so the kit's logits equal the Python reference's bit for bit. A C target so the
// two defines reach the Accelerate headers without unsafe flags, which a remote dependency may not carry.
.target(
name: "CoreAIKitD1BLAS",
cSettings: [.define("ACCELERATE_NEW_LAPACK"), .define("ACCELERATE_LAPACK_ILP64")],
linkerSettings: [.linkedFramework("Accelerate")]
),
.target(
name: "CoreAIKit",
dependencies: [
"CoreAIKitCore",
"CoreAIKitD1BLAS",
// The VL executor runs the paired vision tower through CoreAIKitVision's
// GraphModel (stateless .aimodel runner); it also brings the CoreAI framework
// link the vision path needs.
"CoreAIKitVision",
.product(name: "CoreAILM", package: "coreai-models"),
.product(name: "Transformers", package: "swift-transformers"),
],
// Mel filterbanks for the audio frontends, each bit-exact with its HF feature
// extractor so the mel never recomputes librosa: Whisper-large-v3 ([201,128] fp32,
// gated cos 1.0) and Parakeet ([128,257] fp32 librosa-slaney, gated token-exact e2e).
resources: [
.copy("Audio/Resources/mel_filters.f32"),
.copy("Audio/Resources/parakeet_mel_filters_128x257.f32"),
// Raw-Metal Gemma 4 kernels + oracle refs (compiled at load by
// Gemma4MetalEngine — .txt so nothing tries to precompile them).
.copy("Gemma4Metal/g4msl"),
]
),
.target(
name: "CoreAIKitVision",
dependencies: ["CoreAIKitCore"],
linkerSettings: [.linkedFramework("CoreAI")]
),
.target(
name: "CoreAIKitEmbeddings",
dependencies: [
"CoreAIKitCore",
"CoreAIKitVision",
.product(name: "Transformers", package: "swift-transformers"),
]
),
.target(
name: "CoreAIKitUI",
dependencies: ["CoreAIKit"]
),
.target(
name: "CoreAIOps",
dependencies: ["CoreAIKit", "CoreAIKitVision", "CoreAIKitEmbeddings"]
),
.executableTarget(
name: "coreai-doctor",
dependencies: ["CoreAIOps"]
),
.executableTarget(
name: "systemone",
dependencies: ["CoreAIOps"]
),
.testTarget(
name: "CoreAIKitTests",
dependencies: ["CoreAIKit", "CoreAIKitVision", "CoreAIKitEmbeddings", "CoreAIOps"],
// Read from the source tree (#filePath), not bundled: a test resource bundle would
// make `Bundle.module` ambiguous beside CoreAIKit's under `@testable import`.
exclude: ["Fixtures"],
swiftSettings: [.define("COREAIKIT_XET", .when(traits: ["Xet"]))]
),
]
)