# FastFlow SDK model qualification

The `fastflow-sdk` release wheel from PyPI includes qualification. For a development build, install the optional qualification product from the [FastFlow SDK package index](<https://rocm.github.io/FastFlow-SDK/wheel-releases/index.md#package-index>):

```
python -m pip install --extra-index-url https://rocm.github.io/FastFlow-SDK/simple \
  "fastflow-sdk-qualification==<version>"
```

Candidate-bound runs (`--candidate-manifest`) check each installed component wheel against the candidate, so they need these component packages rather than the PyPI wheel, which `fastflow qualify` rejects for them.

The package depends on the exact same-version `fastflow-sdk-fastflowlm`, which in turn depends on `fastflow-sdk-runtime`, and pins NumPy 2.5.3 and ml-dtypes 0.6.0. Pip resolves those binary dependencies from the package index. The candidate manifest binds their required versions, while each evidence bundle records the installed wheel tags, RECORD digest, and verified payload digest. Only the runtime wheel owns the `fastflow` entry point. The qualification wheel installs `fastflow-qualify`, discovered through the external plugin protocol. CI resolves Linux and Windows dependencies for every supported CPython ABI from the single numeric-runtime contract. Release assembly validates that complete dependency matrix without publishing the third-party wheels.

List and run profiles through the native core:

```
fastflow plugin list --json
fastflow qualify --list-profiles --json
fastflow qualify --output qualification-evidence
```

Profiles are package JSON data conforming to `profile-v1.schema.json`. With no profile option, qualification runs the comprehensive `default` suite: Qwen3 0.6B, content-pinned Qwen3.5 0.8B, and LFM2 1.2B multi-turn, bounded-soak, and 1k/4k benchmark cases. Its measured warm-cache NPU2 runtime is kept below 15 minutes. `--fast` runs the CI gate: five fresh Qwen3 processes with two deterministic turns each, the production XCLBIN inventory, the 1k benchmark/CSV checkpoint, native self-test, the native powermode set/query checks for `balanced`, `performance`, and `turbo` with baseline restore, and the embedded FastFlowLM XADX stress set. `--profile   extended` is an opt-in default-suite superset adding revision-pinned Llama 3.1 8B multi-turn, soak, and 1k/4k coverage, and a Qwen3.5 0.8B `vision`-kind test that sends a sequence of generated solid-colour images, up to 8k prompt tokens, through `flm serve` at original size, failing on HRX runtime errors, short prompts, or a wrong colour answer. Its Gemma 4 E2B soak serves `gemma4-open-it:e2b` through the `gemma4-open` model extension that the FastFlowLM wheel ships, so it covers the source-built engine rather than the prebuilt one. CI selects only `--fast`; default and extended are explicit qualification profiles for broader local or release validation.

`--all-models` runs a complete sweep over *every* model in the installed FastFlowLM registry instead of a curated profile. Models are discovered dynamically from `model_list.json` at runtime, so their per-file and XCLBIN digests are not pre-pinned (identity still comes from the registry URL: `/resolve/<revision>` pins an immutable revision, other URLs are content-sourced). Each chat model runs a single-prompt turn, a five-turn multi-turn conversation, and a benchmark/CSV checkpoint; embed and ASR models are exercised through a `flm serve` probe (`serve`-kind evidence). The benchmark stage defaults to 8k context (a three-iteration `bench_8k_smoke.json` sweep) and can be set to `1k`, `4k`, or `8k` with `--bench-context`. Per-model timeouts scale with the model footprint and with the benchmark context length, and the sweep implies `--keep-going` so one failing model does not abort the run. Because it is a dynamic diagnostic sweep rather than a pinned profile, `--all-models` is meant for broad local coverage and is not a candidate-bound release path.

`--bench` runs a measurement-only variant of the sweep. `MODE` selects the coverage; `--bench all` (the mode used when the flag is given bare) covers *every* model in the installed registry, but drops the correctness stages: chat models run *only* the on-NPU decode benchmark (no single-prompt or multi-turn turns), and embed/ASR models run *only* their serve-probe (the same encode-tok/s, RTF, and WER measurements the complete sweep records). It defaults to a `1k` context benchmark of five iterations; tune the context with `--bench-context <1k|4k|8k>` and the iteration count with `--bench-iterations <N>` (a positive integer). Pass `--models=<tag>[,<tag>...]` to narrow `--bench all` to an explicit subset of registry tags (tags absent from the installed registry are skipped with a warning); it has no effect without `--bench`. Like `--all-models`, `--bench` is a dynamic diagnostic sweep (not pinned, not candidate-bound) and implies `--keep-going`.

`--bench dev` is the fast development variant of `--bench all`. It runs the same measurement stages with the same `--bench-context`/`--bench-iterations` tuning and the same `--models` and `--xrt-flm` modifiers, but over a curated set of chat tags (including the large `gpt-oss` and `qwen3.6-moe` MoE; never embed/ASR) instead of the whole registry. Curated tags absent from the installed registry are skipped with a warning. `--models` then further restricts that curated set: an installed tag that is not curated is skipped as missing from the curated set, not as missing from the registry. The speedup is fewer FastFlowLM tags -- native checks and the XADX kernel recipe still run at the same soak depth as `--bench all` (5/20/32). `--bench` already drops functional chat stages; XADX is a separate envelope.

`--xrt-flm <path>` (meaningful with `--bench` or `--all-models`; Linux and Windows, requires a host XRT install) additionally exercises each model through an XRT-backed FastFlowLM build. `--bench` widens the report to a side-by-side HRX-vs-XRT metric comparison. `--all-models --xrt-flm` runs the single-prompt greedy chat on XRT and records an exact numerical match of `Model RAW Output` text. For chat models the benchmark table gains an XRT Status column plus XRT metric columns (`Model | XRT Status | XRT TTFT s | HRX TTFT s | XRT prefill tok/s | HRX prefill tok/s | XRT decode tok/s | HRX decode tok/s`); for embed/ASR models the Embedding and ASR probe tables gain XRT status and measurement columns (encode tok/s; RTF and WER). It is off by default -- simply supplying the path is what enables the comparison (there is no separate enable flag). Because the shipped wheel only bundles the HRX runtime, point `--xrt-flm` at a separately built XRT entrypoint (`bin/flm.exe` on Windows, `bin/flm` on Linux, or its FHS install root) produced by `python dev.py build fastflowlm-xrt`, which links the host XRT install discovered from `$XILINX_XRT`, the platform default (`/opt/xilinx/xrt` on Linux; Program Files or `C:\Xilinx\XRT` on Windows), or an XRT runtime already on `PATH`. Qualification sets `XILINX_XRT` and the loader path (`LD_LIBRARY_PATH` on Linux, `PATH` on Windows) only on that comparison child. XRT is strictly best-effort: the status column is `PASS`, `FAIL`, or `N/A` (unavailable build or host XRT); metric cells are `N/A` unless the comparison passed. Numerical-match cells are `MATCH`, `MISMATCH`, `FAIL`, or `N/A`. XRT never emits a separate test and never changes the run's pass/fail (so a fully passing HRX sweep still passes even when XRT is unavailable, fails, or mismatches). An unresolved `--xrt-flm` still stamps `unavailable` on every model so the XRT columns remain.

In addition to the machine-readable bundle, the `--all-models` and `--bench` sweeps write a human-readable `report.md` into the output directory. It contains an environment header (OS, NPU device/driver/firmware candidates, target family, FLM and package versions), a per-model functional matrix (single-prompt, five-turn multi-turn, and whether the multi-turn run passed) where those turns ran, and an on-NPU benchmark table with the FLM-averaged TTFT, prefill, and decode throughput for each model. By default only HRX numbers are reported. The context stage and the iteration count the averages span (for example `HRX, 8k, averaged over 3 iterations`) are stated in the benchmark section heading rather than repeated per row. Profile runs (`--fast`, `--profile`) do not emit `report.md`; they produce only the evidence bundle (`evidence.json`, `tests.json`, `junit.xml`, and the summary).

Qualification first validates plugin protocol and exact package versions, then runs native `version`, `probe`, `doctor`, and `self-test` through the absolute executable provided by the core. After those passive native checks pass, it records the baseline NPU powermode. On non-Linux hosts, qualification sets and queries back `balanced`, `performance`, and `turbo`, restores the baseline mode, and queries again. On Linux, qualification skips the mutating roundtrip by default because current AMDXDNA drivers require root privileges for power-mode sets; the passive `powermode` report still has to pass and is written as `artifacts/native/powermode-before.json`. It inspects the configured model cache and runs `flm pull <tag>` when a model is missing. Pull and test output is captured in the evidence logs. `--no-pull` fails instead of downloading. `--offline` never invokes the network-backed `flm check` or `flm pull`. It resolves the model-specific directory and required files from the installed registry, applies offline and proxy-denial controls to inference, and fails if that local contract is incomplete.

Linux powermode roundtrip records appear as `unsupported` in `tests.json` and as skipped in `junit.xml`; this is the only native skip that can coexist with an overall passing qualification run. Use `fastflow powermode <mode>` manually, or run a non-Linux qualification host, when the mutating roundtrip itself must be exercised.

The output directory is a complete report bundle. `evidence.json` records the overall result, package and candidate identity, source revision, observed driver/firmware/platform provenance, content-pinned model inventories, and every native, XADX, run, soak, and benchmark result. Successful native checks are recorded as tests, not merely omitted. `junit.xml` mirrors test outcomes; `core-version.json`, `probe.json`, `doctor.json`, `self-test.json`, `artifacts/native/powermode-*.json`, benchmark CSVs, per-command logs, and `SHA256SUMS` retain the underlying details.

Useful options include:

- `--model-cache <path>`
- `--candidate-manifest <path>`
- `--keep-going`
- `--bench-context <1k|4k|8k>` (with `--bench` or `--all-models`; default `1k` for `--bench`, `8k` for `--all-models`)
- `--bench [all|dev]` (measurement-only sweep; `all` covers the whole registry, `dev` a curated set of chat tags)
- `--bench-iterations <N>` (decode-benchmark iterations per chat model for `--bench`; a positive integer, default `5`)
- `--models <tag>[,<tag>...]` (restrict a `--bench` or `--all-models` sweep to explicit tags; with `dev`, further restricts the curated set; ignored without `--bench` or `--all-models`)
- `--xrt-flm <path>` (with `--bench` or `--all-models`; Linux and Windows; add a best-effort HRX-vs-XRT comparison against a host XRT install, including greedy numerical match on the `--all-models` single-prompt run; off by default)
- `--json`

Profiles support ad-hoc diagnostics and candidate-bound release runs. Packaged profiles pin a canonical-JSON model registry digest and model file digests; the qualification wheel also contains a 53-case NPU2 kernel recipe covering seven distinct production implementations plus explicit execution variants. Those XADX executables embed the production XCLBIN and serialized control transactions. Inputs and expected outputs are generated deterministically at runtime from the qualification-owned capability contract. Reports bind the exact per-case dispatch/readback schedule, validated byte count, and deduplicated materialization inventory. Default 32x256 Q4NX parity is converter-backed; 32x128 and 16x128 are measured-fact C++/Python interpreter agreement, with the 53-case device run serving as the independent authority. See the [qualification evidence v1 contract](<https://rocm.github.io/FastFlow-SDK/contracts/qualification-evidence-v1/index.md>) for the exact identity, archive, and verification rules.

## Detached evidence collection and intake

Linux publishes the canonical `py3-none-any` qualification wheel. Windows independently generates the same wheel. While Linux artifact scheduling is constrained, Windows NPU jobs install that Windows-local wheel; those runs validate the platform build but do not replace canonical candidate evidence. When a canonical artifact is explicitly supplied, the Windows workflow first matches normalized case, source-XCLBIN, transaction, serializer, and XADX hashes. Release assembly creates one candidate from all Linux and Windows runtime/FastFlowLM wheels and the canonical wheel:

```
fastflow qualify candidate \
  --wheel-dir candidate/wheels \
  --output candidate/candidate-manifest.json \
  --expected-source-revision <full-commit> --json
```

The command infers the source revision from every wheel and rejects disagreement. It writes the strict candidate v1 `candidate-manifest.json` plus `candidate-SHA256SUMS`; the manifest and all FastFlow SDK wheels must share one artifact root. Transfer that complete release-wide candidate artifact to every manual hardware machine without rebuilding or selecting only one platform's identities. Treat `candidate-SHA256SUMS` as the publication commit marker: consumers must require it and verify every listed path before using `candidate-manifest.json`.

Collect and seal one run in a single command:

```
fastflow qualify run \
  --candidate-manifest candidate/candidate-manifest.json \
  --model-cache <cache> \
  --output-dir machine-run \
  --bundle-output machine-run.evidence.zip --json
```

The directory remains available for diagnosis. Finalized pass, fail, and interrupted directories can also be sealed later with:

```
fastflow qualify pack \
  --input machine-run --output machine-run.evidence.zip --json
```

ZIP output is deterministic and contains the finalized evidence files exactly as covered by the internal `SHA256SUMS`. Verify transferred evidence without NPU hardware, the core plugin environment, network access, or repository build tools:

```
fastflow qualify verify \
  --input machine-run.evidence.zip \
  --candidate-manifest candidate/candidate-manifest.json --json
```

Verification applies the archive, candidate, profile, model, platform-probe, execution-inventory, and checksum rules defined by the evidence contract.

After transferring independently collected machine bundles into one directory, assemble release intake with:

```
fastflow qualify intake \
  --input-dir incoming \
  --candidate-manifest candidate/candidate-manifest.json \
  --output-dir assembled \
  --bundle-output qualification-evidence-<version>.zip \
  --policy release --require-status pass --json
```

Intake re-verifies every original bundle, preserves it unchanged under its SHA256 name, rejects duplicates and mixed/ad-hoc candidates, writes the versioned `qualification-index.json` and aggregate `SHA256SUMS`, then emits a deterministic aggregate ZIP and an external `qualification-evidence-<version>.zip.sha256`. The checked-in `release` policy requires passing NPU2 `fast` evidence from both Windows and Linux and records the matched run digests in the index. Verify the final asset itself with:

```
fastflow qualify verify \
  --input qualification-evidence-<version>.zip \
  --candidate-manifest candidate/candidate-manifest.json --json
```

Artifact transfer and publication remain manual. See [wheel releases](<https://rocm.github.io/FastFlow-SDK/wheel-releases/index.md>) for the operator flow; rebuilding any candidate wheel invalidates all collected evidence.

Stage the flat GitHub-upload directory from the CI release payload plus intake outputs. The command copies exactly the product files listed in payload `SHA256SUMS` (including `SHA256SUMS` itself), the separate `candidate-manifest.json` / `candidate-SHA256SUMS` pair, ignores nested trees such as `simple/`, adds the aggregate ZIP, its `.sha256` sidecar, and `qualification-index.json`, re-verifies the aggregate, and fails if anything is missing or unexpected. The aggregate basename must be `qualification-evidence-<version>.zip`, and `--output-dir` must be empty (or absent), matching intake:

```
fastflow qualify stage-release \
  --payload-dir release \
  --aggregate qualification-evidence-<version>.zip \
  --index assembled/qualification-index.json \
  --output-dir github-upload \
  --json
```

Upload every top-level file from `github-upload/` to the draft release.

For a shared cache across worktrees:

```
$cache = 'C:\path\to\fastflow-sdk\.cache\FastFlowLM-models'
fastflow qualify --model-cache $cache --output qualification-evidence
fastflow qualify --profile extended --model-cache $cache --output extended-evidence
fastflow qualify --all-models --model-cache $cache --output all-models-evidence
fastflow qualify --all-models --bench-context 1k --model-cache $cache --output all-models-1k-evidence
fastflow qualify --bench all --model-cache $cache --output bench-all-evidence
fastflow qualify --bench all --bench-context 4k --bench-iterations 20 --model-cache $cache --output bench-all-4k-evidence
# HRX-vs-XRT comparison against a host XRT install (Linux and Windows)
# fastflow qualify --bench all --xrt-flm C:\path\to\build\FastFlowLM-xrt-install --model-cache $cache --output bench-all-xrt-evidence
# fastflow qualify --all-models --models=qwen3:0.6b,llama3.2:1b --bench-context 1k --xrt-flm C:\path\to\build\FastFlowLM-xrt-install --model-cache $cache --output all-models-xrt-evidence
fastflow qualify --bench dev --model-cache $cache --output bench-dev-evidence
fastflow qualify --offline --no-pull --model-cache $cache --output offline-evidence
```

On Linux, use the equivalent absolute path. `FLM_MODEL_PATH` may be set instead of passing `--model-cache`.

Diagnostics answer whether the package and bounded native dispatch work. Qualification executes profile-defined installed-product model cases and produces structured evidence. Release acceptance is a later policy and signing decision; a passing evidence bundle does not publish or accept a release by itself.
