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
11 changes: 11 additions & 0 deletions .github/actions/devkit-overlay-package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ inputs:
description: Comma-separated families whose engines to overlay (changes.py devkit-families; every family overlays every engine).
required: false
default: ""
engines:
description: >
engines.json choosing the engines to overlay, relative to the
workspace; empty for the checkout's flm-dev-kit/FLM_DLL/engines.json.
A dispatch benching an earlier run passes that run's commit's.
required: false
default: ""
new-models:
description: Comma-separated models the change adds (changes.py new-models), for the test selection outputs.
required: false
Expand Down Expand Up @@ -171,6 +178,7 @@ runs:
DEVKIT_XCLBIN_MODELS: ${{ inputs.xclbin-models || '[]' }}
FAMILIES: ${{ inputs.families }}
NEW_MODELS: ${{ inputs.new-models }}
ENGINES: ${{ inputs.engines }}
TARGET_OS: ${{ inputs.os }}
RUNTIME: ${{ inputs.runtime }}
run: |
Expand All @@ -184,6 +192,7 @@ runs:
--github-output)
[ -n "${LIBS}" ] && args+=(--libs "${GITHUB_WORKSPACE}/devkit-libs")
[ -n "${XCLBINS}" ] && args+=(--xclbins "${GITHUB_WORKSPACE}/devkit-xclbins")
[ -n "${ENGINES}" ] && args+=(--engines "${ENGINES}")
python3 .github/script/ci/devkit_overlay.py "${args[@]}"
echo "root=${root}" >> "$GITHUB_OUTPUT"

Expand All @@ -199,6 +208,7 @@ runs:
DEVKIT_XCLBIN_MODELS: ${{ inputs.xclbin-models || '[]' }}
FAMILIES: ${{ inputs.families }}
NEW_MODELS: ${{ inputs.new-models }}
ENGINES: ${{ inputs.engines }}
TARGET_OS: ${{ inputs.os }}
RUNTIME: ${{ inputs.runtime }}
run: |
Expand All @@ -213,6 +223,7 @@ runs:
"--families=$env:FAMILIES", "--new-models=$env:NEW_MODELS", '--github-output')
if ($env:LIBS) { $cmdArgs += "--libs=$(Join-Path $env:GITHUB_WORKSPACE 'devkit-libs')" }
if ($env:XCLBINS) { $cmdArgs += "--xclbins=$(Join-Path $env:GITHUB_WORKSPACE 'devkit-xclbins')" }
if ($env:ENGINES) { $cmdArgs += "--engines=$env:ENGINES" }
$env:PYTHONUTF8 = '1'
& python $cmdArgs
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Expand Down
59 changes: 48 additions & 11 deletions .github/script/ci/devkit_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
every system and runtime the run staged files into passed, that the pull
request is not from a fork, and that main gained no commit touching the
dev-kit engine or kernel sources or the prebuilt binaries since the run's
base (else merge main and let CI run again). Then it downloads the manifests
base (documentation there does not count, see main_moved; else merge main
and let CI run again). Then it downloads the manifests
and the artifacts holding the files that differ from the branch, checks
every file's size and SHA-256 against the manifests, writes them under
src/lib and src/xclbins, and makes ONE commit (no push) whose message ends
Expand All @@ -59,10 +60,10 @@
build of an engine, part of the kernels), the recorded run passes the
checks fetch makes (read with the job's token, actions: read: only the
small manifests are downloaded), main gained no dev-kit source or binary
change between the run's base and the pull request's base, and the pull
request changes none of SWAP_CI_PATHS (the code that stages, writes and
checks the manifests: it runs from the pull request's merge commit, so a
swap must not come with changes to it). The bytes are compared by git blob
change (documentation does not count) between the run's base and the pull
request's base, and the pull request changes none of SWAP_CI_PATHS (the
code that stages, writes and checks the manifests: it runs from the pull
request's merge commit, so a swap must not come with changes to it). The bytes are compared by git blob
id (the manifest records it beside the SHA-256; both hash exactly the
bytes), read from the trees alone, so the changes job's blob:none clone
downloads no binary. Prints the reasons and writes swap-verified=true|false
Expand Down Expand Up @@ -171,8 +172,25 @@

