@mmerterden/multi-agent-pipeline 20.6.0 → 20.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +0 -10
  3. package/docs/facts.json +1 -1
  4. package/manifest.json +328 -329
  5. package/package.json +2 -2
  6. package/pipeline/multi-agent-refs/features/design-conformance.md +62 -64
  7. package/pipeline/scripts/_notices.mjs +12 -1
  8. package/pipeline/scripts/gen-skills-index.mjs +1 -1
  9. package/pipeline/skills/.skill-manifest.json +106 -106
  10. package/pipeline/skills/shared/README.md +71 -71
  11. package/pipeline/skills/shared/external/agent-introspection-debugging/SKILL.md +1 -0
  12. package/pipeline/skills/shared/external/alarmkit/SKILL.md +373 -381
  13. package/pipeline/skills/shared/external/alarmkit/evals/evals.json +23 -18
  14. package/pipeline/skills/shared/external/alarmkit/references/alarmkit-patterns.md +328 -378
  15. package/pipeline/skills/shared/external/android-architecture/SKILL.md +2 -0
  16. package/pipeline/skills/shared/external/android-performance/SKILL.md +2 -0
  17. package/pipeline/skills/shared/external/android-security/SKILL.md +2 -0
  18. package/pipeline/skills/shared/external/app-clips/SKILL.md +260 -160
  19. package/pipeline/skills/shared/external/app-clips/evals/evals.json +27 -27
  20. package/pipeline/skills/shared/external/app-clips/references/data-handoff-notifications-location.md +150 -83
  21. package/pipeline/skills/shared/external/app-clips/references/routing-and-experiences.md +135 -83
  22. package/pipeline/skills/shared/external/app-clips/references/size-capabilities-and-promotion.md +143 -85
  23. package/pipeline/skills/shared/external/app-intents/SKILL.md +302 -304
  24. package/pipeline/skills/shared/external/app-intents/evals/evals.json +21 -21
  25. package/pipeline/skills/shared/external/app-intents/references/appintents-advanced.md +594 -894
  26. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +339 -277
  27. package/pipeline/skills/shared/external/app-store-optimization/evals/evals.json +27 -23
  28. package/pipeline/skills/shared/external/app-store-optimization/references/keyword-research-methodology.md +105 -122
  29. package/pipeline/skills/shared/external/app-store-optimization/references/product-page-variants.md +143 -166
  30. package/pipeline/skills/shared/external/app-store-review/SKILL.md +307 -326
  31. package/pipeline/skills/shared/external/app-store-review/evals/evals.json +21 -21
  32. package/pipeline/skills/shared/external/app-store-review/references/privacy-manifest.md +105 -67
  33. package/pipeline/skills/shared/external/app-store-review/references/review-checklists.md +114 -101
  34. package/pipeline/skills/shared/external/apple-on-device-ai/SKILL.md +333 -360
  35. package/pipeline/skills/shared/external/apple-on-device-ai/evals/evals.json +24 -27
  36. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-conversion.md +215 -322
  37. package/pipeline/skills/shared/external/apple-on-device-ai/references/coreml-optimization.md +161 -256
  38. package/pipeline/skills/shared/external/apple-on-device-ai/references/foundation-models.md +277 -387
  39. package/pipeline/skills/shared/external/apple-on-device-ai/references/mlx-swift.md +196 -210
  40. package/pipeline/skills/shared/external/authentication/SKILL.md +265 -381
  41. package/pipeline/skills/shared/external/authentication/evals/evals.json +25 -25
  42. package/pipeline/skills/shared/external/authentication/references/keychain-biometric.md +133 -178
  43. package/pipeline/skills/shared/external/authentication/references/passkeys.md +111 -147
  44. package/pipeline/skills/shared/external/avkit/SKILL.md +267 -364
  45. package/pipeline/skills/shared/external/avkit/evals/evals.json +26 -26
  46. package/pipeline/skills/shared/external/avkit/references/avkit-patterns.md +375 -493
  47. package/pipeline/skills/shared/external/background-processing/SKILL.md +270 -382
  48. package/pipeline/skills/shared/external/background-processing/evals/evals.json +22 -22
  49. package/pipeline/skills/shared/external/background-processing/references/background-task-patterns.md +169 -317
  50. package/pipeline/skills/shared/external/backlog/BACKLOG.md +1 -1
  51. package/pipeline/skills/shared/external/backlog/SKILL.md +56 -33
  52. package/pipeline/skills/shared/external/callkit-voip/SKILL.md +290 -371
  53. package/pipeline/skills/shared/external/callkit-voip/evals/evals.json +24 -24
  54. package/pipeline/skills/shared/external/callkit-voip/references/callkit-patterns.md +175 -343
  55. package/pipeline/skills/shared/external/ci-cd-pipelines/SKILL.md +1 -0
  56. package/pipeline/skills/shared/external/cloudkit-sync/SKILL.md +292 -381
  57. package/pipeline/skills/shared/external/cloudkit-sync/evals/evals.json +33 -30
  58. package/pipeline/skills/shared/external/cloudkit-sync/references/cloudkit-patterns.md +227 -355
  59. package/pipeline/skills/shared/external/compose-components/SKILL.md +2 -0
  60. package/pipeline/skills/shared/external/compose-navigation/SKILL.md +3 -2
  61. package/pipeline/skills/shared/external/compose-testing/SKILL.md +2 -0
  62. package/pipeline/skills/shared/external/contacts-framework/SKILL.md +197 -346
  63. package/pipeline/skills/shared/external/contacts-framework/evals/evals.json +19 -21
  64. package/pipeline/skills/shared/external/contacts-framework/references/contacts-patterns.md +169 -308
  65. package/pipeline/skills/shared/external/core-bluetooth/SKILL.md +226 -376
  66. package/pipeline/skills/shared/external/core-bluetooth/evals/evals.json +25 -22
  67. package/pipeline/skills/shared/external/core-bluetooth/references/ble-patterns.md +257 -337
  68. package/pipeline/skills/shared/external/core-data/SKILL.md +292 -368
  69. package/pipeline/skills/shared/external/core-data/evals/evals.json +30 -27
  70. package/pipeline/skills/shared/external/core-motion/SKILL.md +235 -324
  71. package/pipeline/skills/shared/external/core-motion/evals/evals.json +31 -27
  72. package/pipeline/skills/shared/external/core-motion/references/motion-patterns.md +210 -310
  73. package/pipeline/skills/shared/external/core-nfc/SKILL.md +292 -366
  74. package/pipeline/skills/shared/external/core-nfc/evals/evals.json +22 -24
  75. package/pipeline/skills/shared/external/core-nfc/references/nfc-patterns.md +233 -329
  76. package/pipeline/skills/shared/external/coreml/SKILL.md +323 -367
  77. package/pipeline/skills/shared/external/coreml/evals/evals.json +24 -21
  78. package/pipeline/skills/shared/external/coreml/references/coreml-swift-integration.md +562 -565
  79. package/pipeline/skills/shared/external/council/SKILL.md +1 -0
  80. package/pipeline/skills/shared/external/cryptokit/SKILL.md +253 -394
  81. package/pipeline/skills/shared/external/cryptokit/evals/evals.json +20 -18
  82. package/pipeline/skills/shared/external/cryptokit/references/cryptokit-patterns.md +299 -488
  83. package/pipeline/skills/shared/external/css-modern/SKILL.md +1 -0
  84. package/pipeline/skills/shared/external/database-patterns/SKILL.md +1 -0
  85. package/pipeline/skills/shared/external/debugging-instruments/SKILL.md +270 -323
  86. package/pipeline/skills/shared/external/debugging-instruments/evals/evals.json +27 -30
  87. package/pipeline/skills/shared/external/debugging-instruments/references/instruments-guide.md +167 -315
  88. package/pipeline/skills/shared/external/debugging-instruments/references/lldb-patterns.md +140 -193
  89. package/pipeline/skills/shared/external/device-integrity/SKILL.md +230 -353
  90. package/pipeline/skills/shared/external/device-integrity/evals/evals.json +25 -21
  91. package/pipeline/skills/shared/external/device-integrity/references/device-integrity-patterns.md +159 -197
  92. package/pipeline/skills/shared/external/energykit/SKILL.md +225 -392
  93. package/pipeline/skills/shared/external/energykit/evals/evals.json +29 -28
  94. package/pipeline/skills/shared/external/energykit/references/energykit-patterns.md +174 -470
  95. package/pipeline/skills/shared/external/eventkit-calendar/SKILL.md +261 -383
  96. package/pipeline/skills/shared/external/eventkit-calendar/evals/evals.json +25 -22
  97. package/pipeline/skills/shared/external/eventkit-calendar/references/eventkit-patterns.md +165 -268
  98. package/pipeline/skills/shared/external/evidence-github/SKILL.md +2 -0
  99. package/pipeline/skills/shared/external/evidence-registry/SKILL.md +2 -0
  100. package/pipeline/skills/shared/external/gradle-kotlin-dsl/SKILL.md +2 -0
  101. package/pipeline/skills/shared/external/healthkit/SKILL.md +252 -303
  102. package/pipeline/skills/shared/external/healthkit/evals/evals.json +24 -23
  103. package/pipeline/skills/shared/external/healthkit/references/healthkit-patterns.md +369 -523
  104. package/pipeline/skills/shared/external/homekit-matter/SKILL.md +233 -348
  105. package/pipeline/skills/shared/external/homekit-matter/evals/evals.json +27 -22
  106. package/pipeline/skills/shared/external/homekit-matter/references/matter-commissioning.md +199 -305
  107. package/pipeline/skills/shared/external/html-semantic/SKILL.md +1 -0
  108. package/pipeline/skills/shared/external/humanizer/SKILL.md +1 -0
  109. package/pipeline/skills/shared/external/ios-accessibility/SKILL.md +368 -340
  110. package/pipeline/skills/shared/external/ios-accessibility/evals/evals.json +28 -27
  111. package/pipeline/skills/shared/external/ios-accessibility/references/a11y-patterns.md +314 -260
  112. package/pipeline/skills/shared/external/ios-accessibility/references/media-accessibility.md +97 -67
  113. package/pipeline/skills/shared/external/ios-accessibility/references/nutrition-labels.md +165 -101
  114. package/pipeline/skills/shared/external/ios-coding-standard/SKILL.md +1 -0
  115. package/pipeline/skills/shared/external/ios-localization/SKILL.md +258 -371
  116. package/pipeline/skills/shared/external/ios-localization/evals/evals.json +23 -23
  117. package/pipeline/skills/shared/external/ios-localization/references/formatstyle-locale.md +283 -491
  118. package/pipeline/skills/shared/external/ios-localization/references/string-catalogs.md +313 -440
  119. package/pipeline/skills/shared/external/ios-module-structure/SKILL.md +1 -0
  120. package/pipeline/skills/shared/external/ios-networking/SKILL.md +265 -341
  121. package/pipeline/skills/shared/external/ios-networking/evals/evals.json +24 -24
  122. package/pipeline/skills/shared/external/ios-networking/references/background-websocket.md +425 -652
  123. package/pipeline/skills/shared/external/ios-networking/references/file-storage-patterns.md +143 -285
  124. package/pipeline/skills/shared/external/ios-networking/references/lightweight-clients.md +93 -53
  125. package/pipeline/skills/shared/external/ios-networking/references/network-framework.md +231 -456
  126. package/pipeline/skills/shared/external/ios-networking/references/urlsession-patterns.md +517 -784
  127. package/pipeline/skills/shared/external/ios-security/SKILL.md +2 -0
  128. package/pipeline/skills/shared/external/ios-simulator/SKILL.md +265 -393
  129. package/pipeline/skills/shared/external/ios-simulator/evals/evals.json +21 -21
  130. package/pipeline/skills/shared/external/ios-simulator/references/simctl-commands.md +177 -270
  131. package/pipeline/skills/shared/external/live-activities/SKILL.md +318 -360
  132. package/pipeline/skills/shared/external/live-activities/evals/evals.json +21 -21
  133. package/pipeline/skills/shared/external/live-activities/references/activitykit-patterns.md +478 -710
  134. package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +91 -283
  135. package/pipeline/skills/shared/external/localization-reuse-map/reference/format-and-output.md +119 -151
  136. package/pipeline/skills/shared/external/localization-reuse-map/reference/publish-and-snapshot.md +60 -90
  137. package/pipeline/skills/shared/external/localization-reuse-map/reference/sources-and-recipes.md +119 -156
  138. package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-artifact.py +726 -787
  139. package/pipeline/skills/shared/external/localization-reuse-map/scripts/build-spreadsheet.py +253 -288
  140. package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-annotations.py +243 -304
  141. package/pipeline/skills/shared/external/localization-reuse-map/scripts/fetch-legacy-labels.py +88 -104
  142. package/pipeline/skills/shared/external/localization-reuse-map/scripts/publish-confluence.py +181 -235
  143. package/pipeline/skills/shared/external/localization-reuse-map/scripts/render-key-shots.py +198 -263
  144. package/pipeline/skills/shared/external/localization-reuse-map/scripts/render-overlay.py +461 -466
  145. package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-legacy-values.py +145 -151
  146. package/pipeline/skills/shared/external/localization-reuse-map/scripts/resolve-new-values.py +123 -141
  147. package/pipeline/skills/shared/external/localization-reuse-map/scripts/scan-screen-keys.py +146 -157
  148. package/pipeline/skills/shared/external/localization-reuse-map/scripts/snapshot-resources.sh +22 -19
  149. package/pipeline/skills/shared/external/localization-reuse-map/scripts/verify-map.py +156 -140
  150. package/pipeline/skills/shared/external/mapkit-location/SKILL.md +295 -267
  151. package/pipeline/skills/shared/external/mapkit-location/evals/evals.json +28 -24
  152. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-corelocation-patterns.md +378 -532
  153. package/pipeline/skills/shared/external/mapkit-location/references/mapkit-patterns.md +397 -499
  154. package/pipeline/skills/shared/external/metrickit-diagnostics/SKILL.md +165 -348
  155. package/pipeline/skills/shared/external/metrickit-diagnostics/evals/evals.json +26 -23
  156. package/pipeline/skills/shared/external/metrickit-diagnostics/references/metrickit-patterns.md +123 -130
  157. package/pipeline/skills/shared/external/musickit-audio/SKILL.md +189 -315
  158. package/pipeline/skills/shared/external/musickit-audio/evals/evals.json +22 -21
  159. package/pipeline/skills/shared/external/musickit-audio/references/musickit-patterns.md +181 -270
  160. package/pipeline/skills/shared/external/natural-language/SKILL.md +188 -340
  161. package/pipeline/skills/shared/external/natural-language/evals/evals.json +21 -21
  162. package/pipeline/skills/shared/external/natural-language/references/translation-patterns.md +171 -225
  163. package/pipeline/skills/shared/external/nextjs-app-router/SKILL.md +1 -0
  164. package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +258 -392
  165. package/pipeline/skills/shared/external/passkit-wallet/evals/evals.json +30 -29
  166. package/pipeline/skills/shared/external/passkit-wallet/references/wallet-passes.md +164 -231
  167. package/pipeline/skills/shared/external/pdfkit/SKILL.md +312 -344
  168. package/pipeline/skills/shared/external/pdfkit/evals/evals.json +19 -19
  169. package/pipeline/skills/shared/external/pdfkit/references/pdfkit-patterns.md +413 -624
  170. package/pipeline/skills/shared/external/pencilkit-drawing/SKILL.md +242 -358
  171. package/pipeline/skills/shared/external/pencilkit-drawing/evals/evals.json +25 -21
  172. package/pipeline/skills/shared/external/pencilkit-drawing/references/pencilkit-patterns.md +161 -226
  173. package/pipeline/skills/shared/external/permissionkit/SKILL.md +282 -400
  174. package/pipeline/skills/shared/external/permissionkit/evals/evals.json +27 -30
  175. package/pipeline/skills/shared/external/permissionkit/references/permissionkit-patterns.md +237 -350
  176. package/pipeline/skills/shared/external/photos-camera-media/SKILL.md +276 -325
  177. package/pipeline/skills/shared/external/photos-camera-media/references/av-playback.md +299 -545
  178. package/pipeline/skills/shared/external/photos-camera-media/references/camera-capture.md +344 -588
  179. package/pipeline/skills/shared/external/photos-camera-media/references/image-loading-caching.md +316 -660
  180. package/pipeline/skills/shared/external/photos-camera-media/references/photokit-patterns.md +270 -416
  181. package/pipeline/skills/shared/external/play-store-review/SKILL.md +2 -0
  182. package/pipeline/skills/shared/external/push-notifications/SKILL.md +312 -340
  183. package/pipeline/skills/shared/external/push-notifications/evals/evals.json +27 -26
  184. package/pipeline/skills/shared/external/push-notifications/references/notification-patterns.md +328 -485
  185. package/pipeline/skills/shared/external/push-notifications/references/rich-notifications.md +327 -560
  186. package/pipeline/skills/shared/external/python-patterns/SKILL.md +1 -0
  187. package/pipeline/skills/shared/external/react-best-practices/SKILL.md +1 -0
  188. package/pipeline/skills/shared/external/realitykit-ar/SKILL.md +218 -410
  189. package/pipeline/skills/shared/external/realitykit-ar/evals/evals.json +24 -27
  190. package/pipeline/skills/shared/external/realitykit-ar/references/realitykit-patterns.md +221 -348
  191. package/pipeline/skills/shared/external/rest-api-design/SKILL.md +1 -0
  192. package/pipeline/skills/shared/external/retrofit-networking/SKILL.md +2 -0
  193. package/pipeline/skills/shared/external/room-database/SKILL.md +2 -0
  194. package/pipeline/skills/shared/external/search-first/SKILL.md +1 -0
  195. package/pipeline/skills/shared/external/shareplay-activities/SKILL.md +222 -393
  196. package/pipeline/skills/shared/external/shareplay-activities/evals/evals.json +23 -24
  197. package/pipeline/skills/shared/external/shareplay-activities/references/shareplay-patterns.md +280 -420
  198. package/pipeline/skills/shared/external/signal-community/SKILL.md +2 -0
  199. package/pipeline/skills/shared/external/skill-creator/SKILL.md +80 -41
  200. package/pipeline/skills/shared/external/skill-creator/audit.md +63 -59
  201. package/pipeline/skills/shared/external/skill-creator/checklist.md +28 -20
  202. package/pipeline/skills/shared/external/skill-creator/examples.md +40 -40
  203. package/pipeline/skills/shared/external/skill-creator/label-check.md +48 -36
  204. package/pipeline/skills/shared/external/skill-creator/scripts/audit-panel.js +91 -100
  205. package/pipeline/skills/shared/external/skill-creator/template.md +51 -39
  206. package/pipeline/skills/shared/external/speech-recognition/SKILL.md +217 -421
  207. package/pipeline/skills/shared/external/speech-recognition/evals/evals.json +23 -26
  208. package/pipeline/skills/shared/external/speech-recognition/references/speechanalyzer-patterns.md +133 -125
  209. package/pipeline/skills/shared/external/storekit/SKILL.md +228 -204
  210. package/pipeline/skills/shared/external/storekit/evals/evals.json +27 -24
  211. package/pipeline/skills/shared/external/storekit/references/app-review-guidelines.md +98 -109
  212. package/pipeline/skills/shared/external/storekit/references/core-patterns.md +298 -242
  213. package/pipeline/skills/shared/external/storekit/references/storekit-advanced.md +356 -649
  214. package/pipeline/skills/shared/external/swift-api-design-guidelines/SKILL.md +274 -399
  215. package/pipeline/skills/shared/external/swift-api-design-guidelines/evals/evals.json +22 -24
  216. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/argument-labels-and-parameters.md +107 -108
  217. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/conventions-and-special-rules.md +93 -165
  218. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/naming-and-clarity.md +99 -137
  219. package/pipeline/skills/shared/external/swift-api-design-guidelines/references/side-effects-and-mutating-pairs.md +77 -120
  220. package/pipeline/skills/shared/external/swift-architecture/SKILL.md +334 -350
  221. package/pipeline/skills/shared/external/swift-architecture/evals/evals.json +22 -22
  222. package/pipeline/skills/shared/external/swift-charts/SKILL.md +208 -394
  223. package/pipeline/skills/shared/external/swift-charts/evals/evals.json +27 -30
  224. package/pipeline/skills/shared/external/swift-charts/references/charts-patterns.md +351 -762
  225. package/pipeline/skills/shared/external/swift-codable/SKILL.md +339 -343
  226. package/pipeline/skills/shared/external/swift-codable/evals/evals.json +20 -20
  227. package/pipeline/skills/shared/external/swift-concurrency/SKILL.md +303 -351
  228. package/pipeline/skills/shared/external/swift-concurrency/evals/evals.json +27 -24
  229. package/pipeline/skills/shared/external/swift-concurrency/references/approachable-concurrency.md +65 -80
  230. package/pipeline/skills/shared/external/swift-concurrency/references/async-algorithms.md +48 -84
  231. package/pipeline/skills/shared/external/swift-concurrency/references/bridging-interop.md +134 -79
  232. package/pipeline/skills/shared/external/swift-concurrency/references/concurrency-patterns.md +145 -167
  233. package/pipeline/skills/shared/external/swift-concurrency/references/diagnostics.md +62 -50
  234. package/pipeline/skills/shared/external/swift-concurrency/references/swiftui-concurrency.md +92 -121
  235. package/pipeline/skills/shared/external/swift-concurrency/references/synchronization-primitives.md +177 -241
  236. package/pipeline/skills/shared/external/swift-formatstyle/SKILL.md +258 -234
  237. package/pipeline/skills/shared/external/swift-language/SKILL.md +342 -382
  238. package/pipeline/skills/shared/external/swift-language/evals/evals.json +24 -27
  239. package/pipeline/skills/shared/external/swift-language/references/swift-attributes-interop.md +79 -56
  240. package/pipeline/skills/shared/external/swift-language/references/swift-patterns-extended.md +297 -340
  241. package/pipeline/skills/shared/external/swift-security/SKILL.md +180 -161
  242. package/pipeline/skills/shared/external/swift-security/evals/evals.json +25 -25
  243. package/pipeline/skills/shared/external/swift-security/references/biometric-authentication.md +314 -469
  244. package/pipeline/skills/shared/external/swift-security/references/certificate-trust.md +408 -476
  245. package/pipeline/skills/shared/external/swift-security/references/common-anti-patterns.md +260 -530
  246. package/pipeline/skills/shared/external/swift-security/references/compliance-owasp-mapping.md +270 -477
  247. package/pipeline/skills/shared/external/swift-security/references/credential-storage-patterns.md +573 -571
  248. package/pipeline/skills/shared/external/swift-security/references/cryptokit-public-key.md +370 -441
  249. package/pipeline/skills/shared/external/swift-security/references/cryptokit-symmetric.md +332 -433
  250. package/pipeline/skills/shared/external/swift-security/references/keychain-access-control.md +346 -468
  251. package/pipeline/skills/shared/external/swift-security/references/keychain-fundamentals.md +352 -472
  252. package/pipeline/skills/shared/external/swift-security/references/keychain-item-classes.md +431 -432
  253. package/pipeline/skills/shared/external/swift-security/references/keychain-sharing.md +328 -425
  254. package/pipeline/skills/shared/external/swift-security/references/migration-legacy-stores.md +341 -579
  255. package/pipeline/skills/shared/external/swift-security/references/secure-enclave.md +396 -457
  256. package/pipeline/skills/shared/external/swift-security/references/testing-security-code.md +354 -614
  257. package/pipeline/skills/shared/external/swift-testing/SKILL.md +188 -175
  258. package/pipeline/skills/shared/external/swift-testing/evals/evals.json +26 -24
  259. package/pipeline/skills/shared/external/swift-testing/references/testing-advanced.md +80 -84
  260. package/pipeline/skills/shared/external/swift-testing/references/testing-patterns.md +317 -433
  261. package/pipeline/skills/shared/external/swiftdata/SKILL.md +392 -256
  262. package/pipeline/skills/shared/external/swiftdata/evals/evals.json +24 -24
  263. package/pipeline/skills/shared/external/swiftdata/references/core-data-coexistence.md +206 -402
  264. package/pipeline/skills/shared/external/swiftdata/references/indexing.md +59 -52
  265. package/pipeline/skills/shared/external/swiftdata/references/predicate-pitfalls.md +57 -33
  266. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-advanced.md +354 -747
  267. package/pipeline/skills/shared/external/swiftdata/references/swiftdata-queries.md +300 -508
  268. package/pipeline/skills/shared/external/swiftlint/SKILL.md +175 -226
  269. package/pipeline/skills/shared/external/swiftlint/references/adoption-and-configuration.md +141 -208
  270. package/pipeline/skills/shared/external/swiftlint/references/custom-rules-and-analyze.md +100 -109
  271. package/pipeline/skills/shared/external/swiftlint/references/plugins-run-scripts-and-integrations.md +159 -179
  272. package/pipeline/skills/shared/external/swiftlint/references/rule-reference.md +383 -18
  273. package/pipeline/skills/shared/external/swiftlint/references/rules-suppressions-and-baselines.md +143 -229
  274. package/pipeline/skills/shared/external/swiftui-animation/SKILL.md +283 -366
  275. package/pipeline/skills/shared/external/swiftui-animation/references/animation-advanced.md +396 -608
  276. package/pipeline/skills/shared/external/swiftui-animation/references/core-animation-bridge.md +336 -385
  277. package/pipeline/skills/shared/external/swiftui-gestures/SKILL.md +239 -349
  278. package/pipeline/skills/shared/external/swiftui-gestures/references/gesture-patterns.md +228 -310
  279. package/pipeline/skills/shared/external/swiftui-layout-components/SKILL.md +260 -249
  280. package/pipeline/skills/shared/external/swiftui-layout-components/references/form.md +92 -74
  281. package/pipeline/skills/shared/external/swiftui-layout-components/references/grids.md +112 -177
  282. package/pipeline/skills/shared/external/swiftui-layout-components/references/list.md +61 -64
  283. package/pipeline/skills/shared/external/swiftui-layout-components/references/scrollview.md +94 -134
  284. package/pipeline/skills/shared/external/swiftui-liquid-glass/SKILL.md +193 -225
  285. package/pipeline/skills/shared/external/swiftui-liquid-glass/references/liquid-glass.md +173 -327
  286. package/pipeline/skills/shared/external/swiftui-navigation/SKILL.md +193 -168
  287. package/pipeline/skills/shared/external/swiftui-navigation/references/deeplinks.md +127 -150
  288. package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +132 -133
  289. package/pipeline/skills/shared/external/swiftui-navigation/references/sheets.md +152 -117
  290. package/pipeline/skills/shared/external/swiftui-navigation/references/tabview.md +106 -140
  291. package/pipeline/skills/shared/external/swiftui-patterns/SKILL.md +316 -252
  292. package/pipeline/skills/shared/external/swiftui-patterns/references/architecture-patterns.md +341 -332
  293. package/pipeline/skills/shared/external/swiftui-patterns/references/deprecated-migration.md +547 -854
  294. package/pipeline/skills/shared/external/swiftui-patterns/references/design-polish.md +485 -537
  295. package/pipeline/skills/shared/external/swiftui-patterns/references/platform-and-sharing.md +417 -499
  296. package/pipeline/skills/shared/external/swiftui-performance/SKILL.md +213 -376
  297. package/pipeline/skills/shared/external/swiftui-performance/references/demystify-swiftui-performance-wwdc23.md +86 -175
  298. package/pipeline/skills/shared/external/swiftui-performance/references/optimizing-swiftui-performance-instruments.md +89 -195
  299. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-hangs-in-your-app.md +95 -182
  300. package/pipeline/skills/shared/external/swiftui-performance/references/understanding-improving-swiftui-performance.md +71 -149
  301. package/pipeline/skills/shared/external/swiftui-performance/references/wwdc-session-sources.md +21 -27
  302. package/pipeline/skills/shared/external/swiftui-uikit-interop/SKILL.md +303 -295
  303. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/hosting-migration.md +204 -387
  304. package/pipeline/skills/shared/external/swiftui-uikit-interop/references/representable-recipes.md +469 -683
  305. package/pipeline/skills/shared/external/swiftui-webkit/SKILL.md +140 -186
  306. package/pipeline/skills/shared/external/swiftui-webkit/references/loading-and-observation.md +75 -86
  307. package/pipeline/skills/shared/external/swiftui-webkit/references/local-content-and-custom-schemes.md +63 -60
  308. package/pipeline/skills/shared/external/swiftui-webkit/references/migration-and-fallbacks.md +69 -137
  309. package/pipeline/skills/shared/external/swiftui-webkit/references/navigation-and-javascript.md +95 -67
  310. package/pipeline/skills/shared/external/tailwind-css/SKILL.md +1 -0
  311. package/pipeline/skills/shared/external/testing-backend/SKILL.md +1 -0
  312. package/pipeline/skills/shared/external/tipkit/SKILL.md +220 -335
  313. package/pipeline/skills/shared/external/tipkit/references/tipkit-patterns.md +356 -494
  314. package/pipeline/skills/shared/external/typescript-patterns/SKILL.md +1 -0
  315. package/pipeline/skills/shared/external/vision-framework/SKILL.md +260 -375
  316. package/pipeline/skills/shared/external/vision-framework/references/vision-requests.md +393 -515
  317. package/pipeline/skills/shared/external/vision-framework/references/visionkit-scanner.md +363 -539
  318. package/pipeline/skills/shared/external/vue-composition/SKILL.md +1 -0
  319. package/pipeline/skills/shared/external/weatherkit/SKILL.md +152 -310
  320. package/pipeline/skills/shared/external/weatherkit/references/weatherkit-patterns.md +288 -407
  321. package/pipeline/skills/shared/external/web-accessibility/SKILL.md +1 -0
  322. package/pipeline/skills/shared/external/web-performance/SKILL.md +1 -0
  323. package/pipeline/skills/shared/external/web-testing/SKILL.md +1 -0
  324. package/pipeline/skills/shared/external/widgetkit/SKILL.md +216 -288
  325. package/pipeline/skills/shared/external/widgetkit/references/widgetkit-advanced.md +414 -719
  326. package/pipeline/skills/shared/external/NOTICE-swift-ios-skills.md +0 -39
