Skip to content

Commit 559aacc

Browse files
committed
feat: harden dependable CPU inference
1 parent 33a11d0 commit 559aacc

206 files changed

Lines changed: 44732 additions & 1157 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
os: [ubuntu-latest, macos-15]
27+
os: [ubuntu-latest, macos-15, macos-15-intel, windows-latest]
2828
steps:
2929
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
3030
- uses: dtolnay/rust-toolchain@a75363d06101555fc97c6c7e1e65670b99104d98 # 1.96.1
@@ -48,6 +48,19 @@ jobs:
4848
- run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
4949
- run: cargo test --workspace --all-targets --all-features --locked
5050

51+
macos-rosetta:
52+
name: macOS x86_64 through Rosetta
53+
runs-on: macos-15
54+
steps:
55+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
56+
- uses: dtolnay/rust-toolchain@a75363d06101555fc97c6c7e1e65670b99104d98 # 1.96.1
57+
with:
58+
targets: x86_64-apple-darwin
59+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
60+
with:
61+
key: rosetta-x86_64
62+
- run: cargo test -p ferrite-inference --test batched_decode --target x86_64-apple-darwin --locked
63+
5164
msrv:
5265
name: Minimum supported Rust
5366
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ kernels, and exposes both a command-line interface and an OpenAI-compatible
66
HTTP server.
77

88
Ferrite is currently alpha software. The supported surface is deliberately
9-
small and well tested, but model coverage and sampling features are not yet
9+
small and well tested, but model, template, and sampling coverage are not yet
1010
complete.
1111

1212
## Install
@@ -32,12 +32,22 @@ extraction, container, and model-integrity instructions.
3232

3333
## Highlights
3434

35-
- Llama and Qwen2 model architectures, including Qwen2.5 GGUF artifacts.
36-
- F32, F16, BF16, Q4_K, Q5_0, Q6_K, and Q8_0 tensor loading.
37-
- NEON, Arm I8MM, and x86_64 AVX2 kernels with portable fallbacks.
38-
- Greedy text generation, token streaming, profiling, and reproducible evals.
39-
- OpenAI-compatible models, completions, and chat-completions endpoints.
40-
- Optional prompt-prefix caching and experimental continuous batching.
35+
- Llama, Qwen2, and Phi-3 model architectures, including a verified official
36+
Phi-3 Mini 4K Instruct path.
37+
- F32, F16, BF16, Q4_K, Q5_0, Q5_K, Q6_K, and Q8_0 tensor loading.
38+
- Shared mapped storage for dense-16 and quantized matrices, with bounded
39+
token-embedding row decoding.
40+
- Central runtime dispatch for NEON, Arm DotProd and I8MM, and x86_64 AVX2,
41+
with a forceable portable correctness provider.
42+
- Fused greedy generation plus seeded temperature, top-k, top-p, min-p,
43+
penalty, and logit-bias sampling.
44+
- OpenAI-compatible models, completions, chat completions, and a bounded
45+
non-streaming Responses endpoint.
46+
- Grammar-constrained JSON objects and bounded function-call parsing. Ferrite
47+
reports function calls but never executes application tools.
48+
- Unified prompt-prefix reuse and experimental continuous batching for greedy
49+
streaming and non-streaming requests, with bounded queues and cache budgets.
50+
- Optional fixed-block Locus KV storage with explicit per-session capacity.
4151
- No model or binary test assets committed to the repository. Test GGUF data
4252
is generated in memory, and real-model tests use local artifacts explicitly.
4353

@@ -52,7 +62,25 @@ cd ferrite
5262
cargo build --release --locked -p ferrite-cli -p ferrite-server
5363
```
5464

55-
Place a supported GGUF model under `target/models/`, then run a completion:
65+
For the shortest verified first run, ask Ferrite to acquire the pinned
66+
Microsoft Phi-3 Mini 4K Instruct Q4 artifact and generate locally:
67+
68+
```sh
69+
target/release/ferrite \
70+
--model-id phi3-mini-4k-instruct-q4 \
71+
--prompt '<|user|>
72+
Write one sentence about Rust.<|end|>
73+
<|assistant|>' \
74+
--generate-tokens 32 \
75+
--stream
76+
```
77+
78+
The first invocation downloads about 2.39 GB over HTTPS, verifies the pinned
79+
size and SHA-256, publishes it atomically into the user model cache, and makes
80+
the artifact and provenance manifest read-only. Later invocations reverify the
81+
cached bytes. Pass `--offline` to prohibit acquisition.
82+
83+
To use another supported GGUF, provide its path directly:
5684

5785
```sh
5886
target/release/ferrite \
@@ -95,6 +123,7 @@ experimental kernel is faster or compatible on every CPU.
95123
- [Architecture](docs/architecture.md)
96124
- [Library API](docs/library-api.md)
97125
- [Operational tools](docs/benchmark-tools.md)
126+
- [Acceptance matrix](docs/acceptance-matrix.md)
98127
- [Evaluation and regression gates](docs/evaluation.md)
99128
- [Development guide](docs/development.md)
100129
- [Safety policy](docs/safety.md)
@@ -125,10 +154,12 @@ scripts eval harness, raw eval records, and repository checks
125154
## Quality gates
126155

127156
The required local checks are documented in [CONTRIBUTING.md](CONTRIBUTING.md).
128-
CI runs formatting, strict Clippy, default and all-feature tests on Linux and
129-
macOS, plus a separate Rust 1.96 MSRV check. Linux jobs also enforce rustdoc,
130-
doctests, documentation, repository hygiene, eval-harness tests, package
131-
contents, RustSec advisories, licenses, duplicate dependencies, and sources.
157+
CI runs formatting, strict Clippy, and default plus all-feature tests on Linux
158+
x86_64, Linux arm64, macOS arm64, macOS x86_64, and Windows x86_64, plus a
159+
separate Rust 1.96 MSRV check and focused Rosetta parity. Linux jobs also
160+
enforce rustdoc, doctests, documentation, repository hygiene, eval-harness
161+
tests, package contents, RustSec advisories, licenses, duplicate dependencies,
162+
and sources.
132163

133164
## License
134165

crates/ferrite-cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ path = "src/main.rs"
1919
[dependencies]
2020
ferrite-inference.workspace = true
2121
ferrite-model.workspace = true
22+
serde_json = "1"
23+
sha2 = "0.10"
2224

2325
[dev-dependencies]
2426
ferrite-fixtures.workspace = true

0 commit comments

Comments
 (0)