Skip to content

Add Cua-S1-4B-0.2 Core ML runtime - #12

Open
Alex-Wengg wants to merge 2 commits into
mainfrom
feat/cua-s1-4b
Open

Alex-Wengg wants to merge 2 commits into
mainfrom
feat/cua-s1-4b

Conversation

@Alex-Wengg

@Alex-Wengg Alex-Wengg commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Adds CuaS1FourBManager, which runs Cua-S1-4B-0.2 (Qwen3.5-4B plus Cua's LoRA adapters) on the GPU. Each decision is one forward pass that scores a closed list of (element, action) options, from either an accessibility tree (.text) or a screenshot (.multimodal). Conversion: FluidInference/mobius#104. Models: FluidInference/cua-s1-4b-coreml.

  • The host prepares everything the Core ML graphs don't do. It has a Qwen3.5 BPE tokenizer and renders Cua's FourBModel prompt through the chat template. It builds the input embeddings from the table, computes the M-RoPE positions, and does the vision preprocessing: resize, bicubic AA, patching, position table and 2D rope. It then runs the four decoder parts.
  • Weights download from a pinned manifest with a SHA-256 check on every file. Variants: "" (fp16), w8, and gptq (2.6 GB, text only).
  • prewarm() pays the one-time GPU specialization cost (~100 s the first time a 4B graph runs).
  • FluidUseCuaS1 parity reruns the fixture check against a local mobius build.

Parity against the fp32 reference, 38 tasks: the chat string and token ids match 38/38. Argmax agrees 38/38 for text fp16 (max Δp 0.0053), gptq (0.133) and multimodal (0.135), the same as the Python Core ML path. On GUI-360 text (613 tasks), fp16 and gptq both score 85.5%.

Models pinned at 735de16e. FluidUseCuaS1 parity --models hub --variant gptq downloads 3.8 GB through the pinned store and reproduces the 38/38 parity.

Notes for review:

  • A decoder part's GPU output array is copied before it becomes the next part's input. Passing it straight through trips an MPSGraph stride assertion.
  • The unit tests cover prompt rendering, M-RoPE positions and smart_resize against reference values. Model parity needs the 4B weights, so it's a CLI check rather than a CI test.

🤖 Generated with Claude Code

Alex-Wengg and others added 2 commits September 24, 2026 01:57
Swift host for the mobius Cua-S1-4B conversion (Qwen3.5-4B + Cua LoRA,
text and multimodal): Qwen3.5 byte-level BPE tokenizer, FourBModel prompt
and chat template, host embedding gather, M-RoPE, four GPU decoder parts,
and the vision host side (smart_resize, bicubic AA, merge-window patches,
pos-embed, 2D rope). Pinned, SHA-256 checked download from
FluidInference/cua-s1-4b-coreml; prewarm() for the ~100 s first-call GPU
specialization; FluidUseCuaS1 parity CLI.

A contiguous copy between decoder parts avoids an MPSGraph stride assert
when a GPU output array is fed straight into the next model.

Parity vs the fp32 reference (38 tasks): text fp16 38/38 (max dp 0.0053),
gptq 38/38 (0.133), multimodal 38/38 (0.135); chat string and token ids
match the Python reference 38/38.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
117 files, 26.3 GB. FluidUseCuaS1 parity --models hub downloads through the
pinned store: gptq text 3.8 GB, prewarm 82 s, parity 38/38 (max dp 0.133),
identical to the local build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Alex-Wengg
Alex-Wengg marked this pull request as ready for review September 24, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant