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
3 changes: 1 addition & 2 deletions .github/actions/devkit-bench-acc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ description: >
output is non-zero when the gate fails, for the job's final gate, so the
other benches and the upload still run. Runs the scripts of scripts-dir
(the pull request's base) under clean_run.py: no token or GitHub variable
reaches flm. Ported from FastFlowLM_IRON's bench-acc and bench-vlm-acc
actions.
reaches flm.

inputs:
bench:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/devkit-bench-perf/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description: >
CSV, for the job's final gate. Runs the scripts of scripts-dir (a checkout
of .github/script at the pull request's base, so the pull request's own
edits do not measure it) under clean_run.py: no token or GitHub variable
reaches flm. Ported from FastFlowLM_IRON's bench-perf action.
reaches flm.

inputs:
flm-bin:
Expand Down
4 changes: 2 additions & 2 deletions .github/script/ci/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@
r"|.*~$)", # editor backups such as src/home_install.sh~
re.IGNORECASE)

# The FLM dev kit: kernel, engine, converter and pybind sources imported from
# FastFlowLM_IRON, built and tested by dev-kit jobs of their own. No product
# The FLM dev kit: kernel, engine, converter and pybind sources, built and
# tested by dev-kit jobs of their own. No product
# build reads them yet, so they select no product build or suite (a product
# change that starts consuming one must add it to the product rules here).
# Area -> the prefix that selects it, in output order.
Expand Down
111 changes: 111 additions & 0 deletions .github/script/ci/check_internal_refs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env python3
# Copyright © Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
# Portions of this file consist of AI-generated content.
"""Fail when a tracked file names internal repositories or process details.

check_internal_refs.py [--repo <root>]

The dev kit (flm-dev-kit/) came from a private development tree. Tracked files
must not name that tree, its pull requests, commits, branches or CI, internal
ticket IDs, personal paths, or NPU crash details (keep the engineering warning,
phrased generically). Every text file git tracks is scanned against PATTERNS;
binary files (a NUL byte in the first 8 KB) are skipped, as are the paths in
ALLOWED (each with its reason). "IRON" alone is not matched: it is also the
public mlir-aie Python API ("IRON Python", "IRON's object FIFOs"), so only the
forms that mean the repository are. Prints "check_internal_refs: error:
<path>:<line>: <pattern>: <text>" per hit and exits 1 when there is one.

Standard library and git only. Run by build-and-test.yml's changes job on
every event; its tests are test_check_internal_refs.py.
"""

from __future__ import annotations

import argparse
import re
import subprocess
import sys
from pathlib import Path
from typing import Optional

REPO_ROOT = Path(__file__).resolve().parents[3]

# name -> pattern. Narrow on purpose: a hit should always be worth fixing.
PATTERNS = {
"internal repository": re.compile(r"FastFlowLM_IRON|\bFLM_IRON\b|AMD-ROCm-Internal", re.IGNORECASE),
"internal ticket": re.compile(r"\bSCL-\d+"),
"internal PR or issue": re.compile(r"\bIRON\s*#\d+|\bIRON PR\b"),
"internal commit or branch": re.compile(r"\bIRON\s+`?[0-9a-f]{7,40}\b|\bIRON (?:HEAD|CI)\b|\bIRON tree\b"),
"internal CI or tooling": re.compile(r"\bIRON's (?:CI|local|wheel-aie-env|ironenv|bench-models|walk-up)\b"),
"internal process": re.compile(r"\bPhase 2b exclusion\b|\b(?:pending|for an?) Legal (?:review|decision)\b"),
"crash details": re.compile(r"\bbugcheck\b|VIDEO_SCHEDULER_INTERNAL_ERROR", re.IGNORECASE),
# /scratch/$USER, $(USER) and ${USER} are generic; a literal name is not.
"personal path": re.compile(r"/scratch/(?!\$\(USER\)|\$\{?USER\b)[A-Za-z0-9_.-]+"),
}

# path -> why it may contain the patterns.
ALLOWED = {
".github/script/ci/check_internal_refs.py": "defines the patterns",
}

BINARY_PROBE = 8192


def scan_text(text: str) -> list[tuple[int, str, str]]:
"""(line number, pattern name, matched text) for every hit in text."""
hits = []
for number, line in enumerate(text.splitlines(), 1):
for name, pattern in PATTERNS.items():
match = pattern.search(line)
if match:
hits.append((number, name, match.group(0)))
return hits


def tracked_files(repo: Path) -> Optional[list[str]]:
try:
out = subprocess.run(["git", "-C", str(repo), "ls-files", "-z"], check=True,
capture_output=True).stdout
except (OSError, subprocess.CalledProcessError):
return None
return [p for p in out.decode("utf-8", "surrogateescape").split("\0") if p]


def scan_repo(repo: Path) -> tuple[list[str], int]:
"""(errors, files scanned) for the files git tracks in repo."""
files = tracked_files(repo)
if files is None:
return [f"{repo}: git ls-files failed"], 0
errors = []
scanned = 0
for rel in files:
if rel in ALLOWED:
continue
try:
data = (repo / rel).read_bytes()
except OSError:
continue # deleted in the work tree, or a submodule
if b"\0" in data[:BINARY_PROBE]:
continue
scanned += 1
for number, name, found in scan_text(data.decode("utf-8", "replace")):
errors.append(f"{rel}:{number}: {name}: {found}")
return errors, scanned


def main(argv: Optional[list[str]] = None) -> int:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--repo", type=Path, default=REPO_ROOT)
args = parser.parse_args(argv)
errors, scanned = scan_repo(args.repo)
for err in errors:
print(f"check_internal_refs: error: {err}")
if errors:
print(f"check_internal_refs: {len(errors)} hit(s); reword them (see the docstring)", file=sys.stderr)
return 1
print(f"check_internal_refs: ok ({scanned} text files)")
return 0


if __name__ == "__main__":
sys.exit(main())
2 changes: 1 addition & 1 deletion .github/script/ci/devkit_assemble_xclbins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
merged. For every model of flm-dev-kit/FLM_Xclbin/kernel_assignment.json,
each {<slot>.xclbin: artifact} whose artifact was built is copied to
<out>/<model folder>/<slot>.xclbin, as FastFlowLM's xclbins/ tree lays them
out. Ported from FastFlowLM_IRON's assemble-xclbins action: of an
out. Of an
artifact's .xclbin files, the one named <slot>.xclbin is taken (a unit that
builds several designs names each after the slot it fills); otherwise the
only one, and an artifact with several and none of that name is ambiguous
Expand Down
10 changes: 5 additions & 5 deletions .github/script/ci/devkit_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
third-party notice ("Copyright (c)", "Copyright ©",
"Copyright <year>" or an SPDX line) or a "Generated by ... Do
not edit" first line passes, as AGENTS.md's notice rules give
those no AMD notice. NOTICE_HELD lists the files SCL-5105
holds without any notice, each with its reason
those no AMD notice. NOTICE_HELD lists the files held
without any notice pending review, each with its reason

Standard library only.
"""
Expand Down Expand Up @@ -121,12 +121,12 @@
THIRD_PARTY_NOTICE = re.compile(r"Copyright\s*(?:\(c\)|©|\d{4})|SPDX-(?:License-Identifier|FileCopyrightText):",
re.IGNORECASE)
GENERATED = re.compile(r"\bGenerated by\b.*\bDo not edit\b", re.IGNORECASE)
# Files SCL-5105 holds without any notice (path -> reason). A held file is
# Files held without any notice pending review (path -> reason). A held file is
# reported as a note, not an error; drop it here once its notice lands.
NOTICE_HELD = {
f"{DEVKIT}/FLM_Xclbin/Gemma4/test_top.py":
"the Gemma 4 model-card example (Hugging Face transformers usage); SCL-5105 holds it "
"without a notice (Phase 2b exclusion candidate, kept held in IRON 867542752)",
"the Gemma 4 model-card example (Hugging Face transformers usage); kept without a "
"notice pending review",
}
VENDORED = (f"{DEVKIT}/FLM_DLL/include/nlohmann/", f"{DEVKIT}/FLM_DLL/include/aiebu/",
f"{DEVKIT}/FLM_DLL/external_libs/", f"{DEVKIT}/FLM_Xclbin/host_common/aiebu/")
Expand Down
2 changes: 1 addition & 1 deletion .github/script/ci/devkit_symbol_clash.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
after checking that it is the same in every library.

Run by devkit-engines.yml on flm-dev-kit/FLM_DLL/build/lib (Linux XRT and
HRX). Ported from the internal FLM_IRON CI. Standard library and binutils' nm.
HRX). Standard library and binutils' nm.
"""
import argparse
import collections
Expand Down
6 changes: 3 additions & 3 deletions .github/script/ci/devkit_xclbin_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"touched_models": [<kernel_assignment.json models using a built artifact>],
"bench_models": [<the models worth benching: see below>]}

bench_models, as FastFlowLM_IRON's bench-models: in mode changed, the models
bench_models: in mode changed, the models
using a build selected because its source (or its build_units.json entry)
changed, plus the models whose kernel_assignment.json entry was added or
changed. A canary build, or one rebuilt only because a changed model uses
Expand Down Expand Up @@ -250,8 +250,8 @@ def builds(self) -> list[dict]:
def changed_plan(plan: Plan, files: list[str], base_units: dict[str, list],
base_assignment: Optional[dict], canary: list,
base_lock: Optional[str] = None, head_lock: Optional[str] = None) -> None:
# Units removed or renamed: their old paths select nothing (as IRON's
# walk-up, which found no Makefile there at head).
# Units removed or renamed: their old paths select nothing (a walk-up
# from them finds no Makefile at head).
gone = set(base_units) - set(plan.units)
for path in files:
if TOOLCHAIN.match(path) or DEVKIT_CI.match(path):
Expand Down
123 changes: 123 additions & 0 deletions .github/script/ci/test_check_internal_refs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Copyright © Advanced Micro Devices, Inc., or its affiliates. All rights reserved.
# Portions of this file consist of AI-generated content.
"""Tests for check_internal_refs.py: python3 -m unittest discover -s ci -p 'test_*.py' -t ci"""

from __future__ import annotations

import io
import subprocess
import sys
import tempfile
import unittest
from contextlib import redirect_stdout
from pathlib import Path

HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
import check_internal_refs as cir # noqa: E402

# Built from parts so that a grep of this file finds no whole example.
REPO = "FastFlowLM" + "_IRON"


def names(text: str) -> list[str]:
return [name for _, name, _ in cir.scan_text(text)]


class ScanTextTest(unittest.TestCase):
def test_internal_forms_hit(self):
cases = {
f"imported from {REPO}": "internal repository",
"Ported from the internal FLM" + "_IRON CI.": "internal repository",
"github.com/AMD-ROCm-" + "Internal/x": "internal repository",
"SCL-" + "5105 holds it": "internal ticket",
"(As IRON" + "#148.)": "internal PR or issue",
"IRON" + " PR #137": "internal PR or issue",
"kept held in IRON" + " 0123abcd9": "internal commit or branch",
"it is in git at IRON" + " `2261dffc2`.": "internal commit or branch",
"rebuilt from IRON" + " HEAD": "internal commit or branch",
"built by IRON" + " CI": "internal commit or branch",
"the IRON" + " tree's quant_size.hpp": "internal commit or branch",
"the version IRON's" + " wheel-aie-env action pinned": "internal CI or tooling",
"(Phase 2b" + " exclusion candidate)": "internal process",
"is pending Legal" + " review": "internal process",
"ended in bug" + "check 0x0": "crash details",
"(VIDEO_SCHEDULER_" + "INTERNAL_ERROR)": "crash details",
"cp /scratch/" + "someone/models .": "personal path",
}
for text, name in cases.items():
with self.subTest(text=text):
self.assertIn(name, names(text))

def test_public_iron_and_generic_paths_pass(self):
for text in (
"the IRON Python design in iron/attn_aie.py",
"IRON's task API and IRON's allocator",
"IRON's object FIFOs; the IRON `runtime_sequence`; the IRON `init=` value",
"IRON → MLIR → aiecc.py",
"IRON CT[r][c] = (col c, row r+2)",
"built on [IRON](https://github.com/amd/iron)",
"export FLM_MODEL_PATH=\"/scratch/$USER\"",
"REFERENCE ?= /scratch/$(USER)/ref.safetensors",
"prefix ${USER}: /scratch/${USER}/flm_exe_core",
"Legal notices are in THIRD_PARTY_NOTICES.txt",
):
with self.subTest(text=text):
self.assertEqual(names(text), [])

def test_line_numbers(self):
hits = cir.scan_text("ok\nfrom " + REPO + "\nok\n")
self.assertEqual([(n, name) for n, name, _ in hits], [(2, "internal repository")])

def test_allowed_paths_exist(self):
root = HERE.parents[2]
for rel, reason in cir.ALLOWED.items():
with self.subTest(path=rel):
self.assertTrue((root / rel).is_file())
self.assertTrue(reason)


class ScanRepoTest(unittest.TestCase):
def setUp(self):
self._tmp = tempfile.TemporaryDirectory()
self.repo = Path(self._tmp.name)
subprocess.run(["git", "init", "-q", str(self.repo)], check=True)

def tearDown(self):
self._tmp.cleanup()

def add(self, rel: str, data: bytes):
path = self.repo / rel
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(data)
subprocess.run(["git", "-C", str(self.repo), "add", rel], check=True)