BINARY_ROOTS = ("src/lib/", "src/xclbins/")
# What a change on main since the run's base must not touch: the dev-kit
# engine and kernel sources and build inputs, and the binaries themselves.
# engine and kernel sources and build inputs, and the binaries themselves
# (main_moved: documentation under them, NON_CODE, does not count; anything
# under BINARY_ROOTS does).
SOURCE_PATHS = ("flm-dev-kit/FLM_DLL/", "flm-dev-kit/FLM_Xclbin/", "src/lib/", "src/xclbins/")
# changes.py's NON_CODE, copied rather than imported: verify runs the pull
# request's code, and changes.py is not in SWAP_CI_PATHS, so a pull request
# widening its NON_CODE would otherwise hide source commits on main from
# main_moved. test_devkit_swap pins the two equal.
NON_CODE = re.compile(
r"^(docs/"
r"|assets/" # README images and the like, at the repo root
r"|src/tb_files/"
r"|src/iceCream\.jpg$"
r"|\.github/ISSUE_TEMPLATE/"
r"|\.github/(PULL_REQUEST_TEMPLATE[^/]*|CODEOWNERS|FUNDING\.yml)$"
r"|(.*/)?\.gitignore$|\.mailmap$"
r"|.*\.md$"
r"|.*~$)", # editor backups such as src/home_install.sh~
re.IGNORECASE)
THIRD_PARTY = {k: v for k, v in devkit_check.CATALOG_ALLOW.items() if k.startswith("src/lib/")}


Expand Down Expand Up @@ -767,16 +785,33 @@ def check_recorded_run(api, repo: str, run_id: str, tested: str, pr: Pr, tmp: Pa
return RunCheck(run, manifests, entries, notes, errors)


def counts_for_swap(path: str) -> bool:
"""Whether a change to path (under SOURCE_PATHS) on main makes a run's
swap stale: every binary does, and every source or build input but
documentation (NON_CODE, changes.py's, so that the two agree)."""
return path.startswith(BINARY_ROOTS) or not NON_CODE.match(path)


def main_moved(git: Git, since: str, until: str) -> list[str]:
"""Commits on until since since that touch SOURCE_PATHS (a SwapError
when since is unknown here, or is no commit of until's history: a
run's base is a commit of main)."""
"""Commits on until since since that change a SOURCE_PATHS file that
counts_for_swap (a commit changing only documentation there does not
count; a SwapError when since is unknown here, or is no commit of
until's history: a run's base is a commit of main). Trees only (no
blob is read): a blob:none clone fetches nothing."""
if not git.rev(since):
raise SwapError(f"the run's base {since[:10]} is not in this clone: fetch main")
if not git.is_ancestor(since, until):
raise SwapError(f"the run's base {since[:10]} is not a commit of {until}")
out = git.run("rev-list", f"{since}..{until}", "--", *SOURCE_PATHS)
return out.split()
moved = []
for commit in git.run("rev-list", f"{since}..{until}", "--", *SOURCE_PATHS).split():
# -c: a merge lists the files it changed against every parent (what
# a side brought in is listed by the side's own commits); --root:
# a root commit lists its files.
out = git.run("diff-tree", "-r", "-c", "--root", "--no-commit-id", "--name-only", "-z",
commit, "--", *SOURCE_PATHS)
if any(counts_for_swap(p) for p in out.split("\0") if p):
moved.append(commit)
return moved


# ── verify ───────────────────────────────────────────────────────────────────
Expand All @@ -790,6 +825,8 @@ def main_moved(git: Git, since: str, until: str) -> list[str]:
# run from the pull request's merge commit). changes.py is not here: a new
# model family needs its engine table (ENGINES) and comes with its swap;
# what it decides runs from the pull request's code whatever this says.
# verify does not depend on it: main_moved uses this file's copy of its
# NON_CODE.
# npu_test's pr-tier table (plan.py PR_CHAT) needs no entry for a new
# family (it gets its smallest model), so a new model needs no harness edit.
SWAP_CI_PATHS = (
Expand Down
2 changes: 1 addition & 1 deletion .github/script/ci/test_devkit_assemble_xclbins.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_assemble(self):
# No xclbin built (m:9b), and ambiguous (m:amb): nothing for them.
self.assertFalse((out / "M-9B").exists())
self.assertFalse((out / "M-AMB").exists())
self.assertEqual(sorted(str(p.relative_to(out)) for p in out.rglob("*") if p.is_file()), [
self.assertEqual(sorted(p.relative_to(out).as_posix() for p in out.rglob("*") if p.is_file()), [
"M-1B/dequant.xclbin", "M-1B/layer.xclbin", "M-3B/dequant.xclbin",
"M-3B/vision_mm_a.xclbin", "M-3B/vision_mm_b.xclbin"])

Expand Down
Loading
Loading