Skip to content

feat: clef-flash (Cloudflare 9B decision model) on Core ML + ticket-triage demo - #34

Merged
Alex-Wengg merged 3 commits into
mainfrom
feat/clef-flash-demo
Oct 10, 2026
Merged

Alex-Wengg merged 3 commits into
mainfrom
feat/clef-flash-demo

Conversation

@Alex-Wengg

Copy link
Copy Markdown
Member

Runs Cloudflare's clef-flash (Qwen3.5-9B decision model, Apache-2.0) on the Mac GPU through Core ML, text only. Bundle: FluidInference/clef-flash-coreml @ c1b8fdae.

  • ClefFlashManager: chains 8 four-layer decoder packages (8-bit, one function per 256–2048 bucket), then the joint schema head. The host does Clef's record rendering, the fp16 embedding gather, text-only RoPE and the untied output embeddings for the head's lexical rows.
  • ClefFlashModelStore: pinned revision, per-file SHA-256 (~11 GB).
  • ClefFlashDemo: SwiftUI support-ticket triage. Incoming queue → decided feed with team / urgency / refund + ms; fictional mock tickets; typed tickets jump the queue; Restart. demo.sh also opens Ghostty with macmon and the decision log.
  • ClefRecordEncoder now takes the image token ids directly, so text-only callers don't need ClefVisionConfig. ClefVision behaviour is unchanged.

Numbers (M5 Pro): ~0.49 s per 3-question ticket (p95 0.57 s). 8-bit vs a streamed fp32 reference: 1 / 611 answers differ (a near-tie), ARC-E 100 / ARC-C 99.0. The decoder puts 0 ops on the ANE, so this is a GPU-only model.

Reviewer notes: the tests (ClefFlashTests) need no model, but they couldn't run locally (no XCTest toolchain), so CI is the check. The decoder needs ~7 GB of RAM to itself.

🤖 Generated with Claude Code

Cloudflare clef-flash (Qwen3.5-9B decision model) text-only on Core ML:
8 decoder packages (4 layers, 8-bit, one function per bucket) chained on
the GPU + the joint schema head; host embedding gather, untied output
embeddings for the head's lexical rows, text-only RoPE. ~0.50 s per
3-question ticket at L512 on an M5 Pro; same answers as the Python Core
ML pipeline. ClefRecordEncoder now takes the image token ids directly so
text-only callers don't need a vision config.

ClefFlashDemo: incoming queue -> decided feed (team / urgency / refund +
ms), fictional mock tickets, typed tickets jump the queue, Restart.
demo.sh opens Ghostty with macmon + the decision log. Bundle comes from
model-lab models/clef-flash-coreml (not on Hugging Face).
…lash-coreml @c1b8fdae

Downloads the 11 GB bundle (8 decoder parts, head, embedding tables,
tokenizer, manifest) with per-file SHA-256. ClefFlashDemo uses it unless
CLEF_FLASH_BUNDLE points at a local bundle. Tests: manifest parsing,
text-only RoPE tables, store asset list.
@Alex-Wengg
Alex-Wengg merged commit cebe061 into main Oct 10, 2026
1 check passed
Alex-Wengg added a commit that referenced this pull request Oct 10, 2026
…et demo (#36)

Stacked on #34. Adds the 0.6B student distilled from Cloudflare
clef-flash:
[FluidInference/clef-text-0.6b-coreml](https://huggingface.co/FluidInference/clef-text-0.6b-coreml)
@ `3c61a609` (PyTorch:
[FluidInference/clef-text-0.6b](https://huggingface.co/FluidInference/clef-text-0.6b)).

- `ClefTextManager`: Qwen3-0.6B + Clef joint head. One multifunction
fp16 decoder (L256–L2048) plus an fp16 head; the host does the embedding
gather, RoPE and causal mask. Runs on `.cpuAndGPU` (~48 ms per
3-question ticket) or 100% on the Neural Engine (~77 ms).
- `ClefTextModelStore`: pinned revision, per-file SHA-256 (~1.3 GB).
- `ClefFlashDemo`: `CLEF_MODEL=text` runs the 0.6B; fixed 1,000-ticket
mock backlog with progress and total time ("1,000 tickets in 57 s");
`bars.py` CPU/GPU bar charts over `macmon pipe` (asitop crashes on M5
Pro, and the CPU/ANE power counters read 0 W on macOS 27).
- `ClefCompareDemo`: 9B on the GPU and 0.6B on the ANE side by side (85%
of decisions match, 5.6× faster).
- `ClefTextCheck`: parity CLI. Swift vs PyTorch on the demo tickets:
identical tokens, 0 / 60 flips.

Student quality (held-out test splits): 79.1 vs teacher 88.2.
Classification is within 0–4 points; knowledge QA is far behind (table
on the HF card).

Reviewer notes: `ClefTextTests` need no model. As in #34, they compile
and run on CI only (no local XCTest).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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