@@ -1,431 +1,324 @@
1
- # Core ML Model Conversion Reference
1
+ # Core ML conversion with coremltools
2
2
 
3
- Complete reference for converting models to Core ML format using coremltools.
4
- Use this reference for Python-side export, conversion, deployment-target,
5
- shape, and compression decisions. For Swift app runtime wiring, hand off to the
6
- sibling `coreml` skill; in conversion reviews, describe runtime availability in
7
- prose unless the user explicitly asks for Swift integration code.
3
+ This file is about the Python side: exporting from the training framework,
4
+ converting, choosing a deployment target and input shapes, and preparing for
5
+ compression. Swift runtime wiring belongs to the `coreml` skill. In a
6
+ conversion review, describe what the app needs at runtime in prose unless the
7
+ user asked for Swift code.
8
8
 
9
9
  ## Contents
10
10
 
11
- - [coremltools Installation](#coremltools-installation)
12
- - [Architecture Overview](#architecture-overview)
13
- - [Model Formats](#model-formats)
14
- - [Unified Conversion API](#unified-conversion-api)
15
- - [Converting from PyTorch](#converting-from-pytorch)
16
- - [Converting from TensorFlow](#converting-from-tensorflow)
17
- - [Converting from scikit-learn](#converting-from-scikit-learn)
18
- - [Converting from XGBoost](#converting-from-xgboost)
19
- - [ONNX Conversion (Deprecated)](#onnx-conversion-deprecated)
20
- - [Input and Output Types](#input-and-output-types)
21
- - [Flexible Input Shapes](#flexible-input-shapes)
22
- - [Deployment Targets](#deployment-targets)
23
- - [Compute Precision](#compute-precision)
24
- - [Compute Units](#compute-units)
25
- - [Stateful Models (iOS 18+)](#stateful-models-ios-18)
26
- - [Multifunction Models (iOS 18+)](#multifunction-models-ios-18)
27
- - [Model Utilities](#model-utilities)
28
- - [Graph Pass Control](#graph-pass-control)
29
- - [Custom Composite Operators](#custom-composite-operators)
30
- - [Common Mistakes to Avoid](#common-mistakes-to-avoid)
31
-
32
- ## coremltools Installation
11
+ - [Installing coremltools](#installing-coremltools)
12
+ - [Where Core ML sits](#where-core-ml-sits)
13
+ - [ML program versus neural network](#ml-program-versus-neural-network)
14
+ - [ct.convert parameters](#ctconvert-parameters)
15
+ - [From PyTorch](#from-pytorch)
16
+ - [From TensorFlow, scikit-learn and XGBoost](#from-tensorflow-scikit-learn-and-xgboost)
17
+ - [ONNX](#onnx)
18
+ - [Describing inputs and outputs](#describing-inputs-and-outputs)
19
+ - [Flexible shapes](#flexible-shapes)
20
+ - [Deployment targets](#deployment-targets)
21
+ - [Float16 or Float32](#float16-or-float32)
22
+ - [Which processors to allow](#which-processors-to-allow)
23
+ - [Keeping state between predictions](#keeping-state-between-predictions)
24
+ - [Several functions in one package](#several-functions-in-one-package)
25
+ - [Utilities](#utilities)
26
+ - [Controlling graph passes](#controlling-graph-passes)
27
+ - [Unsupported PyTorch ops](#unsupported-pytorch-ops)
28
+ - [Conversion mistakes](#conversion-mistakes)
29
+
30
+ ## Installing coremltools
31
+
32
+ Install into a fresh virtual environment and check the published wheels against
33
+ your Python version and the version of the source framework:
33
34
 
34
35
  ```bash
36
+ python3 -m venv .venv && source .venv/bin/activate
35
37
  pip install coremltools
36
38
  ```
37
39
 
38
- Use a fresh virtual environment and verify the wheel matrix for your Python and
39
- source-framework versions. The 9.0 release publishes wheels through CPython
40
- 3.13 and adds iOS 26 / macOS 26 deployment targets.
40
+ coremltools 9.0 has wheels up to CPython 3.13 and adds the iOS 26 and macOS 26
41
+ deployment targets.
41
42
 
42
- ## Architecture Overview
43
+ ## Where Core ML sits
43
44
 
44
- ```text
45
- Your App (SwiftUI / UIKit)
46
- |-- Vision, Natural Language, SoundAnalysis, Foundation Models
47
- |-- Core ML (model loading, prediction, compilation)
48
- |-- Metal Performance Shaders Graph (GPU) / Accelerate (CPU) / Neural Engine (ANE)
49
- ```
50
-
51
- ## Model Formats
52
-
53
- | Format | Extension | Model Type | When to Use |
54
- |---|---|---|---|
55
- | `.mlpackage` | Directory | mlprogram | All new models (iOS 15+) |
56
- | `.mlmodel` | Single file | neuralnetwork | Legacy only (iOS 11-14) |
57
- | `.mlmodelc` | Compiled | Either | Pre-compiled for faster loading |
58
-
59
- Always use mlprogram (.mlpackage) for new work. Neural network format is frozen
60
- and receives no new features.
45
+ Higher-level frameworks (SoundAnalysis, Natural Language, Vision and
46
+ Foundation Models) are built on Core ML. Core ML in turn runs each operation on
47
+ the CPU through Accelerate, on the GPU through MPS Graph, or on the Neural
48
+ Engine.
61
49
 
62
- ### mlprogram vs neuralnetwork
50
+ ## ML program versus neural network
63
51
 
64
- | Aspect | neuralnetwork | mlprogram |
52
+ | Aspect | Neural network (`.mlmodel`) | ML program (`.mlpackage`) |
65
53
  |---|---|---|
66
- | GPU precision | Float16 only | Float16 and Float32 |
67
- | Optimization APIs | Limited | Full (quantize, palettize, prune) |
68
- | Stateful models | No | Yes (iOS 18+) |
69
- | Multifunction models | No | Yes (iOS 18+) |
70
- | On-device training | Supported | Not supported |
71
- | Weight storage | Embedded in protobuf | Separated (memory-efficient) |
54
+ | Status | Frozen, no new features | Current format |
55
+ | GPU precision | Float16 only | Float16 or Float32 |
56
+ | Compression APIs | Limited | Quantize, palettize and prune |
57
+ | Where weights live | Inside the protobuf | Separate files, lighter on memory |
58
+ | Training on the device | Yes | No |
59
+ | State and multiple functions | No | Yes, from iOS 18 |
72
60
 
73
- ## Unified Conversion API
61
+ ## ct.convert parameters
74
62
 
75
- ```python
76
- import coremltools as ct
77
-
78
- mlmodel = ct.convert(
79
- model, # PyTorch traced/exported model or TF model
80
- source='auto', # 'auto', 'pytorch', 'tensorflow'
81
- inputs=None, # list of TensorType/ImageType
82
- outputs=None, # list of TensorType/ImageType
83
- minimum_deployment_target=None, # ct.target.iOS15 through ct.target.iOS26
84
- convert_to='mlprogram', # 'mlprogram' (default) or 'neuralnetwork'
85
- compute_precision=None, # ct.precision.FLOAT16 (default), FLOAT32
86
- compute_units=ct.ComputeUnit.ALL,
87
- skip_model_load=False, # True when converting on Linux
88
- states=None, # list of StateType for stateful models
89
- pass_pipeline=None, # PassPipeline for graph optimization
90
- )
91
- mlmodel.save("Model.mlpackage")
92
- ```
63
+ | Parameter | Values |
64
+ |---|---|
65
+ | `source` | `"auto"`, `"pytorch"`, `"tensorflow"` |
66
+ | `inputs`, `outputs` | Lists of `ct.TensorType` or `ct.ImageType` |
67
+ | `convert_to` | `"mlprogram"` (default) or `"neuralnetwork"` |
68
+ | `minimum_deployment_target` | any `ct.target` value from iOS15 up to iOS26 |
69
+ | `compute_precision` | `ct.precision.FLOAT16` (default) or `FLOAT32` |
70
+ | `compute_units` | `ct.ComputeUnit.ALL` and the other unit sets |
71
+ | `skip_model_load` | `True` when converting on Linux, where the model cannot be loaded |
72
+ | `states` | List of `ct.StateType` |
73
+ | `pass_pipeline` | A `ct.PassPipeline` |
93
74
 
94
- ## Converting from PyTorch
75
+ ## From PyTorch
95
76
 
96
- ### torch.jit.trace (Recommended)
77
+ Tracing is the recommended route:
97
78
 
98
79
  ```python
99
80
  import torch
100
81
  import coremltools as ct
101
82
 
102
- model = MyModel()
103
- model.eval() # CRITICAL: always call eval() before tracing
104
-
105
- example_input = torch.rand(1, 3, 224, 224)
106
- traced_model = torch.jit.trace(model, example_input)
83
+ model = load_keyword_spotter()
84
+ model.eval()
85
+ clip = torch.randn(1, 1, 16000)
86
+ traced = torch.jit.trace(model, clip)
107
87
 
108
- mlmodel = ct.convert(
109
- traced_model,
110
- inputs=[ct.TensorType(shape=example_input.shape, name="input")],
88
+ spotter = ct.convert(
89
+ traced,
111
90
  minimum_deployment_target=ct.target.iOS16,
91
+ inputs=[ct.TensorType(name="audio", shape=clip.shape)],
112
92
  )
113
- mlmodel.save("MyModel.mlpackage")
93
+ spotter.save("KeywordSpotter.mlpackage")
114
94
  ```
115
95
 
116
- ### torch.export (Beta)
96
+ `torch.export` is supported in beta. Dynamic dimensions are declared when you
97
+ export and become `RangeDim` automatically:
117
98
 
118
99
  ```python
119
- import torch
120
- import coremltools as ct
121
-
122
- model.eval()
123
- example_inputs = (torch.rand(1, 3, 224, 224),)
100
+ from torch.export import Dim, export
124
101
 
125
- # Dynamic shapes defined at export time
126
- batch_dim = torch.export.Dim(name="batch", min=1, max=128)
127
- exported = torch.export.export(model, example_inputs,
128
- dynamic_shapes={"x": {0: batch_dim}})
129
-
130
- mlmodel = ct.convert(exported)
102
+ length = Dim(name="length", min=4000, max=48000)
103
+ exported = export(model, (clip,), dynamic_shapes={"x": {2: length}})
104
+ spotter = ct.convert(exported, minimum_deployment_target=ct.target.iOS17)
131
105
  ```
132
106
 
133
- Key difference: `torch.export` defines dynamic shapes upfront (auto-converted
134
- to RangeDim). `torch.jit.trace` defines shapes in `ct.convert()` via
135
- RangeDim/EnumeratedShapes.
136
-
137
- ## Converting from TensorFlow
138
-
139
- ```python
140
- import tensorflow as tf
141
- import coremltools as ct
142
-
143
- # Keras model
144
- tf_model = tf.keras.applications.MobileNetV2()
145
- mlmodel = ct.convert(tf_model)
107
+ With `export`, shapes are fixed up front; with `trace`, you express flexibility
108
+ inside `ct.convert()` using `RangeDim` or `EnumeratedShapes`.
146
109
 
147
- # SavedModel directory
148
- mlmodel = ct.convert("/path/to/saved_model/")
110
+ ## From TensorFlow, scikit-learn and XGBoost
149
111
 
150
- # HDF5 file
151
- mlmodel = ct.convert("/path/to/model.h5")
112
+ TensorFlow: `ct.convert` accepts a Keras model object, a SavedModel directory,
113
+ an `.h5` file, or a frozen `.pb` graph (the last needs explicit `inputs`).
152
114
 
153
- # Frozen graph (.pb)
154
- mlmodel = ct.convert("frozen_graph.pb",
155
- inputs=[ct.TensorType(shape=(1, 224, 224, 3))])
115
+ ```python
116
+ keras_net = tf.keras.models.load_model("leaf_classifier.keras")
117
+ leaf = ct.convert(keras_net, minimum_deployment_target=ct.target.iOS17)
156
118
  ```
157
119
 
158
- ## Converting from scikit-learn
120
+ scikit-learn converts to the older `.mlmodel` format:
159
121
 
160
122
  ```python
161
- from sklearn.linear_model import LinearRegression
162
- import coremltools as ct
163
-
164
- model = LinearRegression()
165
- model.fit(X_train, y_train)
166
-
167
- mlmodel = ct.converters.sklearn.convert(
168
- model, ["feature1", "feature2"], "prediction"
169
- )
170
- mlmodel.save("Regressor.mlmodel")
123
+ price = ct.converters.sklearn.convert(forest, ["rooms", "area", "age"], "price")
124
+ price.save("HousePrice.mlmodel")
171
125
  ```
172
126
 
173
- ## Converting from XGBoost
127
+ XGBoost:
174
128
 
175
129
  ```python
176
- import xgboost
177
- import coremltools as ct
178
-
179
- model = xgboost.XGBClassifier()
180
- model.fit(X_train, y_train)
181
- mlmodel = ct.converters.xgboost.convert(model)
130
+ churn = ct.converters.xgboost.convert(booster)
182
131
  ```
183
132
 
184
- ## ONNX Conversion (Deprecated)
185
-
186
- ONNX direct conversion is deprecated since coremltools 6. Convert from the
187
- original framework (PyTorch or TensorFlow) instead. If you only have an ONNX
188
- file, convert back to PyTorch first using `onnx2torch`.
133
+ ## ONNX
189
134
 
190
- ## Input and Output Types
135
+ coremltools stopped supporting direct ONNX input in version 6, so go back to
136
+ the framework the model was trained in. If ONNX is all you have, convert it back to PyTorch
137
+ with `onnx2torch` and trace that.
191
138
 
192
- ### TensorType
193
-
194
- ```python
195
- ct.TensorType(
196
- name="input", # must match model input name
197
- shape=(1, 3, 224, 224), # tuple of int, RangeDim, or EnumeratedShapes
198
- dtype=np.float32, # np.float32, np.float16, np.int32, np.int8 (iOS26+)
199
- default_value=None, # np.ndarray: makes input optional at runtime
200
- )
201
- ```
139
+ ## Describing inputs and outputs
202
140
 
203
- ### ImageType
141
+ `ct.TensorType(name=, shape=, dtype=, default_value=)`:
204
142
 
205
- ```python
206
- ct.ImageType(
207
- name="image",
208
- shape=(1, 3, 224, 224),
209
- scale=1/255.0, # per-channel scaling
210
- bias=[-0.485/0.229, -0.456/0.224, -0.406/0.225], # ImageNet normalization
211
- color_layout=ct.colorlayout.RGB, # RGB, BGR, GRAYSCALE, GRAYSCALE_FLOAT16
212
- channel_first=True, # True for PyTorch (NCHW), False for TF (NHWC)
213
- )
214
- ```
143
+ - `name` must match the model's input name.
144
+ - `shape` takes fixed integers, `RangeDim` or `EnumeratedShapes`.
145
+ - `dtype`: `np.int32`, `np.float16` or `np.float32`, plus `np.int8` from iOS 26.
146
+ - `default_value` (a NumPy array) makes the input optional.
215
147
 
216
- ### StateType (iOS 18+)
148
+ `ct.ImageType(name=, shape=, scale=, bias=, color_layout=, channel_first=)`:
217
149
 
218
150
  ```python
219
- ct.StateType(
220
- wrapped_type=ct.TensorType(shape=(1, 8, 128, 64), dtype=np.float16),
221
- name="kv_cache",
151
+ photo = ct.ImageType(
152
+ name="photo",
153
+ shape=(1, 3, 320, 320),
154
+ scale=1 / 127.5,
155
+ bias=[-1.0, -1.0, -1.0], # maps pixels to the range -1...1
156
+ color_layout=ct.colorlayout.RGB,
157
+ channel_first=True,
222
158
  )
223
159
  ```
224
160
 
225
- ## Flexible Input Shapes
161
+ - Colour layouts: `GRAYSCALE`, `GRAYSCALE_FLOAT16`, `RGB` or `BGR`.
162
+ - PyTorch models are NCHW, so pass `channel_first=True`; TensorFlow's NHWC
163
+ needs `False`.
226
164
 
227
- ### Fixed Shape
228
-
229
- ```python
230
- inputs=[ct.TensorType(shape=(1, 3, 224, 224))]
231
- ```
165
+ `ct.StateType(wrapped_type=ct.TensorType(...), name=)` (iOS 18+) declares
166
+ state, for example a float16 `kv_cache` tensor.
232
167
 
233
- ### RangeDim (Variable Dimensions)
168
+ ## Flexible shapes
234
169
 
235
170
  ```python
236
- inputs=[ct.TensorType(shape=(
237
- 1, 3,
238
- ct.RangeDim(lower_bound=128, upper_bound=512, default=224),
239
- ct.RangeDim(lower_bound=128, upper_bound=512, default=224),
240
- ))]
241
- ```
171
+ fixed = ct.TensorType(name="x", shape=(1, 3, 512, 512))
242
172
 
243
- ### EnumeratedShapes (Best Performance)
173
+ side = ct.RangeDim(lower_bound=256, upper_bound=1024, default=512)
174
+ ranged = ct.TensorType(name="x", shape=(1, 3, side, side))
244
175
 
245
- ```python
246
- inputs=[ct.TensorType(shape=ct.EnumeratedShapes(
247
- shapes=[(1,3,224,224), (1,3,384,384), (1,3,512,512)],
248
- default=(1,3,224,224),
249
- ))]
176
+ sizes = [(1, 3, s, s) for s in (256, 512, 1024)]
177
+ listed = ct.TensorType(name="x", shape=ct.EnumeratedShapes(shapes=sizes, default=sizes[1]))
250
178
  ```
251
179
 
252
- **Rule:** Prefer EnumeratedShapes over RangeDim when you have a known set of
253
- sizes. EnumeratedShapes allows the Neural Engine to optimize for each shape at
254
- compilation time. RangeDim only optimizes for the default shape.
255
-
256
- **Rule:** Before iOS 18, only ONE input can use EnumeratedShapes. Starting
257
- iOS 18, multiple inputs can use EnumeratedShapes.
180
+ When the real sizes are known, list them with `EnumeratedShapes`: the Neural
181
+ Engine compiles an optimised plan for each listed shape, while with `RangeDim`
182
+ only the default shape gets that treatment. Until iOS 18,
183
+ `EnumeratedShapes` was limited to a single input; newer targets allow it on
184
+ several.
258
185
 
259
- ## Deployment Targets
186
+ ## Deployment targets
260
187
 
261
- | Target | Model Type | Key Feature Unlocks |
188
+ | iOS target | Matching macOS target | What it unlocks |
262
189
  |---|---|---|
263
- | `ct.target.iOS13` | neuralnetwork | Basic neural network |
264
- | `ct.target.iOS15` | mlprogram | FP16 precision, typed tensors |
265
- | `ct.target.iOS16` | mlprogram | Palettized weights, sparse weights |
266
- | `ct.target.iOS17` | mlprogram | W8A8 activation quantization (A17 Pro+) |
267
- | `ct.target.iOS18` | mlprogram | Stateful models, multifunction, per-block quantization |
268
- | `ct.target.iOS26` | mlprogram | INT8 I/O dtype, state read/write |
190
+ | `ct.target.iOS13` | `ct.target.macOS10_15` | Neural network models only |
191
+ | `ct.target.iOS15` | `ct.target.macOS12` | ML program, FP16, typed tensors |
192
+ | `ct.target.iOS16` | `ct.target.macOS13` | Palettized and sparse weights |
193
+ | `ct.target.iOS17` | `ct.target.macOS14` | W8A8 activation quantization (A17 Pro and later) |
194
+ | `ct.target.iOS18` | `ct.target.macOS15` | Stateful and multifunction models, block-wise quantization |
195
+ | `ct.target.iOS26` | `ct.target.macOS26` | INT8 input and output types, state read and write |
269
196
 
270
- Corresponding macOS targets: `macOS10_15`, `macOS12`, `macOS13`, `macOS14`,
271
- `macOS15`, `macOS26`.
197
+ ## Float16 or Float32
272
198
 
273
- ## Compute Precision
274
-
275
- | Value | Description |
276
- |---|---|
277
- | `ct.precision.FLOAT16` | Default for mlprogram. Smaller, faster. |
278
- | `ct.precision.FLOAT32` | Higher accuracy. Use when FP16 causes issues. |
279
-
280
- ### Mixed Precision (Selective Per-Op)
199
+ ML programs default to `ct.precision.FLOAT16`, which is smaller and faster. Use
200
+ `FLOAT32` only when half precision measurably hurts accuracy. To keep just the
201
+ sensitive ops in FP32:
281
202
 
282
203
  ```python
283
- def keep_layernorm_fp32(op):
284
- if op.op_type == "layer_norm":
285
- return False # keep in FP32
286
- return True # convert to FP16
287
-
288
- mlmodel = ct.convert(model,
289
- compute_precision=ct.transform.FP16ComputePrecision(
290
- op_selector=keep_layernorm_fp32
291
- ))
204
+ def keep_norms_fp32(op):
205
+ return op.op_type != "layer_norm"
206
+
207
+ policy = ct.transform.FP16ComputePrecision(op_selector=keep_norms_fp32)
208
+ mixed = ct.convert(
209
+ traced,
210
+ compute_precision=policy,
211
+ minimum_deployment_target=ct.target.iOS17,
212
+ inputs=[ct.TensorType(name="tokens", shape=(1, 128))],
213
+ )
292
214
  ```
293
215
 
294
- ## Compute Units
216
+ The selector returns `False` for an op that should stay in FP32.
295
217
 
296
- | Value | Description | When to Use |
297
- |---|---|---|
298
- | `.all` | CPU + GPU + Neural Engine | Default, recommended |
299
- | `.cpuOnly` | CPU exclusively | Debugging, FP32 accuracy |
300
- | `.cpuAndGPU` | CPU and GPU, no ANE | When ANE causes issues |
301
- | `.cpuAndNeuralEngine` | CPU and ANE, no GPU | Energy efficiency (macOS 13+) |
218
+ ## Which processors to allow
302
219
 
303
- ## Stateful Models (iOS 18+)
220
+ | Setting | When |
221
+ |---|---|
222
+ | `.all` | Default and recommended: CPU, GPU and Neural Engine |
223
+ | `.cpuOnly` | Debugging, or checking FP32 reference results |
224
+ | `.cpuAndGPU` | When the Neural Engine produces bad results |
225
+ | `.cpuAndNeuralEngine` | Lowest energy use; macOS 13 or later |
304
226
 
305
- Persist intermediate values across inference runs. Critical for LLM KV-cache.
227
+ ## Keeping state between predictions
306
228
 
307
- ### Python Conversion
229
+ From iOS 18 a model can keep values between predictions. The main use is the
230
+ key-value cache of a language model.
308
231
 
309
232
  ```python
310
- mlmodel = ct.convert(
311
- traced_model,
312
- inputs=[ct.TensorType(shape=(1,), name="x")],
313
- outputs=[ct.TensorType(name="y")],
314
- states=[ct.StateType(
315
- wrapped_type=ct.TensorType(shape=(1,)),
316
- name="accumulator",
317
- )],
233
+ cache = ct.StateType(
234
+ name="kv_cache",
235
+ wrapped_type=ct.TensorType(dtype=np.float16, shape=(2, 1, 16, 1024, 64)),
236
+ )
237
+ decoder = ct.convert(
238
+ traced_decoder,
318
239
  minimum_deployment_target=ct.target.iOS18,
240
+ states=[cache],
241
+ inputs=[ct.TensorType(name="token", dtype=np.int32, shape=(1, 1))],
319
242
  )
320
-
321
- # Python prediction with state
322
- state = mlmodel.make_state()
323
- result = mlmodel.predict({"x": np.array([2.0])}, state=state)
243
+ state = decoder.make_state()
244
+ step = decoder.predict({"token": np.array([[42]], dtype=np.int32)}, state=state)
324
245
  ```
325
246
 
326
- ### Swift Usage
327
-
328
- ```swift
329
- let model = try MLModel(contentsOf: modelURL, configuration: config)
330
- let state = model.makeState()
331
- let input = try MLDictionaryFeatureProvider(
332
- dictionary: ["x": MLFeatureValue(double: 2.0)]
333
- )
334
- let output = try model.prediction(from: input, using: state)
335
- ```
247
+ On the Swift side the equivalent is `let state = model.makeState()` followed by
248
+ `try model.prediction(from: MLDictionaryFeatureProvider(dictionary: inputs), using: state)`.
336
249
 
337
- Impact: Llama 3.1 with stateful KV-cache achieves 16.26 tokens/s vs 1.25
338
- tokens/s without (13x improvement).
250
+ Apple's published measurement for Llama 3.1: 16.26 tokens per second with a
251
+ stateful KV cache against 1.25 without, roughly thirteen times faster.
339
252
 
340
- ## Multifunction Models (iOS 18+)
253
+ ## Several functions in one package
341
254
 
342
- Pack multiple model functions (e.g., LoRA adapters) into a single .mlpackage.
343
- Shared weights are deduplicated.
255
+ Also from iOS 18, one `.mlpackage` can hold several functions that share
256
+ deduplicated weights, for example a base model and LoRA variants:
344
257
 
345
258
  ```python
346
- desc = ct.utils.MultiFunctionDescriptor()
347
- desc.add_function("base.mlpackage", src_function_name="main",
348
- target_function_name="base")
349
- desc.add_function("adapter1.mlpackage", src_function_name="main",
350
- target_function_name="style_1")
351
- desc.default_function_name = "base"
352
- ct.utils.save_multifunction(desc, "combined.mlpackage")
259
+ bundle = ct.utils.MultiFunctionDescriptor()
260
+ for variant in ("plain", "legal"):
261
+ bundle.add_function(f"Drafting-{variant}.mlpackage",
262
+ target_function_name=variant, src_function_name="main")
263
+ bundle.default_function_name = "plain"
264
+ ct.utils.save_multifunction(bundle, "Drafting.mlpackage")
353
265
  ```
354
266
 
355
- ```swift
356
- let config = MLModelConfiguration()
357
- config.functionName = "style_1"
358
- let model = try MLModel(contentsOf: modelURL, configuration: config)
359
- ```
267
+ In Swift, pick the function with `MLModelConfiguration.functionName`.
360
268
 
361
- ## Model Utilities
269
+ ## Utilities
362
270
 
363
271
  ```python
364
- # Inspect model
365
- spec = mlmodel.get_spec()
366
- print(spec.description)
367
-
368
- # Rename inputs/outputs
369
- ct.utils.rename_feature(spec, "old_name", "new_name")
370
-
371
- # Set metadata
372
- mlmodel.author = "Author"
373
- mlmodel.short_description = "Description"
374
- mlmodel.input_description["image"] = "RGB image 224x224"
375
-
376
- # Split large models for debugging
377
- ct.models.utils.bisect_model("large.mlpackage", "./output/")
272
+ spec = spotter.get_spec()
273
+ ct.utils.rename_feature(spec, "var_512", "probabilities")
378
274
 
379
- # Create pipeline from multiple models
380
- pipeline = ct.models.utils.make_pipeline(model1, model2)
381
-
382
- # Randomize weights (for testing)
383
- random_model = ct.models.utils.randomize_weights(mlmodel)
275
+ spotter.author = "Audio team"
276
+ spotter.short_description = "Wake-word detector"
277
+ spotter.input_description["audio"] = "One second of 16 kHz mono audio"
384
278
  ```
385
279
 
386
- ## Graph Pass Control
280
+ - `ct.models.utils.bisect_model` splits a large model into pieces for
281
+ debugging.
282
+ - `make_pipeline` chains models.
283
+ - `randomize_weights` produces a structurally identical model for tests.
284
+
285
+ ## Controlling graph passes
387
286
 
388
287
  ```python
389
- # Skip specific optimization passes
390
- pipeline = ct.PassPipeline()
391
- pipeline.remove_passes({"common::fuse_conv_batchnorm"})
392
- mlmodel = ct.convert(model, pass_pipeline=pipeline)
393
-
394
- # Predefined pipelines
395
- ct.PassPipeline.EMPTY # no passes
396
- ct.PassPipeline.CLEANUP # minimal cleanup
397
- ct.PassPipeline.DEFAULT_PRUNING # optimized for pruned models
398
- ct.PassPipeline.DEFAULT_PALETTIZATION # optimized for palettized models
288
+ passes = ct.PassPipeline()
289
+ passes.remove_passes({"common::fuse_conv_batchnorm"}) # keep BN visible while debugging
290
+ debuggable = ct.convert(traced, minimum_deployment_target=ct.target.iOS17,
291
+ pass_pipeline=passes)
399
292
  ```
400
293
 
401
- ## Custom Composite Operators
294
+ Predefined pipelines: `ct.PassPipeline.EMPTY`, `CLEANUP`, `DEFAULT_PRUNING`,
295
+ `DEFAULT_PALETTIZATION`.
402
296
 
403
- When PyTorch uses ops not natively supported:
297
+ ## Unsupported PyTorch ops
298
+
299
+ Register a composite for an op the converter does not know, built from MIL
300
+ builder ops:
404
301
 
405
302
  ```python
406
- from coremltools.converters.mil.frontend.torch.torch_op_registry import register_torch_op
407
303
  from coremltools.converters.mil.frontend.torch.ops import _get_inputs
304
+ from coremltools.converters.mil import register_torch_op
408
305
  from coremltools.converters.mil import Builder as mb
409
306
 
410
307
  @register_torch_op
411
- def selu(context, node):
412
- x = _get_inputs(context, node, expected=1)[0]
413
- x = mb.elu(x=x, alpha=1.6732632423543772)
414
- x = mb.mul(x=x, y=1.0507009873554805, name=node.name)
415
- context.add(x)
308
+ def hardswish(ctx, torch_node):
309
+ (value,) = _get_inputs(ctx, torch_node, expected=1)
310
+ gate = mb.clip(x=mb.add(x=value, y=3.0), alpha=0.0, beta=6.0)
311
+ scaled = mb.mul(y=gate, x=value)
312
+ ctx.add(mb.real_div(x=scaled, y=6.0, name=torch_node.name))
416
313
  ```
417
314
 
418
- ## Common Mistakes to Avoid
419
-
420
- 1. **Forgetting model.eval().** PyTorch models MUST be in eval mode before
421
- tracing or exporting.
422
- 2. **Using RangeDim when EnumeratedShapes would work.** Known input sizes
423
- should use EnumeratedShapes for better Neural Engine performance.
424
- 3. **Targeting neuralnetwork format for new models.** Always use mlprogram.
425
- 4. **Not specifying minimum_deployment_target.** Always set it explicitly.
426
- 5. **Using Float32 when Float16 suffices.** Float16 is the default and correct
427
- for most models.
428
- 6. **Converting from ONNX directly.** ONNX conversion is deprecated. Convert
429
- from the original framework.
430
- 7. **Not testing on physical devices.** Simulator does not support Metal GPU
431
- or Neural Engine.
315
+ ## Conversion mistakes
316
+
317
+ - Tracing or exporting without `model.eval()`.
318
+ - `RangeDim` where `EnumeratedShapes` would do.
319
+ - Targeting the neural network format for a new model.
320
+ - Leaving out `minimum_deployment_target`; always set it.
321
+ - Picking Float32 when Float16 is accurate enough.
322
+ - Converting straight from ONNX.
323
+ - Testing only in the Simulator, which has no Metal GPU or Neural Engine path;
324
+ verify on physical devices.