[PR #3537] [Other] setup (Mac): Swift 1.5 IQ3_S, opt-in with --family swift #4676

Open
opened 2026-11-07 15:38:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3537
Author: @oceanio
Created: 10/21/2026
Status: 🔄 Open

Base: main ← Head: feat/mac-swift


📝 Commits (2)

  • 5596527 setup (Mac): Swift 1.5 IQ3_S, opt-in with --family swift
  • aa30567 setup (Mac): Swift 1.5 reads images, with its own projector

📊 Changes

4 files changed (+165 additions, -39 deletions)

View changed files

📝 docs/MAC.md (+36 -4)
📝 metal/setup_mac.py (+38 -22)
📝 strata_control/mac_fit.py (+23 -13)
📝 tools/test_setup_mac.py (+68 -0)

📄 Description

Problem and result

On a Mac, ./setup.sh sets up the original Qwen3.8-Flash-Next, Unsloth's UD files and agentionai's Gyro files only;
docs/MAC.md says "The Swift and Coder releases are not set up on Mac yet". Swift 1.5 itself runs on the Metal engine,
but setup cannot prepare it: its two shards cut through a layer (IQ3_S: layer 14's gate in shard 1, its up and down in shard 2), shard 1 also holds
the n-gram table, and the Metal engine maps one file.

With this PR, ./setup.sh --family swift downloads Swift 1.5 IQ3_S, repacks its shards into one GGUF with the existing
metal/tools/metal_repack.py (as setup already does for Unsloth's files), builds the pack and writes a config. Without
--family swift nothing changes: the size menu, the original model, Unsloth's and Gyro's files.

#2898 (feature request). No maintainer reply on scope yet: opened as a draft so the change can be read beside the request.

Approach

  • Whether a model is repacked now follows repacks() (shards that cut through layers: Unsloth's 4-6, Swift's 2)
    instead of the shard count. The n-gram table stays in Swift's shard 1.
  • --family takes swift beside qwen, unsloth and gyro. --family swift takes IQ3_S only, the size measured
    on a Mac; another size stops setup with the command to run.
    Images follow the original model's choice (on by default, --vision no turns them off), with Swift's own projector
    as on a PC: setup.py's Swift entry names UkisAI's mmproj-Swift-Qwen3.8-Flash-Next-BF16.gguf, and its size and
    SHA-256 (setup.py's pin) are added to VISION_SHA256.
  • Swift's pack size lives in strata_control/mac_fit.py (MAC_SWIFT, mac_model(), and an optional family
    argument on model_need_gb / streams / model_note). The existing callers (setup.py's Control mode,
    tools/strata_mcp.py, strata launch) pass (model, ram) and see no change.
  • No engine change: the pack, the MTP draft layer and the engine are the same. iq_pack writes Swift's 96 F32 routers
    as BF16 (all exact), and the draft layer is the original model's, as on a PC.
  • docs/MAC.md: the --family swift option, what is measured, and the Families line.

Validation

Re-run on v0.2.11 (2026-11-06). Rebased onto main c3b3f503 (v0.2.11). Two conflicts, both beside 0.2.11's Unsloth v3.1 sets: mac_fit.py keeps 0.2.11's Mac app helpers next to mac_model, and model_shard_names names Unsloth's shards through setup.py's model_file, as 0.2.11 does. Swift's download URL is unchanged: model_hf only moves the v3.1 sets, which carry a revision. At the new tip aa305676:

  • tools/test_setup_mac.py: 48 tests OK; tools/test_setup_menu.py OK; tools.test_strata_mcp MacCatalog and Helpers: 20 OK. The last set ran with TMPDIR outside macOS's /var/folders, where 0.2.11's new Unsloth install-plan test fails on main too (check_data_dir calls it a system folder).
  • Swift 1.5 IQ3_S on v0.2.11's own engine (0.1.57-metal; this PR changes no engine code): needles 9 of 9 at 2K, 16K and 32K, depths 10/50/90%; the three test pictures read right.
  • 0.2.11 leaves engine_env and spec_args as they were, so the v0.2.10 measurements below still describe what setup writes for Swift.

Re-run on v0.2.10 (2026-11-03). Rebased onto main ffa80d73 (v0.2.10) with no conflicts; the setup commits are the same lines. At the new tip 486cc722:

  • tools/test_setup_mac.py: 38 tests OK.

  • Swift 1.5 IQ3_S runs on v0.2.10's own engine (0.1.56-metal; this PR changes no engine code). Needles: 9 of 9 found at 2K, 16K and 32K, depths 10/50/90%.

  • All three test pictures are read right: the shape counts, the invoice text word for word, and the tallest and shortest bars. The projector is the same copy as on v0.2.9 (below).

  • 0.2.10's Mac setup writes STRATA_METAL_F16=1 and --spec 3 --spec-min-p 0.5 into the config of a resident IQ3_S pack (mac_fit.engine_env and spec_args). --family swift takes IQ3_S, so a Swift config gets both, although they were measured on Qwen3.8-Flash-Next. I measured them on Swift and they hold there, so this PR adds no exception for Swift:

    over --spec 2 with the fp32 decode story code JSON agent turn
    --spec 2, fp32 (tok/s) 96.0 100.8 107.3 108.0
    --spec 3 --spec-min-p 0.5 +0.0% -3.2% +4.4% +3.8%
    STRATA_METAL_F16=1 +6.8% +10.6% +5.5% +10.0%
    both (what setup writes) +6.4% +11.7% +13.2% +22.6%

    Setup: M5 Max, Swift 1.5 IQ3_S resident, MTP, 262K context, "parallel": 2, one request at a time, greedy, 300 tokens (the agent turn's answer is a 93-token tool call). Medians of the per-round ratios over 5 rounds, with the arms' order rotated each round. The engine was my build of 0.2.10 plus my open Mac PRs (#3536, #3541, #4960, #4961). On the same Qwen config it gives 0.2.10's tokens (8 of 8 requests) and speed (98.4 against 98.3 tok/s).

    • --spec 3 gives the same tokens as --spec 2, with and without the fp16 decode, in every round.
    • The fp16 decode gives other tokens than fp32. tools/quant_quality.py against the fp32 decode (the v1 set, 4,995 positions, teacher-forced): top-1 agreement 95.5%, mean KL 0.018 (p99 0.25), perplexity 4.017 against 4.009. That is close to the commit's Qwen IQ3_S figures (96.2%, 0.016). The weakest segment is docs (91.3%, 0.029).
    • With "parallel": 2, a request decoded in a batch slot beside another gives the same tokens as alone with the fp32 decode, and other tokens with the fp16 decode, because the slot rows stay fp32.

On v0.2.9 (tip 7e9b9a0e, 2026-11-01): 35 setup tests OK, needles 9 of 9, the three pictures read right. The projector was SC117's copy (mmproj-Qwen3.8-Flash-Next-BF16.gguf in SC117's Swift repo); its 334 tensors are byte-identical to UkisAI's file that this PR pins, and only the general.* metadata differs.

The rest of this section is the run on v0.2.2.

Environment: M5 Max 128 GB, macOS 26.7.1, Command Line Tools 27.0 (Apple clang 21).

Passed:

  • python3 tools/test_setup_mac.py on 8943a2bb (= main 011c9e60, 0.2.2, + this PR's 2 commits): 32 tests OK, 6 of
    them new
    (the original's and Unsloth's file names and repack decision unchanged; Swift's file names, its repack, its engine
    arguments; IQ3_S with --vision yes and no warning, its projector's pin equal to setup.py's; an unmeasured size
    stopping; the choices without --family swift).
  • python3 -m unittest tools.test_strata_mcp.MacCatalog tools.test_strata_mcp.Helpers (the tests that import
    mac_fit): OK on this PR; python3 tools/test_setup_menu.py: OK.
  • Swift 1.5 IQ3_S on the Metal engine (SC117's abliterated build, the same two-file layout as UkisAI's release),
    repacked file 54.8 GB: decode 93.1-110.4 tok/s on 4 prompts (Qwen IQ3_S 94.3-109.2 on the same Mac), prompt
    1,636-1,731 tok/s, 6.8K-token needles 3 of 3, 3 reasoning questions right with thinking on. Measured on the 0.1.45
    engine with the Mac build fix that 0.2.0 carries.
  • The engine built from this branch (= main 011c9e60, 0.2.2, no engine change; cmake --build build-metal --target strata,
    0 errors) with the repacked Swift file, through this branch's serve/server.py at --max-context 262144: answers a
    short question ("Paris"), and tools/needle_bench.py --lengths 2k,16k,32k --depths 10,50,90 finds 9 of 9
    (1,644 / 15,070 / 31,643 prompt tokens). The same checks passed on 0.2.1.4 (main 9de04cd4) before the rebase.
  • Images, with the same engine and server and UkisAI's projector (SHA-256 equal to the pin), greedy:
    three test pictures read right (6 shapes counted by color, an invoice transcribed exactly, 5 bars ranked).

Failed: none observed.

Not run:

  • tools/test_strata_mcp.py in full: its fake server uses port 8080, which a running Strata held on this Mac.
  • A fresh end-to-end ./setup.sh --family swift on 0.2.1.4 (55 GB download and repack). It ran end to end
    (--gguf-dir) before the rebase, on 0.1.45 with the Mac build fix.
  • UkisAI's own model files (SC117's build has the same layout; UkisAI's projector is the one checked above), other Macs, streaming on a smaller Mac, quality beyond 32K
    tokens, the KL harness against a Q8_0 or CUDA reference, the Coder release, the 61-task quality suite that the fp16
    default passed on Qwen (not available here).

Limits

  • IQ3_S only; other Swift sizes stop setup with a message until they are measured on a Mac.
  • Opt-in only: the size menu, the app and strata launch do not offer Swift.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3537 **Author:** [@oceanio](https://github.com/oceanio) **Created:** 10/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/mac-swift` --- ### 📝 Commits (2) - [`5596527`](https://github.com/Niko1221/Strata/commit/55965276e5de580d842e374fc364a6389477dec3) setup (Mac): Swift 1.5 IQ3_S, opt-in with --family swift - [`aa30567`](https://github.com/Niko1221/Strata/commit/aa305676c05f5b72361e47110b5c2cdaad74d82f) setup (Mac): Swift 1.5 reads images, with its own projector ### 📊 Changes **4 files changed** (+165 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `docs/MAC.md` (+36 -4) 📝 `metal/setup_mac.py` (+38 -22) 📝 `strata_control/mac_fit.py` (+23 -13) 📝 `tools/test_setup_mac.py` (+68 -0) </details> ### 📄 Description ## Problem and result On a Mac, `./setup.sh` sets up the original Qwen3.8-Flash-Next, Unsloth's UD files and agentionai's Gyro files only; docs/MAC.md says "The Swift and Coder releases are not set up on Mac yet". Swift 1.5 itself runs on the Metal engine, but setup cannot prepare it: its two shards cut through a layer (IQ3_S: layer 14's gate in shard 1, its up and down in shard 2), shard 1 also holds the n-gram table, and the Metal engine maps one file. With this PR, `./setup.sh --family swift` downloads Swift 1.5 IQ3_S, repacks its shards into one GGUF with the existing `metal/tools/metal_repack.py` (as setup already does for Unsloth's files), builds the pack and writes a config. Without `--family swift` nothing changes: the size menu, the original model, Unsloth's and Gyro's files. ## Related discussion #2898 (feature request). No maintainer reply on scope yet: opened as a draft so the change can be read beside the request. ## Approach - Whether a model is repacked now follows `repacks()` (shards that cut through layers: Unsloth's 4-6, Swift's 2) instead of the shard count. The n-gram table stays in Swift's shard 1. - `--family` takes `swift` beside `qwen`, `unsloth` and `gyro`. `--family swift` takes IQ3_S only, the size measured on a Mac; another size stops setup with the command to run. Images follow the original model's choice (on by default, `--vision no` turns them off), with Swift's own projector as on a PC: `setup.py`'s Swift entry names UkisAI's `mmproj-Swift-Qwen3.8-Flash-Next-BF16.gguf`, and its size and SHA-256 (`setup.py`'s pin) are added to `VISION_SHA256`. - Swift's pack size lives in `strata_control/mac_fit.py` (`MAC_SWIFT`, `mac_model()`, and an optional `family` argument on `model_need_gb` / `streams` / `model_note`). The existing callers (`setup.py`'s Control mode, `tools/strata_mcp.py`, `strata launch`) pass `(model, ram)` and see no change. - No engine change: the pack, the MTP draft layer and the engine are the same. `iq_pack` writes Swift's 96 F32 routers as BF16 (all exact), and the draft layer is the original model's, as on a PC. - docs/MAC.md: the `--family swift` option, what is measured, and the Families line. ## Validation **Re-run on v0.2.11 (2026-11-06).** Rebased onto main `c3b3f503` (v0.2.11). Two conflicts, both beside 0.2.11's Unsloth v3.1 sets: `mac_fit.py` keeps 0.2.11's Mac app helpers next to `mac_model`, and `model_shard_names` names Unsloth's shards through `setup.py`'s `model_file`, as 0.2.11 does. Swift's download URL is unchanged: `model_hf` only moves the v3.1 sets, which carry a revision. At the new tip `aa305676`: - `tools/test_setup_mac.py`: 48 tests OK; `tools/test_setup_menu.py` OK; `tools.test_strata_mcp` MacCatalog and Helpers: 20 OK. The last set ran with `TMPDIR` outside macOS's `/var/folders`, where 0.2.11's new Unsloth install-plan test fails on main too (`check_data_dir` calls it a system folder). - Swift 1.5 IQ3_S on v0.2.11's own engine (0.1.57-metal; this PR changes no engine code): needles 9 of 9 at 2K, 16K and 32K, depths 10/50/90%; the three test pictures read right. - 0.2.11 leaves `engine_env` and `spec_args` as they were, so the v0.2.10 measurements below still describe what setup writes for Swift. **Re-run on v0.2.10 (2026-11-03).** Rebased onto main `ffa80d73` (v0.2.10) with no conflicts; the setup commits are the same lines. At the new tip `486cc722`: - `tools/test_setup_mac.py`: 38 tests OK. - Swift 1.5 IQ3_S runs on v0.2.10's own engine (0.1.56-metal; this PR changes no engine code). Needles: 9 of 9 found at 2K, 16K and 32K, depths 10/50/90%. - All three test pictures are read right: the shape counts, the invoice text word for word, and the tallest and shortest bars. The projector is the same copy as on v0.2.9 (below). - 0.2.10's Mac setup writes `STRATA_METAL_F16=1` and `--spec 3 --spec-min-p 0.5` into the config of a resident IQ3_S pack (`mac_fit.engine_env` and `spec_args`). `--family swift` takes IQ3_S, so a Swift config gets both, although they were measured on Qwen3.8-Flash-Next. I measured them on Swift and they hold there, so this PR adds no exception for Swift: | over `--spec 2` with the fp32 decode | story | code | JSON | agent turn | |---|---:|---:|---:|---:| | `--spec 2`, fp32 (tok/s) | 96.0 | 100.8 | 107.3 | 108.0 | | `--spec 3 --spec-min-p 0.5` | +0.0% | -3.2% | +4.4% | +3.8% | | `STRATA_METAL_F16=1` | +6.8% | +10.6% | +5.5% | +10.0% | | both (what setup writes) | +6.4% | +11.7% | +13.2% | +22.6% | Setup: M5 Max, Swift 1.5 IQ3_S resident, MTP, 262K context, `"parallel": 2`, one request at a time, greedy, 300 tokens (the agent turn's answer is a 93-token tool call). Medians of the per-round ratios over 5 rounds, with the arms' order rotated each round. The engine was my build of 0.2.10 plus my open Mac PRs (#3536, #3541, #4960, #4961). On the same Qwen config it gives 0.2.10's tokens (8 of 8 requests) and speed (98.4 against 98.3 tok/s). - `--spec 3` gives the same tokens as `--spec 2`, with and without the fp16 decode, in every round. - The fp16 decode gives other tokens than fp32. `tools/quant_quality.py` against the fp32 decode (the v1 set, 4,995 positions, teacher-forced): top-1 agreement 95.5%, mean KL 0.018 (p99 0.25), perplexity 4.017 against 4.009. That is close to the commit's Qwen IQ3_S figures (96.2%, 0.016). The weakest segment is docs (91.3%, 0.029). - With `"parallel": 2`, a request decoded in a batch slot beside another gives the same tokens as alone with the fp32 decode, and other tokens with the fp16 decode, because the slot rows stay fp32. On v0.2.9 (tip `7e9b9a0e`, 2026-11-01): 35 setup tests OK, needles 9 of 9, the three pictures read right. The projector was SC117's copy (`mmproj-Qwen3.8-Flash-Next-BF16.gguf` in SC117's Swift repo); its 334 tensors are byte-identical to UkisAI's file that this PR pins, and only the `general.*` metadata differs. The rest of this section is the run on v0.2.2. Environment: M5 Max 128 GB, macOS 26.7.1, Command Line Tools 27.0 (Apple clang 21). **Passed:** - `python3 tools/test_setup_mac.py` on 8943a2bb (= `main` 011c9e60, 0.2.2, + this PR's 2 commits): 32 tests OK, 6 of them new (the original's and Unsloth's file names and repack decision unchanged; Swift's file names, its repack, its engine arguments; IQ3_S with `--vision yes` and no warning, its projector's pin equal to `setup.py`'s; an unmeasured size stopping; the choices without `--family swift`). - `python3 -m unittest tools.test_strata_mcp.MacCatalog tools.test_strata_mcp.Helpers` (the tests that import `mac_fit`): OK on this PR; `python3 tools/test_setup_menu.py`: OK. - Swift 1.5 IQ3_S on the Metal engine (SC117's abliterated build, the same two-file layout as UkisAI's release), repacked file 54.8 GB: decode 93.1-110.4 tok/s on 4 prompts (Qwen IQ3_S 94.3-109.2 on the same Mac), prompt 1,636-1,731 tok/s, 6.8K-token needles 3 of 3, 3 reasoning questions right with thinking on. Measured on the 0.1.45 engine with the Mac build fix that 0.2.0 carries. - The engine built from this branch (= `main` 011c9e60, 0.2.2, no engine change; `cmake --build build-metal --target strata`, 0 errors) with the repacked Swift file, through this branch's `serve/server.py` at `--max-context 262144`: answers a short question ("Paris"), and `tools/needle_bench.py --lengths 2k,16k,32k --depths 10,50,90` finds 9 of 9 (1,644 / 15,070 / 31,643 prompt tokens). The same checks passed on 0.2.1.4 (`main` 9de04cd4) before the rebase. - Images, with the same engine and server and UkisAI's projector (SHA-256 equal to the pin), greedy: three test pictures read right (6 shapes counted by color, an invoice transcribed exactly, 5 bars ranked). **Failed:** none observed. **Not run:** - `tools/test_strata_mcp.py` in full: its fake server uses port 8080, which a running Strata held on this Mac. - A fresh end-to-end `./setup.sh --family swift` on 0.2.1.4 (55 GB download and repack). It ran end to end (`--gguf-dir`) before the rebase, on 0.1.45 with the Mac build fix. - UkisAI's own model files (SC117's build has the same layout; UkisAI's projector is the one checked above), other Macs, streaming on a smaller Mac, quality beyond 32K tokens, the KL harness against a Q8_0 or CUDA reference, the Coder release, the 61-task quality suite that the fp16 default passed on Qwen (not available here). ## Limits - IQ3_S only; other Swift sizes stop setup with a message until they are measured on a Mac. - Opt-in only: the size menu, the app and `strata launch` do not offer Swift. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4676
No description provided.