File size: 3,871 Bytes
986b7a8 | 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 | ---
language:
- en
license: mit
library_name: aether-kit
pipeline_tag: text-generation
base_model: microsoft/phi-2
tags:
- aether-kit
- core-ai
- phi
- text-generation
- experimental
---
# Phi-2 for Aether Kit
A macOS Core AI conversion of [microsoft/phi-2](https://huggingface.co/microsoft/phi-2),
at upstream revision `9a5117d15e407c48fa40f8adbac1244abae52d6f`.
Aether Kit source: [`1881cf4`](https://github.com/bubstackdev/aether-kit/commit/1881cf48628c8f15a7e8e92ed38098a68865063e).
## Requirements and usage
The `mac/` subdirectory is a registered Aether language bundle. It requires Apple
silicon, macOS 27 or newer, and an Aether Kit checkout containing the Phi-2 spike
(`1881cf4` or a descendant). Published Aether Kit 0.0.4 lacks the padded-cache
support required by this model. No iOS bundle is qualified.
This is a **base completion model**, with no chat template. Use
`AetherLanguageCoreAI.LanguageGenerationSession`, rather than the chat facade
(which reports `unsupportedTemplate`). No instruction tuning was added.
The context limit is **2,048 tokens**, including prompt and continuation, with
maximum prefill chunks of 64 tokens. Weights, KV caches and logits use fp16
storage; projections, normalization, residuals and attention use float32 arithmetic.
This conversion is not int8/int4 quantized.
```swift
import AetherLanguageCoreAI
import AetherLanguageTokenizers
let tokenizer = try await LanguageTokenizer.open(bundle: bundleURL)
let session = try await LanguageGenerationSession.open(bundle: bundleURL, platform: .macos)
let result = try await session.generate(
prompt: tokenizer.encode("def fibonacci(n):"), maximumTokens: 64)
print(tokenizer.decode(result.tokens))
await session.unload()
```
Download `mac/` at an immutable Hub revision and use that local directory as
`bundleURL`. A pinned catalog entry will be maintained in
[`Spikes/phi2/catalog-macos.json`](https://github.com/bubstackdev/aether-kit/blob/main/Spikes/phi2/catalog-macos.json).
Model SHA-256: `8b2a3f6388406f183163440449aced556008f05e6b7a0308b1d423bc2ce79085`.
## Qualification and limits
Evidence is included under `verification/`; reproduction commands are in
[`Spikes/phi2`](https://github.com/bubstackdev/aether-kit/tree/main/Spikes/phi2).
The converter used Torch 2.11.0, Transformers 4.57.3 and coreai-torch 0.4.2.
The recorded host ran macOS build 26B123, Core AI architecture `h17c`.
- Both float32 port contracts match all 64 reference argmax rows on each of three
prompts (7, 280 and 224 tokens), with cosine >= 0.999999 and absolute tolerance
0.01. Upstream Transformers itself varies by up to 0.00815 between full-sequence
and cached/chunked float32 execution on the long prompt.
- The compiled checkpoint passes the Core AI CPU logits/cache self-check:
exact argmax, no lost cache rows, minimum cosine 0.99298.
- Native GPU execution matches all 192 forced-token choices and all three
64-token continuations exactly, repeatably across prefill widths 7 and 16;
minimum native cosine is 0.99847. Exact agreement on these cases does not
promise bit-exact float32 generation for arbitrary prompts.
- The 224-token case exercises padded-cache growth from 256 to 512 rows.
- The Swift Release regression suite reports 714 passing tests; existing GPT-2
native qualification also passes with the stride-aware cache implementation.
This experimental v0.0.6 development asset is qualified on these prompts on one
Mac, not for general task quality, all Apple devices, or iOS. Phi-2 retains the
capabilities and limitations described in its
[upstream model card](https://huggingface.co/microsoft/phi-2).
## License and provenance
Original model and tokenizer assets retain the MIT terms in `LICENSE`, Copyright
(c) Microsoft Corporation. `NOTICE` identifies conversion and architecture sources.
Aether Kit's conversion tooling is Apache-2.0.
|