Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ on:
push:
branches: [main]
tags: ["v*"]
paths-ignore:
- "**/*.md"
- "LICENSE*"
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- "**/*.md"
- "LICENSE*"

permissions:
contents: read
Expand All @@ -32,33 +39,56 @@ jobs:
needs: [trufflehog, lint]
uses: ./.github/workflows/tests.yml
with:
cache_scope: ${{ github.event_name }}
source_sha: ${{ github.sha }}
secrets:
HF_TOKEN: ${{ github.event_name == 'push' && secrets.HF_TOKEN || '' }}

build:
name: Build
build_main:
name: Build main
needs: tests
if: github.ref_type != 'tag'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
actions: write
contents: read
packages: write
uses: ./.github/workflows/build.yml
with:
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
push: true
source_sha: ${{ github.sha }}

approve_pr_build:
name: Approve PR build
needs: tests
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
environment: pr-build
steps:
- run: echo "PR build approved"

build_pr:
name: Build PR
needs: approve_pr_build
permissions:
actions: write
contents: read
packages: write
uses: ./.github/workflows/build.yml
with:
push: true
source_sha: ${{ github.sha }}

push:
name: Push
needs: [tests, build]
needs: [tests, build_main]
if: >-
always() &&
needs.tests.result == 'success' &&
github.event_name == 'push' &&
(github.ref == 'refs/heads/main' || github.ref_type == 'tag') &&
(github.ref_type == 'tag' || needs.build.result == 'success')
(github.ref_type == 'tag' || needs.build_main.result == 'success')
permissions:
contents: read
packages: write
Expand Down
29 changes: 18 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name: Tests
on:
workflow_call:
inputs:
cache_scope:
required: true
type: string
source_sha:
required: true
type: string
Expand All @@ -25,14 +22,19 @@ jobs:
with:
persist-credentials: false
ref: ${{ inputs.source_sha }}
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- name: Cache models
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/huggingface/hub
key: models-v1-${{ runner.os }}-aa8c91ca-1a793eb5-e4e9ddf2
- name: Cache Cargo
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/huggingface/hub
~/.cargo/registry
~/.cargo/git
key: test-v2-${{ inputs.cache_scope }}-cpu-${{ hashFiles('Cargo.lock') }}-aa8c91ca088ec597df95a0d1c76b3063cb2ae5e8
restore-keys: test-v2-${{ inputs.cache_scope }}-cpu-
key: test-v3-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: test-v3-${{ runner.os }}-
- name: Test
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
Expand All @@ -46,14 +48,19 @@ jobs:
with:
persist-credentials: false
ref: ${{ inputs.source_sha }}
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- name: Cache models
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/huggingface/hub
key: models-v1-${{ runner.os }}-aa8c91ca-1a793eb5-e4e9ddf2
- name: Cache Cargo
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/huggingface/hub
~/.cargo/registry
~/.cargo/git
key: test-v2-${{ inputs.cache_scope }}-metal-${{ hashFiles('Cargo.lock') }}-aa8c91ca088ec597df95a0d1c76b3063cb2ae5e8
restore-keys: test-v2-${{ inputs.cache_scope }}-metal-
key: test-v3-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: test-v3-${{ runner.os }}-
- name: Test
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ cargo install sys1 --features cpu
# cargo install sys1 --no-default-features --features cuda
```

Then run it with [`convaiinnovations/laya`](https://huggingface.co/convaiinnovations/laya) (more models coming soon!).
Then run it with any of the supported models (more coming soon!).

- [`convaiinnovations/laya`](https://huggingface.co/convaiinnovations/laya) for English text, guardrails, email triage
- [`convaiinnovations/laya-multilingual`](https://huggingface.co/convaiinnovations/laya-multilingual) for 100+ languages, ~2.2x faster
- [`convaiinnovations/laya-typed-decisions`](https://huggingface.co/convaiinnovations/laya-typed-decisions) for typed-decisions workflows

```bash
sys1 --model-id convaiinnovations/laya --dtype auto
Expand Down
19 changes: 18 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct Args {
request_timeout_ms: u64,
#[arg(long, default_value_t = 1_048_576)]
max_request_bytes: usize,
#[arg(long)]
max_model_len: Option<usize>,
#[arg(long, value_enum, default_value_t = Precision::Auto)]
dtype: Precision,
}
Expand All @@ -72,6 +74,10 @@ impl Args {
self.max_request_bytes > 0,
"--max-request-bytes must be positive"
);
anyhow::ensure!(
self.max_model_len != Some(0),
"--max-model-len must be positive"
);
Ok(())
}
}
Expand Down Expand Up @@ -146,7 +152,7 @@ async fn main() -> anyhow::Result<()> {
path = %model_path.display(),
"loading model"
);
let model = models::load(&model_path, architecture, dtype)
let model = models::load(&model_path, architecture, dtype, args.max_model_len)
.with_context(|| format!("failed to load model from {}", model_path.display()))?;
info!(
model = %served_model_name,
Expand Down Expand Up @@ -236,6 +242,7 @@ mod tests {
assert_eq!(args.max_queue_size, 256);
assert_eq!(args.request_timeout_ms, 30_000);
assert_eq!(args.max_request_bytes, 1_048_576);
assert_eq!(args.max_model_len, None);
assert_eq!(args.dtype, Precision::Auto);
}

Expand All @@ -256,6 +263,16 @@ mod tests {
assert_eq!(args.dtype, Precision::Bf16);
}

#[test]
fn accepts_a_model_length_override() {
let args = Args::try_parse_from(["sys1", "--max-model-len", "8192"]).unwrap();
assert_eq!(args.max_model_len, Some(8192));
assert!(args.validate().is_ok());

let args = Args::try_parse_from(["sys1", "--max-model-len", "0"]).unwrap();
assert!(args.validate().is_err());
}

#[test]
fn rejects_two_model_sources() {
assert!(
Expand Down
Loading
Loading