Repository navigation
122 lines (101 loc) · 3.99 KB
/
Copy pathdeploy.yml
File metadata and controls
122 lines (101 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Build model and deploy to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
inputs:
variants:
description: "Model builds to publish (comma separated: qdq8, q8e8, q4e8)"
default: "q8e8,q4e8"
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
env:
VARIANTS: ${{ inputs.variants || 'q8e8,q4e8' }}
HF_MODEL_REPO: ${{ vars.HF_MODEL_REPO }}
# Optional second checkpoint (e.g. convaiinnovations/laya-typed-decisions), built and uploaded by the
# separate deploy-typed.yml workflow. This workflow never builds it -- it only links to it if present,
# so a Pages deploy here never waits on or fails because of the typed-decisions build.
HF_MODEL_REPO_TYPED: ${{ vars.HF_MODEL_REPO_TYPED }}
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: requirements-build.txt
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
# Cache keys cannot contain commas, so turn q8e8,q4e8 into q8e8-q4e8.
- name: Cache key for the variant list
run: echo "VARIANTS_KEY=${VARIANTS//,/-}" >> "$GITHUB_ENV"
# The converted model is rebuilt only when the conversion code, its pinned dependencies or the variant list change.
- name: Restore converted model
id: model-cache
uses: actions/cache@v4
with:
path: |
build/model
build/verify_report.md
build/verify_report.json
key: laya-model-${{ hashFiles('scripts/build_model.py', 'requirements-build.txt') }}-${{ env.VARIANTS_KEY }}
- name: Install Python dependencies
if: steps.model-cache.outputs.cache-hit != 'true'
run: pip install -r requirements-build.txt
- name: Convert and quantize the model
if: steps.model-cache.outputs.cache-hit != 'true'
run: python scripts/build_model.py --variants "$VARIANTS"
- name: Check the converted model against PyTorch
if: steps.model-cache.outputs.cache-hit != 'true'
run: python scripts/verify_model.py
- name: Install web dependencies
run: npm ci
- name: Check the JavaScript port builds identical token sequences
run: node tests/seq_parity.mjs
- name: Assemble a full local copy of the site for testing
run: node scripts/prepare_site.mjs --out dist-test
- name: Browser smoke test (headless Chromium, WASM)
env:
SMOKE_DIST: dist-test
run: |
pip install playwright
python -m playwright install --with-deps chromium
python tests/browser_smoke.py
# Optional: keep the model on Hugging Face instead of inside the Pages site.
# Set the repository variable HF_MODEL_REPO (for example yourname/laya-en-web) and the secret HF_TOKEN (write access).
- name: Upload the model to Hugging Face
if: env.HF_MODEL_REPO != ''
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
pip install huggingface_hub
python scripts/upload_to_hf.py "$HF_MODEL_REPO"
- name: Assemble the site to deploy
run: |
ARGS=()
if [ -n "$HF_MODEL_REPO" ]; then ARGS+=(--external-model-base "https://huggingface.co/${HF_MODEL_REPO}/resolve/main/"); fi
if [ -n "$HF_MODEL_REPO_TYPED" ]; then ARGS+=(--external-model-base-typed "https://huggingface.co/${HF_MODEL_REPO_TYPED}/resolve/main/"); fi
node scripts/prepare_site.mjs "${ARGS[@]}"
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4