def test_hits_binary_allowed_and_untracked(self):
self.add("docs/a.md", f"line\nsee {REPO}\n".encode())
self.add("img.bin", b"\0\1" + REPO.encode())
self.add(".github/script/ci/check_internal_refs.py", REPO.encode())
(self.repo / "untracked.md").write_text(REPO)
errors, scanned = cir.scan_repo(self.repo)
self.assertEqual(errors, [f"docs/a.md:2: internal repository: {REPO}"])
self.assertEqual(scanned, 1)
out = io.StringIO()
with redirect_stdout(out):
self.assertEqual(cir.main(["--repo", str(self.repo)]), 1)
self.assertIn("check_internal_refs: error: docs/a.md:2:", out.getvalue())

def test_clean_repo_passes(self):
self.add("README.md", b"IRON Python kernels, /scratch/$USER/x\n")
out = io.StringIO()
with redirect_stdout(out):
self.assertEqual(cir.main(["--repo", str(self.repo)]), 0)
self.assertIn("ok (1 text files)", out.getvalue())

def test_not_a_repo(self):
with tempfile.TemporaryDirectory() as plain:
errors, scanned = cir.scan_repo(Path(plain) / "missing")
self.assertEqual(scanned, 0)
self.assertEqual(len(errors), 1)


if __name__ == "__main__":
unittest.main()
2 changes: 0 additions & 2 deletions .github/script/devkit-bench/acc_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Portions of this file consist of AI-generated content.
"""Shared plumbing for the two dev-kit accuracy benches.

Ported from FastFlowLM_IRON's .github/scripts/acc-bench-common.

gsm8k_run.py (GSM8K) and run_vqa.py (DocVQA) both stream questions through
an already-running `flm serve` over /v1/chat/completions. They used to handle
a bad question differently -- GSM8K counted a request failure, DocVQA silently
Expand Down
2 changes: 0 additions & 2 deletions .github/script/devkit-bench/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Portions of this file consist of AI-generated content.
"""Comparisons and soft gates of the dev-kit benches (pure functions).

Adapted from FastFlowLM_IRON's .github/scripts/comparer-perf/compare.py and
comparer-acc/compare.py (which drew matplotlib plots and set no threshold);
report.py renders what these return.

Perf (flm bench CSVs: context_length_k, prefill/decoding avg tok/s, TTFT):
Expand Down
2 changes: 0 additions & 2 deletions .github/script/devkit-bench/docvqa_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Portions of this file consist of AI-generated content.
"""Build the DocVQA evaluation subset from a pinned public source.

Adapted from FastFlowLM_IRON's .github/scripts/vlm-acc-bench/build_dataset.py.

Runs on a GitHub-hosted runner (devkit-bench.yml's docvqa job), never on an
NPU runner: it downloads one validation shard of the Hugging Face dataset
lmms-lab/DocVQA at a pinned commit (REVISION), checks its SHA-256 and size
Expand Down
2 changes: 0 additions & 2 deletions .github/script/devkit-bench/gsm8k_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Portions of this file consist of AI-generated content.
"""Run the GSM8K accuracy bench against an already-running `flm serve` model.

Ported from FastFlowLM_IRON's .github/scripts/llm-acc-bench.

Streams the vendored GSM8K test questions (data/gsm8k_100.jsonl, the first
100 of the GSM8K test set; see THIRD_PARTY_NOTICES.txt) through
/v1/chat/completions, asks for step-by-step work ending in a fixed
Expand Down
2 changes: 0 additions & 2 deletions .github/script/devkit-bench/gsm8k_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Portions of this file consist of AI-generated content.
"""Accuracy for GSM8K predictions written by gsm8k_run.py.

Ported from FastFlowLM_IRON's .github/scripts/llm-acc-bench.

Accuracy = 100 * (# correct) / (# total). A question counts as correct when
the parsed final numeric answer exactly matches the reference answer.

Expand Down
2 changes: 0 additions & 2 deletions .github/script/devkit-bench/perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"""Runs `flm bench` for one model, on the dev-kit build and optionally on the
package it was overlaid on, back to back on the same runner.

Adapted from FastFlowLM_IRON's .github/scripts/bench-perf/bench-perf.sh.

perf.py --flm-bin <overlaid flm> [--base-flm-bin <unmodified flm>]
--model <tag> --out-dir <dir> [--ctx-len 8192]
[--timeout 3600] [--pull]
Expand Down
3 changes: 0 additions & 3 deletions .github/script/devkit-bench/run_acc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"""Runs one accuracy bench (GSM8K or DocVQA) for one model against its own
`flm serve`.

Adapted from the serve/poll/run/score/stop steps of FastFlowLM_IRON's
.github/actions/bench-acc and bench-vlm-acc.

run_acc.py --bench gsm8k|docvqa --flm-bin <flm> --model <tag>
--out-dir <dir> [--n 50] [--data eval.jsonl]
[--max-unanswered 5] [--time-budget-s 0]
Expand Down
Loading
Loading