diff --git a/.crumb b/.crumb new file mode 100644 index 0000000..5729cee --- /dev/null +++ b/.crumb @@ -0,0 +1,31 @@ +{ + "schema_version": "1.0.0", + "name": "openaccel-lab", + "layer": "tooling", + "path": "aien-dev/openaccel-lab", + "purpose": "Vendor-neutral, execution-verified conformance and performance lab for accelerator kernels: one float64 reference and written tolerance per workload, identical seeded inputs for every entrant (OpenCL C, Triton, HIP, CUDA, Omega), wrong-kernel controls that must be flagged, distribution-only timings, and a GitHub Pages board. CPU evidence on CI; GPU rows only as labelled receipts.", + "creator": "AIEN (lane OpenAccelLab)", + "created_at": "2026-10-27T02:30:00Z", + "lineage": { + "parent": [ + "aien-dev/omega-gpu-bench@be6e65acafa9f75e705a308100bc5ddec8bfaa66", + "aien-dev/omega-kernel-template@23a04c9fbe8a2e47ff86deaa1c537960f8986158", + "aien-dev/omega-mv@369dbc96daa1684db2d7c2c7085bbf16b3fd77ee" + ], + "generation": 1 + }, + "invariants": [ + "A control that passes on any backend fails the gate.", + "Every entrant of a workload receives byte-identical input (case_sha256 must agree across runners).", + "Timings are reported as distributions with sample counts, never means; CPU timings are labelled not-GPU.", + "NOT_RUN, NO_SOURCE and COMPILED are never counted as PASS.", + "No NVIDIA binary, SASS or generated machine artifact is inspected or translated; entrants are source only." + ], + "whispers": [ + { + "agent": "OpenAccelLab", + "timestamp": "2026-10-27T02:30:00Z", + "message": "Created from the deep-research report's OpenAccel Lab recommendation; Omega is one entrant, not the referee." + } + ] +} diff --git a/.github/workflows/lab.yml b/.github/workflows/lab.yml new file mode 100644 index 0000000..e434082 --- /dev/null +++ b/.github/workflows/lab.yml @@ -0,0 +1,155 @@ +# OpenAccel Lab: run every workload and control on every entrant that a free GitHub runner can host, +# judge them against one reference, fail on any entrant failure or any control that passes, and +# publish the board to GitHub Pages. No GPU is used here; GPU rows enter only as labelled receipts. +name: OpenAccel Lab + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + schedule: + - cron: "17 5 * * 1" + +permissions: + contents: read + +concurrency: + group: lab-${{ github.ref }} + cancel-in-progress: true + +jobs: + run: + name: ${{ matrix.backend }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + include: + - { os: ubuntu-24.04-arm, backend: omega } + - { os: ubuntu-24.04-arm, backend: opencl } + - { os: ubuntu-24.04-arm, backend: triton } + - { os: ubuntu-24.04-arm, backend: hip } + - { os: ubuntu-24.04, backend: opencl } + - { os: ubuntu-24.04, backend: triton } + - { os: ubuntu-24.04, backend: hip } + - { os: ubuntu-24.04, backend: cuda } + env: + OAL_RUNNER_LABEL: gh-${{ matrix.os }} + TRITON_INTERPRET: "1" + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install Ubuntu packages + run: | + sudo apt-get update -qq + case "${{ matrix.backend }}@${{ matrix.os }}" in + opencl@ubuntu-24.04-arm) pk="clang-18 libllvm18 libllvmspirvlib18.1 ocl-icd-libopencl1 ocl-icd-opencl-dev" ;; + opencl@ubuntu-24.04) pk="pocl-opencl-icd ocl-icd-libopencl1 ocl-icd-opencl-dev" ;; + hip@*) pk="libtbb-dev g++ perl" ;; + cuda@*) pk="nvidia-cuda-toolkit" ;; + *) pk="" ;; + esac + [ -z "$pk" ] || sudo apt-get install -y -qq --no-install-recommends $pk + + - name: Install Python packages + run: | + python3 -m pip install --user --break-system-packages -q numpy==2.5.4 + case "${{ matrix.backend }}" in + opencl) python3 -m pip install --user --break-system-packages -q pyopencl==2026.1.4 ;; + triton) python3 -m pip install --user --break-system-packages -q triton==3.8.0 torch==2.14.1 \ + --extra-index-url https://download.pytorch.org/whl/cpu ;; + esac + + - name: Fetch pinned toolchain (sha256-checked) + run: | + case "${{ matrix.backend }}@${{ matrix.os }}" in + omega@*) sh tools/fetch.sh omega ;; + opencl@ubuntu-24.04-arm) sh tools/fetch.sh pocl; echo "OCL_ICD_VENDORS=$PWD/.oal/icd" >> "$GITHUB_ENV" ;; + hip@*) sh tools/fetch.sh hip ;; + esac + + - name: Run matrix + run: | + mkdir -p out + python3 bin/oal-matrix --backends ${{ matrix.backend }} --controls --seeds 1,2,3 \ + > "out/results-${{ matrix.backend }}-${{ matrix.os }}.jsonl" + wc -l out/*.jsonl + + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: always() + with: + name: results-${{ matrix.backend }}-${{ matrix.os }} + path: out/ + if-no-files-found: error + + gate: + name: gate + board + needs: run + if: always() + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + env: + TRITON_INTERPRET: "1" + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: results-* + path: out + merge-multiple: true + - name: Install Python packages + run: python3 -m pip install --user --break-system-packages -q numpy==2.5.4 + - name: Fetch Omega compiler (for shrinking Omega failures) + run: sh tools/fetch.sh omega + - name: Every expected runner reported + run: | + ls -l out + test "$(ls out/results-*.jsonl | wc -l)" -eq 8 + - name: Minimise Omega failures and record control verdicts + run: | + mkdir -p site out/shrink + python3 - <<'EOF' > out/shrink/todo.txt + import json, glob + seen = set() + for p in glob.glob("out/results-*.jsonl"): + for l in open(p): + r = json.loads(l) + if r["backend"] == "omega" and r["status"] == "FAIL" and r["workload"] not in seen: + seen.add(r["workload"]) + print(r["workload"], r["seed"], " ".join("--set %s=%s" % kv for kv in r["params"].items())) + EOF + : > out/results.shrink.jsonl + while read -r w s rest; do + [ -n "$w" ] || continue + python3 bin/oal-shrink omega "$w" --seed "$s" >> out/results.shrink.jsonl || true + done < out/shrink/todo.txt + wc -l out/results.shrink.jsonl + - name: Build board + if: always() + run: | + python3 bin/oal-board out/results-*.jsonl out/results.shrink.jsonl > site/data.json + cat out/results-*.jsonl > site/results.jsonl + - name: Gate (controls must fail, entrants must pass, >= 3 backends per workload) + shell: bash + run: python3 bin/oal-gate --min-backends 3 out/results-*.jsonl | tee -a "$GITHUB_STEP_SUMMARY" + - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 + if: always() && github.ref == 'refs/heads/main' + with: + path: site/ + + pages: + name: publish board + needs: gate + if: always() && github.ref == 'refs/heads/main' && needs.gate.result != 'skipped' + runs-on: ubuntu-24.04 + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deploy.outputs.page_url }} + steps: + - id: deploy + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54bf7e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.oal/ +__pycache__/ +*.pyc +site/data.json +site/results.jsonl +out/ diff --git a/.goals.json b/.goals.json new file mode 100644 index 0000000..e584318 --- /dev/null +++ b/.goals.json @@ -0,0 +1,58 @@ +{ + "project_name": "OpenAccel Lab", + "goals": [ + { + "id": "goal-conformance", + "title": "25 workloads, >=3 backends each, controls flagged, in CI", + "status": "Active", + "milestones": [ + { + "id": 1, + "description": "Case container, reference oracle, tolerance contract, five entrant runners", + "completed": true + }, + { + "id": 2, + "description": "25 workloads + 6 controls authored for all entrants", + "completed": true + }, + { + "id": 3, + "description": "CI on ubuntu-24.04-arm and ubuntu-24.04 green with every control flagged", + "completed": true + }, + { + "id": 4, + "description": "Board published on GitHub Pages", + "completed": false + } + ], + "created_at": "2026-10-27T02:30:00Z", + "updated_at": "2026-10-27T02:30:00Z" + }, + { + "id": "goal-gpu", + "title": "Labelled GPU receipts", + "status": "Active", + "milestones": [ + { + "id": 1, + "description": "Import omega-gpu-bench rented-GPU receipts with sha256", + "completed": true + }, + { + "id": 2, + "description": "CUDA entrant on GB10 under the GPU lock, QUALIFIED-on-GB10 candidate", + "completed": false + }, + { + "id": 3, + "description": "Rented AMD/Intel GPU rows for HIP and OpenCL entrants", + "completed": false + } + ], + "created_at": "2026-10-27T02:30:00Z", + "updated_at": "2026-10-27T02:30:00Z" + } + ] +} diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md new file mode 100644 index 0000000..b860f29 --- /dev/null +++ b/DEPENDENCIES.md @@ -0,0 +1,39 @@ +# Dependencies + +Everything below is outside code the lab runs. Entrant toolchains are the thing being measured, +so they are kept; the host glue is INTERIM and each piece names its Omega successor. + +## INTERIM host glue (first-party, to be replaced by seeded Omega) + +| file | language | job | Omega successor | +|---|---|---|---| +| `bin/oal-gen`, `oal/case.py`, `oal/manifest.py` | Python 3.12 | build the case container from a manifest and seed | `oal-gen` unit: splitmix64 and FNV-1a are integer-only and already expressible in seeded Omega | +| `bin/oal-check`, `oal/check.py`, `oal/ref.py`, `workloads/*/reference.py` | Python + numpy | float64 reference and tolerance check | `oal-check` unit with float64 references written in Omega; numpy stays only as an independent cross-check oracle | +| `bin/oal-run`, `oal/run.py`, `bin/oal-matrix`, `oal/matrix.py` | Python | build and launch entrants, write result lines | `oal-run` unit once seeded Omega has a process-spawn word | +| `bin/oal-gate`, `bin/oal-shrink`, `bin/oal-board` | Python + numpy | gate, minimise failures, fold the board data | Omega units over JSON lines | +| `oal/entrants/opencl.py` | Python + pyopencl | OpenCL host program | the OpenCL host path in aien-dev/omega-mv `seed/spirv/` | +| `oal/entrants/triton.py` | Python | Triton launcher (Triton is a Python DSL; this stays as long as Triton is an entrant) | none needed: it is the entrant's own host language | +| `runners/cuda/host.cu` | CUDA C++ | CUDA and HIP host program (also hipified for HIP) | stays C++: it is the CUDA/HIP entrant's own host language | +| `tools/fetch.sh`, `runners/cuda/run_all.sh` | POSIX sh | fetch pinned tools; run CUDA entrants on a GPU | Omega fetch-and-verify unit when seeded Omega has an HTTPS client word | +| `site/index.html` | HTML + JS | render the board in a browser | page generated from seeded Omega (as aienos.com pages already are) | + +## Entrant toolchains and runtimes + +| dependency | version / pin | what it does here | Omega replacement | +|---|---|---|---| +| Omega compiler `omc` | aien-dev/omega-mv `369dbc96`, sha256 `2c824805…` | compiles the Omega entrant to native AArch64 | it is the Omega entrant | +| PoCL (AArch64) | 7.2 at pocl `888c9774`, aien-dev/omega-kernel-template release `pocl-7.2-888c9774-noble-arm64.1`, sha256 `68892ec0…` | OpenCL C on the CPU of the arm64 runner | none: OpenCL is an entrant, not glue | +| PoCL (x86-64) | Ubuntu 24.04 `pocl-opencl-icd` | OpenCL C on the CPU of the x86 runner | none | +| clang-18, libLLVMSPIRVLib 18.1, ocl-icd | Ubuntu 24.04 packages | PoCL's compiler and the OpenCL loader | none | +| pyopencl | 2026.1.4 (PyPI) | OpenCL host API from Python | see `oal/entrants/opencl.py` above | +| Triton | 3.8.0 (PyPI), run with `TRITON_INTERPRET=1` | Triton entrant on CPU (the interpreter: correctness only, timings are not Triton GPU performance) | none: Triton is an entrant | +| PyTorch | 2.14.1 CPU wheel | tensors for the Triton interpreter | none | +| numpy | 2.5.4 (PyPI) | float64 reference arithmetic, quantiles | Omega float64 references (see above) | +| HIP-CPU | ROCm/HIP-CPU `e112c935` (MIT, archived upstream) | runs HIP source on the CPU with TBB | none: HIP is an entrant | +| oneTBB | Ubuntu 24.04 `libtbb-dev` | HIP-CPU's thread pool | none | +| hipify-perl | ROCm/HIPIFY `7d531fc2`, sha256 `3bd75514…` | turns each `kernel.cu` into HIP source, so the HIP entrant is the CUDA source hipified, not a second hand-written port | none | +| nvcc | Ubuntu 24.04 `nvidia-cuda-toolkit` on CI (compile only); CUDA 13.0 V13.0.88 on the GB10 | builds the CUDA entrant | none: CUDA is an entrant | +| GitHub Actions | checkout `11bd7190`, upload-artifact `ea165f8d`, download-artifact `9000827c`, upload-pages-artifact `fc324d35`, deploy-pages `368f8252` | CI and Pages | none | + +Python packages come from PyPI and the PyTorch CPU index; everything else from GitHub or the +Ubuntu archive, at the pins in `toolchain.lock`. diff --git a/LICENSE b/LICENSE index d645695..de87dc7 100644 --- a/LICENSE +++ b/LICENSE @@ -200,3 +200,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +---- LLVM Exceptions to the Apache 2.0 License ---- + + As an exception, if, as a result of your compiling your source code, portions + of this Software are embedded into an Object form of such source code, you + may redistribute such embedded portions in such Object form without complying + with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + + In addition, if you combine or link compiled forms of this Software with + software that is licensed under the GPLv2 ("Combined Software") and if a + court of competent jurisdiction determines that the patent provision (Section + 3), the indemnity provision (Section 9) or other Section of the License + conflicts with the conditions of the GPLv2, you may retroactively and + prospectively choose to deem waived or otherwise exclude such Section(s) of + the License, but only in their entirety and only with respect to the Combined + Software. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..b9f1a07 --- /dev/null +++ b/NOTICE @@ -0,0 +1,24 @@ +AIEN Sovereign Ecosystem (AienOS / Omega / CUDA++ / INTERPLANE) +Copyright 2024-2026 Drake Stapleton and AIEN Contributors (https://github.com/aien-dev) + +This product includes software developed as part of the AIEN Sovereign +Ecosystem (https://www.aienos.com). + +The Omega language (omega-mv), CUDA++ GPU toolchain (CUDApp), Aienux kernel, +INTERPLANE protocol, and FORGE realization layer (physics-mv) are foundational +components designed and architected by Drake Stapleton. + +TRADEMARK NOTICE: +Pursuant to Section 6 of the Apache License, Version 2.0, this license does not +grant permission to use the trade names, trademarks, service marks, or product +names of the Licensor. "AIEN", "AienOS", "Aienux", "Omega", "CUDA++", "CUDApp", +"INTERPLANE", and "FORGE" are trademarks of Drake Stapleton. Any derivative +works or redistributions modified from the canonical upstream repositories +(https://github.com/aien-dev) may not be branded or marketed as official +"AienOS Verified" or "Omega" distributions without express written permission. + +LLVM EXCEPTION: +This software is licensed under the Apache License, Version 2.0 with LLVM +Exceptions. The exception permits compiled object code derived from this +software to be distributed under terms of the recipient's choosing, and +resolves the GPLv2 patent/indemnity conflict described in the exception text. diff --git a/README.md b/README.md index c18f672..281c1e3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,70 @@ -# openaccel-lab +# OpenAccel Lab + +A vendor-neutral, execution-verified conformance and performance lab for accelerator kernels. + +Each workload in `workloads/` has one float64 reference, a written tolerance contract and seeded +inputs that are byte-identical for every entrant. The entrants are **OpenCL C, Triton, HIP, CUDA +and Omega**. None of them referees the others. CI runs every entrant that a free GitHub runner can +host, judges it against the reference, and publishes the board: + +**Board: https://aien-dev.github.io/openaccel-lab/** + +Wrong kernels are part of the lab. Each of the six controls in `controls/` has one defect written +into every entrant: a GEMM that stops one term short, an exclusive scan where an inclusive one +belongs, a reduction that drops its last element, a softmax and an attention without the max +subtraction, and an int4 dequantiser without sign extension. The gate fails if any control passes +on any backend. + +## What the numbers mean + +- **CI rows are CPU evidence.** On the runners, OpenCL runs on PoCL, Triton in its interpreter, HIP + on HIP-CPU and Omega as native AArch64. The CUDA source is compiled with nvcc but not run. Every + CI timing is labelled host CPU wall clock. These timings say nothing about GPU performance. +- **GPU rows are receipts.** They live in `receipts/`, each with its machine, driver, date and who + ran it. Rented-GPU rows imported from aien-dev/omega-gpu-bench are marked as imported. +- **Timings are distributions.** The board shows min / p10 / p25 / median / p75 / p90 / max and the + sample count. It never shows a mean. +- **Only PASS counts.** `COMPILED`, `NOT_RUN` and `NO_SOURCE` never count as passing. + +## Use it + +```sh +git clone https://github.com/aien-dev/openaccel-lab && cd openaccel-lab +sh tools/fetch.sh all # pinned omc, PoCL, HIP-CPU, hipify-perl; sha256-checked +export OCL_ICD_VENDORS=$PWD/.oal/icd TRITON_INTERPRET=1 +bin/oal-gen vecadd --seed 1 > case.bin # one case, docs/CONTAINER.md +bin/oal-run opencl vecadd < case.bin > out.bin # one entrant, one case +bin/oal-check vecadd case.bin out.bin # one verdict line; exit 0 PASS, 1 FAIL +bin/oal-matrix --controls > results.jsonl # everything; docs/RESULTS.md +bin/oal-gate results.jsonl # exit 1 on any failure or passing control +bin/oal-shrink omega gemm_offbyone # smallest shape that still fails +``` + +Each tool does one job. Data goes to stdout, diagnostics to stderr, and exit codes mean what the +header of each tool says. To add a workload or an entrant, see `docs/AUTHORING.md`. The tolerance +rules, with their Wolfram checks, are in `docs/TOLERANCE.md`. + +## GPU runs + +`runners/cuda/run_all.sh OUT.jsonl` runs the CUDA entrant of every workload on the local NVIDIA +GPU and labels the lines with the GPU, compute capability and driver. Rows from AMD and Intel GPUs +are welcome as receipts in the same format. + +## Limits + +- HIP-CPU is archived upstream and does not implement every HIP feature. Workloads stay inside + what it supports (see `docs/AUTHORING.md`). +- The Triton interpreter checks semantics, not Triton's GPU code generation. +- The lab takes source code only. It never inspects or translates NVIDIA binaries, SASS or other + generated machine artifacts. + +## Connected repos + +- [aien-dev/omega-gpu-bench](https://github.com/aien-dev/omega-gpu-bench) at `be6e65ac`: rented-GPU receipts and their board. Its receipts are imported unchanged under `receipts/imported/`. +- [aien-dev/omega-kernel-template](https://github.com/aien-dev/omega-kernel-template) at `23a04c9f`: the single-kernel Omega check on AArch64 and SPIR-V/PoCL. Its PoCL release asset is the lab's arm64 OpenCL runtime. +- [aien-dev/omega-mv](https://github.com/aien-dev/omega-mv) at `369dbc96`: the Omega compiler used by the Omega entrant. + +Pins are in `toolchain.lock`, and outside code is listed in `DEPENDENCIES.md`. License: Apache-2.0 with the LLVM exception ([LICENSE](LICENSE), [NOTICE](NOTICE)). ## Human-Directed Agentic Engineering @@ -11,6 +77,3 @@ For the documented method and a systems-software case study, see Gregory M. Kurt [*Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed Agentic Engineering* (2026)](https://doi.org/10.5281/zenodo.23682548). -## License - -See [LICENSE](LICENSE). diff --git a/bin/oal-board b/bin/oal-board new file mode 100755 index 0000000..c31feef --- /dev/null +++ b/bin/oal-board @@ -0,0 +1,126 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# oal-board [--receipts DIR] RESULTS.jsonl... > site/data.json +# Fold oal-matrix results (and imported GPU receipts) into the dashboard data file. Distributions +# only: every timing cell is min/p10/p25/median/p75/p90/max with its sample count, never a mean. +# Exit 0, or 2 on a usage error. +# INTERIM host glue (Python + numpy). Successor: oal-board in seeded Omega. +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +import argparse +import collections +import glob +import json +import time + +import numpy as np + +from oal import manifest + +ap = argparse.ArgumentParser(prog="oal-board") +ap.add_argument("--receipts", default=os.path.join(manifest.ROOT, "receipts")) +ap.add_argument("files", nargs="*") +a = ap.parse_args() + +QS = (0, 10, 25, 50, 75, 90, 100) + + +def dist(xs): + if not xs: + return None + v = np.asarray(xs, dtype=np.float64) + return {"n": int(v.size), "q": [float(x) for x in np.percentile(v, QS)]} + + +recs = [] +for path in a.files: + if path.endswith(".shrink.jsonl"): + continue + with open(path) as f: + recs += [json.loads(l) for l in f if l.strip()] +gpu_jsonl = sorted(glob.glob(os.path.join(a.receipts, "gpu", "*.jsonl"))) +for path in gpu_jsonl: + with open(path) as f: + for l in f: + if l.strip(): + r = json.loads(l) + r["_receipt"] = os.path.relpath(path, manifest.ROOT) + recs.append(r) + +cells = collections.OrderedDict() +outs_by_case = collections.defaultdict(lambda: collections.defaultdict(set)) +for r in recs: + mach = r["machine"] + where = r["machine"].get("runner") or mach["arch"] + key = (r["workload"], r["backend"], where) + c = cells.setdefault(key, {"workload": r["workload"], "backend": r["backend"], "runner": where, + "arch": mach["arch"], "cpu": mach.get("cpu"), "control": r["control"], + "expect": r.get("expect", "pass"), "status": collections.Counter(), + "err": [], "time_default": [], "time_label": r.get("timing_label"), + "evidence": r.get("evidence"), "versions": set(), "toolchain": r.get("toolchain"), + "first_failure": None, "run_url": mach.get("run_url"), + "receipt": r.get("_receipt")}) + c["status"][r["status"]] += 1 + if r.get("err_ratio") is not None: + c["err"].append(r["err_ratio"]) + for v in r.get("versions", []): + c["versions"].add(v) + m = manifest.load(r["workload"]) + if r["status"] == "PASS" and r["params"] == manifest.params_of(m): + c["time_default"] += r.get("times_ns", []) + if r["status"] not in ("PASS", "NO_SOURCE", "COMPILED") and c["first_failure"] is None: + bad = next((o.get("first_bad") for o in r.get("outputs", []) if not o.get("pass", True)), None) + c["first_failure"] = {"status": r["status"], "params": r["params"], "seed": r["seed"], + "first_bad": bad, "log": (r.get("log") or "")[-400:]} + if r.get("outputs_sha256"): + outs_by_case[(r["workload"], r["case_sha256"])][r["outputs_sha256"]].add(r["backend"]) + +workloads = {} +for name in manifest.all_names(include_controls=True): + m = manifest.load(name) + workloads[name] = {"family": m.get("family"), "summary": m.get("summary"), "control": m["_control"], + "expect": m.get("expect", "pass"), "reference_from": m.get("reference_from"), + "params": manifest.params_of(m), "cases": len(m.get("cases", [{}])), + "tolerance": {k: {kk: vv for kk, vv in v.items()} for k, v in m["tolerance"].items()}, + "provenance": m.get("provenance")} + +agree = {} +for (w, _), groups in outs_by_case.items(): + a_ = agree.setdefault(w, {"cases": 0, "distinct_hist": collections.Counter()}) + a_["cases"] += 1 + a_["distinct_hist"][len(groups)] += 1 + +shrunk = [] +for path in sorted(glob.glob(os.path.join(a.receipts, "shrink", "*.jsonl"))) + [ + p for p in a.files if p.endswith(".shrink.jsonl")]: + with open(path) as f: + shrunk += [json.loads(l) for l in f if l.strip()] + +imported = [] +for path in sorted(glob.glob(os.path.join(a.receipts, "imported", "*", "*.json"))): + rc = json.load(open(path)) + for res in rc.get("results", []): + imported.append({"gpu": rc["machine"].get("gpu"), "cc": rc["machine"].get("cc"), + "driver": rc["machine"].get("driver_version"), "provider": rc.get("provider"), + "kernel": res.get("cubin"), "kind": res.get("kind"), "verdict": res.get("verdict"), + "checked": res.get("checked"), "mismatches": res.get("mismatches"), + "kernel_ms": res.get("kernel_ms"), "receipt": os.path.relpath(path, manifest.ROOT), + "receipt_sha256": rc.get("receipt_sha256"), + "label": "rented GPU, imported receipt from aien-dev/omega-gpu-bench"}) + +out_cells = [] +for c in cells.values(): + c = dict(c) + c["status"] = dict(c["status"]) + c["err"] = dist(c["err"]) + c["time_default"] = dist(c["time_default"]) + c["versions"] = sorted(c["versions"]) + out_cells.append(c) + +json.dump({"schema": "oal-board/1", "generated": int(time.time()), + "lab_commit": next((r.get("lab_commit") for r in recs if r.get("lab_commit")), None), + "quantiles": list(QS), "workloads": workloads, "cells": out_cells, + "agreement": {w: {"cases": v["cases"], "distinct_hist": dict(v["distinct_hist"])} for w, v in agree.items()}, + "shrunk": shrunk, "imported_gpu": imported}, sys.stdout, indent=1, sort_keys=True) +sys.stdout.write("\n") diff --git a/bin/oal-check b/bin/oal-check new file mode 100755 index 0000000..3d65254 --- /dev/null +++ b/bin/oal-check @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# oal-check WORKLOAD CASE OUTPUTS +# Compare an entrant's outputs with the float64 reference under the workload's tolerance contract. +# stdout: one JSON verdict line. Exit 0 PASS, 1 FAIL, 2 usage or malformed input. +# INTERIM host glue (Python + numpy). Successor: oal-check in seeded Omega. +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +import json +from oal import case, check, manifest, ref + +if len(sys.argv) != 4: + sys.stderr.write("usage: oal-check WORKLOAD CASE OUTPUTS\n") + sys.exit(2) +m = manifest.load(sys.argv[1]) +blob = open(sys.argv[2], "rb").read() +raw = open(sys.argv[3], "rb").read() +pvals, sizes, ins, warm, reps = case.unpack(blob) +params = dict(zip(manifest.params_of(m).keys(), pvals)) +import numpy as np +tensors = {} +for k, s in enumerate(m["inputs"]): + tensors[s["name"]] = np.frombuffer(ins[k], dtype=manifest.DTYPES[s["dtype"]][0]).reshape(manifest.shape(s, params)) +try: + got = case.split_outputs(m, params, raw) +except ValueError as e: + print(json.dumps({"workload": m["name"], "pass": False, "why": str(e)})) + sys.exit(1) +v = check.compare(m, params, ref.compute(m, params, tensors), got) +v["workload"] = m["name"] +v["case_sha256"] = case.sha256(blob) +print(json.dumps(v)) +sys.exit(0 if v["pass"] else 1) diff --git a/bin/oal-gate b/bin/oal-gate new file mode 100755 index 0000000..44b40c2 --- /dev/null +++ b/bin/oal-gate @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# oal-gate [--min-backends N] RESULTS.jsonl... +# Judge oal-matrix output. Prints one line per finding, then a summary line. Exit 0 when: +# every control fails (FAIL or RUNTIME_FAIL) wherever it ran, and never passes; +# every workload has at least N backends whose every record PASSed; +# no workload record ends FAIL, RUNTIME_FAIL, COMPILE_FAIL or TIMEOUT; +# the same (workload, params, seed) produced the same case_sha256 on every runner. +# Exit 1 otherwise, 2 on a usage error. +# INTERIM host glue (Python). Successor: oal-gate in seeded Omega. +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +import argparse +import collections +import json + +ap = argparse.ArgumentParser(prog="oal-gate") +ap.add_argument("--min-backends", type=int, default=3) +ap.add_argument("files", nargs="+") +a = ap.parse_args() +recs = [] +for path in a.files: + with open(path) as f: + recs += [json.loads(l) for l in f if l.strip()] +bad = 0 +cases = {} +passing = collections.defaultdict(lambda: collections.defaultdict(list)) +names = set() +for r in recs: + key = (r["workload"], json.dumps(r["params"], sort_keys=True), r["seed"]) + prev = cases.setdefault(key, (r["case_sha256"], r["machine"]["arch"])) + if prev[0] != r["case_sha256"]: + print("CASE-MISMATCH %s %s seed %d: %s on %s, %s on %s" % (key[0], key[1], key[2], prev[0][:12], prev[1], + r["case_sha256"][:12], r["machine"]["arch"])) + bad += 1 + if r["control"]: + if r["status"] == "PASS": + print("CONTROL-PASSED %s on %s (%s) seed %d: the wrong kernel was not flagged" % ( + r["workload"], r["backend"], r["machine"]["arch"], r["seed"])) + bad += 1 + continue + names.add(r["workload"]) + if r["status"] in ("FAIL", "RUNTIME_FAIL", "COMPILE_FAIL", "TIMEOUT"): + print("ENTRANT-%s %s on %s (%s) params %s seed %d" % (r["status"], r["workload"], r["backend"], + r["machine"]["arch"], key[1], r["seed"])) + bad += 1 + if r["status"] in ("PASS", "FAIL", "RUNTIME_FAIL", "COMPILE_FAIL", "TIMEOUT"): + passing[r["workload"]][r["backend"]].append(r["status"] == "PASS") +for w in sorted(names): + ok = sorted(b for b, v in passing[w].items() if v and all(v)) + if len(ok) < a.min_backends: + print("TOO-FEW-BACKENDS %s: %d passing (%s), need %d" % (w, len(ok), ",".join(ok) or "none", a.min_backends)) + bad += 1 +nctl = len({r["workload"] for r in recs if r["control"]}) +print("oal-gate: %d records, %d workloads, %d controls, %d findings" % (len(recs), len(names), nctl, bad)) +sys.exit(1 if bad else 0) diff --git a/bin/oal-gen b/bin/oal-gen new file mode 100755 index 0000000..34c61df --- /dev/null +++ b/bin/oal-gen @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# oal-gen WORKLOAD [--seed S] [--set k=v ...] > case.bin +# Write one case container (docs/CONTAINER.md) for WORKLOAD to stdout. Exit 0, or 2 on a usage error. +# INTERIM host glue (Python). Successor: oal-gen in seeded Omega. +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +import argparse +from oal import manifest, matrix + +ap = argparse.ArgumentParser(prog="oal-gen") +ap.add_argument("workload") +ap.add_argument("--seed", type=int, default=1) +ap.add_argument("--set", action="append", default=[], metavar="K=V") +a = ap.parse_args() +m = manifest.load(a.workload) +over = dict(kv.split("=", 1) for kv in a.set) +params, _, blob = matrix.make_case(m, over, a.seed) +sys.stderr.write("oal-gen %s seed %d params %s bytes %d\n" % (a.workload, a.seed, params, len(blob))) +sys.stdout.buffer.write(blob) diff --git a/bin/oal-matrix b/bin/oal-matrix new file mode 100755 index 0000000..bb42e04 --- /dev/null +++ b/bin/oal-matrix @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# oal-matrix [--backends B,..] [--workloads W,..] [--controls] [--seeds 1,2,3] +# Run every (workload, case, seed, backend) and print one oal-result/1 JSON line each (docs/RESULTS.md). +# Exit 0 when every line was written, whatever the verdicts; judging is oal-gate's job. +# INTERIM host glue (Python). Successor: oal-matrix in seeded Omega. +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +import argparse +import json +from oal import manifest, matrix, run + +ap = argparse.ArgumentParser(prog="oal-matrix") +ap.add_argument("--backends", default=",".join(run.BACKENDS)) +ap.add_argument("--workloads", default="") +ap.add_argument("--controls", action="store_true", help="also run controls/") +ap.add_argument("--only-controls", action="store_true") +ap.add_argument("--seeds", default="1,2,3") +ap.add_argument("--timeout", type=int, default=600) +a = ap.parse_args() +names = [w for w in a.workloads.split(",") if w] or manifest.all_names(include_controls=a.controls or a.only_controls) +if a.only_controls: + names = [n for n in names if manifest.load(n)["_control"]] +seeds = [int(s) for s in a.seeds.split(",") if s] +cache = {} +for name in names: + m = manifest.load(name) + for over in matrix.cases_of(m): + for seed in seeds: + for b in a.backends.split(","): + rec = matrix.run_one(b, m, over, seed, a.timeout, cache) + sys.stdout.write(json.dumps(rec, sort_keys=True) + "\n") + sys.stdout.flush() + sys.stderr.write("%-16s %-7s seed %-3d %s %s\n" % (name, b, seed, json.dumps(over), rec["status"])) diff --git a/bin/oal-run b/bin/oal-run new file mode 100755 index 0000000..82d20ec --- /dev/null +++ b/bin/oal-run @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# oal-run BACKEND WORKLOAD < case.bin > outputs.bin +# Build and run one entrant on one case. stdout: the entrant's output tensors; stderr: its log and a +# final JSON status line. Exit 0 ran, 2 compile failure, 3 runtime failure or timeout, 4 NOT_RUN, +# 5 NO_SOURCE, 6 COMPILED (built, not run). +# INTERIM host glue (Python). Successor: oal-run in seeded Omega. +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +import json +from oal import case, manifest, run + +if len(sys.argv) != 3 or sys.argv[1] not in run.BACKENDS: + sys.stderr.write("usage: oal-run {%s} WORKLOAD < case > outputs\n" % ",".join(run.BACKENDS)) + sys.exit(2) +backend, name = sys.argv[1], sys.argv[2] +m = manifest.load(name) +blob = sys.stdin.buffer.read() +pvals = case.unpack(blob)[0] +params = dict(zip(manifest.params_of(m).keys(), pvals)) +r = run.execute(backend, m, params, blob, int(os.environ.get("OAL_TIMEOUT", "600"))) +if r.get("outputs") is not None: + sys.stdout.buffer.write(r.pop("outputs")) +sys.stderr.write(json.dumps(r) + "\n") +sys.exit({"RAN": 0, "COMPILE_FAIL": 2, "RUNTIME_FAIL": 3, "TIMEOUT": 3, "NOT_RUN": 4, "NO_SOURCE": 5, + "COMPILED": 6}[r["status"]]) diff --git a/bin/oal-shrink b/bin/oal-shrink new file mode 100755 index 0000000..0336003 --- /dev/null +++ b/bin/oal-shrink @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# oal-shrink BACKEND WORKLOAD [--seed S] [--set k=v ...] +# Failure minimisation: starting from a failing case, reduce each parameter toward its manifest +# "shrink" minimum (respecting multiple_of) while the entrant still fails the same way, then print +# one JSON line with the original and minimal parameters and the minimal failure. The minimal case +# reproduces with: oal-gen WORKLOAD --seed S --set k=v ... | oal-run BACKEND WORKLOAD +# Exit 0 when a minimal failing case was printed, 1 when the starting case does not fail, 2 on usage. +# INTERIM host glue (Python). Successor: oal-shrink in seeded Omega. +import os +import sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) +import argparse +import json +from oal import manifest, matrix + +ap = argparse.ArgumentParser(prog="oal-shrink") +ap.add_argument("backend") +ap.add_argument("workload") +ap.add_argument("--seed", type=int, default=1) +ap.add_argument("--set", action="append", default=[], metavar="K=V") +ap.add_argument("--timeout", type=int, default=300) +a = ap.parse_args() +m = manifest.load(a.workload) +start = dict(m["params"]) +start.update({k: int(v) for k, v in (kv.split("=", 1) for kv in a.set)}) +FAILS = ("FAIL", "RUNTIME_FAIL", "TIMEOUT") +tries = 0 + + +def attempt(p): + global tries + tries += 1 + return matrix.run_one(a.backend, m, p, a.seed, a.timeout) + + +first = attempt(start) +if first["status"] not in FAILS: + print(json.dumps({"workload": a.workload, "backend": a.backend, "seed": a.seed, "params": start, + "status": first["status"], "minimised": False})) + sys.exit(1) +cls = first["status"] +cur, best = dict(start), first +changed = True +while changed: + changed = False + for k, rule in m.get("shrink", {}).items(): + lo, mult = int(rule.get("min", 1)), int(rule.get("multiple_of", 1)) + v = cur[k] + # smallest first: the minimum, the midpoint, one step down; repeat until nothing smaller fails + cands = {lo, (lo + v) // 2, v - mult} + for c in sorted(x - x % mult for x in cands): + if c < lo or c >= v: + continue + trial = dict(cur) + trial[k] = c + try: + r = attempt(trial) + except (ValueError, ZeroDivisionError): + continue + if r["status"] == cls: + cur, best, changed = trial, r, True + break +out = {"workload": a.workload, "backend": a.backend, "seed": a.seed, "status": cls, "minimised": True, + "original_params": start, "params": cur, "tries": tries, "case_sha256": best["case_sha256"], + "reproduce": "bin/oal-gen %s --seed %d %s > case.bin && bin/oal-run %s %s < case.bin > out.bin; " + "bin/oal-check %s case.bin out.bin" % ( + a.workload, a.seed, " ".join("--set %s=%d" % kv for kv in cur.items()), a.backend, a.workload, + a.workload)} +for o in best.get("outputs", []): + if not o.get("pass", True): + out["first_bad"] = dict(o.get("first_bad", {}), output=o["output"], failed=o.get("failed"), + elements=o.get("elements")) + break +if cls != "FAIL": + out["log"] = best.get("log", "")[-600:] +print(json.dumps(out, sort_keys=True)) diff --git a/controls/attention_nomax/kernel.cl b/controls/attention_nomax/kernel.cl new file mode 100644 index 0000000..9528f6f --- /dev/null +++ b/controls/attention_nomax/kernel.cl @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL attention_nomax: exp(s_j) without subtracting the row max m (m is still computed). +// attn_p: one work-item per row i writes the softmax weights pw[i][j], j <= i. +__kernel void attn_p(__global const float *q, __global const float *k, __global float *pw, + const int T, const int D) +{ + int i = get_global_id(0); + if (i >= T) + return; + float m = -1e30f; + for (int j = 0; j <= i; j++) { + float acc = 0.0f; + for (int c = 0; c < D; c++) + acc += q[i * D + c] * k[j * D + c]; + float s = acc * 0.125f; + pw[i * T + j] = s; + m = fmax(m, s); + } + float z = 0.0f; + for (int j = 0; j <= i; j++) { + float e = exp(pw[i * T + j]); + pw[i * T + j] = e; + z += e; + } + for (int j = 0; j <= i; j++) + pw[i * T + j] = pw[i * T + j] / z; +} + +// attn_o: o[i][c] = sum_{j <= i} pw[i][j] v[j][c]. +__kernel void attn_o(__global const float *pw, __global const float *v, __global float *o, + const int T, const int D) +{ + int i = get_global_id(0); + int c = get_global_id(1); + if (i >= T || c >= D) + return; + float acc = 0.0f; + for (int j = 0; j <= i; j++) + acc += pw[i * T + j] * v[j * D + c]; + o[i * D + c] = acc; +} diff --git a/controls/attention_nomax/kernel.cu b/controls/attention_nomax/kernel.cu new file mode 100644 index 0000000..9f963c5 --- /dev/null +++ b/controls/attention_nomax/kernel.cu @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL attention_nomax: expf(s_j) without subtracting the row max m (m is still computed). +#include + +// attn_p: one thread per row i writes the softmax weights pw[i][j], j <= i. +__global__ void attn_p(const float *q, const float *k, float *pw, int T, int D) +{ + int i = blockIdx.x * blockDim.x + threadIdx.x; + if (i >= T) + return; + float m = -1e30f; + for (int j = 0; j <= i; j++) { + float acc = 0.0f; + for (int c = 0; c < D; c++) + acc += q[i * D + c] * k[j * D + c]; + float s = acc * 0.125f; + pw[i * T + j] = s; + m = fmaxf(m, s); + } + float z = 0.0f; + for (int j = 0; j <= i; j++) { + float e = expf(pw[i * T + j]); + pw[i * T + j] = e; + z += e; + } + for (int j = 0; j <= i; j++) + pw[i * T + j] = pw[i * T + j] / z; +} + +// attn_o: o[i][c] = sum_{j <= i} pw[i][j] v[j][c]. +__global__ void attn_o(const float *pw, const float *v, float *o, int T, int D) +{ + int c = blockIdx.x * blockDim.x + threadIdx.x; + int i = blockIdx.y; + if (i >= T || c >= D) + return; + float acc = 0.0f; + for (int j = 0; j <= i; j++) + acc += pw[i * T + j] * v[j * D + c]; + o[i * D + c] = acc; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int T = (int)p[0]; + int D = (int)p[1]; + float *pw = (float *)buf[4]; + attn_p<<<(T + 63) / 64, 64>>>((const float *)buf[0], (const float *)buf[1], pw, T, D); + dim3 grid((D + 63) / 64, T); + attn_o<<>>(pw, (const float *)buf[2], (float *)buf[3], T, D); +} diff --git a/controls/attention_nomax/omega.om b/controls/attention_nomax/omega.om new file mode 100644 index 0000000..b2db306 --- /dev/null +++ b/controls/attention_nomax/omega.om @@ -0,0 +1,69 @@ +note CONTROL attention_nomax: as workloads/attention but exp(s_j) without the row max subtraction +global kt ulong 1 +global kd ulong 1 +global sr f32 65536 +fn dotqk qi ulong kj ulong d ulong to f32 +acc = 0.0f32 +for c ulong d +x = get fa add qi c +acc = add acc mul x get fb add kj c +end +ret acc +end +fn rowexp n ulong m f32 to f32 +z = 0.0f32 +for j ulong n +e = f32 oal_expf f64 sub get sr j m +put sr j e +z = add z e +end +ret z +end +fn rowpv i ulong n ulong d ulong z f32 to void +for c ulong d +acc = 0.0f32 +for j ulong n +x = get sr j +acc = add acc mul x get fc add mul j d c +end +put fo add mul i d c div acc z +end +end +fn kern to void +t = get kt 0 +d = get kd 0 +for i ulong t +n = add i 1 +m = -1.0e30f32 +for j ulong n +s = mul dotqk mul i d mul j d d 0.125f32 +put sr j s +m = fmax m s +end +z = rowexp n 0.0f32 +rowpv i n d z +end +end +fn main to int +oal_begin +put kt 0 ulong oal_p 0 +put kd 0 ulong oal_p 1 +if gt get kt 0 65536 +trap 9 +end +a = oal_fa 0 +b = oal_fb 1 +c = oal_fc 2 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get kt 0 get kd 0 +oal_end +ret 0 +end diff --git a/controls/attention_nomax/triton_kernel.py b/controls/attention_nomax/triton_kernel.py new file mode 100644 index 0000000..fc92a5f --- /dev/null +++ b/controls/attention_nomax/triton_kernel.py @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 +# CONTROL attention_nomax: exp(s_j) without subtracting the row max. +import triton +import triton.language as tl + + +@triton.jit +def _attention(q, k, v, o, D: tl.constexpr, BJ: tl.constexpr): + i = tl.program_id(0) + j = tl.arange(0, BJ) + c = tl.arange(0, D) + live = j <= i + qv = tl.load(q + i * D + c) + kv = tl.load(k + j[:, None] * D + c[None, :], mask=live[:, None], other=0.0) + s = tl.where(live, tl.sum(kv * qv[None, :], axis=1) * 0.125, -1e30) + e = tl.where(live, tl.exp(s), 0.0) + pw = e / tl.sum(e, axis=0) + vv = tl.load(v + j[:, None] * D + c[None, :], mask=live[:, None], other=0.0) + tl.store(o + i * D + c, tl.sum(pw[:, None] * vv, axis=0)) + + +def launch(p, t): + n = p["T"] + _attention[(n,)](t["q"], t["k"], t["v"], t["o"], D=p["Dh"], BJ=triton.next_power_of_2(n)) diff --git a/controls/attention_nomax/workload.json b/controls/attention_nomax/workload.json new file mode 100644 index 0000000..8c412c8 --- /dev/null +++ b/controls/attention_nomax/workload.json @@ -0,0 +1,145 @@ +{ + "name": "attention_nomax", + "expect": "fail", + "reference_from": "attention", + "family": "attention", + "summary": "CONTROL: workloads/attention with the row max subtraction omitted in every entrant (e_j = exp(s_j)); Q and K have mean 3.5, so scores near 98 exceed ln(f32 max) = 88.72 and exp overflows, giving NaN rows; the T = 1 case is left out because one score may fall below 88.72", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "T": 48, + "Dh": 64 + }, + "cases": [ + {}, + { + "T": 17 + } + ], + "shrink": { + "T": { + "min": 1 + }, + "Dh": { + "min": 64, + "multiple_of": 64 + } + }, + "inputs": [ + { + "name": "q", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 3.5, + "std": 1.0 + } + }, + { + "name": "k", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 3.5, + "std": 1.0 + } + }, + { + "name": "v", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 0.0, + "std": 1.0 + } + } + ], + "outputs": [ + { + "name": "o", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ] + } + ], + "scratch": [ + { + "name": "pw", + "dtype": "f32", + "shape": [ + "T", + "T" + ] + } + ], + "tolerance": { + "o": { + "kind": "bound", + "rtol": 1, + "atol": 1e-35, + "why": "reference.py returns the whole bound as the scale, per element: for row i with n = i+1 terms, bound = sum_j p_j |v_jc| c_j. Algorithm covered: scores, row max, exp(score - max), sum, then either p_j = e_j/sum and O = sum_j p_j v_j or O = (sum_j e_j v_j)/sum, every sum in any order, with or without FMA. Each score is within e_j = gamma(Dh) a_j, a_j = 0.125 sum_c |q_c k_jc| (Higham Thm 3.1; 0.125 exact); the row max within E = max_j e_j; the subtraction adds u|s_j - max|; so exp's argument is within tau_j = e_j + E + u(|d_j| + e_j + E), and with exp budgeted at 3 ulp <= 6u relative (OpenCL C 3.0 s7.4; CUDA expf 2 ulp = 4u is inside it) each exp(score - max) has relative error theta_j = e^tau_j (1 + 6u) - 1. The positive denominator sum has relative error K = sum_j p_j((1+theta_j)(1+gamma(n-1)) - 1); the numerator dot, including the p_j division, is within gamma(n+1) and a final division adds u, giving c_j = (1+theta_j)(1+gamma(n+1))(1+u)/(1-K) - 1. WolframLanguageEvaluator: u=2^-24; g[n_]:=n u/(1-n u); N[g[64],10] -> 3.814711818*10^-6; N[g[49],10] -> 2.920636124*10^-6; N[g[47],10] -> 2.801426152*10^-6; N[3*2^-23/u] -> 6.; N[2*2^-23/u] -> 4.; N[64*2^-24/(1-64*2^-24)*98*2,10] -> 0.0007476835162 (2 gamma(64) a with a near 8*3.5^2 = 98: the order of c_j, so a dropped term or a missing mask fails). atol covers exp, p_j and p_j v_j results flushed or rounded below 2^-126: at most 3 n of them, each < 2^-126 max|v| with max|v| <= Sqrt[12] (normal4 range) and the denominator >= 1: N[3*48*2^-126*Sqrt[12],10] -> 5.863725906*10^-36 <= 1e-35. Without the max subtraction exp overflows: N[Log[2^128],10] -> 88.72283911 is below scores near 98, so O becomes NaN." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "attn_p", + "global": [ + "T" + ], + "local": null, + "args": [ + "q", + "k", + "pw", + "T", + "Dh" + ] + }, + { + "kernel": "attn_o", + "global": [ + "T", + "Dh" + ], + "local": null, + "args": [ + "pw", + "v", + "o", + "T", + "Dh" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/controls/dequant_int4_nosign/kernel.cl b/controls/dequant_int4_nosign/kernel.cl new file mode 100644 index 0000000..a1c1b4b --- /dev/null +++ b/controls/dequant_int4_nosign/kernel.cl @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL dequant_int4_nosign: the nibble is not sign-extended. +__kernel void dequant_int4(__global const uchar *w, __global const float *s, __global float *y, + const int R, const int C, const int G, const int NB) +{ + int r = get_global_id(0); + int c = get_global_id(1); + if (r >= R || c >= C) + return; + int b = w[r * NB + c / 2]; + int nib = (c & 1) ? (b >> 4) : (b & 15); + y[r * C + c] = (float)nib * s[r * G + c / 32]; +} diff --git a/controls/dequant_int4_nosign/kernel.cu b/controls/dequant_int4_nosign/kernel.cu new file mode 100644 index 0000000..e4eae8e --- /dev/null +++ b/controls/dequant_int4_nosign/kernel.cu @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL dequant_int4_nosign: the nibble is not sign-extended. +#include + +__global__ void dequant_int4(const unsigned char *w, const float *s, float *y, int R, int C, int G, int NB) +{ + long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; + if (i >= (long long)R * C) + return; + int r = (int)(i / C); + int c = (int)(i % C); + int b = w[r * NB + c / 2]; + int nib = (c & 1) ? (b >> 4) : (b & 15); + y[i] = (float)nib * s[r * G + c / 32]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0] * p[1]; + dequant_int4<<<(unsigned)((n + 255) / 256), 256>>>((const unsigned char *)buf[0], (const float *)buf[1], + (float *)buf[2], (int)p[0], (int)p[1], (int)p[2], (int)p[3]); +} diff --git a/controls/dequant_int4_nosign/omega.om b/controls/dequant_int4_nosign/omega.om new file mode 100644 index 0000000..8bda6b2 --- /dev/null +++ b/controls/dequant_int4_nosign/omega.om @@ -0,0 +1,49 @@ +note CONTROL dequant_int4_nosign: as workloads/dequant_int4 but the nibble is not sign-extended +global kr ulong 1 +global kc ulong 1 +global kg ulong 1 +global kb ulong 1 +fn nib4 v long hi ulong to f32 +if lt v 0 +v = add v 256 +end +n = and v 15 +if eq hi 1 +n = shr v 4 +end +ret f32 n +end +fn drow i ulong c ulong g ulong nb ulong to void +for j ulong c +v = long get qa add mul i nb div j 2 +sc = get fa add mul i g div j 32 +put fo add mul i c j mul nib4 v rem j 2 sc +end +end +fn kern to void +r = get kr 0 +for i ulong r +drow i get kc 0 get kg 0 get kb 0 +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kc 0 ulong oal_p 1 +put kg 0 ulong oal_p 2 +put kb 0 ulong oal_p 3 +n = oal_qa 0 +a = oal_fa 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get kr 0 get kc 0 +oal_end +ret 0 +end diff --git a/controls/dequant_int4_nosign/triton_kernel.py b/controls/dequant_int4_nosign/triton_kernel.py new file mode 100644 index 0000000..f9eb6dd --- /dev/null +++ b/controls/dequant_int4_nosign/triton_kernel.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# CONTROL dequant_int4_nosign: the nibble is not sign-extended. +import triton +import triton.language as tl + + +@triton.jit +def _dequant_int4(w, s, y, C, G, NB, BC: tl.constexpr): + r = tl.program_id(0) + c = tl.arange(0, BC) + live = c < C + b = tl.load(w + r * NB + c // 2, mask=live, other=0).to(tl.int32) + nib = tl.where((c % 2) == 1, b >> 4, b & 15) + sc = tl.load(s + r * G + c // 32, mask=live, other=0.0) + tl.store(y + r * C + c, nib.to(tl.float32) * sc, mask=live) + + +def launch(p, t): + _dequant_int4[(p["R"],)](t["w"], t["s"], t["y"], p["C"], p["G"], p["NB"], BC=triton.next_power_of_2(p["C"])) diff --git a/controls/dequant_int4_nosign/workload.json b/controls/dequant_int4_nosign/workload.json new file mode 100644 index 0000000..0ca9047 --- /dev/null +++ b/controls/dequant_int4_nosign/workload.json @@ -0,0 +1,113 @@ +{ + "name": "dequant_int4_nosign", + "expect": "fail", + "reference_from": "dequant_int4", + "family": "quantization", + "summary": "CONTROL: workloads/dequant_int4 with the nibble sign extension omitted in every entrant (nibbles read as 0..15 instead of -8..7); every element whose nibble is >= 8 is off by 16 * scale, so the exact check must fail; the R = 1, C = 2 case is left out because both nibbles of its single byte may be < 8", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the packed signed-nibble, group-32 layout of common 4-bit weight formats", + "params": { + "R": 64, + "C": 256 + }, + "derived": { + "G": "(C + 31) // 32", + "NB": "C // 2" + }, + "cases": [ + {}, + { + "R": 5, + "C": 70 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "C": { + "min": 2, + "multiple_of": 2 + } + }, + "inputs": [ + { + "name": "w", + "dtype": "u8", + "shape": [ + "R", + "NB" + ], + "gen": { + "kind": "int", + "lo": 0, + "hi": 255 + } + }, + { + "name": "s", + "dtype": "f32", + "shape": [ + "R", + "G" + ], + "gen": { + "kind": "uniform", + "lo": 0.001, + "hi": 0.05 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "R", + "C" + ] + } + ], + "tolerance": { + "y": { + "kind": "exact", + "why": "the nibble is an exact integer -8..7, converts to f32 exactly, then one correctly rounded f32 multiply per element" + } + }, + "timing": { + "warmup": 2, + "repeats": 10 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "dequant_int4", + "global": [ + "R", + "C" + ], + "local": null, + "args": [ + "w", + "s", + "y", + "R", + "C", + "G", + "NB" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/controls/gemm_offbyone/kernel.cl b/controls/gemm_offbyone/kernel.cl new file mode 100644 index 0000000..45bd57e --- /dev/null +++ b/controls/gemm_offbyone/kernel.cl @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +// One work-group of 256 per 16x16 tile; A and B are staged in local memory, C[i][j] = sum_k A[i][k] B[k][j]. +__kernel void tmatmul16(__global const float *a, __global const float *b, __global float *c, const int tiles) +{ + __local float la[256]; + __local float lb[256]; + int t = get_group_id(0); + int l = get_local_id(0); + int i = l / 16, j = l % 16; + la[l] = a[t * 256 + l]; + lb[l] = b[t * 256 + l]; + barrier(CLK_LOCAL_MEM_FENCE); + float s = 0.0f; + for (int k = 0; k < 15; k++) + s += la[i * 16 + k] * lb[k * 16 + j]; + c[t * 256 + l] = s; +} diff --git a/controls/gemm_offbyone/kernel.cu b/controls/gemm_offbyone/kernel.cu new file mode 100644 index 0000000..f8a74ac --- /dev/null +++ b/controls/gemm_offbyone/kernel.cu @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +// One 16x16 block per tile; A and B are staged in shared memory, C[i][j] = sum_k A[i][k] B[k][j]. +__global__ void tmatmul16(const float *a, const float *b, float *c) +{ + __shared__ float la[256]; + __shared__ float lb[256]; + long long t = blockIdx.x; + int i = threadIdx.y, j = threadIdx.x, l = i * 16 + j; + la[l] = a[t * 256 + l]; + lb[l] = b[t * 256 + l]; + __syncthreads(); + float s = 0.0f; + for (int k = 0; k < 15; k++) + s += la[i * 16 + k] * lb[k * 16 + j]; + c[t * 256 + l] = s; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long tiles = p[0]; + tmatmul16<<<(unsigned)tiles, dim3(16, 16)>>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2]); +} diff --git a/controls/gemm_offbyone/omega.om b/controls/gemm_offbyone/omega.om new file mode 100644 index 0000000..ba10729 --- /dev/null +++ b/controls/gemm_offbyone/omega.om @@ -0,0 +1,38 @@ +global tn ulong 1 +fn kern to void +nt = get tn 0 +for t ulong nt +for i ulong 16 +ai = add mul t 256 mul i 16 +for j ulong 16 +pb = add mul t 256 j +s = 0.0f32 +for k ulong 15 +x = get fa add ai k +y = get fb pb +s = add s mul x y +pb = add pb 16 +end +put fo add ai j s +end +end +end +end +fn main to int +oal_begin +put tn 0 ulong oal_p 0 +na = oal_fa 0 +nb = oal_fb 1 +w = oal_warm +for r ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge r w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get tn 0 256 +oal_end +ret 0 +end diff --git a/controls/gemm_offbyone/triton_kernel.py b/controls/gemm_offbyone/triton_kernel.py new file mode 100644 index 0000000..30f157c --- /dev/null +++ b/controls/gemm_offbyone/triton_kernel.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _tmatmul16(a, b, c, KN: tl.constexpr): + t = tl.program_id(0) + r = tl.arange(0, 16) + km = r < KN + av = tl.load(a + t * 256 + r[:, None] * 16 + r[None, :], mask=km[None, :], other=0.0) + bv = tl.load(b + t * 256 + r[:, None] * 16 + r[None, :], mask=km[:, None], other=0.0) + acc = tl.dot(av, bv, input_precision="ieee", out_dtype=tl.float32) + tl.store(c + t * 256 + r[:, None] * 16 + r[None, :], acc) + + +def launch(p, t): + _tmatmul16[(p["TILES"],)](t["a"], t["b"], t["c"], KN=15) diff --git a/controls/gemm_offbyone/workload.json b/controls/gemm_offbyone/workload.json new file mode 100644 index 0000000..8342184 --- /dev/null +++ b/controls/gemm_offbyone/workload.json @@ -0,0 +1,111 @@ +{ + "name": "gemm_offbyone", + "family": "tile-matmul", + "summary": "CONTROL: tmatmul16 with the k loop stopping at 15 of 16 terms in every entrant", + "provenance": "control for tmatmul16 (Apache-2.0); authored for OpenAccel Lab (Apache-2.0); the shape follows the tile kernels of aien-dev/omega-mv PR #869 (unmerged, head 6d08fd9c, seed/kflow/specs/tmatmul16.spec and seed/kflow/sm121/tmatmul16.s2)", + "params": { + "TILES": 64 + }, + "cases": [ + {}, + { + "TILES": 1 + }, + { + "TILES": 3 + } + ], + "shrink": { + "TILES": { + "min": 1 + } + }, + "inputs": [ + { + "name": "a", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 16 + ], + "gen": { + "kind": "grid", + "klo": -1024, + "khi": 1024, + "shift": 10 + } + }, + { + "name": "b", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 16 + ], + "gen": { + "kind": "grid", + "klo": -1024, + "khi": 1024, + "shift": 10 + } + } + ], + "outputs": [ + { + "name": "c", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 16 + ] + } + ], + "tolerance": { + "c": { + "kind": "bound", + "rtol": "gamma(15)", + "atol": 0.0, + "why": "Inputs are k*2^-10 with |k|<=1024, so every value is exact in f16 and in f32, every product a*b is an integer multiple of 2^-20 with |a*b|<=1 and is exact in f32, and with or without FMA a length-16 dot product starting from 0 takes at most 15 rounded additions (the first product enters exactly). Higham Thm 3.1/3.5 for any summation order with round-to-nearest (u=2^-24): |d-ref| <= gamma(15)*sum_k |a_ik b_kj|; reference.py passes that sum as scale. WolframLanguageEvaluator: u=2^-24; gam[n_]:=n u/(1-n u); N[gam[15],12] -> 8.94070470992e-7 (PR #869 quotes gamma_15 = 1.78814254071e-6 with u=2^-23 to allow any rounding mode; every entrant here rounds to nearest, so u=2^-24). On this grid the bound is not the binding fact: every partial sum is an integer multiple of 2^-20 of magnitude <= 16*2^20 = 2^24 (WolframLanguageEvaluator: 16*1024*1024==2^24 -> True), hence exact in f32, so a correct entrant's observed error is 0; the bound is what the contract guarantees for general f16 tiles. One dropped k term changes an element by |a_ik b_kj| up to 1, far above the bound, so gemm_offbyone fails." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "tmatmul16", + "global": [ + "TILES*256" + ], + "local": [ + 256 + ], + "args": [ + "a", + "b", + "c", + "TILES" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + }, + "expect": "fail", + "reference_from": "tmatmul16" +} diff --git a/controls/reduce_drop_last/kernel.cl b/controls/reduce_drop_last/kernel.cl new file mode 100644 index 0000000..7d71c37 --- /dev/null +++ b/controls/reduce_drop_last/kernel.cl @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL (deliberately wrong): pass 1 reads x[0..n-2] only, dropping the last element. +// Pass 1: each work-group of 256 sums its slice in a local-memory tree and writes one partial. +// Pass 2: one work-group sums the nb partials (strided, then a tree) into y[0]. +__kernel void rsum_part(__global const float *x, __global float *part, const int n, __local float *s) +{ + int l = get_local_id(0); + int i = get_global_id(0); + s[l] = i < n - 1 ? x[i] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + part[get_group_id(0)] = s[0]; +} + +__kernel void rsum_fin(__global const float *part, __global float *y, const int nb, __local float *s) +{ + int l = get_local_id(0); + float a = 0.0f; + for (int j = l; j < nb; j += get_local_size(0)) + a += part[j]; + s[l] = a; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + y[0] = s[0]; +} diff --git a/controls/reduce_drop_last/kernel.cu b/controls/reduce_drop_last/kernel.cu new file mode 100644 index 0000000..f35ae5c --- /dev/null +++ b/controls/reduce_drop_last/kernel.cu @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL (deliberately wrong): pass 1 reads x[0..n-2] only, dropping the last element. +// Pass 1: each block of 256 sums its slice in a shared-memory tree and writes one partial. +// Pass 2: one block sums the nb partials (strided, then a tree) into y[0]. +#include + +#define OAL_B 256 + +__global__ void rsum_part(const float *x, float *part, long long n) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + long long i = (long long)blockIdx.x * OAL_B + l; + s[l] = i < n - 1 ? x[i] : 0.0f; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + __syncthreads(); + } + if (l == 0) + part[blockIdx.x] = s[0]; +} + +__global__ void rsum_fin(const float *part, float *y, long long nb) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + float a = 0.0f; + for (long long j = l; j < nb; j += OAL_B) + a += part[j]; + s[l] = a; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + __syncthreads(); + } + if (l == 0) + y[0] = s[0]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0], nb = p[1]; + rsum_part<<<(unsigned)nb, OAL_B>>>((const float *)buf[0], (float *)buf[2], n); + rsum_fin<<<1, OAL_B>>>((const float *)buf[2], (float *)buf[1], nb); +} diff --git a/controls/reduce_drop_last/omega.om b/controls/reduce_drop_last/omega.om new file mode 100644 index 0000000..c6ba8e9 --- /dev/null +++ b/controls/reduce_drop_last/omega.om @@ -0,0 +1,26 @@ +note CONTROL (deliberately wrong): sums x[0..n-2] only, dropping the last element. +global kn ulong 1 +fn kern to void +s = 0.0f32 +for i ulong sub get kn 0 1 +s = add s get fa i +end +put fo 0 s +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 1 +oal_end +ret 0 +end diff --git a/controls/reduce_drop_last/triton_kernel.py b/controls/reduce_drop_last/triton_kernel.py new file mode 100644 index 0000000..2ffc51b --- /dev/null +++ b/controls/reduce_drop_last/triton_kernel.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# CONTROL (deliberately wrong): sums x[0..n-2] only, dropping the last element. +import triton +import triton.language as tl + + +@triton.jit +def _rsum(x, y, n, BLOCK: tl.constexpr): + # one program: BLOCK lane accumulators over the strided input, then a tree sum of the lanes + lane = tl.arange(0, BLOCK) + acc = tl.zeros([BLOCK], dtype=tl.float32) + for off in range(0, n, BLOCK): + i = off + lane + acc += tl.load(x + i, mask=i < n, other=0.0) + tl.store(y, tl.sum(acc, axis=0)) + + +def launch(p, t): + _rsum[(1,)](t["x"], t["y"], p["n"] - 1, BLOCK=4096) diff --git a/controls/reduce_drop_last/workload.json b/controls/reduce_drop_last/workload.json new file mode 100644 index 0000000..4e199e6 --- /dev/null +++ b/controls/reduce_drop_last/workload.json @@ -0,0 +1,52 @@ +{ + "name": "reduce_drop_last", + "family": "reduction", + "summary": "CONTROL for reduce_sum: every entrant sums only x[0..n-2], skipping the last element; judged by the reduce_sum reference and bound, it must fail", + "provenance": "authored for OpenAccel Lab (Apache-2.0); deliberately wrong copy of workloads/reduce_sum", + "expect": "fail", + "reference_from": "reduce_sum", + "params": { + "n": 2003 + }, + "derived": { + "nb": "(n + 255) // 256" + }, + "cases": [ + {}, + {"n": 1}, + {"n": 257} + ], + "shrink": { + "n": {"min": 1} + }, + "inputs": [ + {"name": "x", "dtype": "f32", "shape": ["n"], "gen": {"kind": "uniform", "lo": 0.5, "hi": 1.0}} + ], + "outputs": [ + {"name": "y", "dtype": "f32", "shape": [1]} + ], + "scratch": [ + {"name": "part", "dtype": "f32", "shape": ["nb"]} + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": "gamma(n)", + "atol": 0, + "why": "reduce_sum's contract. Inputs lie in [0.5, 1), so the bound gamma(n)*sum|x_i| < gamma(n)*n while the dropped element is >= 0.5 and the summation error is far below it: WolframLanguageEvaluator: u=2^-24; g[n_]:=n u/(1-n u); N[g[2003]*2003,10] -> 0.2391629245; N[g[257]*257,10] -> 0.003936887490; n = 1 drops the only element (y = 0 against x[0] >= 0.5). At reduce_sum's n = 100003 a single element of [-1, 1] sits under the bound (N[g[100003]*100003/2,10] -> 299.8282749), so the control uses n = 2003." + } + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": { + "src": "kernel.cl", + "launches": [ + {"kernel": "rsum_part", "global": ["nb * 256"], "local": [256], "args": ["x", "part", "n", "local:f32:256"]}, + {"kernel": "rsum_fin", "global": [256], "local": [256], "args": ["part", "y", "nb", "local:f32:256"]} + ] + }, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/controls/scan_exclusive/kernel.cl b/controls/scan_exclusive/kernel.cl new file mode 100644 index 0000000..dcadcfa --- /dev/null +++ b/controls/scan_exclusive/kernel.cl @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL (deliberately wrong): scans x shifted right by one, i.e. the EXCLUSIVE prefix sum. +// Launch 1: each work-group of 256 scans its slice in local memory (Hillis-Steele), writes the +// block-local inclusive prefix to y and the block total to bsum[g]. +// Launch 2: one work-group scans bsum in place (chunks of 256 with a running carry). +// Launch 3: every element of block g > 0 adds bsum[g - 1]. + +static void scan_tree(__local int *s, int l) +{ + for (int off = 1; off < (int)get_local_size(0); off <<= 1) { + int t = l >= off ? s[l - off] : 0; + barrier(CLK_LOCAL_MEM_FENCE); + s[l] += t; + barrier(CLK_LOCAL_MEM_FENCE); + } +} + +__kernel void scan_blk(__global const int *x, __global int *y, __global int *bsum, const int n, __local int *s) +{ + int l = get_local_id(0); + int i = get_global_id(0); + s[l] = (i >= 1 && i < n) ? x[i - 1] : 0; + barrier(CLK_LOCAL_MEM_FENCE); + scan_tree(s, l); + if (i < n) + y[i] = s[l]; + if (l == get_local_size(0) - 1) + bsum[get_group_id(0)] = s[l]; +} + +__kernel void scan_sums(__global int *bsum, const int nb, __local int *s) +{ + int l = get_local_id(0); + int w = get_local_size(0); + int carry = 0; + for (int base = 0; base < nb; base += w) { + int j = base + l; + s[l] = j < nb ? bsum[j] : 0; + barrier(CLK_LOCAL_MEM_FENCE); + scan_tree(s, l); + if (j < nb) + bsum[j] = s[l] + carry; + carry += s[w - 1]; + barrier(CLK_LOCAL_MEM_FENCE); + } +} + +__kernel void scan_add(__global int *y, __global const int *bsum, const int n) +{ + int i = get_global_id(0); + int g = get_group_id(0); + if (g > 0 && i < n) + y[i] += bsum[g - 1]; +} diff --git a/controls/scan_exclusive/kernel.cu b/controls/scan_exclusive/kernel.cu new file mode 100644 index 0000000..0c62932 --- /dev/null +++ b/controls/scan_exclusive/kernel.cu @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: Apache-2.0 +// CONTROL (deliberately wrong): scans x shifted right by one, i.e. the EXCLUSIVE prefix sum. +// Launch 1: each block of 256 scans its slice in shared memory (Hillis-Steele), writes the +// block-local inclusive prefix to y and the block total to bsum[g]. +// Launch 2: one block scans bsum in place (chunks of 256 with a running carry). +// Launch 3: every element of block g > 0 adds bsum[g - 1]. +#include + +#define OAL_B 256 + +__global__ void scan_blk(const int *x, int *y, int *bsum, long long n) +{ + __shared__ int s[OAL_B]; + int l = threadIdx.x; + long long i = (long long)blockIdx.x * OAL_B + l; + s[l] = (i >= 1 && i < n) ? x[i - 1] : 0; + __syncthreads(); + for (int off = 1; off < OAL_B; off <<= 1) { + int t = l >= off ? s[l - off] : 0; + __syncthreads(); + s[l] += t; + __syncthreads(); + } + if (i < n) + y[i] = s[l]; + if (l == OAL_B - 1) + bsum[blockIdx.x] = s[l]; +} + +__global__ void scan_sums(int *bsum, long long nb) +{ + __shared__ int s[OAL_B]; + int l = threadIdx.x; + int carry = 0; + for (long long base = 0; base < nb; base += OAL_B) { + long long j = base + l; + s[l] = j < nb ? bsum[j] : 0; + __syncthreads(); + for (int off = 1; off < OAL_B; off <<= 1) { + int t = l >= off ? s[l - off] : 0; + __syncthreads(); + s[l] += t; + __syncthreads(); + } + if (j < nb) + bsum[j] = s[l] + carry; + carry += s[OAL_B - 1]; + __syncthreads(); + } +} + +__global__ void scan_add(int *y, const int *bsum, long long n) +{ + long long i = (long long)blockIdx.x * OAL_B + threadIdx.x; + if (blockIdx.x > 0 && i < n) + y[i] += bsum[blockIdx.x - 1]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0], nb = p[1]; + int *x = (int *)buf[0], *y = (int *)buf[1], *bsum = (int *)buf[2]; + scan_blk<<<(unsigned)nb, OAL_B>>>(x, y, bsum, n); + scan_sums<<<1, OAL_B>>>(bsum, nb); + scan_add<<<(unsigned)nb, OAL_B>>>(y, bsum, n); +} diff --git a/controls/scan_exclusive/omega.om b/controls/scan_exclusive/omega.om new file mode 100644 index 0000000..748fdc0 --- /dev/null +++ b/controls/scan_exclusive/omega.om @@ -0,0 +1,26 @@ +note CONTROL (deliberately wrong): stores the prefix before adding x[i], i.e. the EXCLUSIVE scan. +global kn ulong 1 +fn kern to void +s = int 0 +for i ulong get kn 0 +put io i s +s = add s get ia i +end +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_ia 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_sio 0 get kn 0 +oal_end +ret 0 +end diff --git a/controls/scan_exclusive/triton_kernel.py b/controls/scan_exclusive/triton_kernel.py new file mode 100644 index 0000000..cfb2317 --- /dev/null +++ b/controls/scan_exclusive/triton_kernel.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 +# CONTROL (deliberately wrong): stores the EXCLUSIVE prefix sum. +import triton +import triton.language as tl + + +@triton.jit +def _scan(x, y, n, BLOCK: tl.constexpr): + lane = tl.arange(0, BLOCK) + carry = tl.sum(tl.zeros([BLOCK], dtype=tl.int32), axis=0) + for off in range(0, n, BLOCK): + i = off + lane + m = i < n + v = tl.load(x + i, mask=m, other=0) + tl.store(y + i, tl.cumsum(v, axis=0) - v + carry, mask=m) + carry += tl.sum(v, axis=0) + + +def launch(p, t): + _scan[(1,)](t["x"], t["y"], p["n"], BLOCK=4096) diff --git a/controls/scan_exclusive/workload.json b/controls/scan_exclusive/workload.json new file mode 100644 index 0000000..a1c0b90 --- /dev/null +++ b/controls/scan_exclusive/workload.json @@ -0,0 +1,52 @@ +{ + "name": "scan_exclusive", + "family": "scan", + "summary": "CONTROL for scan_i32: every entrant computes the EXCLUSIVE prefix sum (inclusive scan of x shifted right by one); judged by the scan_i32 reference, it must fail", + "provenance": "authored for OpenAccel Lab (Apache-2.0); deliberately wrong copy of workloads/scan_i32", + "expect": "fail", + "reference_from": "scan_i32", + "params": { + "n": 100003 + }, + "derived": { + "nb": "(n + 255) // 256" + }, + "cases": [ + {}, + {"n": 1}, + {"n": 257} + ], + "shrink": { + "n": {"min": 1} + }, + "inputs": [ + {"name": "x", "dtype": "i32", "shape": ["n"], "gen": {"kind": "int", "lo": 1, "hi": 9}} + ], + "outputs": [ + {"name": "y", "dtype": "i32", "shape": ["n"]} + ], + "scratch": [ + {"name": "bsum", "dtype": "i32", "shape": ["nb"]} + ], + "tolerance": { + "y": { + "kind": "int", + "atol": 0, + "why": "same contract as scan_i32; inputs are 1..9 so the exclusive prefix differs from the inclusive one at every element, including n = 1" + } + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": { + "src": "kernel.cl", + "launches": [ + {"kernel": "scan_blk", "global": ["nb * 256"], "local": [256], "args": ["x", "y", "bsum", "n", "local:i32:256"]}, + {"kernel": "scan_sums", "global": [256], "local": [256], "args": ["bsum", "nb", "local:i32:256"]}, + {"kernel": "scan_add", "global": ["nb * 256"], "local": [256], "args": ["y", "bsum", "n"]} + ] + }, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/controls/softmax_unstable/kernel.cl b/controls/softmax_unstable/kernel.cl new file mode 100644 index 0000000..47a0e05 --- /dev/null +++ b/controls/softmax_unstable/kernel.cl @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: Apache-2.0 +// one work-group per row; get_local_size(0) must be a power of two +// CONTROL: the max subtraction is deliberately omitted +__kernel void softmax(__global const float *x, __global float *y, const int D, __local float *red) +{ + int t = get_local_id(0), nt = get_local_size(0); + __global const float *xr = x + (long)get_group_id(0) * D; + __global float *yr = y + (long)get_group_id(0) * D; + float acc = 0.0f; + for (int k = t; k < D; k += nt) { + float e = exp(xr[k]); + yr[k] = e; + acc += e; + } + red[t] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int h = nt / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + barrier(CLK_LOCAL_MEM_FENCE); + } + float s = red[0]; + for (int k = t; k < D; k += nt) + yr[k] = yr[k] / s; +} diff --git a/controls/softmax_unstable/kernel.cu b/controls/softmax_unstable/kernel.cu new file mode 100644 index 0000000..ab338c8 --- /dev/null +++ b/controls/softmax_unstable/kernel.cu @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: Apache-2.0 +#include +#include + +#define NT 128 + +// one block of NT threads per row +// CONTROL: the max subtraction is deliberately omitted +__global__ void softmax(const float *x, float *y, long long D) +{ + __shared__ float red[NT]; + int t = threadIdx.x; + const float *xr = x + (long long)blockIdx.x * D; + float *yr = y + (long long)blockIdx.x * D; + float acc = 0.0f; + for (long long k = t; k < D; k += NT) { + float e = expf(xr[k]); + yr[k] = e; + acc += e; + } + red[t] = acc; + __syncthreads(); + for (int h = NT / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + __syncthreads(); + } + float s = red[0]; + for (long long k = t; k < D; k += NT) + yr[k] = yr[k] / s; +} + +void oal_launch(const long long *p, void *const *buf) +{ + softmax<<<(unsigned)p[0], NT>>>((const float *)buf[0], (float *)buf[1], p[1]); +} diff --git a/controls/softmax_unstable/omega.om b/controls/softmax_unstable/omega.om new file mode 100644 index 0000000..60d9841 --- /dev/null +++ b/controls/softmax_unstable/omega.om @@ -0,0 +1,38 @@ +note CONTROL softmax_unstable: the max subtraction is deliberately omitted, e = exp(x) rounded to f32 +global kr ulong 1 +global kd ulong 1 +fn smrow o ulong d ulong to void +s = 0.0f32 +for k ulong d +e = f32 oal_expf f64 get fa add o k +put fo add o k e +s = add s e +end +for k ulong d +put fo add o k div get fo add o k s +end +end +fn kern to void +d = get kd 0 +for i ulong get kr 0 +smrow mul i d d +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kd 0 ulong oal_p 1 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 a +oal_end +ret 0 +end diff --git a/controls/softmax_unstable/triton_kernel.py b/controls/softmax_unstable/triton_kernel.py new file mode 100644 index 0000000..6689686 --- /dev/null +++ b/controls/softmax_unstable/triton_kernel.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _softmax(x, y, D, BLOCK: tl.constexpr): + r = tl.program_id(0) + k = tl.arange(0, BLOCK) + m = k < D + # CONTROL: the max subtraction is deliberately omitted + v = tl.load(x + r * D + k, mask=m, other=-float("inf")) + e = tl.exp(v) + tl.store(y + r * D + k, e / tl.sum(e, axis=0), mask=m) + + +def launch(p, t): + _softmax[(p["R"],)](t["x"], t["y"], p["D"], BLOCK=triton.next_power_of_2(p["D"])) diff --git a/controls/softmax_unstable/workload.json b/controls/softmax_unstable/workload.json new file mode 100644 index 0000000..b58bd0b --- /dev/null +++ b/controls/softmax_unstable/workload.json @@ -0,0 +1,99 @@ +{ + "name": "softmax_unstable", + "family": "row-reduction-transcendental", + "summary": "CONTROL: row softmax with the max subtraction omitted in every entrant (y = exp(x) / sum(exp(x))); inputs in [80,100] overflow f32 exp (e^100 = 2.69e43 > f32 max 3.40e38), so every entrant must fail against the stable softmax reference", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "R": 24, + "D": 200 + }, + "cases": [ + {}, + { + "R": 4, + "D": 7 + }, + { + "R": 5, + "D": 1023 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "D": { + "min": 1 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "R", + "D" + ], + "gen": { + "kind": "uniform", + "lo": 80.0, + "hi": 100.0 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "R", + "D" + ] + } + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": 1.0, + "atol": 0.0, + "why": "same contract as workloads/softmax (reference_from softmax). Expected to fail: without the max subtraction exp overflows f32 for x > ln(f32 max) (WolframLanguageEvaluator: Log[(2-2^-23) 2^127] -> 88.7228; Exp[100] -> 2.6881e43 > (2-2^-23)2^127 = 3.4028e38), so row sums are +inf and the outputs NaN or 0." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "softmax", + "global": [ + "R*64" + ], + "local": [ + "64" + ], + "args": [ + "x", + "y", + "D", + "local:f32:64" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + }, + "expect": "fail", + "reference_from": "softmax" +} diff --git a/docs/AUTHORING.md b/docs/AUTHORING.md new file mode 100644 index 0000000..c21a462 --- /dev/null +++ b/docs/AUTHORING.md @@ -0,0 +1,117 @@ +# Writing a workload + +A workload is one directory `workloads//` (or `controls//` for a deliberately wrong +kernel). The directory name, the `name` field and the reference module agree. Everything an entrant +needs is in the directory; nothing outside it is workload-specific. + +``` +workloads// + workload.json manifest: shapes, generators, tolerance contract, entrant sources + reference.py reference(p, x): float64 numpy oracle, never an entrant + omega.om Omega entrant (kernel + main), compiled after lib/omega/oal.om + kernel.cl OpenCL C entrant (one or more __kernel functions) + triton_kernel.py Triton entrant: launch(p, t) + kernel.cu CUDA entrant: oal_launch(p, buf); the HIP entrant is this file through hipify-perl +``` + +## workload.json + +| field | meaning | +|---|---| +| `name`, `family`, `summary`, `provenance` | identity; provenance says who wrote it and under what licence | +| `params` | integer parameters with their default values, in container order | +| `derived` | optional `{name: expression}` computed from params after overrides, appended in order | +| `cases` | list of parameter overrides run by `oal-matrix`; `{}` is the default case. Include an edge shape (a size of 1, a size that is not a multiple of any block). | +| `shrink` | per parameter `{"min": m, "multiple_of": k}`: how far `oal-shrink` may reduce it | +| `inputs` | tensors `{name, dtype, shape, gen}`; dtype one of f32 f64 i32 i8 u8; shape a list of expressions | +| `outputs` | tensors `{name, dtype, shape}` | +| `tolerance` | per output: `{"kind": "exact"}`, `{"kind": "bound", "rtol": expr, "atol": expr, "why": text}` or `{"kind": "int", "atol": n}` | +| `timing` | `{"warmup": w, "repeats": r}` | +| `backends` | `omega: {src}`, `opencl: {src, launches, scratch?, options?}`, `triton: {src}`, `cuda: {src}` | +| `scratch` | optional top-level list of tensors `{name, dtype, shape}` that OpenCL/Triton/CUDA entrants may use as device temporaries (zeroed for Triton/CUDA, undefined for OpenCL) | +| `expect` | controls only: `"fail"` | +| `reference_from` | controls only: the workload whose reference judges this control | + +Expressions are Python arithmetic over parameter names plus `gamma(n)`, `u` (2^-24), `max`, `min`, +`log2`, `ceil`. `gamma(n)` is n·u/(1−n·u), Higham's bound on n roundings in binary32. + +Generators (`gen`), all from splitmix64 with stream seed `seed ^ fnv1a64("/")`: + +- `{"kind":"uniform","lo":a,"hi":b}`: a + (b−a)·k·2^-24 +- `{"kind":"normal4","mean":m,"std":s}`: Irwin–Hall sum of four uniforms, unit variance, then scaled +- `{"kind":"grid","klo":i,"khi":j,"shift":s}`: integer k in [i, j] times 2^-s, exact in f16 when |k| < 2048 +- `{"kind":"int","lo":i,"hi":j}`: integers; required for i32, i8, u8 inputs +- `{"kind":"const","value":v}`, `{"kind":"iota","mod":m}` + +Float scalars (alpha, eps) are written as constants in every source or passed as one-element f32 +inputs; integer scalars are parameters. + +## The tolerance contract + +`exact` is for outputs made by at most one correctly rounded operation per element (add, mul, +copy, max, integer work). Everything else uses `bound` with a bound you can defend: state it in the +`why` field, and derive any numeric constant through the Wolfram Language evaluator, quoting the +query and result (`WolframLanguageEvaluator: -> `). The bound must hold for any +summation order and for fused multiply-add, because OpenCL C contracts `a*b+c` by default and GPU +compilers fuse; a recursive dot product of length n in any order is within gamma(n)·Σ|a_i b_i| +(Higham Thm 3.1/3.5), so pass that sum as the `scale` from `reference.py` and use `rtol: gamma(n)`. +For a transcendental, budget its documented accuracy: OpenCL `exp` ≤ 3 ulp (OpenCL C 3.0 §7.4), +CUDA `expf` ≤ 2 ulp (CUDA C Programming Guide, Mathematical Functions), so allow at least 4·u +relative per exp on top of the arithmetic bound. A bound so loose that a wrong kernel passes is a +defect: every workload family needs a control that fails it. + +## reference.py + +```python +import numpy as np + +def reference(p, x): # p: params dict, x: inputs as numpy arrays (manifest dtypes) + a = x["a"].astype(np.float64) + return {"y": a * 2.0} # or {"y": (value, scale)} with an elementwise scale for "bound" +``` + +Compute in float64 from the exact input values, in the obvious order, with no float32 shortcut. The +reference shape must equal the manifest shape. + +## Entrants + +All entrants see the same case: parameters in manifest order (`params`, then `derived`), inputs in +manifest order, outputs in manifest order. Outputs start filled with 0xFF bytes (NaN for f32), so an +element the kernel never writes fails the check. + +**Omega (`omega.om`).** Compiled as `lib/omega/oal.om` + `omega.om` by the pinned omc +(aien-dev/omega-mv 369dbc96), program mode, Linux AArch64. The prelude reads the case and gives: +`oal_begin`, `oal_p k` (parameter k, long), `oal_warm`, `oal_reps`, loaders that copy input k into a +pool and return its element count (`oal_fa..oal_fe k` into f32 pools `fa..fe`, `oal_ia/oal_ic k` into +int pools `ia/ic`, `oal_qa k` into byte pool `qa`, values −128..127), stores that copy a pool to output +k (`oal_so k n` from `fo`, `oal_sp k n` from `fp`, `oal_sio k n` from `io`, `oal_sqo k n` from `qo`), +`oal_tick ns` (one timing line), `oal_end` (writes stdout) and `oal_expf x` (binary64 e^x). Pools hold +4194304 elements; a workload may declare its own globals (names up to 8 characters, not clashing with +the prelude). Globals cannot be passed as arguments (error 19); functions use them by name. A +function takes at most 6 parameters. The pattern is `workloads/vecadd/omega.om`: a `kern` function +over globals, a main that loads, times `oal_reps` calls after `oal_warm` untimed ones with `monons`, +stores and ends. Language reference: `docs/one_layer/OMEGESE.md` in aien-dev/omega-mv; the pinned +compiler is the authority on what compiles. + +**OpenCL (`kernel.cl` + `launches`).** Each launch is `{"kernel", "global": [exprs], "local": +[exprs] or null, "args": [...]}`, run in order once per timed repeat. An argument is a tensor name +(input, output or scratch buffer), a parameter expression (passed as `int`), `"f32:"` (a float), +or `"local::"` (`__local` memory). No fast-math options. + +**Triton (`triton_kernel.py`).** Define `launch(p, t)`; `t` maps every input, output and scratch name +to a contiguous CPU torch tensor. CI runs with `TRITON_INTERPRET=1`: keep shapes small and blocks +powers of two. + +**CUDA and HIP (`kernel.cu`).** `#include `, the kernels, then +`void oal_launch(const long long *p, void *const *buf)` that launches them; `buf` holds device +pointers for inputs, outputs, then scratch, in manifest order. The HIP entrant is this file through +`hipify-perl -hip-kernel-execution-syntax`, built against HIP-CPU (ROCm/HIP-CPU e112c935) with g++: +use static `__shared__` arrays only, no templates on kernels, no warp intrinsics, no dynamic +parallelism, and `__syncthreads()` only where every thread of the block reaches it. CUDA is built +with nvcc on CI and run only on rented GPUs (`runners/cuda/run_all.sh`). + +## Controls + +A control is a copy of a workload with the same defect written into every entrant (for example the +k loop stops one short). It sets `"expect": "fail"` and `"reference_from": ""`. `oal-gate` +fails CI if a control passes anywhere it ran. diff --git a/docs/CONTAINER.md b/docs/CONTAINER.md new file mode 100644 index 0000000..b9dfc51 --- /dev/null +++ b/docs/CONTAINER.md @@ -0,0 +1,33 @@ +# Case container (`OALCASE1`) + +One case is one byte stream. `bin/oal-gen` writes it to stdout; every entrant program reads it on +stdin and writes its outputs to stdout. Because every entrant is a separate process that only sees +these bytes, a crash in one entrant cannot corrupt another, and identical input is provable: the +container's sha256 is recorded in every result line and the gate requires it to agree across runners. + +All integers are little-endian. + +| offset | size | field | +|---|---|---| +| 0 | 8 | magic `OALCASE1` | +| 8 | 8 | u64 `nparam`: declared parameters, then derived parameters, in manifest order | +| 16 | 8 | u64 `nin`: input tensors | +| 24 | 8 | u64 `nout`: output tensors | +| 32 | 8 | u64 `warmup`: untimed launches before timing | +| 40 | 8 | u64 `repeats`: timed launches | +| 48 | 8*nparam | i64 parameter values | +| ... | 8*(nin+nout) | u64 byte sizes of each input, then each output | +| ... | ... | input tensors in manifest order, each padded with zero bytes to a multiple of 8 | + +Outputs: the entrant writes each output tensor in manifest order, each padded to a multiple of 8, +and nothing else on stdout. Output buffers start filled with `0xFF` bytes in every runner, so an +element the kernel never writes is a NaN (floats) or -1 (integers) and fails the check instead of +passing by luck on zeroed memory. + +Timing: for each timed launch the entrant writes `oal-time-ns N` on stderr, where `N` is the +wall-clock nanoseconds of that launch including the wait for completion and excluding host-device +copies. It may write `oal-version TEXT` lines naming its runtime. Anything else on stderr is a +diagnostic and is kept in the result's `log` field only on failure. + +Exit codes of entrant programs: 0 success, 2 malformed case, 3 runtime error (device, launch or +API failure), 100+N an Omega `trap N` (9 bad header, 10 output size mismatch, 11 trailing bytes). diff --git a/docs/RESULTS.md b/docs/RESULTS.md new file mode 100644 index 0000000..3ef83e7 --- /dev/null +++ b/docs/RESULTS.md @@ -0,0 +1,29 @@ +# Result lines (`oal-result/1`) + +`bin/oal-matrix` writes one JSON object per line per (workload, backend, case, seed). `bin/oal-gate` +and `bin/oal-board` read only these lines. + +| field | meaning | +|---|---| +| `workload`, `family`, `control`, `expect` | from the manifest; `control` lines are expected to fail | +| `backend` | `omega`, `opencl`, `triton`, `hip` or `cuda` | +| `params`, `seed` | the case; `bin/oal-gen WORKLOAD --seed S --set k=v ...` rebuilds it byte for byte | +| `case_sha256`, `case_bytes` | sha256 and size of the container the entrant received | +| `status` | `PASS`, `FAIL` (ran, outside tolerance), `RUNTIME_FAIL`, `COMPILE_FAIL`, `TIMEOUT`, `COMPILED` (CUDA built but no GPU run), `NOT_RUN` (toolchain absent), `NO_SOURCE` (no entrant file) | +| `err_ratio` | largest `abs(got - ref) / bound` over every output element (see TOLERANCE.md) | +| `outputs` | per output: `pass`, `failed` count, `elements`, `first_bad` (index, got, ref, bound) | +| `outputs_sha256` | sha256 of the entrant's whole stdout, for bitwise agreement across backends | +| `times_ns` | every timed launch, in order; never averaged | +| `timing_label` | what the times mean on this machine; CPU runners say so | +| `evidence` | evidence level and machine, for example `EXERCISED: CPU runner` | +| `machine` | os, arch, cpu, cpu count, `runner` label, CI run URL | +| `versions`, `toolchain`, `build` | runtime versions the entrant reported and the build command used | +| `lab_commit` | commit of this repository | + +Only `PASS` counts toward the gate's "at least 3 backends per workload". `COMPILED`, `NOT_RUN` and +`NO_SOURCE` are never counted as passing. + +GPU result lines live under `receipts/gpu/*.jsonl` and use the same schema, with `machine.runner` +naming the GPU, compute capability and driver, and `evidence` stating who ran them, when and how. +Imported receipts from aien-dev/omega-gpu-bench sit under `receipts/imported/` unchanged, with a +`SHA256SUMS` file. diff --git a/docs/TOLERANCE.md b/docs/TOLERANCE.md new file mode 100644 index 0000000..583dff2 --- /dev/null +++ b/docs/TOLERANCE.md @@ -0,0 +1,47 @@ +# Tolerance contract + +Every workload states, per output, how close an entrant has to come to the float64 reference. +`oal/check.py` applies the contract; the entrant never sees it. + +| kind | rule | used for | +|---|---|---| +| `exact` | bitwise equal to the reference rounded to the output dtype | integer outputs, copies, elementwise ops whose float32 result is correctly rounded | +| `int` | `abs(got - ref) <= atol` on integers | quantisation, where round-half cases may differ by one step | +| `bound` | `abs(got - ref) <= c * gamma(n) * scale + atol` | reductions, dot products, matmuls, normalisations | + +`gamma(n) = n*u / (1 - n*u)` with `u = 2^-24` (float32 unit roundoff) is the standard forward error +bound for a length-`n` floating-point sum or dot product computed in any order (Higham, *Accuracy +and Stability of Numerical Algorithms*, 2nd ed., Section 3.1). `scale` is the reference's own +magnitude term, for example `sum |a_i * b_i|` for a dot product, so the bound does not depend on +cancellation in the exact answer. `c` and `atol` are written in each `workload.json` with a one-line +reason. A record's `err_ratio` is the largest `abs(got - ref) / bound` over all elements: +0 means bit-exact, 1 means at the bound, above 1 fails. + +The bound allows any summation order on purpose. A tree reduction on a GPU, a serial loop on a CPU +and a Kahan sum all pass; a dropped term, an off-by-one index or an exclusive scan in place of an +inclusive one does not, and the controls in `controls/` prove that on every backend. + +## Transcendentals in the Omega entrant + +Seeded Omega has no `exp` word at omega-mv 369dbc96, so `lib/omega/oal.om` implements `oal_expf` +in float64: `x = n*ln2 + r` with `n = round(x / ln2)`, a two-part `ln2` (Cody-Waite) and a degree-11 +Taylor polynomial for `exp(r)`, then scaling by `2^n` through the exponent bits. The result is +rounded to float32 by the caller. Every constant was checked with Wolfram: + +- `WolframLanguageEvaluator: N[Log[2] - (SetPrecision[0.6931471803691238,40] + SetPrecision[1.9082149292705877*^-10,40]), 20]` + -> `1.16122272293625318506558032769199*^-26` (the split of ln2 is exact far below float64 precision). +- `WolframLanguageEvaluator: N[1/Log[2], 20]` -> `1.4426950408889634074` (the `oal_expf` constant + `1.4426950408889634`). +- `WolframLanguageEvaluator: Table[{k, N[1/k!, 17]}, {k, 2, 11}]` -> `0.5, 0.16666666666666667, + 0.041666666666666667, 0.0083333333333333333, 0.0013888888888888889, 0.00019841269841269841, + 0.000024801587301587302, 2.7557319223985891*^-6, 2.7557319223985891*^-7, 2.5052108385441719*^-8` + (the polynomial coefficients). +- `WolframLanguageEvaluator: N[MaxValue[{Abs[Exp[r] - (1 + Sum[r^k/k!, {k, 1, 11}])]/Exp[r], -Log[2]/2 <= r <= Log[2]/2}, r], 6]` + -> `8.63527402609310923645372*^-15` (largest relative truncation error of the polynomial on the + reduced range). + +That truncation error is 1.45e-7 of the float32 unit roundoff `2^-24` +(`WolframLanguageEvaluator: N[8.63527402609310923645372*^-15/2^-24, 6]` -> `1.44876*^-7`), so after the +final rounding to float32 the Omega `expf` differs from a correctly rounded `expf` only on inputs +that lie within that distance of a rounding boundary. Workloads that use `exp` (softmax, silu, +attention) carry it in their `bound` term through `c`, not through a special case per entrant. diff --git a/lib/omega/oal.om b/lib/omega/oal.om new file mode 100644 index 0000000..22ef01c --- /dev/null +++ b/lib/omega/oal.om @@ -0,0 +1,339 @@ +note lib/omega/oal.om: OpenAccel Lab case I/O for Omega entrants (seeded Omega, program mode, Linux AArch64). +note The runner puts this file in front of a workload's kernel.om and compiles the pair with the pinned omc. +note stdin: one case container (docs/CONTAINER.md). stdout: the output tensors, each padded to 8 bytes. +note stderr: one line "oal-time-ns N" per timed repeat. Exit 0, or 100 + N on trap N. +note Arrays cannot be passed by global name (error 19), so each pool has its own load and store word. +global ib uchar 16777216 +global ob uchar 16777216 +global hdr ulong 8 +global prm long 32 +global tsz ulong 32 +global tof ulong 32 +global fa f32 4194304 +global fb f32 4194304 +global fc f32 4194304 +global fd f32 4194304 +global fe f32 4194304 +global fo f32 4194304 +global fp f32 4194304 +global ia int 4194304 +global ic int 4194304 +global io int 4194304 +global qa byte 4194304 +global qo byte 4194304 +global tline uchar 64 + +fn oal_u64 o ulong to ulong +v = ulong 0 +for k ulong 8 +v = or v shl ulong get ib add o k mul k 8 +end +ret v +end + +fn oal_u32 o ulong to uint +v = uint 0 +for k ulong 4 +v = or v shl uint get ib add o k uint mul k 8 +end +ret v +end + +fn oal_pad8 n ulong to ulong +ret mul div add n 7 8 8 +end + +fn oal_begin to void +n = ulong 0 +while true bound 999999 +r = read 0 ib n sub len ib n +if lt r 0 +trap 9 +end +if eq r 0 +break +end +n = add n ulong r +end +if lt n 48 +trap 9 +end +if ne oal_u64 0 3550335421018554703 +trap 9 +end +for k ulong 5 +put hdr k oal_u64 add 8 mul k 8 +end +np = get hdr 0 +nt = add get hdr 1 get hdr 2 +if gt np 32 +trap 9 +end +if gt nt 32 +trap 9 +end +o = ulong 48 +for k ulong np +put prm k bitcast long oal_u64 o +o = add o 8 +end +for k ulong nt +put tsz k oal_u64 o +o = add o 8 +end +for k ulong get hdr 1 +put tof k o +o = add o oal_pad8 get tsz k +end +if gt o n +trap 9 +end +end + +fn oal_p k ulong to long +ret get prm k +end + +fn oal_warm to ulong +ret get hdr 3 +end + +fn oal_reps to ulong +ret get hdr 4 +end + +fn oal_lf32 k ulong to ulong +if ge k get hdr 1 +trap 9 +end +n = div get tsz k 4 +if gt n 4194304 +trap 9 +end +ret n +end + +fn oal_fa k ulong to ulong +n = oal_lf32 k +o = get tof k +for i ulong n +put fa i bitcast f32 oal_u32 add o mul i 4 +end +ret n +end + +fn oal_fb k ulong to ulong +n = oal_lf32 k +o = get tof k +for i ulong n +put fb i bitcast f32 oal_u32 add o mul i 4 +end +ret n +end + +fn oal_fc k ulong to ulong +n = oal_lf32 k +o = get tof k +for i ulong n +put fc i bitcast f32 oal_u32 add o mul i 4 +end +ret n +end + +fn oal_fd k ulong to ulong +n = oal_lf32 k +o = get tof k +for i ulong n +put fd i bitcast f32 oal_u32 add o mul i 4 +end +ret n +end + +fn oal_fe k ulong to ulong +n = oal_lf32 k +o = get tof k +for i ulong n +put fe i bitcast f32 oal_u32 add o mul i 4 +end +ret n +end + +fn oal_ia k ulong to ulong +n = oal_lf32 k +o = get tof k +for i ulong n +put ia i bitcast int oal_u32 add o mul i 4 +end +ret n +end + +fn oal_ic k ulong to ulong +n = oal_lf32 k +o = get tof k +for i ulong n +put ic i bitcast int oal_u32 add o mul i 4 +end +ret n +end + +fn oal_qa k ulong to ulong +if ge k get hdr 1 +trap 9 +end +n = get tsz k +if gt n 4194304 +trap 9 +end +o = get tof k +for i ulong n +v = long get ib add o i +if ge v 128 +v = sub v 256 +end +put qa i byte v +end +ret n +end + +fn oal_oof k ulong to ulong +nin = get hdr 1 +if ge k get hdr 2 +trap 9 +end +o = ulong 0 +for j ulong k +o = add o oal_pad8 get tsz add nin j +end +ret o +end + +fn oal_o32 o ulong v uint to void +for k ulong 4 +put ob add o k uchar and shr v uint mul k 8 255 +end +end + +fn oal_ochk k ulong n ulong w ulong to ulong +if ne mul n w get tsz add get hdr 1 k +trap 10 +end +ret oal_oof k +end + +fn oal_so k ulong n ulong to void +o = oal_ochk k n 4 +for i ulong n +oal_o32 add o mul i 4 bitcast uint get fo i +end +end + +fn oal_sp k ulong n ulong to void +o = oal_ochk k n 4 +for i ulong n +oal_o32 add o mul i 4 bitcast uint get fp i +end +end + +fn oal_sio k ulong n ulong to void +o = oal_ochk k n 4 +for i ulong n +oal_o32 add o mul i 4 bitcast uint get io i +end +end + +fn oal_sqo k ulong n ulong to void +o = oal_ochk k n 1 +for i ulong n +v = long get qo i +if lt v 0 +v = add v 256 +end +put ob add o i uchar v +end +end + +fn oal_end to void +nin = get hdr 1 +nout = get hdr 2 +t = ulong 0 +for j ulong nout +t = add t oal_pad8 get tsz add nin j +end +o = ulong 0 +while lt o t bound 999999 +r = write 1 ob o sub t o +if le r 0 +trap 11 +end +o = add o ulong r +end +end + +fn oal_tick ns long to void +put tline 0 111 +put tline 1 97 +put tline 2 108 +put tline 3 45 +put tline 4 116 +put tline 5 105 +put tline 6 109 +put tline 7 101 +put tline 8 45 +put tline 9 110 +put tline 10 115 +put tline 11 32 +v = ulong ns +d = new uchar 24 0 +k = ulong 0 +while true bound 30 +put d k uchar add rem v 10 48 +k = add k 1 +v = div v 10 +if eq v 0 +break +end +end +p = ulong 12 +while gt k 0 bound 30 +k = sub k 1 +put tline p get d k +p = add p 1 +end +put tline p 10 +r = write 2 tline 0 add p 1 +end + +fn oal_expf x f64 to f64 +note e^x in binary64: x = n ln2 + r, |r| <= ln2/2, degree-11 Taylor polynomial in r, scaled by 2^n +note built from the exponent bits. x < -708 gives 0.0 and x > 709 gives +infinity. +if lt x -708.0f64 +ret 0.0f64 +end +if gt x 709.0f64 +ret div 1.0f64 0.0f64 +end +t = mul x 1.4426950408889634f64 +n = long 0 +if ge t 0.0f64 +n = long add t 0.5f64 +else +n = long sub t 0.5f64 +end +fn64 = f64 n +r = sub x mul fn64 0.6931471803691238f64 +r = sub r mul fn64 1.9082149292705877e-10f64 +p = 2.505210838544172e-8f64 +p = add mul p r 2.755731922398589e-7f64 +p = add mul p r 2.7557319223985893e-6f64 +p = add mul p r 2.48015873015873e-5f64 +p = add mul p r 1.984126984126984e-4f64 +p = add mul p r 1.3888888888888889e-3f64 +p = add mul p r 8.333333333333333e-3f64 +p = add mul p r 4.1666666666666664e-2f64 +p = add mul p r 0.16666666666666666f64 +p = add mul p r 0.5f64 +p = add mul p r 1.0f64 +p = add mul p r 1.0f64 +s = bitcast f64 shl ulong add n 1023 52 +ret mul p s +end diff --git a/oal/case.py b/oal/case.py new file mode 100644 index 0000000..6f668ed --- /dev/null +++ b/oal/case.py @@ -0,0 +1,144 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Deterministic inputs and the case container (docs/CONTAINER.md). + +Every input value is made from splitmix64 integers with IEEE basic operations only (+ - * /), +never with a libm function, so two machines produce byte-identical inputs. The case sha256 is +recorded with every result so the board can show that two runners ran the same bytes. + +INTERIM host glue (Python + numpy). Successor: oal-gen in seeded Omega (splitmix64 and the +container writer need only integer words and write). +""" +import hashlib +import struct + +import numpy as np + +from . import manifest + +MAGIC = b"OALCASE1" +M64 = np.uint64(0xFFFFFFFFFFFFFFFF) + + +def fnv1a64(text): + h = 0xCBF29CE484222325 + for b in text.encode(): + h = ((h ^ b) * 0x100000001B3) & 0xFFFFFFFFFFFFFFFF + return h + + +def splitmix64(seed, count): + """count outputs of splitmix64 (Steele, Lea, Flood 2014) starting from state seed.""" + with np.errstate(over="ignore"): + idx = np.arange(1, count + 1, dtype=np.uint64) + z = np.uint64(seed) + idx * np.uint64(0x9E3779B97F4A7C15) + z = (z ^ (z >> np.uint64(30))) * np.uint64(0xBF58476D1CE4E5B9) + z = (z ^ (z >> np.uint64(27))) * np.uint64(0x94D049BB133111EB) + return z ^ (z >> np.uint64(31)) + + +def unit24(bits): + """Top 24 bits as a float64 in [0, 1), exact.""" + return (bits >> np.uint64(40)).astype(np.float64) * (2.0 ** -24) + + +def generate(spec, count, stream_seed): + g = spec["gen"] + kind = g["kind"] + if kind == "uniform": + v = g["lo"] + (g["hi"] - g["lo"]) * unit24(splitmix64(stream_seed, count)) + elif kind == "normal4": + # Irwin-Hall: sum of four U(0,1) minus 2, scaled to unit variance (var = 4/12). + b = splitmix64(stream_seed, 4 * count).reshape(count, 4) + s = unit24(b).sum(axis=1) - 2.0 + v = g.get("mean", 0.0) + g.get("std", 1.0) * s * np.sqrt(3.0) + elif kind == "grid": + # integers k in [klo, khi] times 2^-shift: exactly representable in narrow formats. + span = np.uint64(g["khi"] - g["klo"] + 1) + k = (splitmix64(stream_seed, count) % span).astype(np.int64) + g["klo"] + v = k.astype(np.float64) * (2.0 ** -g["shift"]) + elif kind == "int": + span = np.uint64(g["hi"] - g["lo"] + 1) + v = (splitmix64(stream_seed, count) % span).astype(np.int64) + g["lo"] + elif kind == "const": + v = np.full(count, g["value"], dtype=np.float64) + elif kind == "iota": + v = (np.arange(count, dtype=np.int64) % g.get("mod", count)).astype(np.float64) + else: + raise ValueError("unknown generator %r" % kind) + return v + + +def inputs(m, params, seed): + """Dict name -> numpy array (manifest dtype and shape), in manifest order.""" + out = {} + for spec in m["inputs"]: + dims = manifest.shape(spec, params) + count = int(np.prod(dims)) + stream = (seed ^ fnv1a64(m["name"] + "/" + spec["name"])) & 0xFFFFFFFFFFFFFFFF + v = generate(spec, count, stream) + np_dtype = manifest.DTYPES[spec["dtype"]][0] + if spec["dtype"] in ("i32", "i8", "u8"): + arr = np.asarray(v).astype(np.int64) + info = np.iinfo(np_dtype) + if arr.min() < info.min or arr.max() > info.max: + raise ValueError("%s: generator leaves %s range" % (spec["name"], spec["dtype"])) + arr = arr.astype(np_dtype) + else: + arr = np.asarray(v, dtype=np.float64).astype(np_dtype) + out[spec["name"]] = arr.reshape(dims) + return out + + +def pad8(n): + return (n + 7) // 8 * 8 + + +def pack(m, params, tensors, warmup, repeats): + """The container bytes: header, int64 params, tensor byte sizes, then padded input data.""" + names = list(params) + head = MAGIC + struct.pack("<5Q", len(names), len(m["inputs"]), len(m["outputs"]), warmup, repeats) + head += struct.pack("<%dq" % len(names), *[int(params[k]) for k in names]) + sizes = [manifest.nbytes(s, params) for s in m["inputs"] + m["outputs"]] + head += struct.pack("<%dQ" % len(sizes), *sizes) + body = b"" + for spec in m["inputs"]: + raw = np.ascontiguousarray(tensors[spec["name"]]).tobytes() + body += raw + b"\0" * (pad8(len(raw)) - len(raw)) + return head + body + + +def unpack(blob): + """Inverse of pack for Python entrants: (params list, sizes list, inputs bytes list, warmup, repeats).""" + if blob[:8] != MAGIC: + raise ValueError("not an OALCASE1 container") + np_, nin, nout, warm, reps = struct.unpack_from("<5Q", blob, 8) + o = 48 + params = list(struct.unpack_from("<%dq" % np_, blob, o)) + o += 8 * np_ + sizes = list(struct.unpack_from("<%dQ" % (nin + nout), blob, o)) + o += 8 * (nin + nout) + ins = [] + for k in range(nin): + ins.append(blob[o:o + sizes[k]]) + o += pad8(sizes[k]) + return params, sizes, ins, warm, reps + + +def split_outputs(m, params, raw): + """Cut an entrant's stdout into named output arrays; raises on a short or long stream.""" + out = {} + o = 0 + for spec in m["outputs"]: + n = manifest.nbytes(spec, params) + if o + n > len(raw): + raise ValueError("output stream ends inside %s (%d of %d bytes)" % (spec["name"], len(raw) - o, n)) + out[spec["name"]] = np.frombuffer(raw[o:o + n], dtype=manifest.DTYPES[spec["dtype"]][0]).reshape( + manifest.shape(spec, params)) + o += pad8(n) + if o != len(raw): + raise ValueError("output stream has %d bytes, expected %d" % (len(raw), o)) + return out + + +def sha256(blob): + return hashlib.sha256(blob).hexdigest() diff --git a/oal/check.py b/oal/check.py new file mode 100644 index 0000000..6d30d38 --- /dev/null +++ b/oal/check.py @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: Apache-2.0 +"""The tolerance contract (docs/TOLERANCE.md). + +The reference (workloads//reference.py) computes in float64 from the exact input values and +returns, per output, the value and optionally a scale array. The contract kinds are: + + exact every element equals the reference rounded once to the output dtype (bitwise for floats, + with -0.0 == 0.0); used where one correctly rounded operation, or none, makes each element. + bound |got - ref| <= rtol * scale + atol elementwise; scale defaults to |ref|. rtol and atol are + manifest expressions (gamma(n), u, parameters), so the bound follows the shape. + int |got - ref| <= atol on integers (atol 0 is exact). + +NaN or infinity in an output fails unless the reference has the same value at that element. +The verdict carries err_ratio = max(|got - ref| / bound) so the board can show how much of the +bound each entrant used (1.0 = at the limit). + +INTERIM host glue (Python + numpy). Successor: oal-check in seeded Omega (f32/f64 words exist). +""" +import numpy as np + +from . import manifest + + +def _bound_arrays(contract, params, ref, scale): + rtol = float(manifest.evaluate(contract.get("rtol", 0.0), params)) + atol = float(manifest.evaluate(contract.get("atol", 0.0), params)) + sc = np.abs(ref) if scale is None else np.asarray(scale, dtype=np.float64) + return rtol * sc + atol, rtol, atol + + +def compare(m, params, refs, got): + """refs: name -> (value float64 array, scale or None). got: name -> array. Returns verdict dict.""" + worst = 0.0 + details = [] + ok = True + for spec in m["outputs"]: + name = spec["name"] + contract = m["tolerance"][name] + ref, scale = refs[name] + ref = np.asarray(ref, dtype=np.float64) + g = np.asarray(got[name]) + if g.shape != ref.shape: + details.append({"output": name, "pass": False, "why": "shape %s vs %s" % (g.shape, ref.shape)}) + ok = False + continue + kind = contract["kind"] + gd = g.astype(np.float64) + bad_nonfinite = ~np.isfinite(gd) & ~(np.isnan(gd) & np.isnan(ref)) & ~(gd == ref) + if kind == "exact": + want = ref.astype(manifest.DTYPES[spec["dtype"]][0]).astype(np.float64) + err = np.abs(gd - want) + err[np.isnan(gd) & np.isnan(want)] = 0.0 + bound = np.zeros_like(err) + fail = (err != 0) | bad_nonfinite + ratio = float(np.nanmax(np.where(err > 0, np.inf, 0.0))) if err.size else 0.0 + elif kind in ("bound", "int"): + bound, rtol, atol = _bound_arrays(contract, params, ref, scale) + err = np.abs(gd - ref) + fail = ~(err <= bound) | bad_nonfinite + with np.errstate(divide="ignore", invalid="ignore"): + r = np.where(bound > 0, err / bound, np.where(err > 0, np.inf, 0.0)) + ratio = float(np.nanmax(r)) if r.size else 0.0 + else: + raise ValueError("%s: unknown tolerance kind %r" % (name, kind)) + nfail = int(np.count_nonzero(fail)) + d = {"output": name, "pass": nfail == 0, "kind": kind, "elements": int(fail.size), + "failed": nfail, "err_ratio": ratio if np.isfinite(ratio) else None, + "max_abs_err": float(np.nanmax(err)) if err.size else 0.0} + if nfail: + flat = np.flatnonzero(fail.ravel()) + i = int(flat[0]) + d["first_bad"] = {"index": [int(x) for x in np.unravel_index(i, fail.shape)], + "got": float(gd.ravel()[i]), "ref": float(ref.ravel()[i]), + "bound": float(np.asarray(bound).ravel()[i]) if np.size(bound) else 0.0} + ok = False + if np.isfinite(ratio): + worst = max(worst, ratio) + else: + worst = float("inf") + details.append(d) + return {"pass": ok, "err_ratio": worst if np.isfinite(worst) else None, "outputs": details} diff --git a/oal/entrants/opencl.py b/oal/entrants/opencl.py new file mode 100644 index 0000000..1d168b9 --- /dev/null +++ b/oal/entrants/opencl.py @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: Apache-2.0 +"""OpenCL C entrant host: python -m oal.entrants.opencl WORKLOAD [SCRATCH_BYTES...] < case > outputs. + +Builds workloads// on the first OpenCL CPU or GPU device (OAL_OPENCL_PLATFORM +picks a platform by substring), runs every launch in backends.opencl.launches, and times warmup+repeats +rounds of all launches plus clFinish. Output buffers start as 0xFF bytes so an unwritten element is NaN +(f32) or -1 (integers). Exit 2 on a build failure, 3 on a runtime failure. + +INTERIM host glue (Python + pyopencl). Successor: the Omega OpenCL host of aien-dev/omega-mv +seed/spirv (opencl-host.c today), once it takes a case container. +""" +import os +import sys +import time + +import numpy as np +import pyopencl as cl + +from oal import case, manifest + + +def pick_device(): + want = os.environ.get("OAL_OPENCL_PLATFORM", "") + for plat in cl.get_platforms(): + if want and want.lower() not in plat.name.lower(): + continue + devs = plat.get_devices() + if devs: + return plat, devs[0] + raise SystemExit("opencl: no platform matching %r" % want) + + +def main(): + name = sys.argv[1] + m = manifest.load(name) + spec = m["backends"]["opencl"] + blob = sys.stdin.buffer.read() + pvals, sizes, ins, warm, reps = case.unpack(blob) + params = dict(zip(manifest.params_of(m).keys(), pvals)) + plat, dev = pick_device() + sys.stderr.write("oal-version opencl %s | %s | %s\n" % (plat.name, plat.version, dev.name)) + ctx = cl.Context([dev]) + q = cl.CommandQueue(ctx) + src = open(os.path.join(m["_dir"], spec["src"])).read() + try: + prog = cl.Program(ctx, src).build(options=spec.get("options", "")) + except cl.RuntimeError as e: + sys.stderr.write("opencl build failed: %s\n" % e) + sys.exit(2) + mf = cl.mem_flags + bufs = {} + for k, t in enumerate(m["inputs"]): + bufs[t["name"]] = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=np.frombuffer(ins[k], np.uint8).copy()) + nin = len(m["inputs"]) + outs = [] + for k, t in enumerate(m["outputs"]): + host = np.full(sizes[nin + k], 0xFF, np.uint8) + bufs[t["name"]] = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=host) + outs.append(host) + for t in m.get("scratch", []): + nb = max(1, manifest.nbytes(t, params)) + bufs[t["name"]] = cl.Buffer(ctx, mf.READ_WRITE, size=nb) + launches = [] + for L in spec["launches"]: + kern = getattr(prog, L["kernel"]) + args = [] + for a in L["args"]: + if a in bufs: + args.append(bufs[a]) + elif isinstance(a, str) and a.startswith("local:"): + _, dt, count = a.split(":") + args.append(cl.LocalMemory(manifest.DTYPES[dt][1] * int(manifest.evaluate(count, params)))) + elif isinstance(a, str) and a.startswith("f32:"): + args.append(np.float32(manifest.evaluate(a[4:], params))) + else: + args.append(np.int32(manifest.evaluate(a, params))) + gsz = tuple(int(manifest.evaluate(g, params)) for g in L["global"]) + lsz = tuple(int(manifest.evaluate(g, params)) for g in L["local"]) if L.get("local") else None + launches.append((kern, gsz, lsz, args)) + try: + for r in range(warm + reps): + t0 = time.perf_counter_ns() + for kern, gsz, lsz, args in launches: + kern(q, gsz, lsz, *args) + q.finish() + t1 = time.perf_counter_ns() + if r >= warm: + sys.stderr.write("oal-time-ns %d\n" % (t1 - t0)) + for k, t in enumerate(m["outputs"]): + cl.enqueue_copy(q, outs[k], bufs[t["name"]]) + q.finish() + except cl.Error as e: + sys.stderr.write("opencl runtime failure: %s\n" % e) + sys.exit(3) + w = sys.stdout.buffer + for h in outs: + w.write(h.tobytes()) + w.write(b"\0" * (case.pad8(h.size) - h.size)) + w.flush() + + +if __name__ == "__main__": + main() diff --git a/oal/entrants/triton.py b/oal/entrants/triton.py new file mode 100644 index 0000000..e359c24 --- /dev/null +++ b/oal/entrants/triton.py @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Triton entrant host: python -m oal.entrants.triton WORKLOAD < case > outputs. + +Imports workloads// and calls its launch(p, t): p maps parameter names to +ints, t maps every input, output and scratch name to a CPU torch tensor. In CI TRITON_INTERPRET=1 is +set, so the kernel runs in Triton's numpy interpreter: a correctness entrant, never a GPU timing. +Output tensors start as 0xFF bytes (NaN for f32). Exit 3 on an exception in launch. + +INTERIM host glue (Python + torch). Successor: none planned; Triton is a foreign entrant and its +host is part of what is measured. +""" +import importlib.util +import os +import sys +import time +import traceback + +import numpy as np + +from oal import case, manifest + +TORCH_DT = {"f32": "float32", "f64": "float64", "i32": "int32", "i8": "int8", "u8": "uint8"} + + +def main(): + import torch + import triton + name = sys.argv[1] + m = manifest.load(name) + spec = m["backends"]["triton"] + blob = sys.stdin.buffer.read() + pvals, sizes, ins, warm, reps = case.unpack(blob) + params = dict(zip(manifest.params_of(m).keys(), pvals)) + sys.stderr.write("oal-version triton %s torch %s interpret=%s\n" % ( + triton.__version__, torch.__version__, os.environ.get("TRITON_INTERPRET", "0"))) + path = os.path.join(m["_dir"], spec["src"]) + mod_spec = importlib.util.spec_from_file_location("oal_triton_" + name, path) + mod = importlib.util.module_from_spec(mod_spec) + mod_spec.loader.exec_module(mod) + t = {} + for k, s in enumerate(m["inputs"]): + arr = np.frombuffer(ins[k], dtype=manifest.DTYPES[s["dtype"]][0]).reshape(manifest.shape(s, params)).copy() + t[s["name"]] = torch.from_numpy(arr) + for s in m["outputs"]: + dims = manifest.shape(s, params) + raw = np.full(manifest.nbytes(s, params), 0xFF, np.uint8) + t[s["name"]] = torch.from_numpy(raw.view(manifest.DTYPES[s["dtype"]][0]).reshape(dims).copy()) + for s in m.get("scratch", []): + t[s["name"]] = torch.zeros(manifest.shape(s, params), dtype=getattr(torch, TORCH_DT[s["dtype"]])) + try: + for r in range(warm + reps): + t0 = time.perf_counter_ns() + mod.launch(params, t) + t1 = time.perf_counter_ns() + if r >= warm: + sys.stderr.write("oal-time-ns %d\n" % (t1 - t0)) + except Exception: + traceback.print_exc(file=sys.stderr) + sys.exit(3) + w = sys.stdout.buffer + for s in m["outputs"]: + raw = t[s["name"]].contiguous().numpy().tobytes() + w.write(raw) + w.write(b"\0" * (case.pad8(len(raw)) - len(raw))) + w.flush() + + +if __name__ == "__main__": + main() diff --git a/oal/manifest.py b/oal/manifest.py new file mode 100644 index 0000000..ffe39d0 --- /dev/null +++ b/oal/manifest.py @@ -0,0 +1,112 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Workload manifests: load workloads//workload.json and evaluate its shape and tolerance +expressions against the case parameters. Expressions are integer/float arithmetic over parameter +names plus gamma(n) and u (unit roundoff 2^-24); nothing else is evaluated. + +INTERIM host glue (Python). Successor: an Omega manifest reader once seeded Omega has the JSON +reader of seed/json/ wired into a program-mode library. +""" +import ast +import json +import math +import os + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +DTYPES = {"f32": ("float32", 4), "f64": ("float64", 8), "i32": ("int32", 4), "i8": ("int8", 1), + "u8": ("uint8", 1)} +U32 = 2.0 ** -24 # unit roundoff of binary32, round to nearest + + +def gamma(n): + """gamma_n = n u / (1 - n u), the classic bound on n roundings (Higham, ASNA 2nd ed. 3.1).""" + n = float(n) + if n * U32 >= 1.0: + raise ValueError("gamma(%g) undefined: n u >= 1" % n) + return n * U32 / (1.0 - n * U32) + + +_FUNCS = {"gamma": gamma, "max": max, "min": min, "log2": math.log2, "ceil": math.ceil} +_OPS = (ast.Expression, ast.BinOp, ast.UnaryOp, ast.Add, ast.Sub, ast.Mult, ast.Div, ast.FloorDiv, + ast.Mod, ast.Pow, ast.USub, ast.UAdd, ast.Constant, ast.Name, ast.Load, ast.Call) + + +def evaluate(expr, params): + """Evaluate a shape or tolerance expression. Numbers pass through unchanged.""" + if isinstance(expr, (int, float)): + return expr + tree = ast.parse(str(expr), mode="eval") + for node in ast.walk(tree): + if not isinstance(node, _OPS): + raise ValueError("manifest expression %r: %s not allowed" % (expr, type(node).__name__)) + if isinstance(node, ast.Call) and not (isinstance(node.func, ast.Name) and node.func.id in _FUNCS): + raise ValueError("manifest expression %r: unknown function" % expr) + env = dict(_FUNCS) + env["u"] = U32 + env.update(params) + return eval(compile(tree, "", "eval"), {"__builtins__": {}}, env) + + +def shape(spec, params): + dims = [int(evaluate(d, params)) for d in spec["shape"]] + if any(d < 1 for d in dims): + raise ValueError("%s: non-positive dimension %s" % (spec["name"], dims)) + return dims + + +def nbytes(spec, params): + n = 1 + for d in shape(spec, params): + n *= d + return n * DTYPES[spec["dtype"]][1] + + +def workload_dir(name): + for top in ("workloads", "controls"): + d = os.path.join(ROOT, top, name) + if os.path.isfile(os.path.join(d, "workload.json")): + return d + raise FileNotFoundError("no workload %r under workloads/ or controls/" % name) + + +def load(name): + d = workload_dir(name) + with open(os.path.join(d, "workload.json")) as f: + m = json.load(f) + if m.get("name") != name: + raise ValueError("%s/workload.json names %r" % (d, m.get("name"))) + m["_dir"] = d + m["_control"] = os.path.basename(os.path.dirname(d)) == "controls" + for key in ("params", "inputs", "outputs", "tolerance", "timing", "backends"): + if key not in m: + raise ValueError("%s: missing %r" % (name, key)) + for t in m["inputs"] + m["outputs"]: + if t["dtype"] not in DTYPES: + raise ValueError("%s: tensor %s has dtype %s" % (name, t["name"], t["dtype"])) + for o in m["outputs"]: + if o["name"] not in m["tolerance"]: + raise ValueError("%s: output %s has no tolerance contract" % (name, o["name"])) + return m + + +def all_names(include_controls=False): + tops = ["workloads"] + (["controls"] if include_controls else []) + names = [] + for top in tops: + base = os.path.join(ROOT, top) + if not os.path.isdir(base): + continue + for n in sorted(os.listdir(base)): + if os.path.isfile(os.path.join(base, n, "workload.json")): + names.append(n) + return names + + +def params_of(m, overrides=None): + p = dict(m["params"]) + for k, v in (overrides or {}).items(): + if k not in p: + raise ValueError("%s has no parameter %r" % (m["name"], k)) + p[k] = int(v) + for k, expr in m.get("derived", {}).items(): + p[k] = int(evaluate(expr, p)) + return p diff --git a/oal/matrix.py b/oal/matrix.py new file mode 100644 index 0000000..c98672d --- /dev/null +++ b/oal/matrix.py @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: Apache-2.0 +"""One result record per (workload, case, backend): the JSONL schema in docs/RESULTS.md. + +INTERIM host glue (Python). Successor: oal-matrix in seeded Omega. +""" +import os +import platform +import subprocess +import time + +from . import case, check, manifest, ref, run + +SCHEMA = "oal-result/1" + + +def runner_info(): + cpu = platform.processor() or "" + try: + with open("/proc/cpuinfo") as f: + for line in f: + if line.lower().startswith(("model name", "cpu part", "hardware")): + cpu = line.split(":", 1)[1].strip() + break + except OSError: + pass + return {"os": platform.system(), "arch": platform.machine(), "cpu": cpu, "ncpu": os.cpu_count(), + "ci": os.environ.get("GITHUB_ACTIONS") == "true", + "runner": os.environ.get("OAL_RUNNER_LABEL", os.environ.get("RUNNER_NAME", "local")), + "run_url": ("%s/%s/actions/runs/%s" % (os.environ["GITHUB_SERVER_URL"], os.environ["GITHUB_REPOSITORY"], + os.environ["GITHUB_RUN_ID"]) if os.environ.get("GITHUB_RUN_ID") else None)} + + +def lab_commit(): + try: + return subprocess.run(["git", "-C", manifest.ROOT, "rev-parse", "HEAD"], capture_output=True, + text=True).stdout.strip() or None + except OSError: + return None + + +def cases_of(m): + return [dict(c) for c in m.get("cases", [{}])] + + +def make_case(m, overrides, seed): + params = manifest.params_of(m, overrides) + tensors = case.inputs(m, params, seed) + t = m["timing"] + blob = case.pack(m, params, tensors, t.get("warmup", 2), t.get("repeats", 10)) + return params, tensors, blob + + +def run_one(backend, m, overrides, seed, timeout=600, refs_cache=None): + params, tensors, blob = make_case(m, overrides, seed) + rec = {"schema": SCHEMA, "workload": m["name"], "family": m.get("family"), "control": m["_control"], + "expect": m.get("expect", "pass"), "backend": backend, "params": params, "seed": seed, + "case_sha256": case.sha256(blob), "case_bytes": len(blob), "when": int(time.time()), + "lab_commit": lab_commit(), "machine": runner_info(), + "timing_label": os.environ.get("OAL_TIMING_LABEL") or m["timing"].get( + "label", "host CPU wall clock; not GPU performance"), + "evidence": os.environ.get("OAL_EVIDENCE", "EXERCISED: CPU runner")} + r = run.execute(backend, m, params, blob, timeout) + rec.update({k: r[k] for k in ("status", "times_ns", "versions", "log") if k in r}) + for k in ("toolchain", "build", "exit"): + if k in r: + rec[k] = r[k] + if r["status"] != "RAN": + return rec + rec["outputs_sha256"] = case.sha256(r["outputs"]) + try: + got = case.split_outputs(m, params, r["outputs"]) + except ValueError as e: + rec["status"] = "RUNTIME_FAIL" + rec["log"] = "output stream: %s" % e + return rec + key = (m["name"], case.sha256(blob)) + if refs_cache is not None and key in refs_cache: + refs = refs_cache[key] + else: + refs = ref.compute(m, params, tensors) + if refs_cache is not None: + refs_cache[key] = refs + v = check.compare(m, params, refs, got) + rec["status"] = "PASS" if v["pass"] else "FAIL" + rec["err_ratio"] = v["err_ratio"] + rec["outputs"] = v["outputs"] + return rec diff --git a/oal/ref.py b/oal/ref.py new file mode 100644 index 0000000..dbb2f85 --- /dev/null +++ b/oal/ref.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Independent reference: workloads//reference.py defines reference(p, x) -> {output: value or +(value, scale)}, computed in float64 numpy from the exact input values. The reference is the oracle, +not an entrant; it never appears on the board as a backend. A control may borrow the reference of +the workload it breaks with "reference_from". +""" +import importlib.util +import os + +import numpy as np + +from . import manifest + + +def load(m): + src_name = m.get("reference_from", m["name"]) + d = manifest.workload_dir(src_name) + path = os.path.join(d, "reference.py") + spec = importlib.util.spec_from_file_location("oal_ref_" + src_name, path) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod.reference + + +def compute(m, params, inputs): + fn = load(m) + x = {k: np.asarray(v) for k, v in inputs.items()} + out = fn(dict(params), x) + refs = {} + for spec in m["outputs"]: + v = out[spec["name"]] + if isinstance(v, tuple): + refs[spec["name"]] = (np.asarray(v[0], dtype=np.float64), np.asarray(v[1], dtype=np.float64)) + else: + refs[spec["name"]] = (np.asarray(v, dtype=np.float64), None) + want = tuple(manifest.shape(spec, params)) + if refs[spec["name"]][0].shape != want: + raise ValueError("%s reference %s has shape %s, manifest says %s" % ( + m["name"], spec["name"], refs[spec["name"]][0].shape, want)) + return refs diff --git a/oal/run.py b/oal/run.py new file mode 100644 index 0000000..6ac3027 --- /dev/null +++ b/oal/run.py @@ -0,0 +1,243 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Backends: how each entrant is built and run. Every entrant is a program that reads one case +container on stdin and writes the output tensors on stdout (docs/CONTAINER.md); this module only +builds the program, runs it with a timeout and reads back stdout, the exit status and the +"oal-time-ns" / "oal-version" lines on stderr. + +Statuses: PASS / FAIL come later from oal.check; here a run ends RAN, COMPILE_FAIL, RUNTIME_FAIL, +TIMEOUT, COMPILED (built, deliberately not run: CUDA without a GPU), NOT_RUN (toolchain or platform +missing) or NO_SOURCE (the workload has no entrant for this backend). + +INTERIM host glue (Python). Successor: oal-run in seeded Omega (fork/execprog/pipefds/waitpid +host words exist in omc 369dbc96). +""" +import hashlib +import os +import platform +import shutil +import subprocess +import sys + +from . import manifest + +ROOT = manifest.ROOT +TOOLS = os.path.join(ROOT, ".oal") +BACKENDS = ("omega", "opencl", "triton", "hip", "cuda") + + +def _sha(path): + with open(path, "rb") as f: + return hashlib.sha256(f.read()).hexdigest() + + +def _workdir(backend, name): + d = os.path.join(TOOLS, "build", backend, name) + os.makedirs(d, exist_ok=True) + return d + + +def _scratch_args(m, params): + return [str(max(1, manifest.nbytes(s, params))) for s in m.get("scratch", [])] + + +def _sh(cmd, **kw): + return subprocess.run(cmd, capture_output=True, **kw) + + +def omc_path(): + return os.environ.get("OAL_OMC", os.path.join(TOOLS, "tools", "omc")) + + +def probe(backend): + """(available, detail): whether this machine can build/run the backend at all.""" + if backend == "omega": + if platform.system() != "Linux" or platform.machine() not in ("aarch64", "arm64"): + return False, "Omega program mode emits Linux AArch64 only; this host is %s %s" % ( + platform.system(), platform.machine()) + p = omc_path() + return (os.access(p, os.X_OK), "omc %s sha256 %s" % (p, _sha(p)) if os.path.exists(p) else "omc missing at %s" % p) + if backend == "opencl": + try: + import pyopencl # noqa: F401 + except ImportError: + return False, "pyopencl not installed" + return True, "pyopencl" + if backend == "triton": + try: + import triton # noqa: F401 + import torch # noqa: F401 + except ImportError: + return False, "triton or torch not installed" + return True, "triton" + if backend == "hip": + inc = os.environ.get("OAL_HIPCPU", os.path.join(TOOLS, "hip-cpu", "include")) + hip = os.environ.get("OAL_HIPIFY", os.path.join(TOOLS, "tools", "hipify-perl")) + if not os.path.isdir(inc) or not os.path.exists(hip): + return False, "HIP-CPU headers (%s) or hipify-perl (%s) missing" % (inc, hip) + return True, "HIP-CPU %s, hipify-perl sha256 %s" % (inc, _sha(hip)) + if backend == "cuda": + nvcc = shutil.which(os.environ.get("OAL_NVCC", "nvcc")) + if not nvcc: + return False, "nvcc not found" + return True, nvcc + raise ValueError(backend) + + +def _build_omega(m, wd): + src = os.path.join(m["_dir"], m["backends"]["omega"]["src"]) + unit = os.path.join(wd, "unit.om") + with open(unit, "wb") as f: + f.write(open(os.path.join(ROOT, "lib", "omega", "oal.om"), "rb").read()) + f.write(open(src, "rb").read()) + exe = os.path.join(wd, "prog") + with open(unit, "rb") as fi, open(exe, "wb") as fo: + r = subprocess.run([omc_path()], stdin=fi, stdout=fo, stderr=subprocess.PIPE) + if r.returncode != 0: + os.unlink(exe) + return None, r.stderr.decode(errors="replace").strip() or "omc exit %d" % r.returncode + os.chmod(exe, 0o755) + return [exe], "omc exit 0, unit sha256 %s" % _sha(unit) + + +def _cuda_unit(m, wd, hip): + src = os.path.join(m["_dir"], m["backends"]["cuda"]["src"]) + unit = os.path.join(wd, "prog.cu") + with open(unit, "wb") as f: + f.write(open(src, "rb").read()) + f.write(b"\n") + f.write(open(os.path.join(ROOT, "runners", "cuda", "host.cu"), "rb").read()) + if not hip: + return unit, None + hipify = os.environ.get("OAL_HIPIFY", os.path.join(TOOLS, "tools", "hipify-perl")) + out = os.path.join(wd, "prog.hip.cpp") + # HIP-CPU has no triple-chevron launch: ask hipify for hipLaunchKernelGGL calls. + r = _sh(["perl", hipify, "-quiet-warnings", "-hip-kernel-execution-syntax", unit]) + if r.returncode != 0: + return None, "hipify-perl: " + r.stderr.decode(errors="replace") + with open(out, "wb") as f: + f.write(r.stdout) + return out, None + + +def _build_hip(m, wd): + unit, err = _cuda_unit(m, wd, hip=True) + if unit is None: + return None, err + inc = os.environ.get("OAL_HIPCPU", os.path.join(TOOLS, "hip-cpu", "include")) + exe = os.path.join(wd, "prog") + cxx = os.environ.get("CXX", "g++") + extra = os.environ.get("OAL_HIP_FLAGS", "").split() + # HIP-CPU e112c935 external/libco/aarch64.inl calls VALGRIND_STACK_REGISTER even when valgrind.h is + # absent; define it away (no-op on x86, where that file is not used). + shim = ["-DVALGRIND_STACK_REGISTER(a,b)=0"] + r = _sh([cxx, "-std=c++17", "-O2", "-I", inc] + shim + extra + ["-x", "c++", unit, "-o", exe, "-ltbb", "-lpthread"]) + if r.returncode != 0: + return None, r.stderr.decode(errors="replace")[-4000:] + return [exe], "%s -std=c++17 -O2 HIP-CPU, hipified unit sha256 %s" % (cxx, _sha(unit)) + + +def _build_cuda(m, wd): + unit, _ = _cuda_unit(m, wd, hip=False) + nvcc = shutil.which(os.environ.get("OAL_NVCC", "nvcc")) + arch = os.environ.get("OAL_CUDA_ARCH", "sm_80") + exe = os.path.join(wd, "prog") + stamp = os.path.join(wd, "prog.stamp") + want = "%s %s" % (arch, _sha(unit)) + # Reuse a build of the identical unit for the same arch, so a GPU run can be split into a build + # phase and a run phase (no compiler inside a GPU lock). + if os.path.exists(exe) and os.path.exists(stamp) and open(stamp).read().split("\n")[0] == want: + return [exe], open(stamp).read().split("\n", 1)[1].strip() + " (reused build)" + r = _sh([nvcc, "-O2", "-arch=" + arch, "-o", exe, unit]) + if r.returncode != 0: + return None, r.stderr.decode(errors="replace")[-4000:] + v = _sh([nvcc, "--version"]).stdout.decode().strip().splitlines()[-1] + log = "nvcc -O2 -arch=%s (%s)" % (arch, v) + with open(stamp, "w") as f: + f.write(want + "\n" + log + "\n") + return [exe], log + + +_BUILT = {} + + +def build(backend, m): + """(argv or None, log). argv is the entrant program without scratch arguments; one build per + (backend, workload) per process.""" + key = (backend, m["name"]) + if key not in _BUILT: + _BUILT[key] = _build(backend, m) + return _BUILT[key] + + +def _build(backend, m): + wd = _workdir(backend, m["name"]) + if backend == "omega": + return _build_omega(m, wd) + if backend == "opencl": + return [sys.executable, "-m", "oal.entrants.opencl", m["name"]], "pyopencl host" + if backend == "triton": + return [sys.executable, "-m", "oal.entrants.triton", m["name"]], "triton host" + if backend == "hip": + return _build_hip(m, wd) + if backend == "cuda": + return _build_cuda(m, wd) + raise ValueError(backend) + + +def source_for(backend, m): + b = m["backends"] + if backend == "hip": + return b.get("hip") or ("cuda" in b and {"from": "cuda"}) + return b.get(backend) + + +def execute(backend, m, params, blob, timeout): + """Build and run one entrant on one case. Returns a dict; outputs (bytes) only when status RAN.""" + res = {"status": None, "times_ns": [], "versions": [], "log": ""} + if not source_for(backend, m): + res["status"] = "NO_SOURCE" + return res + ok, detail = probe(backend) + res["toolchain"] = detail + if not ok: + res["status"] = "NOT_RUN" + res["log"] = detail + return res + argv, log = build(backend, m) + res["build"] = log + if argv is None: + res["status"] = "COMPILE_FAIL" + res["log"] = log + return res + if backend == "cuda" and os.environ.get("OAL_CUDA_RUN") != "1": + res["status"] = "COMPILED" + res["log"] = "built; not run (no GPU on this runner; OAL_CUDA_RUN unset)" + return res + env = dict(os.environ) + env["PYTHONPATH"] = ROOT + os.pathsep + env.get("PYTHONPATH", "") + try: + r = subprocess.run(argv + _scratch_args(m, params), input=blob, capture_output=True, + timeout=timeout, env=env, cwd=ROOT) + except subprocess.TimeoutExpired: + res["status"] = "TIMEOUT" + res["log"] = "no exit within %ds" % timeout + return res + err = r.stderr.decode(errors="replace") + other = [] + for line in err.splitlines(): + if line.startswith("oal-time-ns "): + res["times_ns"].append(int(line.split()[1])) + elif line.startswith("oal-version "): + res["versions"].append(line[len("oal-version "):]) + else: + other.append(line) + res["log"] = "\n".join(other)[-4000:] + res["exit"] = r.returncode + if r.returncode != 0: + res["status"] = "COMPILE_FAIL" if (backend == "opencl" and r.returncode == 2) else "RUNTIME_FAIL" + if backend == "omega" and r.returncode > 100: + res["log"] = ("trap %d. " % (r.returncode - 100)) + res["log"] + return res + res["status"] = "RAN" + res["outputs"] = r.stdout + return res diff --git a/receipts/gpu/gb10-2026-10-27.jsonl b/receipts/gpu/gb10-2026-10-27.jsonl new file mode 100644 index 0000000..5f90e40 --- /dev/null +++ b/receipts/gpu/gb10-2026-10-27.jsonl @@ -0,0 +1,87 @@ +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 400096, "case_sha256": "fb683adc672ca22b34c560db3e1ed9a9693ed38b9698fbac9ee2dc9963c61a59", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "4d159113222bfeb85fbe717cc2393ee8a6a85b7ce5ac1791c4eade5e3dd6de41", "params": {"n": 100003, "nb": 391}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [24192, 12432, 11441, 11696, 9792], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064702, "workload": "argmax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 88, "case_sha256": "b8e639947304c322f669ae75eef0e7371145ee0be9952b5a6227934f905430f3", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "af5570f5a1810b7af78caf4bc70a660f0df51e42baf91d4de5b2328de0e83dfc", "params": {"n": 1, "nb": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [10272, 8480, 8160, 8304, 8465], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064702, "workload": "argmax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1112, "case_sha256": "c844e5e7255c374f42e72049968069bf61a0dd59e0008cd7fd2855acabc32d61", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "4d159113222bfeb85fbe717cc2393ee8a6a85b7ce5ac1791c4eade5e3dd6de41", "params": {"n": 257, "nb": 2}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [10224, 10240, 9536, 8160, 8000], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064703, "workload": "argmax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 36960, "case_sha256": "e939c34cdc770f2925738d723f685d665c24685afc9eac1554d5c0f9f11c3b8f", "control": false, "err_ratio": 0.012742776782118699, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 3072, "err_ratio": 0.012742776782118699, "failed": 0, "kind": "bound", "max_abs_err": 2.042407075397712e-05, "output": "o", "pass": true}], "outputs_sha256": "c6b69733faceb12c2d6f1430c05d68f14fed8522c8c8832698553fc3256fc5f1", "params": {"Dh": 64, "T": 48}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [186834, 81937, 81680, 80673, 82033], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064703, "workload": "attention"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 864, "case_sha256": "65e882dd5fcdee40fd16355079cd9645c0226673703f178e342e9db931afaa74", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 64, "err_ratio": 0.0, "failed": 0, "kind": "bound", "max_abs_err": 0.0, "output": "o", "pass": true}], "outputs_sha256": "f5bb4a93fc3d6de2a6deab764d3a646c194e10947e8a7c5af44054c231844ad5", "params": {"Dh": 64, "T": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [10592, 9184, 7888, 8656, 7712], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064704, "workload": "attention"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 13152, "case_sha256": "2dc3dab513ea57e9b644c07e67bceaa74d964ee428c5dfd2787f5d3db9f6eba0", "control": false, "err_ratio": 0.012742776782118699, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1088, "err_ratio": 0.012742776782118699, "failed": 0, "kind": "bound", "max_abs_err": 9.670128660044242e-06, "output": "o", "pass": true}], "outputs_sha256": "47909f3aae3b46a7a58d919c25d125557d4c99dd2ab290d71f8182ed537972b5", "params": {"Dh": 64, "T": 17}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [69409, 33664, 32033, 31536, 30976], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064704, "workload": "attention"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 24664, "case_sha256": "f5cdc46b3f34eb9d239628ec50663dabc006a35d4232ef7678a91bf2c8071690", "control": false, "err_ratio": 0.04672246820574235, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 2304, "err_ratio": 0.04672246820574235, "failed": 0, "kind": "bound", "max_abs_err": 9.857187968087544e-07, "output": "s", "pass": true}], "outputs_sha256": "802a6f619d48ce5c61916f61cfc8890aad632e376ab18ab1cbacfaa687a93179", "params": {"Dh": 64, "T": 48}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [10272, 8816, 10192, 9472, 9184, 9856, 8337, 10464, 9664, 8176], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064705, "workload": "attn_scores"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 600, "case_sha256": "42a5ad77a0e03d20e555cbbe46d40e7ebc6753b3682c414a570e2b56bb64b3a7", "control": false, "err_ratio": 0.0015758273664865509, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0015758273664865509, "failed": 0, "kind": "bound", "max_abs_err": 3.038350782080812e-08, "output": "s", "pass": true}], "outputs_sha256": "64b578432cd838df77cdf89b28f5975c95e1ede88ed22bde4aa146adeada3cd0", "params": {"Dh": 64, "T": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5568, 5712, 5616, 5856, 5552, 5568, 5072, 5792, 6960, 5328], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064705, "workload": "attn_scores"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 8792, "case_sha256": "5bc1ca9fa6d05ec4f1be8f76aa82f45fbf01c25090f02b8d6ad0affae12db96d", "control": false, "err_ratio": 0.04672246820574235, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 289, "err_ratio": 0.04672246820574235, "failed": 0, "kind": "bound", "max_abs_err": 9.857187968087544e-07, "output": "s", "pass": true}], "outputs_sha256": "c9e774dad89eefb7c86f879d5864957016a1ba1940e683826bc6ea0d21477e08", "params": {"Dh": 64, "T": 17}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [7424, 7456, 6992, 7825, 7568, 7168, 7216, 7056, 7248, 7024], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064706, "workload": "attn_scores"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 19112, "case_sha256": "a577f3578605dd216782d0c2931b7baed55bf2a5804e04fa7adb2544983212f1", "control": false, "err_ratio": 0.05728412138522625, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1440, "err_ratio": 0.05728412138522625, "failed": 0, "kind": "bound", "max_abs_err": 1.5806098998538687e-06, "output": "C", "pass": true}], "outputs_sha256": "8076ddb5b5330cb730a8872d515ea6a84e277f4891749228cf3e1f20cea459e1", "params": {"BATCH": 3, "K": 36, "M": 24, "N": 20}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5840, 5920, 6704, 5744, 5504], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064706, "workload": "batched_gemm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1512, "case_sha256": "26ab006de4cf32cee50c7d79c069702bc751d95bacd6b1704cdb334a6597c1a7", "control": false, "err_ratio": 0.11589473634720683, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 126, "err_ratio": 0.11589473634720683, "failed": 0, "kind": "bound", "max_abs_err": 3.435532311968359e-07, "output": "C", "pass": true}], "outputs_sha256": "ddd0917fd787a78d20e54e88e373714f9c5cfd4e5270f6d6ec988ebcc6d21e0f", "params": {"BATCH": 2, "K": 11, "M": 9, "N": 7}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5328, 5392, 5104, 5440, 5120], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064707, "workload": "batched_gemm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 10344, "case_sha256": "8cc56710aeb7af1e643006e596ce062065fb092c7c67535ab9e8da6a84f1b820", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 16384, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "392bded9817cfc9219b59fbaab0c44ffa2b66c86e8f46cffde88f981aec2fe09", "params": {"C": 256, "G": 8, "NB": 128, "R": 64}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4704, 5024, 4832, 4752, 4704, 5280, 5376, 4592, 4496, 4464], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064707, "workload": "dequant_int4"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 120, "case_sha256": "9a955588c09cef9c04a0f77fc1c458d431293c4b11c6ada2f77c2be3789da85a", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 2, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "9cc1a88d4abfdd258438b96a39868cb24bf39fa5203021f54e54846624912e25", "params": {"C": 2, "G": 1, "NB": 1, "R": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4768, 5088, 5664, 9520, 6144, 6129, 5376, 4624, 5168, 4448], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064708, "workload": "dequant_int4"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 344, "case_sha256": "f393b8f285d18ba543ef53997fa9f48bae8725c0bccb6baca484e9c5c0e955e7", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 350, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "3c9cb5896934013570fb836cb28fd062721468c0df72053b50f56caac5201114", "params": {"C": 70, "G": 3, "NB": 35, "R": 5}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4944, 4928, 4753, 4736, 4832, 5312, 5376, 4624, 4720, 4704], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064708, "workload": "dequant_int4"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 16728, "case_sha256": "80bfa58bd4b4b488dde0ff069ca0b07c582b870e5f5b2a18ed0f17a1917803e4", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 16384, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "948ba26edb6802a7fe77faff84e861182ecd065d59901fc251d3e86661e9500e", "params": {"C": 256, "R": 64}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6320, 4720, 4784, 4720, 5280, 5552, 5392, 4624, 4368, 5056], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064709, "workload": "dequant_int8"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 104, "case_sha256": "d24467897a06ded0bcf7d24043e9dfec4722dab4374f3bbb2758c92ae3318167", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "e6e5185554d9bcef924b1c3eaf41b28ac8b18e5842b7729457ba8faad06f7d62", "params": {"C": 1, "R": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5904, 5296, 5040, 4800, 4848, 5392, 5328, 4624, 4416, 4576], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064709, "workload": "dequant_int8"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 504, "case_sha256": "a5531860c0541648f11fd9158b28f30549981d40141fb669a66e4793d3c607e8", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 385, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "ce864b1250318a350c04d03878ac125bfcf414eafe87157ceca0c1836ac4ed26", "params": {"C": 77, "R": 5}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4656, 5552, 5920, 5760, 4880, 4784, 5312, 4496, 4480, 4880], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064710, "workload": "dequant_int8"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 800120, "case_sha256": "21d4dda250f83617b6505da86b5c315e55d9e542de67046957bff0aecf608b02", "control": false, "err_ratio": 1.0441428581352141e-07, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 1.0441428581352141e-07, "failed": 0, "kind": "bound", "max_abs_err": 5.0634687113415566e-05, "output": "y", "pass": true}], "outputs_sha256": "1a4754bdc9ee79aa800e95c1651dfa0f6e2730179dda2fab0761e8999e890242", "params": {"n": 100003, "nb": 391}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [12096, 9296, 9632, 9696, 8736], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064710, "workload": "dot"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 104, "case_sha256": "e79c69e5a9c11a950677db7534ac01ab791335e58a078ebb07b81ea7db2f0650", "control": false, "err_ratio": 0.5868665311567457, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.5868665311567457, "failed": 0, "kind": "bound", "max_abs_err": 4.698397049196501e-08, "output": "y", "pass": true}], "outputs_sha256": "2af7ca429d2bc0f696861380c445fcdee9d1576db0984816cdc11b3c80143499", "params": {"n": 1, "nb": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [8272, 8272, 7440, 8080, 7600], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064711, "workload": "dot"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2152, "case_sha256": "8baab6bcee7a409f79ea11582d9f4ff53f5c4a7e0a8849a2abf2fbb86e041fce", "control": false, "err_ratio": 0.00034934397109491087, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.00034934397109491087, "failed": 0, "kind": "bound", "max_abs_err": 9.740799029600566e-07, "output": "y", "pass": true}], "outputs_sha256": "607129b8aded0a7544ea2835d3e61a62bb7571d12f4af1ea8ce7ead179a8e80a", "params": {"n": 257, "nb": 2}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [8097, 7680, 7824, 7248, 6880], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064712, "workload": "dot"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 25608, "case_sha256": "4afba14b511a0c4c6e926bc20a1bbe342f0a1acd3d62c3a00e3ebca0c3f07169", "control": false, "err_ratio": 0.045746414128837204, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1920, "err_ratio": 0.045746414128837204, "failed": 0, "kind": "bound", "max_abs_err": 6.072865968320684e-06, "output": "C", "pass": true}], "outputs_sha256": "b052d531179cae39143a59b439a86c91de6598d5265a912038351c49648e3919", "params": {"K": 72, "M": 48, "N": 40}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6768, 6448, 6672, 6640, 6288], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064712, "workload": "gemm_bias_relu"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2448, "case_sha256": "4b5789f7dd6285d0baacde21e9fc8b24fcfc94bb571cd2eb8057ff719101b2f7", "control": false, "err_ratio": 0.07865379581904305, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 221, "err_ratio": 0.07865379581904305, "failed": 0, "kind": "bound", "max_abs_err": 9.76164134414148e-07, "output": "C", "pass": true}], "outputs_sha256": "5a2572d55fa3fa5bc76b8260367ca01501f31f734af68e8f1430483b67ec116d", "params": {"K": 19, "M": 17, "N": 13}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6657, 5888, 5632, 5728, 5376], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064713, "workload": "gemm_bias_relu"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 25440, "case_sha256": "f67a56b0573bbffa8c116c1f338fce9ca27c8780d007fe2bf38ba59b7273b0a4", "control": false, "err_ratio": 0.03305299530996739, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1920, "err_ratio": 0.03305299530996739, "failed": 0, "kind": "bound", "max_abs_err": 4.122927409255794e-06, "output": "C", "pass": true}], "outputs_sha256": "303d266d1dee2d4800b40da3d02b1d519f4977be755b5dc1037f5a09e50197e2", "params": {"K": 72, "M": 48, "N": 40}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6816, 6912, 6560, 7600, 6816], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064713, "workload": "gemm_nn"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2384, "case_sha256": "568b8edb58bea5d411373bbd3b913067fb3d6821587a9ac6a63198555699baa5", "control": false, "err_ratio": 0.08943942031738648, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 221, "err_ratio": 0.08943942031738648, "failed": 0, "kind": "bound", "max_abs_err": 9.064279407056119e-07, "output": "C", "pass": true}], "outputs_sha256": "0e9b9b7518434aa2354400ce4a3103156144b70885316a5d0e9a1316e8c69322", "params": {"K": 19, "M": 17, "N": 13}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5536, 6224, 5328, 5488, 5248], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064714, "workload": "gemm_nn"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 25440, "case_sha256": "3be47472f9acf24f70d38db169f1f7fa23a038afd6450201bb1151f5dfe09747", "control": false, "err_ratio": 0.03869119024208295, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1920, "err_ratio": 0.03869119024208295, "failed": 0, "kind": "bound", "max_abs_err": 5.6063772415626545e-06, "output": "C", "pass": true}], "outputs_sha256": "b7ce1548ac69c21f2115d8f447ca7ccf8fdc91e44f3c14f81bc18dae95adf5c2", "params": {"K": 72, "M": 48, "N": 40}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6736, 6944, 7744, 7264, 7824], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064714, "workload": "gemm_nt"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2384, "case_sha256": "d088bd65485f4c61d2c8360e5a265bf78c8e5a06c5b2908cc5fff556e1f25b0b", "control": false, "err_ratio": 0.060999412233170514, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "compute-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 221, "err_ratio": 0.060999412233170514, "failed": 0, "kind": "bound", "max_abs_err": 6.104859746614011e-07, "output": "C", "pass": true}], "outputs_sha256": "0e51ab464fd8716469ae3ae10ed7a8ec4343621dc17e036acbb236ce507b7bfc", "params": {"K": 19, "M": 17, "N": 13}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6112, 5200, 6480, 5600, 5025], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064715, "workload": "gemm_nt"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 241288, "case_sha256": "f1dcffb68f50d0a9e2605243ff3e22fb93a1381dc90a8cbd44457247a2dd86da", "control": false, "err_ratio": 0.007759413663992363, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 200, "err_ratio": 0.007759413663992363, "failed": 0, "kind": "bound", "max_abs_err": 1.7313964967513584e-05, "output": "y", "pass": true}], "outputs_sha256": "af9194db560111802688b8b713ccfdd557d9a940564e37f5cb5d71fd0fe23bc7", "params": {"M": 200, "N": 300}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [11552, 11696, 11456, 11440, 11248, 11345, 11280, 11408, 11072, 11136], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064715, "workload": "gemv"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2408, "case_sha256": "1155bd174c2a5231d659a0978c26317a5acd10f26d8f6a0b6a025c12900ae51b", "control": false, "err_ratio": 0.06122144025817628, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 33, "err_ratio": 0.06122144025817628, "failed": 0, "kind": "bound", "max_abs_err": 4.469885261926265e-07, "output": "y", "pass": true}], "outputs_sha256": "aa90d3b8cc999c52ccea961027d1e522e8f05f84df28583732cb19970318e3c9", "params": {"M": 33, "N": 17}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5904, 5248, 7056, 4992, 5504, 5312, 4960, 5232, 5521, 12064], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064716, "workload": "gemv"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 104, "case_sha256": "e24293d7d5c6ec8af2c550038d16273ff71620c1780cc68dc274b9c035b11762", "control": false, "err_ratio": 0.008361735018145347, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.008361735018145347, "failed": 0, "kind": "bound", "max_abs_err": 3.0740920919924974e-10, "output": "y", "pass": true}], "outputs_sha256": "4f74fdacb579243e11a6d5b2e1a0038d3a648ea189fcac822981c1c5c77a26c9", "params": {"M": 1, "N": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5520, 6112, 5296, 5424, 5408, 5696, 4800, 4544, 4704, 5376], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064716, "workload": "gemv"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 20896, "case_sha256": "bcbbb00c6aae2951bd837350b5e53144a3c25835d90fd444e4d8e316e72fa49b", "control": false, "err_ratio": 0.010104652579163613, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-normalization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 4800, "err_ratio": 0.010104652579163613, "failed": 0, "kind": "bound", "max_abs_err": 5.162196963226506e-07, "output": "y", "pass": true}], "outputs_sha256": "8d83e7df05a9406428838a2b170a4d8def1b3afaa32242134158f303c4623705", "params": {"D": 200, "R": 24}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6912, 6080, 6464, 5872, 5744], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064716, "workload": "layernorm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 120, "case_sha256": "2f491d0201d83047f87982cf84fe6959c54d74906b4ad30b8eb3d6f841d59b0a", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-normalization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "bound", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "c2d41353b624dbf355ff76ece387311f627790f3edbb1be673d8f54ecbd6f1df", "params": {"D": 1, "R": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6080, 5504, 5537, 5552, 5664], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064717, "workload": "layernorm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 21864, "case_sha256": "77ec641e81199b65af549808bf92540ceb76de4ece1e4bd815ccc601db5c222d", "control": false, "err_ratio": 0.0026666941266354407, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-normalization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 3885, "err_ratio": 0.0026666941266354407, "failed": 0, "kind": "bound", "max_abs_err": 5.575774442156956e-07, "output": "y", "pass": true}], "outputs_sha256": "d2196a0fde90a9e46b6137e3f20a20d25072d7cac2013d0332303478803b93c4", "params": {"D": 777, "R": 5}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [7280, 7088, 7824, 7072, 6848], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064717, "workload": "layernorm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 32856, "case_sha256": "61557a98a71027ed3e896948d587624ac473ee14839a4e03a9959ec54c2f7879", "control": false, "err_ratio": 0.19490981290607579, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 8192, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "q", "pass": true}, {"elements": 32, "err_ratio": 0.19490981290607579, "failed": 0, "kind": "bound", "max_abs_err": 1.8186456576807508e-09, "output": "s", "pass": true}], "outputs_sha256": "77dc1005d2fb0f506985dbc012212f5b81e6c89f3f1fa6df91648ba67f0d1231", "params": {"C": 256, "R": 32}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [40384, 40673, 41440, 40465, 40336, 40160, 42593, 40288, 40640, 40193], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064718, "workload": "quant_int8"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 96, "case_sha256": "f54865426ffb1be50749188b55eebcd5e365e05a611941f89e0c770691e9a784", "control": false, "err_ratio": 0.001915306509929446, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "q", "pass": true}, {"elements": 1, "err_ratio": 0.001915306509929446, "failed": 0, "kind": "bound", "max_abs_err": 7.333248591701036e-12, "output": "s", "pass": true}], "outputs_sha256": "f159f439d53c906de1f55737bcd4992b24276ef35a0b3e99b8e01aea44bbcdbd", "params": {"C": 1, "R": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5392, 5392, 4928, 4896, 5712, 4864, 4960, 4752, 5744, 4752], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064718, "workload": "quant_int8"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1632, "case_sha256": "8588da566df6d9268f5365ad698bef155f216957abc1a437f8fe1a6d9374268a", "control": false, "err_ratio": 0.11501107008272325, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 385, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "q", "pass": true}, {"elements": 5, "err_ratio": 0.11501107008272325, "failed": 0, "kind": "bound", "max_abs_err": 9.093228288403754e-10, "output": "s", "pass": true}], "outputs_sha256": "e88c8281dd4b47d3a777f61abd04f62541f04dd34ebe18ecc8d21287c7dcbb6f", "params": {"C": 77, "R": 5}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [10400, 11488, 11072, 11441, 10352, 10432, 10960, 11024, 10384, 10272], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064719, "workload": "quant_int8"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 400096, "case_sha256": "914689c6d4b80f8f601708c8194fd07a01a1d5b596248c7b311551389362d949", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "f5194ffc63979fa4567587258c0b77816444bd234b340e26d7e5b417c603945a", "params": {"n": 100003, "nb": 391}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [11760, 9136, 10624, 8720, 8800], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064719, "workload": "reduce_max"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 88, "case_sha256": "e1412d4c6bbe3211c0769d56a503f2e38223ca909ca9c411398836b585022b50", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "fa173a24c62a2ec9f5b2f01c4fd708c1e29a37b114dcdfeaf0726982aa50f47f", "params": {"n": 1, "nb": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [8368, 8385, 8192, 7472, 6816], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064720, "workload": "reduce_max"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1112, "case_sha256": "109fcaaa639032bb6345fff93755a22a0e490538c94fc7df273bd0a3209c7d04", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "099ce3d1a39b0fc6f13b7072e8a77f7b9ddfdb4eb18f8de7a98a9c9ee6504667", "params": {"n": 257, "nb": 2}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [7744, 7537, 8352, 7216, 7088], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064720, "workload": "reduce_max"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 400096, "case_sha256": "3f100777ea5f0768ccace876afdbdcb75774f06f37da5bb9baba194fcba37101", "control": false, "err_ratio": 7.559073443128502e-08, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 7.559073443128502e-08, "failed": 0, "kind": "bound", "max_abs_err": 2.2649765014648438e-05, "output": "y", "pass": true}], "outputs_sha256": "9f0f1f4305e7baaaa56e253fb43f4f6e422163028947d8839f1ac5856fc183dd", "params": {"n": 100003, "nb": 391}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [12144, 9632, 9873, 9344, 8992], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064721, "workload": "reduce_sum"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 88, "case_sha256": "e67724ce862fe4d4eb283f17c9683fab1c7122b9a104b64768f6959480f30471", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "bound", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "e29b2ddb1dbdc8dbeeaed5760651c39bc13b0965a6954c8afaafad47ec0f4eb5", "params": {"n": 1, "nb": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [7968, 8800, 7888, 7456, 7168], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064721, "workload": "reduce_sum"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1112, "case_sha256": "cc8c55c3a4ed3ed22efbfa99ba5bc7590aefb8ea8003e5545e9964fdbd871a03", "control": false, "err_ratio": 0.0001843046376947924, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0001843046376947924, "failed": 0, "kind": "bound", "max_abs_err": 3.5762786865234375e-07, "output": "y", "pass": true}], "outputs_sha256": "421439b8a1836707d23bfb0f57307e0a18d7535a97ccc5a7accf8921b4697a0c", "params": {"n": 257, "nb": 2}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [8560, 9648, 9472, 9968, 7456], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064722, "workload": "reduce_sum"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 25688, "case_sha256": "9d9b6e06d3f3c268da921b2247c6c07640263317fd988d60ab6ce69f0bad8cc0", "control": false, "err_ratio": 0.010820729428102194, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-normalization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 6144, "err_ratio": 0.010820729428102194, "failed": 0, "kind": "bound", "max_abs_err": 3.8118711076506884e-07, "output": "y", "pass": true}], "outputs_sha256": "813d2e87f8a83ba7d5f4f26a465711b79088548aa297aa74536a090fad801463", "params": {"D": 256, "R": 24}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5904, 6256, 6368, 6544, 5488], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064722, "workload": "rmsnorm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 104, "case_sha256": "07998b3c55869b4a0e690f33277f0977743791da2a8d40e8a175ce0bd29135d5", "control": false, "err_ratio": 0.10878630904765883, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-normalization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.10878630904765883, "failed": 0, "kind": "bound", "max_abs_err": 6.029411891983472e-08, "output": "y", "pass": true}], "outputs_sha256": "2d155f994a193d22c8eb252366b7800c2377e319aa82684446c8e3247be18230", "params": {"D": 1, "R": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [7376, 5536, 5232, 5248, 5392], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064723, "workload": "rmsnorm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 32064, "case_sha256": "dfa6957dff1b2fe2d9d2a0e36fba26a7b3657ef014433cc9f4fdb5800e0270ed", "control": false, "err_ratio": 0.0025835339052188246, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-normalization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 6993, "err_ratio": 0.0025835339052188246, "failed": 0, "kind": "bound", "max_abs_err": 3.003355826258769e-07, "output": "y", "pass": true}], "outputs_sha256": "d1f717520fbc7682ea317c76d43ec4537d12d3a902ac4ff226aa55a8c4ae4e4e", "params": {"D": 999, "R": 7}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [9520, 8976, 8032, 7936, 8256], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064723, "workload": "rmsnorm"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 20592, "case_sha256": "5e81ff2912552134f2ef9051f64e7b67a42b7dd66355f0bd09e81b26f97121c3", "control": false, "err_ratio": 0.8758098357383561, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "elementwise-rotation", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 4096, "err_ratio": 0.8758098357383561, "failed": 0, "kind": "bound", "max_abs_err": 3.9658647210671916e-07, "output": "y", "pass": true}], "outputs_sha256": "546cbe03249da99937720df07184bdf2ad01bfbcf0b7eb948676a71ddcf9ff76", "params": {"Dh": 64, "H": 4, "T": 16, "h": 32}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4896, 5312, 5600, 5696, 5520], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064723, "workload": "rope"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 136, "case_sha256": "83531c59b4d27b63092dbc2c4510985764eaaa0fcc0b65edc49618ae3d2e3bcf", "control": false, "err_ratio": 0.5489173845106642, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "elementwise-rotation", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 2, "err_ratio": 0.5489173845106642, "failed": 0, "kind": "bound", "max_abs_err": 8.786292582385613e-08, "output": "y", "pass": true}], "outputs_sha256": "b2665f4e399e8f8183ef5e2ac37b53f0cf97e83339af8481a65325d1ed50dab9", "params": {"Dh": 2, "H": 1, "T": 1, "h": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6240, 5088, 5120, 5616, 5072], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064724, "workload": "rope"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 5832, "case_sha256": "b53f1841784dc06e8d376bab7acc7bd114d521ceabab086d8b1770840d98ba4f", "control": false, "err_ratio": 0.6698896589305302, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "elementwise-rotation", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1190, "err_ratio": 0.6698896589305302, "failed": 0, "kind": "bound", "max_abs_err": 3.847626999231579e-07, "output": "y", "pass": true}], "outputs_sha256": "7dd02d2d711f9298cf6dbb642996b7d0b2e025a70b9150791723c3e299a71897", "params": {"Dh": 34, "H": 5, "T": 7, "h": 17}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5824, 6640, 5136, 5072, 4912], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064724, "workload": "rope"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 800128, "case_sha256": "dde9df7bcb811f150e37ced37e2a8a6c79b30eb272f06e6676d7064ff23aa029", "control": false, "err_ratio": 0.4959324279114466, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 100003, "err_ratio": 0.4959324279114466, "failed": 0, "kind": "bound", "max_abs_err": 4.765824996866286e-07, "output": "y", "pass": true}], "outputs_sha256": "d2ad9cceef47782acd56779a646dfc564b1a12f763d72c92ececc41693835665", "params": {"n": 100003}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5344, 5280, 5200, 5488, 5296, 5265, 5168, 5360, 5424, 5008], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064725, "workload": "saxpy"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 112, "case_sha256": "35196781a406b6126a8a89e8bd29f647c890ce42f4e214db5fb4a8810ddfdf30", "control": false, "err_ratio": 0.24305568298379437, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.24305568298379437, "failed": 0, "kind": "bound", "max_abs_err": 2.2526819520862773e-08, "output": "y", "pass": true}], "outputs_sha256": "4d28f9e4662c9ca6010fc3b7a40e5e0f647a487c45a8e1029dfaa513d1a842e5", "params": {"n": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4496, 4960, 5392, 5360, 4432, 4416, 4624, 4208, 4288, 4864], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064725, "workload": "saxpy"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 32896, "case_sha256": "a17f47d11563e9fc806ac203d2ab7e25e0a30365f9f7c934017c82922e2640da", "control": false, "err_ratio": 0.4925833164668829, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 4099, "err_ratio": 0.4925833164668829, "failed": 0, "kind": "bound", "max_abs_err": 4.655521479435265e-07, "output": "y", "pass": true}], "outputs_sha256": "dd505d82bb08d0232a71e22e2381dff6df6d206e1114c1d7c888e0563fb93182", "params": {"n": 4099}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5584, 4864, 5808, 4656, 5520, 4672, 4592, 4656, 5360, 5696], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064726, "workload": "saxpy"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 400096, "case_sha256": "d14ffcfeb1515f1e4de9af98097fa9d23419032f043e7e3c89eab60f310bfd55", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "scan", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 100003, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "13b0a6d7f279f687d6acd38c045b2ba3e508d125166972552736c43386d81e54", "params": {"n": 100003, "nb": 391}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [15776, 13392, 13552, 12800, 13744], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064726, "workload": "scan_i32"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 88, "case_sha256": "57ef0a38ea7df62f01aa8952c80152aeac2bd975eb214c068ee2e093dbf9a74a", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "scan", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "d1c2a0df0c87d1e7ae3bb1f4d5e599a41fc62780dae1ad287f695d17498fbce6", "params": {"n": 1, "nb": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [10161, 8960, 8720, 9136, 8496], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064727, "workload": "scan_i32"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1112, "case_sha256": "317dea924cb3b678ca7b1a1191fab0613969d4fb1af7891860179fc73b6637e3", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "scan", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 257, "err_ratio": 0.0, "failed": 0, "kind": "int", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "1a3b2d2522c6327bcf99e2f8cfa6231a28727481c05953e5f7da3c1afd8fec15", "params": {"n": 257, "nb": 2}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [10704, 9648, 9056, 8624, 8368], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064727, "workload": "scan_i32"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 400088, "case_sha256": "c9bab4c88e3bde7851a8d1a19a9726955f753290cb7d2af72aad554483cef2b4", "control": false, "err_ratio": 0.3730698116852144, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "elementwise-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 100003, "err_ratio": 0.3730698116852144, "failed": 0, "kind": "bound", "max_abs_err": 1.259533787489886e-06, "output": "y", "pass": true}], "outputs_sha256": "fe5e4edeb58090fb95559bfe963464c9ee6a32bfa481e81e9982c79a56576df5", "params": {"n": 100003}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6400, 5312, 5232, 5312, 5184], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064728, "workload": "silu"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 80, "case_sha256": "56bb433888346da5c4b8f55d11f38309a1d0d86e9c273651111e4d0d365c9b3c", "control": false, "err_ratio": 0.005662212523207504, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "elementwise-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.005662212523207504, "failed": 0, "kind": "bound", "max_abs_err": 2.4353177252578462e-08, "output": "y", "pass": true}], "outputs_sha256": "3589b5f98fcbf75026a553f2143392487866aa021e7cefa50e5c231385e13b72", "params": {"n": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5264, 5232, 6385, 5328, 6640], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064728, "workload": "silu"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 16464, "case_sha256": "567636924d9fe824ac6e9aa0dac371b77f6caed0482e75023044d8706dd1cd91", "control": false, "err_ratio": 0.28862614051636004, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "elementwise-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 4097, "err_ratio": 0.28862614051636004, "failed": 0, "kind": "bound", "max_abs_err": 1.1932087389254775e-06, "output": "y", "pass": true}], "outputs_sha256": "569e68b19ee103e2e4abcb348631dbaae4d4cd16a42c2aefcd5fb953074f2554", "params": {"n": 4097}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4912, 5040, 4736, 4864, 5392], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064729, "workload": "silu"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 19280, "case_sha256": "c4e9fa1666a35e56be2a7803aa8f8eb241ccbbe369ccd0e0b5deba7052524543", "control": false, "err_ratio": 0.11219689721405195, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-reduction-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 4800, "err_ratio": 0.11219689721405195, "failed": 0, "kind": "bound", "max_abs_err": 3.529479364328125e-08, "output": "y", "pass": true}], "outputs_sha256": "aa5b376319a430c04f1f507a36f25273a7853914a75ad9f7c9202e79c775db66", "params": {"D": 200, "R": 24}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5760, 5729, 6304, 5584, 5328], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064729, "workload": "softmax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 96, "case_sha256": "4c68e6713feca023713e0ec28614c58120cc27bab499f9f68218e0a1b4986319", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-reduction-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 3, "err_ratio": 0.0, "failed": 0, "kind": "bound", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "66aa5265fb25a9151e9b998b2153e6a19358611fed4e7bdc7b0885ef36ca04de", "params": {"D": 1, "R": 3}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5792, 5552, 6336, 5584, 5344], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064730, "workload": "softmax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 20544, "case_sha256": "7a1e0483c8849fff2c68bcfb88496a41e6b6ba5244a74725475f0786cc97412d", "control": false, "err_ratio": 0.03019323118286517, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "row-reduction-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 5115, "err_ratio": 0.03019323118286517, "failed": 0, "kind": "bound", "max_abs_err": 4.358563274187155e-09, "output": "y", "pass": true}], "outputs_sha256": "8872bfb49785c70bac9f41a6ff639d244e9984a168304f00a570b44d6ef8e456", "params": {"D": 1023, "R": 5}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [7712, 7296, 6880, 7184, 6528], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064730, "workload": "softmax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 131152, "case_sha256": "48efb8cf8e65028fc7eaba84d23f72c730cf279bedad4695a585961a4051a6b7", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "tile-matmul", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 16384, "err_ratio": 0.0, "failed": 0, "kind": "bound", "max_abs_err": 0.0, "output": "c", "pass": true}], "outputs_sha256": "09fb7ef4f07153b0168bac45f488d1e0295bd6f8d4f86cf254253785695c6ae1", "params": {"TILES": 64}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5216, 5296, 5232, 5408, 5424], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064731, "workload": "tmatmul16"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2128, "case_sha256": "d52f8b0f56819cfb4e3b4ef15dc1df1cda6b0a433966da32cfd81751db2912ff", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "tile-matmul", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 256, "err_ratio": 0.0, "failed": 0, "kind": "bound", "max_abs_err": 0.0, "output": "c", "pass": true}], "outputs_sha256": "ab836b68a8d5e2bd0ca01aef7e819115de3f8626ee08dab4f78965740e687f38", "params": {"TILES": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4944, 8736, 5248, 6672, 4704], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064731, "workload": "tmatmul16"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 6224, "case_sha256": "249b9457990e7e017075cc668a366eca77ccfe5c0248cfb08568bb2c20386de1", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "tile-matmul", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 768, "err_ratio": 0.0, "failed": 0, "kind": "bound", "max_abs_err": 0.0, "output": "c", "pass": true}], "outputs_sha256": "e3189d6420168eddb116146fddca19b0dfa6eff99146b13b11d542c5ec305557", "params": {"TILES": 3}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [12320, 4944, 5216, 5456, 4800], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064731, "workload": "tmatmul16"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 30800, "case_sha256": "187258c35afcf2ab3a671de218bedd377e23c893c48bec4566ad09ebf406c08b", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 7680, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "b", "pass": true}], "outputs_sha256": "24f090debd5314118d5142db06dce58bf564d97df09c344815d681c546ae7ad0", "params": {"C": 80, "R": 96}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5104, 5328, 4928, 5920, 4816, 5520, 13536, 4352, 5024, 4640], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064732, "workload": "transpose"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1008, "case_sha256": "e23c47bc3cf3a9c675b1fa102a9d21c7dcdf0f38ec072880423d98c4d41d448a", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 231, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "b", "pass": true}], "outputs_sha256": "b87b298dd4d569c0f9929ca5aa24429e35897fbabda1ceac50f8ffe781e4d1d3", "params": {"C": 7, "R": 33}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [9792, 5104, 5408, 5040, 5648, 4544, 5104, 4896, 4432, 5648], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064732, "workload": "transpose"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 88, "case_sha256": "a438352970b25343e3d910fa708993f467334e87838ff505d60acaa4b6c085e3", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "b", "pass": true}], "outputs_sha256": "f0ad26e59b1560b4f207e61e06c86a7a1c4264443d37d83d4142f6cd690b2073", "params": {"C": 1, "R": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5408, 5536, 6656, 5072, 5440, 5104, 5312, 5376, 5168, 5040], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064733, "workload": "transpose"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 131144, "case_sha256": "41574aafe97a51538aab58b527839dba6313e3ce760e7a5d7f8e5b65a0184d43", "control": false, "err_ratio": 0.09675823672257239, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "tile-softmax", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 32768, "err_ratio": 0.09675823672257239, "failed": 0, "kind": "bound", "max_abs_err": 1.699170685265372e-07, "output": "y", "pass": true}], "outputs_sha256": "e5695f2b22900ed782d36d3cfb9c39684df651a96331f395aa22a5859ad19bc6", "params": {"TILES": 64}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6081, 6048, 6480, 6800, 6736], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064733, "workload": "tsoftmax16"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2120, "case_sha256": "582a0e440c346860059dee98b66d4f156bf0452f98f24304c0e8a37b3ce2bbc4", "control": false, "err_ratio": 0.07678211094914424, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "tile-softmax", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 512, "err_ratio": 0.07678211094914424, "failed": 0, "kind": "bound", "max_abs_err": 4.807166031906007e-08, "output": "y", "pass": true}], "outputs_sha256": "c5c034bfed0663bad8b95599cfb08e2fbcd815461ca3c1656507e8243a0a70d2", "params": {"TILES": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [6592, 5312, 4960, 6704, 5360], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064734, "workload": "tsoftmax16"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 6216, "case_sha256": "85a89b05ebbc3c78809c9ba46b15125db265f1af9b1d432684f464c19c8f4b76", "control": false, "err_ratio": 0.07678211094914424, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "tile-softmax", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1536, "err_ratio": 0.07678211094914424, "failed": 0, "kind": "bound", "max_abs_err": 6.505770722142756e-08, "output": "y", "pass": true}], "outputs_sha256": "4ca458f1c4ac187a2bd89fc63dc541b038c2a6ea5b2f8b4788718a1bbbeaaf69", "params": {"TILES": 3}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5200, 5136, 5168, 5456, 5408], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064734, "workload": "tsoftmax16"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 800112, "case_sha256": "0f2a9afd0ebc29e643967248adcce074205061ee9aaf07073ee81dfc81ad2ada", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 100003, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "1a9525420bda06fedb0521d348421f46aa9ce6943513a55c845d905847f9ac84", "params": {"n": 100003}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5472, 6544, 6512, 5536, 5568, 5585, 5424, 6720, 5664, 5568], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064735, "workload": "vecadd"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 96, "case_sha256": "85850531cf906603d84934058cb722c01d5ebd820bf8da6ebd21be06d7f3e866", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "1324b5d77139286d823a56ef379de366c8da4fb45d7d03b45e87e47ef4f5a275", "params": {"n": 1}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [5152, 5136, 5296, 4656, 4544, 4689, 5232, 4864, 4688, 4528], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064735, "workload": "vecadd"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 32848, "case_sha256": "8839faa35133c8ab8170c9d536cbdd0cafe030b42d2da40cfa347cd94086dce1", "control": false, "err_ratio": 0.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "pass", "family": "memory-bound", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 4096, "err_ratio": 0.0, "failed": 0, "kind": "exact", "max_abs_err": 0.0, "output": "y", "pass": true}], "outputs_sha256": "56019513e75c0cb9bbe219d1db20d4626cb953624ccd5e49b9c5aaabe7cd666e", "params": {"n": 4096}, "schema": "oal-result/1", "seed": 1, "status": "PASS", "times_ns": [4720, 5264, 9088, 8880, 4544, 4416, 4848, 5968, 5840, 5072], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064736, "workload": "vecadd"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 36960, "case_sha256": "a6fa13f85baecd1b13c7585d9bd4917d0725d75e6ed2e554013d50a43040ea07", "control": true, "err_ratio": null, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 3072, "err_ratio": null, "failed": 3072, "first_bad": {"bound": 0.0008887332457192187, "got": NaN, "index": [0, 0], "ref": 0.5851597189903259}, "kind": "bound", "max_abs_err": NaN, "output": "o", "pass": false}], "outputs_sha256": "70e2471b11ce235e8b9f7a34b8ad15bd825006509afc6e36e2d140a0298403ae", "params": {"Dh": 64, "T": 48}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [187586, 84577, 85761, 85968, 85041], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064736, "workload": "attention_nomax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 13152, "case_sha256": "300de3b04a7394cdf7f398ddf5b6ce278102a7e2c15e0d6d17b971f333c34836", "control": true, "err_ratio": null, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "attention", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1088, "err_ratio": null, "failed": 1088, "first_bad": {"bound": 0.0008887332457192187, "got": NaN, "index": [0, 0], "ref": 0.5851597189903259}, "kind": "bound", "max_abs_err": NaN, "output": "o", "pass": false}], "outputs_sha256": "8977b0895238217f30641dc78ef77332348a5dc9c9a70cec07a2e5ea0d5b2840", "params": {"Dh": 64, "T": 17}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [72609, 34288, 33248, 33633, 31840], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064737, "workload": "attention_nomax"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 10344, "case_sha256": "9b89b474d2d37d26ba04312b48e67ffc2a559e70299b4c6a4e3e9abe5b0c9e15", "control": true, "err_ratio": null, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 16384, "err_ratio": null, "failed": 8300, "first_bad": {"bound": 0.0, "got": 0.1891838014125824, "index": [0, 2], "ref": -0.11351028084754944}, "kind": "exact", "max_abs_err": 0.7969768941402435, "output": "y", "pass": false}], "outputs_sha256": "4377614738a0c389e411b662f7dd66dd73415990427649048a5341477911ab2a", "params": {"C": 256, "G": 8, "NB": 128, "R": 64}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [4752, 5984, 5392, 5584, 5552, 5600, 5392, 4528, 5232, 4608], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064737, "workload": "dequant_int4_nosign"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 344, "case_sha256": "02b32c7d09797f79ff80dfeaa47f0c04e6e44a722e332a0fad731078454cc544", "control": true, "err_ratio": null, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "quantization", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 350, "err_ratio": null, "failed": 167, "first_bad": {"bound": 0.0, "got": 0.1891838014125824, "index": [0, 2], "ref": -0.11351028084754944}, "kind": "exact", "max_abs_err": 0.7281678020954132, "output": "y", "pass": false}], "outputs_sha256": "3175f78ecea2535657b564dd923b9cbfb1667cb8556020dfb1aaaf348d3495e1", "params": {"C": 70, "G": 3, "NB": 35, "R": 5}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [5536, 5184, 4912, 4752, 4640, 5024, 4576, 4400, 4656, 4512], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064738, "workload": "dequant_int4_nosign"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 131152, "case_sha256": "8531991e513b70d206fd222a14c77ef43ddfa43aea3c36fa95ab0f6d0e19faa6", "control": true, "err_ratio": 369910.39460835, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "tile-matmul", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 16384, "err_ratio": 369910.39460835, "failed": 16384, "first_bad": {"bound": 4.807736537438655e-06, "got": -1.1351547241210938, "index": [0, 0, 0], "ref": -1.6839332580566406}, "kind": "bound", "max_abs_err": 0.9843893051147461, "output": "c", "pass": false}], "outputs_sha256": "86baae164aa682c2777bcee42ea628b6c426fe3b7b05bd7594a8506168c0a5ca", "params": {"TILES": 64}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [5312, 5152, 4992, 5408, 5216], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064738, "workload": "gemm_offbyone"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 2128, "case_sha256": "d95a71ea98e158581451894046c96ff76213a8e2bcb8996817a379822eadb8b0", "control": true, "err_ratio": 250404.3702602956, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "tile-matmul", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 256, "err_ratio": 250404.3702602956, "failed": 256, "first_bad": {"bound": 4.807736537438655e-06, "got": -1.1351547241210938, "index": [0, 0, 0], "ref": -1.6839332580566406}, "kind": "bound", "max_abs_err": 0.9392738342285156, "output": "c", "pass": false}], "outputs_sha256": "cbe7ea2a4bab847b17499727ee7b58cbde59da621b41737d254695d5d3061a82", "params": {"TILES": 1}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [5584, 5041, 5056, 6432, 5232], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064739, "workload": "gemm_offbyone"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 6224, "case_sha256": "90382ff7ae3569973903502a1c82530907070d635fe37e38ae36eb042e4bf46b", "control": true, "err_ratio": 276438.67466506135, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "tile-matmul", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 768, "err_ratio": 276438.67466506135, "failed": 768, "first_bad": {"bound": 4.807736537438655e-06, "got": -1.1351547241210938, "index": [0, 0, 0], "ref": -1.6839332580566406}, "kind": "bound", "max_abs_err": 0.95928955078125, "output": "c", "pass": false}], "outputs_sha256": "71ef7a93bf57b3e26cfb9ff52fd551217a816368bbcbf3124ae63194784cddae", "params": {"TILES": 3}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [6480, 4864, 5696, 4944, 4752], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064739, "workload": "gemm_offbyone"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 8096, "case_sha256": "dd4b9d5706b276d3f069dee0844756096e11da1a70bdb8e87215954e880ec0eb", "control": true, "err_ratio": 3.4791514339942027, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 3.4791514339942027, "failed": 1, "first_bad": {"bound": 0.17982682137071299, "got": 1505.431884765625, "index": [0], "ref": 1506.0575295090675}, "kind": "bound", "max_abs_err": 0.6256447434425354, "output": "y", "pass": false}], "outputs_sha256": "e553df5bd4c35464bc9d470b105814b3bc6a2f39333865d949ba48adefb6d394", "params": {"n": 2003, "nb": 8}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [9088, 8416, 9168, 7441, 8960], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064739, "workload": "reduce_drop_last"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 88, "case_sha256": "a218ad110712f4fce4a6ed2df008edba8e2f65a56c89985578da1169e75a8f1e", "control": true, "err_ratio": 16777215.0, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 16777215.0, "failed": 1, "first_bad": {"bound": 3.388978544399013e-08, "got": 0.0, "index": [0], "ref": 0.5685762166976929}, "kind": "bound", "max_abs_err": 0.5685762166976929, "output": "y", "pass": false}], "outputs_sha256": "af5570f5a1810b7af78caf4bc70a660f0df51e42baf91d4de5b2328de0e83dfc", "params": {"n": 1, "nb": 1}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [8448, 8576, 9504, 7200, 9057], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064740, "workload": "reduce_drop_last"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1112, "case_sha256": "deef3c952faa8ccfecf5bf6073d0802e095e43acfda1ad1d1d22d54fb81b78e2", "control": true, "err_ratio": 277.8340432422769, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "reduction", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": 277.8340432422769, "failed": 1, "first_bad": {"bound": 0.0029599272739388714, "got": 192.40167236328125, "index": [0], "ref": 193.22404092550278}, "kind": "bound", "max_abs_err": 0.8223685622215271, "output": "y", "pass": false}], "outputs_sha256": "4f90c295a76bc0ceb1f4eedd7c7894e47deded51fcdd86021646db692778d7a1", "params": {"n": 257, "nb": 2}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [8160, 7184, 8032, 7152, 7936], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064740, "workload": "reduce_drop_last"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 400096, "case_sha256": "7bcf24d72808a73ef8b0b0f37ce09ece62b1baee219f334b2230639a47d0bd59", "control": true, "err_ratio": null, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "scan", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 100003, "err_ratio": null, "failed": 100003, "first_bad": {"bound": 0.0, "got": 0.0, "index": [0], "ref": 4.0}, "kind": "int", "max_abs_err": 9.0, "output": "y", "pass": false}], "outputs_sha256": "3ff3c168a409cd1d0cf3bc622116bde2eb0e372cead8b3678fcf1b3e983f8066", "params": {"n": 100003, "nb": 391}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [15824, 23328, 13728, 11937, 12992], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064741, "workload": "scan_exclusive"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 88, "case_sha256": "0d04fc5f36b1eaf8782d6c3be8f629174e4d5a27d1d254bb62b629e629f87add", "control": true, "err_ratio": null, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "scan", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 1, "err_ratio": null, "failed": 1, "first_bad": {"bound": 0.0, "got": 0.0, "index": [0], "ref": 4.0}, "kind": "int", "max_abs_err": 4.0, "output": "y", "pass": false}], "outputs_sha256": "af5570f5a1810b7af78caf4bc70a660f0df51e42baf91d4de5b2328de0e83dfc", "params": {"n": 1, "nb": 1}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [9409, 9152, 8704, 10064, 9296], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064741, "workload": "scan_exclusive"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 1112, "case_sha256": "dcdcb6fef0fa131bc7e3dfa004d7af3d7b7c35adaf2d353c63e71c5e8fb59d4d", "control": true, "err_ratio": null, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "scan", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 257, "err_ratio": null, "failed": 257, "first_bad": {"bound": 0.0, "got": 0.0, "index": [0], "ref": 4.0}, "kind": "int", "max_abs_err": 9.0, "output": "y", "pass": false}], "outputs_sha256": "bb2e99139166669022b34fda0c81217251cd54d79de095df892fd9452a90a38e", "params": {"n": 257, "nb": 2}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [9904, 9600, 9024, 8768, 9184], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064742, "workload": "scan_exclusive"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 19280, "case_sha256": "52b8cc841097b85675bae7504fcf90f0eb67841810c7d6cfb34d6a36ae86b46c", "control": true, "err_ratio": 69026.87166760262, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "row-reduction-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 4800, "err_ratio": 69026.87166760262, "failed": 4800, "first_bad": {"bound": 5.640916536677621e-09, "got": NaN, "index": [0, 0], "ref": 0.00039692947712432526}, "kind": "bound", "max_abs_err": 2.0069951603468602e-06, "output": "y", "pass": false}], "outputs_sha256": "076da8097ff091c41a300cc43610dcd58545b86ad7833e3304e3fe6e749d7a1f", "params": {"D": 200, "R": 24}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [5376, 6480, 6448, 6048, 5680], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064742, "workload": "softmax_unstable"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 192, "case_sha256": "fa735c2759381ced849384e10b6a8206e394fce0d82426db2a16928df100c97c", "control": true, "err_ratio": 377598.0662097793, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "row-reduction-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 28, "err_ratio": 377598.0662097793, "failed": 28, "first_bad": {"bound": 5.19275265078032e-08, "got": NaN, "index": [0, 0], "ref": 0.022679454649234865}, "kind": "bound", "max_abs_err": 6.89036887238759e-05, "output": "y", "pass": false}], "outputs_sha256": "04d52474c45e298cd641a6a153fb7b9243e46bd3d19f35c66cb505bd24683f56", "params": {"D": 7, "R": 4}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [6032, 5120, 5120, 4944, 4960], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064743, "workload": "softmax_unstable"} +{"backend": "cuda", "build": "nvcc -O2 -arch=sm_121 (Build cuda_13.0.r13.0/compiler.36424714_0) (reused build)", "case_bytes": 20544, "case_sha256": "fca80810f551e1cf6bd2016566354125c59f0e074ad80dbeef40a269b9cabd64", "control": true, "err_ratio": 15719.983841248053, "evidence": "GPU run on NVIDIA GB10, driver 580.173.02, 2026-10-27T01:31Z", "exit": 0, "expect": "fail", "family": "row-reduction-transcendental", "lab_commit": "707a1e42a827eb6a705f3e970795600d8938d2a9", "log": "", "machine": {"arch": "aarch64", "ci": false, "cpu": "0xd87", "ncpu": 20, "os": "Linux", "run_url": null, "runner": "NVIDIA GB10 sm_121 driver 580.173.02"}, "outputs": [{"elements": 5115, "err_ratio": 15719.983841248053, "failed": 5115, "first_bad": {"bound": 4.433650268874704e-09, "got": NaN, "index": [0, 0], "ref": 7.006905063174815e-05}, "kind": "bound", "max_abs_err": 2.616287814431964e-07, "output": "y", "pass": false}], "outputs_sha256": "038598ae362b7e8d49c4d6ff8a58b7d282c1a4a62af069f363a5424a88521986", "params": {"D": 1023, "R": 5}, "schema": "oal-result/1", "seed": 1, "status": "FAIL", "times_ns": [8161, 8288, 8000, 8064, 7760], "timing_label": "GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat", "toolchain": "/usr/local/cuda/bin/nvcc", "versions": [], "when": 1793064743, "workload": "softmax_unstable"} diff --git a/receipts/gpu/gb10-2026-10-27.meta.json b/receipts/gpu/gb10-2026-10-27.meta.json new file mode 100644 index 0000000..7f9dd84 --- /dev/null +++ b/receipts/gpu/gb10-2026-10-27.meta.json @@ -0,0 +1 @@ +{"receipt": "gb10-2026-10-27.jsonl", "sha256": "8be4983697b93103414e4d796dd8f9020885b841de59ad4f072e10a6094e160a", "label": "QUALIFIED-on-GB10 candidate", "gpu": "NVIDIA GB10 (sm_121)", "driver": "580.173.02", "nvcc": "13.0 V13.0.88", "date": "2026-10-27T01:31Z", "lock": "/tmp/aien-gb10.lock", "lock_hold_s_max": 43, "lab_commit": "707a1e4", "command": "flock -w 900 /tmp/aien-gb10.lock timeout 840 runners/cuda/run_all.sh receipts/gpu/gb10-2026-10-27.jsonl --seeds 1", "summary": {"workload_cases_pass": 71, "workload_cases_total": 71, "control_cases_fail": 16, "control_cases_total": 16}, "after": "nvidia-smi --query-compute-apps=pid returned empty", "note": "The evidence field inside the JSONL predates the label change in run_all.sh; this sidecar carries the label. One run on one machine; not a cross-run qualification."} diff --git a/receipts/imported/omega-gpu-bench/20261026T231633Z-nvidia-geforce-rtx-4090-24bc78ab.json b/receipts/imported/omega-gpu-bench/20261026T231633Z-nvidia-geforce-rtx-4090-24bc78ab.json new file mode 100644 index 0000000..b812401 --- /dev/null +++ b/receipts/imported/omega-gpu-bench/20261026T231633Z-nvidia-geforce-rtx-4090-24bc78ab.json @@ -0,0 +1,150 @@ +{ + "evidence": { + "files": [ + { + "path": "evidence/cloudkernels/RTX_4090-231340/driver-version.txt", + "sha256": "e5df95e42a3ef4fea577f66c73fd48658f91201d7a85cc1d722cc80a1c2a9651" + }, + { + "path": "evidence/cloudkernels/RTX_4090-231340/nvidia-smi.txt", + "sha256": "4d814d0b7fe8c3dc031e4d5872d2402a6df235e531d02b3cf61c8688fe035dcd" + }, + { + "path": "evidence/cloudkernels/RTX_4090-231340/rental.txt", + "sha256": "41283d34fee86a73ea439c28837916ed4975f50f227aa5fc99c9a763058969fa" + }, + { + "path": "evidence/cloudkernels/RTX_4090-231340/results.jsonl", + "sha256": "49e167801d61b8183209f53e2df9aa7ff95e4bb4a6ba1dc4311f66e5ede394c4" + } + ], + "note": "Kit kernels only; alu/ctl rows of the same run are in results.jsonl. No output hash or kernel timing was recorded by that harness.", + "source": "CloudKernels rental run RTX_4090-231340 (aien-dev, 2026-10-26), harness ck.py, through NVIDIA libcuda" + }, + "kit": { + "commit": null, + "kernels_sha256sums": null, + "modified": false, + "repo": null + }, + "machine": { + "arch": "x86_64", + "cc": "8.9", + "cpu": "AMD EPYC 7402P 24-Core Processor", + "cuda_driver_api": 13000, + "driver_version": "580.65.06", + "gpu": "NVIDIA GeForce RTX 4090", + "kernel": "5.15.0-157-generic", + "nvrm": "NVRM version: NVIDIA UNIX x86_64 Kernel Module 580.65.06 Sun Jul 27 07:14:19 UTC 2025", + "os": "Ubuntu 24.04.3 LTS" + }, + "not_run": null, + "origin": "cloudkernels-import", + "path": "NVIDIA libcuda (cuModuleLoadData + cuLaunchKernel): an interop oracle for Omega's machine-code encoder and cubin writer, not CUDA++'s own user-space driver path", + "provider": "vast (rented through OpenResearch)", + "receipt_sha256": "24bc78ab006e277f51bd0ff5c425cf5918b26a13393223b6130bde69d9207bab", + "results": [ + { + "checked": 1048583, + "cubin": "neg_sm80_v7.cubin", + "cubin_sha256": "c99156d05d69eacb5aed13c9c2059dd31dc7e66005c654f0048c23e6e81c7418", + "error": null, + "first_bad": [ + [ + 0, + 2933846, + 1339800579 + ], + [ + 1, + 2951185981, + 1085748091 + ], + [ + 2, + 493186248, + 1698942161 + ] + ], + "gbps": null, + "kernel_ms": null, + "kind": "neg", + "mismatches": 1048583, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "NEG_DETECTED" + }, + { + "checked": 1048583, + "cubin": "neg_sm89_v7.cubin", + "cubin_sha256": "d949c29a75fa1d5b7a7892ee39370446e3d2c6e1e0e738001ab946bdb758a5b9", + "error": null, + "first_bad": [ + [ + 0, + 1311556694, + 1339800579 + ], + [ + 1, + 4259808829, + 1085748091 + ], + [ + 2, + 1801809096, + 1698942161 + ] + ], + "gbps": null, + "kernel_ms": null, + "kind": "neg", + "mismatches": 1048583, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "NEG_DETECTED" + }, + { + "checked": 1048583, + "cubin": "vecadd_sm80_v7.cubin", + "cubin_sha256": "b9fe4b043e9c3adc2d5552d82fb924122b4dbfdca6d4d684f08cfd6670f3cd6e", + "error": null, + "first_bad": [], + "gbps": null, + "kernel_ms": null, + "kind": "vecadd", + "mismatches": 0, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "PASS" + }, + { + "checked": 1048583, + "cubin": "vecadd_sm89_v7.cubin", + "cubin_sha256": "2e71dc66b564dc15174d3c059aed10189485da1e5a637dfa49bc3e6f42e196e0", + "error": null, + "first_bad": [], + "gbps": null, + "kernel_ms": null, + "kind": "vecadd", + "mismatches": 0, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "PASS" + } + ], + "run": { + "driver": "libcuda", + "python": null, + "utc": "2026-10-26T23:16:33Z" + }, + "schema": "omega-gpu-bench/receipt/v1", + "submitter": { + "signed_off_by": "Aien agents, CloudKernels import ", + "statement": "Imported from aien-dev's own CloudKernels run RTX_4090-231340; not run with this kit." + } +} diff --git a/receipts/imported/omega-gpu-bench/20261026T231745Z-nvidia-a100-pcie-40gb-aec125c6.json b/receipts/imported/omega-gpu-bench/20261026T231745Z-nvidia-a100-pcie-40gb-aec125c6.json new file mode 100644 index 0000000..9902be0 --- /dev/null +++ b/receipts/imported/omega-gpu-bench/20261026T231745Z-nvidia-a100-pcie-40gb-aec125c6.json @@ -0,0 +1,104 @@ +{ + "evidence": { + "files": [ + { + "path": "evidence/cloudkernels/A100_PCIE_40GB-231428/driver-version.txt", + "sha256": "f5c6938bfe815dca5a8f046823b95433559135bf5f5ec240a9cd6e3bd0551251" + }, + { + "path": "evidence/cloudkernels/A100_PCIE_40GB-231428/nvidia-smi.txt", + "sha256": "bf364458bde9429527f09f04eac65a2ba42dc6ea19b5c920e3440489a419c648" + }, + { + "path": "evidence/cloudkernels/A100_PCIE_40GB-231428/rental.txt", + "sha256": "cab30af5bd7f17210f780f7bcc1a726b341513c0f5a5a10324d72e1bcbc3fe82" + }, + { + "path": "evidence/cloudkernels/A100_PCIE_40GB-231428/results.jsonl", + "sha256": "baddc9847ab6eec2ec598a18ffff931b78c9caac164faa6f942982f4a665f958" + } + ], + "note": "Kit kernels only; alu/ctl rows of the same run are in results.jsonl. No output hash or kernel timing was recorded by that harness.", + "source": "CloudKernels rental run A100_PCIE_40GB-231428 (aien-dev, 2026-10-26), harness ck.py, through NVIDIA libcuda" + }, + "kit": { + "commit": null, + "kernels_sha256sums": null, + "modified": false, + "repo": null + }, + "machine": { + "arch": "x86_64", + "cc": "8.0", + "cpu": "AMD Ryzen Threadripper 3970X 32-Core Processor", + "cuda_driver_api": 12080, + "driver_version": "570.211.01", + "gpu": "NVIDIA A100-PCIE-40GB", + "kernel": "6.8.0-106-generic", + "nvrm": "NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 570.211.01 Release Build (dvs-builder@U22-I3-AM27-29-5) Tue Nov 25 16:23:07 UTC 2025", + "os": "Ubuntu 24.04.3 LTS" + }, + "not_run": null, + "origin": "cloudkernels-import", + "path": "NVIDIA libcuda (cuModuleLoadData + cuLaunchKernel): an interop oracle for Omega's machine-code encoder and cubin writer, not CUDA++'s own user-space driver path", + "provider": "vast (rented through OpenResearch)", + "receipt_sha256": "aec125c67f2dd68e781a928a5b01a82590d7bb052f625bb5cf73d35c1c5f94fb", + "results": [ + { + "checked": 1048583, + "cubin": "neg_sm80_v7.cubin", + "cubin_sha256": "c99156d05d69eacb5aed13c9c2059dd31dc7e66005c654f0048c23e6e81c7418", + "error": null, + "first_bad": [ + [ + 0, + 1787610198, + 1339800579 + ], + [ + 1, + 440895037, + 1085748091 + ], + [ + 2, + 2277862600, + 1698942161 + ] + ], + "gbps": null, + "kernel_ms": null, + "kind": "neg", + "mismatches": 1048583, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "NEG_DETECTED" + }, + { + "checked": 1048583, + "cubin": "vecadd_sm80_v7.cubin", + "cubin_sha256": "b9fe4b043e9c3adc2d5552d82fb924122b4dbfdca6d4d684f08cfd6670f3cd6e", + "error": null, + "first_bad": [], + "gbps": null, + "kernel_ms": null, + "kind": "vecadd", + "mismatches": 0, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "PASS" + } + ], + "run": { + "driver": "libcuda", + "python": null, + "utc": "2026-10-26T23:17:45Z" + }, + "schema": "omega-gpu-bench/receipt/v1", + "submitter": { + "signed_off_by": "Aien agents, CloudKernels import ", + "statement": "Imported from aien-dev's own CloudKernels run A100_PCIE_40GB-231428; not run with this kit." + } +} diff --git a/receipts/imported/omega-gpu-bench/20261026T232057Z-nvidia-geforce-rtx-3090-6b9a64a1.json b/receipts/imported/omega-gpu-bench/20261026T232057Z-nvidia-geforce-rtx-3090-6b9a64a1.json new file mode 100644 index 0000000..dcfec49 --- /dev/null +++ b/receipts/imported/omega-gpu-bench/20261026T232057Z-nvidia-geforce-rtx-3090-6b9a64a1.json @@ -0,0 +1,150 @@ +{ + "evidence": { + "files": [ + { + "path": "evidence/cloudkernels/RTX_3090-231552/driver-version.txt", + "sha256": "9f350e333e9684ff0fab554a75cf82c2cd12be46efb95f4003fc0461f5ce6051" + }, + { + "path": "evidence/cloudkernels/RTX_3090-231552/nvidia-smi.txt", + "sha256": "c79b06912dbca6ccf1e390d0c3acffc9fcf9f8fcfb7f0b965837bfe20155dd78" + }, + { + "path": "evidence/cloudkernels/RTX_3090-231552/rental.txt", + "sha256": "b6cd3566f3f5a3986a5c1198806c7d6fb8cbce861db6c901c3eb67d8d8fbe64c" + }, + { + "path": "evidence/cloudkernels/RTX_3090-231552/results.jsonl", + "sha256": "1833a6c16e553da7a5ec1299b0a8983e67a4e443adfd2924eea76fffeae6fa63" + } + ], + "note": "Kit kernels only; alu/ctl rows of the same run are in results.jsonl. No output hash or kernel timing was recorded by that harness.", + "source": "CloudKernels rental run RTX_3090-231552 (aien-dev, 2026-10-26), harness ck.py, through NVIDIA libcuda" + }, + "kit": { + "commit": null, + "kernels_sha256sums": null, + "modified": false, + "repo": null + }, + "machine": { + "arch": "x86_64", + "cc": "8.6", + "cpu": "Intel(R) Xeon(R) CPU E5-2696 v3 @ 2.30GHz", + "cuda_driver_api": 13000, + "driver_version": "580.159.03", + "gpu": "NVIDIA GeForce RTX 3090", + "kernel": "5.15.0-179-generic", + "nvrm": "NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 580.159.03 Release Build (dvs-builder@U22-I3-AM27-29-6) Fri Apr 24 06:03:03 UTC 2026", + "os": "Ubuntu 24.04.3 LTS" + }, + "not_run": null, + "origin": "cloudkernels-import", + "path": "NVIDIA libcuda (cuModuleLoadData + cuLaunchKernel): an interop oracle for Omega's machine-code encoder and cubin writer, not CUDA++'s own user-space driver path", + "provider": "vast (rented through OpenResearch)", + "receipt_sha256": "6b9a64a187d55bc56e64464b636592a630925c7ce0f6fb871084c18d5870d21b", + "results": [ + { + "checked": 1048583, + "cubin": "neg_sm80_v7.cubin", + "cubin_sha256": "c99156d05d69eacb5aed13c9c2059dd31dc7e66005c654f0048c23e6e81c7418", + "error": null, + "first_bad": [ + [ + 0, + 3314336854, + 1339800579 + ], + [ + 1, + 1967621693, + 1085748091 + ], + [ + 2, + 3804589256, + 1698942161 + ] + ], + "gbps": null, + "kernel_ms": null, + "kind": "neg", + "mismatches": 1048583, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "NEG_DETECTED" + }, + { + "checked": 1048583, + "cubin": "neg_sm86_v7.cubin", + "cubin_sha256": "9a39a29a77b354f218fbb49942ba72171aaadc6cd36de13f1c096e40de9e6a58", + "error": null, + "first_bad": [ + [ + 0, + 1837941846, + 1339800579 + ], + [ + 1, + 491226685, + 1085748091 + ], + [ + 2, + 2328194248, + 1698942161 + ] + ], + "gbps": null, + "kernel_ms": null, + "kind": "neg", + "mismatches": 1048583, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "NEG_DETECTED" + }, + { + "checked": 1048583, + "cubin": "vecadd_sm80_v7.cubin", + "cubin_sha256": "b9fe4b043e9c3adc2d5552d82fb924122b4dbfdca6d4d684f08cfd6670f3cd6e", + "error": null, + "first_bad": [], + "gbps": null, + "kernel_ms": null, + "kind": "vecadd", + "mismatches": 0, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "PASS" + }, + { + "checked": 1048583, + "cubin": "vecadd_sm86_v7.cubin", + "cubin_sha256": "2e166ba0b1ec2918521830d65f92a1badfb8c3601e396c4f6b4a1bc6d4044549", + "error": null, + "first_bad": [], + "gbps": null, + "kernel_ms": null, + "kind": "vecadd", + "mismatches": 0, + "output_sha256": null, + "timing_error": null, + "timing_n": null, + "verdict": "PASS" + } + ], + "run": { + "driver": "libcuda", + "python": null, + "utc": "2026-10-26T23:20:57Z" + }, + "schema": "omega-gpu-bench/receipt/v1", + "submitter": { + "signed_off_by": "Aien agents, CloudKernels import ", + "statement": "Imported from aien-dev's own CloudKernels run RTX_3090-231552; not run with this kit." + } +} diff --git a/receipts/imported/omega-gpu-bench/SHA256SUMS b/receipts/imported/omega-gpu-bench/SHA256SUMS new file mode 100644 index 0000000..54c0475 --- /dev/null +++ b/receipts/imported/omega-gpu-bench/SHA256SUMS @@ -0,0 +1,3 @@ +1d86ed25c9dadc9250e6af42cd68fad21d44f5f0a3526f582ec163a2ff0edf9d 20261026T231633Z-nvidia-geforce-rtx-4090-24bc78ab.json +f9e3e49f9a8ed2549492e5de499c54fe8047e38de791deaf1076946c708b208c 20261026T231745Z-nvidia-a100-pcie-40gb-aec125c6.json +0169f3f4a2b415f8a8500e9d734592508cd067be1b07214e1da3a4b8855a2703 20261026T232057Z-nvidia-geforce-rtx-3090-6b9a64a1.json diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ec5b9ae --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +# Python packages for the INTERIM host glue and the OpenCL/Triton entrants. See DEPENDENCIES.md. +numpy==2.5.4 +pyopencl==2026.1.4 +triton==3.8.0 +torch==2.14.1 diff --git a/runners/cuda/host.cu b/runners/cuda/host.cu new file mode 100644 index 0000000..1753d21 --- /dev/null +++ b/runners/cuda/host.cu @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: Apache-2.0 +// OpenAccel Lab CUDA entrant host. The runner writes workloads//kernel.cu followed by this file +// into one translation unit; kernel.cu defines +// void oal_launch(const long long *p, void *const *buf); +// p holds the case parameters in manifest order, buf the device buffers: inputs, outputs, then the +// scratch buffers whose byte sizes are this program's arguments. +// stdin: one case container (docs/CONTAINER.md). stdout: outputs, each padded to 8 bytes. +// stderr: "oal-time-ns N" per timed repeat (launch + cudaDeviceSynchronize, host clock). +// Exit 2 on a malformed case, 3 on a CUDA error. +// The HIP entrant is this file and kernel.cu passed through hipify-perl unchanged by hand. +#include +#include +#include +#include +#include +#include + +#define OAL_CK(x) do { cudaError_t e_ = (x); if (e_ != cudaSuccess) { \ + std::fprintf(stderr, "cuda error %s at %s:%d\n", cudaGetErrorString(e_), __FILE__, __LINE__); \ + std::exit(3); } } while (0) + +static unsigned long long oal_rd64(const unsigned char *b) { + unsigned long long v = 0; + for (int k = 7; k >= 0; k--) v = (v << 8) | b[k]; + return v; +} + +static size_t oal_pad8(size_t n) { return (n + 7) / 8 * 8; } + +int main(int argc, char **argv) { + std::vector in; + unsigned char chunk[65536]; + size_t got; + while ((got = std::fread(chunk, 1, sizeof chunk, stdin)) > 0) in.insert(in.end(), chunk, chunk + got); + if (in.size() < 48 || std::memcmp(in.data(), "OALCASE1", 8) != 0) { std::fprintf(stderr, "bad case\n"); return 2; } + unsigned long long np = oal_rd64(&in[8]), nin = oal_rd64(&in[16]), nout = oal_rd64(&in[24]); + unsigned long long warm = oal_rd64(&in[32]), reps = oal_rd64(&in[40]); + if (np > 32 || nin + nout > 32) { std::fprintf(stderr, "bad case counts\n"); return 2; } + size_t o = 48; + std::vector p(np + 1); + for (unsigned long long k = 0; k < np; k++, o += 8) p[k] = (long long)oal_rd64(&in[o]); + std::vector sz(nin + nout); + for (unsigned long long k = 0; k < nin + nout; k++, o += 8) sz[k] = (size_t)oal_rd64(&in[o]); + int nscr = argc - 1; + std::vector buf(nin + nout + nscr + 1); + for (unsigned long long k = 0; k < nin; k++) { + if (o + sz[k] > in.size()) { std::fprintf(stderr, "case truncated\n"); return 2; } + OAL_CK(cudaMalloc(&buf[k], sz[k] ? sz[k] : 1)); + OAL_CK(cudaMemcpy(buf[k], &in[o], sz[k], cudaMemcpyHostToDevice)); + o += oal_pad8(sz[k]); + } + for (unsigned long long k = nin; k < nin + nout; k++) { + OAL_CK(cudaMalloc(&buf[k], sz[k] ? sz[k] : 1)); + OAL_CK(cudaMemset(buf[k], 0xFF, sz[k])); + } + for (int s = 0; s < nscr; s++) { + size_t n = (size_t)std::strtoull(argv[1 + s], nullptr, 10); + OAL_CK(cudaMalloc(&buf[nin + nout + s], n ? n : 1)); + OAL_CK(cudaMemset(buf[nin + nout + s], 0, n)); + } + OAL_CK(cudaDeviceSynchronize()); + for (unsigned long long r = 0; r < warm + reps; r++) { + auto t0 = std::chrono::steady_clock::now(); + oal_launch(p.data(), buf.data()); + OAL_CK(cudaGetLastError()); + OAL_CK(cudaDeviceSynchronize()); + auto t1 = std::chrono::steady_clock::now(); + if (r >= warm) + std::fprintf(stderr, "oal-time-ns %lld\n", + (long long)std::chrono::duration_cast(t1 - t0).count()); + } + std::vector out; + for (unsigned long long k = nin; k < nin + nout; k++) { + size_t base = out.size(); + out.resize(base + oal_pad8(sz[k]), 0); + OAL_CK(cudaMemcpy(&out[base], buf[k], sz[k], cudaMemcpyDeviceToHost)); + } + std::fwrite(out.data(), 1, out.size(), stdout); + std::fflush(stdout); + return 0; +} diff --git a/runners/cuda/run_all.sh b/runners/cuda/run_all.sh new file mode 100755 index 0000000..1665581 --- /dev/null +++ b/runners/cuda/run_all.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 +# runners/cuda/run_all.sh OUT.jsonl [oal-matrix options...] +# Run the CUDA entrant of every workload and control on the GPU of this machine and write +# oal-result/1 lines to OUT.jsonl. Needs nvcc, nvidia-smi and one NVIDIA GPU; the lab never runs +# this on CI. The records carry the GPU name, compute capability and driver in machine.runner and +# the label below, so the board can tell them from CPU rows. +# Exit: oal-matrix's status (0 when every line was written), 2 on a usage error, 4 without a GPU. +# INTERIM host glue (POSIX sh). Successor: an Omega runner script once omega-mv has one. +set -eu +[ $# -ge 1 ] || { echo "usage: run_all.sh OUT.jsonl [oal-matrix options]" >&2; exit 2; } +out=$1; shift +here=$(cd "$(dirname "$0")/../.." && pwd) +q=$(nvidia-smi --query-gpu=name,compute_cap,driver_version --format=csv,noheader 2>/dev/null | sed -n 1p) || true +[ -n "$q" ] || { echo "run_all.sh: no NVIDIA GPU visible" >&2; exit 4; } +name=$(echo "$q" | cut -d, -f1 | sed 's/^ *//;s/ *$//') +cc=$(echo "$q" | cut -d, -f2 | tr -d ' .') +drv=$(echo "$q" | cut -d, -f3 | tr -d ' ') +export OAL_CUDA_RUN=1 +export OAL_CUDA_ARCH="${OAL_CUDA_ARCH:-sm_$cc}" +export OAL_RUNNER_LABEL="${OAL_RUNNER_LABEL:-$name sm_$cc driver $drv}" +export OAL_TIMING_LABEL="${OAL_TIMING_LABEL:-GPU: launch + cudaDeviceSynchronize, host steady_clock, per repeat}" +export OAL_EVIDENCE="${OAL_EVIDENCE:-QUALIFIED-on-$name candidate: GPU run, driver $drv, $(date -u +%Y-%m-%dT%H:%MZ)}" +echo "run_all.sh: $OAL_RUNNER_LABEL arch $OAL_CUDA_ARCH" >&2 +exec python3 "$here/bin/oal-matrix" --backends cuda --controls "$@" > "$out" diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..75d9b76 --- /dev/null +++ b/site/index.html @@ -0,0 +1,156 @@ + + + + + +OpenAccel Lab: cross-backend kernel conformance board + + + +

OpenAccel Lab

+

A vendor-neutral, execution-verified conformance and performance lab for accelerator kernels. Every workload has one float64 +reference oracle, a written tolerance contract and the same seeded inputs for every entrant. The entrants are OpenCL C, Triton, +HIP, CUDA and Omega; none is privileged. Wrong kernels are kept in the lab as controls, and the board shows them being caught.

+

Read this before reading the numbers. CI timings are host CPU wall-clock times on GitHub runners (OpenCL on PoCL, Triton in +its interpreter, HIP on HIP-CPU, Omega native AArch64). They show distributions for one runner and are not GPU performance. GPU +rows appear only from labelled receipts, each linked to its evidence. Timings are shown as min / p10 / p25 / median / p75 / p90 / max +with the sample count, never as means.

+

+ +

Conformance matrix

+

Cell: status over every case and seed (count), and the median share of the tolerance bound used (err ratio; 0 = bit-exact, 1 = at the bound). +COMPILED means the CUDA source built with nvcc on a runner with no GPU and was not run.

+
+ +

Negative controls

+

Each control is a workload with one defect written into every entrant (a dropped term, an exclusive scan, a softmax without max subtraction). +Green means the lab flagged it on that backend; red means a wrong kernel passed.

+
+ +

Cross-backend agreement

+

For each workload: how many cases produced 1, 2, 3 or more distinct output byte streams across backends. Bitwise agreement is not +required, only the tolerance contract; this shows where entrants differ in rounding.

+
+ +

Timing distributions (default case)

+

Box: p25 to p75, line at median; whiskers p10 to p90; dots min and max. Log scale, nanoseconds.

+
+ +

Minimised failures

+

For every failing record the CI runs oal-shrink, which reduces the shape while the failure persists and prints the command that reproduces it.

+
+ +

GPU receipts

+

Rows from real GPUs. Each row carries its provenance label; none of them is a CI result.

+
+ +

Source

+

github.com/aien-dev/openaccel-lab (Apache-2.0 with LLVM exception). Data file: data.json.

+ + + + diff --git a/toolchain.lock b/toolchain.lock new file mode 100644 index 0000000..65966a2 --- /dev/null +++ b/toolchain.lock @@ -0,0 +1,32 @@ +# Pinned toolchain for OpenAccel Lab. Sourced by tools/fetch.sh and the CI workflow. +# Every file comes from GitHub at an exact commit or release and is refused unless its sha256 +# (or, for git checkouts, its commit id) matches. Change a pin only together with a passing run. + +# Parent repositories this lab grows out of (read-only; nothing is copied from them except the +# imported receipts under receipts/imported/, which carry their own sha256 list). +OMEGA_GPU_BENCH_REPO=aien-dev/omega-gpu-bench +OMEGA_GPU_BENCH_COMMIT=be6e65acafa9f75e705a308100bc5ddec8bfaa66 +OMEGA_KERNEL_TEMPLATE_REPO=aien-dev/omega-kernel-template +OMEGA_KERNEL_TEMPLATE_COMMIT=23a04c9fbe8a2e47ff86deaa1c537960f8986158 + +# Omega compiler (the Omega entrant), from aien-dev/omega-mv. +OMEGA_MV_REPO=aien-dev/omega-mv +OMEGA_MV_COMMIT=369dbc96daa1684db2d7c2c7085bbf16b3fd77ee +OMC_SHA256=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f + +# PoCL 7.2 CPU OpenCL runtime for AArch64 (the OpenCL entrant on the arm64 runner): the release +# asset aien-dev/omega-kernel-template built and self-tested on ubuntu-24.04-arm. +POCL_REPO=aien-dev/omega-kernel-template +POCL_TAG=pocl-7.2-888c9774-noble-arm64.1 +POCL_ASSET=pocl-7.2-888c9774-noble-arm64.tar.gz +POCL_SHA256=68892ec0b43b2edbbee27ff3b799826af92a8cc061e0e5a111eca83e78166fbd +POCL_LIB=lib/libpocl.so.2.16.0 + +# HIP-CPU (the HIP entrant runs HIP source on the host CPU). MIT; archived upstream. +HIPCPU_REPO=ROCm/HIP-CPU +HIPCPU_COMMIT=e112c935057434897bb12d9ab3910380a8bd5f58 + +# hipify-perl (CUDA source -> HIP source). Apache-2.0 WITH LLVM-exception. +HIPIFY_REPO=ROCm/HIPIFY +HIPIFY_COMMIT=7d531fc2620f66990aca1971b6cdd96c74f83d75 +HIPIFY_PERL_SHA256=3bd7551403e5e861bbca020690e0dfdad5aff1c7ed0558203abd7fc629128790 diff --git a/tools/fetch.sh b/tools/fetch.sh new file mode 100755 index 0000000..b26af0f --- /dev/null +++ b/tools/fetch.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 +# tools/fetch.sh [all|omega|pocl|hip] +# Fetch the toolchain pinned in toolchain.lock into .oal/ and refuse anything whose sha256 or +# commit id differs. Sources are GitHub only. Writes nothing outside .oal/. +# Exit 0, 1 on a refused or missing file, 2 on a usage error. +# INTERIM host glue (POSIX sh + curl + git). Successor: an Omega fetch-and-verify unit once seeded +# Omega has an HTTPS client word; curl moves bytes, sha256sum decides what is accepted. +set -eu +cd "$(dirname "$0")/.." +. ./toolchain.lock +what=${1:-all} +case $what in all|omega|pocl|hip) ;; *) echo "usage: tools/fetch.sh [all|omega|pocl|hip]" >&2; exit 2;; esac +D=.oal +mkdir -p "$D/tools" + +get() { + url=$1; out=$2; want=$3 + if [ -f "$out" ] && [ "$(sha256sum "$out" | cut -d ' ' -f 1)" = "$want" ]; then + echo "fetch: cached $want $out" >&2 + return 0 + fi + curl -fsSL --retry 3 -o "$out.part" "$url" + got=$(sha256sum "$out.part" | cut -d ' ' -f 1) + if [ "$got" != "$want" ]; then + rm -f "$out.part" + echo "fetch: REFUSED $url sha256 $got, pinned $want" >&2 + exit 1 + fi + mv "$out.part" "$out" + echo "fetch: OK $want $out" >&2 +} + +checkout() { + repo=$1; commit=$2; dir=$3 + if [ -d "$dir/.git" ] && [ "$(git -C "$dir" rev-parse HEAD)" = "$commit" ]; then + echo "fetch: cached $repo@$commit" >&2 + return 0 + fi + rm -rf "$dir" + git init -q "$dir" + git -C "$dir" fetch -q --depth 1 "https://github.com/$repo.git" "$commit" + git -C "$dir" checkout -q FETCH_HEAD + got=$(git -C "$dir" rev-parse HEAD) + [ "$got" = "$commit" ] || { echo "fetch: REFUSED $repo at $got, pinned $commit" >&2; exit 1; } + echo "fetch: OK $repo@$commit" >&2 +} + +if [ "$what" = all ] || [ "$what" = omega ]; then + get "https://raw.githubusercontent.com/$OMEGA_MV_REPO/$OMEGA_MV_COMMIT/seed/out/omc" "$D/tools/omc" "$OMC_SHA256" + chmod +x "$D/tools/omc" +fi + +if [ "$what" = all ] || [ "$what" = pocl ]; then + get "https://github.com/$POCL_REPO/releases/download/$POCL_TAG/$POCL_ASSET" "$D/$POCL_ASSET" "$POCL_SHA256" + rm -rf "$D/pocl" "$D/icd" + mkdir -p "$D/pocl" "$D/icd" + tar -xzf "$D/$POCL_ASSET" -C "$D/pocl" --strip-components=1 + [ -f "$D/pocl/$POCL_LIB" ] || { echo "fetch: $POCL_LIB missing from $POCL_ASSET" >&2; exit 1; } + echo "$(pwd)/$D/pocl/$POCL_LIB" > "$D/icd/pocl.icd" + echo "fetch: PoCL at $D/pocl; export OCL_ICD_VENDORS=$(pwd)/$D/icd" >&2 +fi + +if [ "$what" = all ] || [ "$what" = hip ]; then + checkout "$HIPCPU_REPO" "$HIPCPU_COMMIT" "$D/hip-cpu" + get "https://raw.githubusercontent.com/$HIPIFY_REPO/$HIPIFY_COMMIT/bin/hipify-perl" "$D/tools/hipify-perl" "$HIPIFY_PERL_SHA256" +fi diff --git a/workloads/argmax/kernel.cl b/workloads/argmax/kernel.cl new file mode 100644 index 0000000..1e57ace --- /dev/null +++ b/workloads/argmax/kernel.cl @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: Apache-2.0 +// (value, index) pairs; (v2, i2) beats (v1, i1) when v2 > v1, or v2 == v1 and i2 < i1 (first maximum). +// Pass 1: each work-group of 256 reduces its slice in local memory. Pass 2: one work-group reduces +// the nb partials. Padding is (-INFINITY, INT_MAX), which never beats a real element. + +#define OAL_BEATS(v2, i2, v1, i1) ((v2) > (v1) || ((v2) == (v1) && (i2) < (i1))) + +static void amax_tree(__local float *sv, __local int *si, int l) +{ + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k && OAL_BEATS(sv[l + k], si[l + k], sv[l], si[l])) { + sv[l] = sv[l + k]; + si[l] = si[l + k]; + } + barrier(CLK_LOCAL_MEM_FENCE); + } +} + +__kernel void amax_part(__global const float *x, __global float *pval, __global int *pidx, const int n, + __local float *sv, __local int *si) +{ + int l = get_local_id(0); + int i = get_global_id(0); + sv[l] = i < n ? x[i] : -INFINITY; + si[l] = i < n ? i : INT_MAX; + barrier(CLK_LOCAL_MEM_FENCE); + amax_tree(sv, si, l); + if (l == 0) { + pval[get_group_id(0)] = sv[0]; + pidx[get_group_id(0)] = si[0]; + } +} + +__kernel void amax_fin(__global const float *pval, __global const int *pidx, __global int *y, const int nb, + __local float *sv, __local int *si) +{ + int l = get_local_id(0); + float bv = -INFINITY; + int bi = INT_MAX; + for (int j = l; j < nb; j += get_local_size(0)) { + if (OAL_BEATS(pval[j], pidx[j], bv, bi)) { + bv = pval[j]; + bi = pidx[j]; + } + } + sv[l] = bv; + si[l] = bi; + barrier(CLK_LOCAL_MEM_FENCE); + amax_tree(sv, si, l); + if (l == 0) + y[0] = si[0]; +} diff --git a/workloads/argmax/kernel.cu b/workloads/argmax/kernel.cu new file mode 100644 index 0000000..18145ab --- /dev/null +++ b/workloads/argmax/kernel.cu @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: Apache-2.0 +// (value, index) pairs; (v2, i2) beats (v1, i1) when v2 > v1, or v2 == v1 and i2 < i1 (first maximum). +// Pass 1: each block of 256 reduces its slice in shared memory. Pass 2: one block reduces the nb +// partials. Padding is (-INFINITY, INT_MAX), which never beats a real element. +#include +#include +#include + +#define OAL_B 256 +#define OAL_BEATS(v2, i2, v1, i1) ((v2) > (v1) || ((v2) == (v1) && (i2) < (i1))) + +__global__ void amax_part(const float *x, float *pval, int *pidx, long long n) +{ + __shared__ float sv[OAL_B]; + __shared__ int si[OAL_B]; + int l = threadIdx.x; + long long i = (long long)blockIdx.x * OAL_B + l; + sv[l] = i < n ? x[i] : -INFINITY; + si[l] = i < n ? (int)i : INT_MAX; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k && OAL_BEATS(sv[l + k], si[l + k], sv[l], si[l])) { + sv[l] = sv[l + k]; + si[l] = si[l + k]; + } + __syncthreads(); + } + if (l == 0) { + pval[blockIdx.x] = sv[0]; + pidx[blockIdx.x] = si[0]; + } +} + +__global__ void amax_fin(const float *pval, const int *pidx, int *y, long long nb) +{ + __shared__ float sv[OAL_B]; + __shared__ int si[OAL_B]; + int l = threadIdx.x; + float bv = -INFINITY; + int bi = INT_MAX; + for (long long j = l; j < nb; j += OAL_B) { + if (OAL_BEATS(pval[j], pidx[j], bv, bi)) { + bv = pval[j]; + bi = pidx[j]; + } + } + sv[l] = bv; + si[l] = bi; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k && OAL_BEATS(sv[l + k], si[l + k], sv[l], si[l])) { + sv[l] = sv[l + k]; + si[l] = si[l + k]; + } + __syncthreads(); + } + if (l == 0) + y[0] = si[0]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0], nb = p[1]; + amax_part<<<(unsigned)nb, OAL_B>>>((const float *)buf[0], (float *)buf[2], (int *)buf[3], n); + amax_fin<<<1, OAL_B>>>((const float *)buf[2], (const int *)buf[3], (int *)buf[1], nb); +} diff --git a/workloads/argmax/omega.om b/workloads/argmax/omega.om new file mode 100644 index 0000000..55fff1b --- /dev/null +++ b/workloads/argmax/omega.om @@ -0,0 +1,30 @@ +global kn ulong 1 +fn kern to void +m = get fa 0 +k = ulong 0 +for i ulong get kn 0 +v = get fa i +if gt v m +m = v +k = i +end +end +put io 0 int k +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_sio 0 1 +oal_end +ret 0 +end diff --git a/workloads/argmax/reference.py b/workloads/argmax/reference.py new file mode 100644 index 0000000..a29a363 --- /dev/null +++ b/workloads/argmax/reference.py @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + a = x["x"].astype(np.float64) + return {"y": np.array([np.flatnonzero(a == a.max())[0]], dtype=np.float64)} diff --git a/workloads/argmax/triton_kernel.py b/workloads/argmax/triton_kernel.py new file mode 100644 index 0000000..121168f --- /dev/null +++ b/workloads/argmax/triton_kernel.py @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _amax(x, y, n, BLOCK: tl.constexpr): + # one program: lane j keeps the first maximum of x[j], x[j+BLOCK], ... (strict > keeps the + # earlier index); then the smallest index among the lanes that hold the overall maximum. + lane = tl.arange(0, BLOCK) + bv = tl.full([BLOCK], float("-inf"), dtype=tl.float32) + bi = tl.full([BLOCK], 2147483647, dtype=tl.int32) + for off in range(0, n, BLOCK): + i = off + lane + v = tl.load(x + i, mask=i < n, other=float("-inf")) + take = (v > bv) & (i < n) + bv = tl.where(take, v, bv) + bi = tl.where(take, i, bi) + m = tl.max(bv, axis=0) + tl.store(y, tl.min(tl.where(bv == m, bi, 2147483647), axis=0)) + + +def launch(p, t): + _amax[(1,)](t["x"], t["y"], p["n"], BLOCK=4096) diff --git a/workloads/argmax/workload.json b/workloads/argmax/workload.json new file mode 100644 index 0000000..ac5c3e9 --- /dev/null +++ b/workloads/argmax/workload.json @@ -0,0 +1,50 @@ +{ + "name": "argmax", + "family": "reduction", + "summary": "y[0] = index of the first maximum of n f32 elements (grid inputs repeat values, so ties are common); OpenCL/CUDA reduce (value, index) pairs in a 256-wide local tree per block, then one block reduces the block partials", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "n": 100003 + }, + "derived": { + "nb": "(n + 255) // 256" + }, + "cases": [ + {}, + {"n": 1}, + {"n": 257} + ], + "shrink": { + "n": {"min": 1} + }, + "inputs": [ + {"name": "x", "dtype": "f32", "shape": ["n"], "gen": {"kind": "grid", "klo": -40, "khi": 40, "shift": 3}} + ], + "outputs": [ + {"name": "y", "dtype": "i32", "shape": [1]} + ], + "scratch": [ + {"name": "pval", "dtype": "f32", "shape": ["nb"]}, + {"name": "pidx", "dtype": "i32", "shape": ["nb"]} + ], + "tolerance": { + "y": { + "kind": "int", + "atol": 0, + "why": "integer index, exact: the first index i with x[i] equal to the maximum (numpy argmax). With 81 grid values each occurs about n/81 times, so a kernel that keeps any but the first maximum fails" + } + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": { + "src": "kernel.cl", + "launches": [ + {"kernel": "amax_part", "global": ["nb * 256"], "local": [256], "args": ["x", "pval", "pidx", "n", "local:f32:256", "local:i32:256"]}, + {"kernel": "amax_fin", "global": [256], "local": [256], "args": ["pval", "pidx", "y", "nb", "local:f32:256", "local:i32:256"]} + ] + }, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/attention/kernel.cl b/workloads/attention/kernel.cl new file mode 100644 index 0000000..05400d8 --- /dev/null +++ b/workloads/attention/kernel.cl @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: Apache-2.0 +// attn_p: one work-item per row i writes the softmax weights pw[i][j], j <= i. +__kernel void attn_p(__global const float *q, __global const float *k, __global float *pw, + const int T, const int D) +{ + int i = get_global_id(0); + if (i >= T) + return; + float m = -1e30f; + for (int j = 0; j <= i; j++) { + float acc = 0.0f; + for (int c = 0; c < D; c++) + acc += q[i * D + c] * k[j * D + c]; + float s = acc * 0.125f; + pw[i * T + j] = s; + m = fmax(m, s); + } + float z = 0.0f; + for (int j = 0; j <= i; j++) { + float e = exp(pw[i * T + j] - m); + pw[i * T + j] = e; + z += e; + } + for (int j = 0; j <= i; j++) + pw[i * T + j] = pw[i * T + j] / z; +} + +// attn_o: o[i][c] = sum_{j <= i} pw[i][j] v[j][c]. +__kernel void attn_o(__global const float *pw, __global const float *v, __global float *o, + const int T, const int D) +{ + int i = get_global_id(0); + int c = get_global_id(1); + if (i >= T || c >= D) + return; + float acc = 0.0f; + for (int j = 0; j <= i; j++) + acc += pw[i * T + j] * v[j * D + c]; + o[i * D + c] = acc; +} diff --git a/workloads/attention/kernel.cu b/workloads/attention/kernel.cu new file mode 100644 index 0000000..2b6142a --- /dev/null +++ b/workloads/attention/kernel.cu @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +// attn_p: one thread per row i writes the softmax weights pw[i][j], j <= i. +__global__ void attn_p(const float *q, const float *k, float *pw, int T, int D) +{ + int i = blockIdx.x * blockDim.x + threadIdx.x; + if (i >= T) + return; + float m = -1e30f; + for (int j = 0; j <= i; j++) { + float acc = 0.0f; + for (int c = 0; c < D; c++) + acc += q[i * D + c] * k[j * D + c]; + float s = acc * 0.125f; + pw[i * T + j] = s; + m = fmaxf(m, s); + } + float z = 0.0f; + for (int j = 0; j <= i; j++) { + float e = expf(pw[i * T + j] - m); + pw[i * T + j] = e; + z += e; + } + for (int j = 0; j <= i; j++) + pw[i * T + j] = pw[i * T + j] / z; +} + +// attn_o: o[i][c] = sum_{j <= i} pw[i][j] v[j][c]. +__global__ void attn_o(const float *pw, const float *v, float *o, int T, int D) +{ + int c = blockIdx.x * blockDim.x + threadIdx.x; + int i = blockIdx.y; + if (i >= T || c >= D) + return; + float acc = 0.0f; + for (int j = 0; j <= i; j++) + acc += pw[i * T + j] * v[j * D + c]; + o[i * D + c] = acc; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int T = (int)p[0]; + int D = (int)p[1]; + float *pw = (float *)buf[4]; + attn_p<<<(T + 63) / 64, 64>>>((const float *)buf[0], (const float *)buf[1], pw, T, D); + dim3 grid((D + 63) / 64, T); + attn_o<<>>(pw, (const float *)buf[2], (float *)buf[3], T, D); +} diff --git a/workloads/attention/omega.om b/workloads/attention/omega.om new file mode 100644 index 0000000..b40c56a --- /dev/null +++ b/workloads/attention/omega.om @@ -0,0 +1,69 @@ +note attention: per row i, scores into sr, row max, e_j = exp(s_j - max) rounded to f32, o = (sum e_j v_j) / sum e_j +global kt ulong 1 +global kd ulong 1 +global sr f32 65536 +fn dotqk qi ulong kj ulong d ulong to f32 +acc = 0.0f32 +for c ulong d +x = get fa add qi c +acc = add acc mul x get fb add kj c +end +ret acc +end +fn rowexp n ulong m f32 to f32 +z = 0.0f32 +for j ulong n +e = f32 oal_expf f64 sub get sr j m +put sr j e +z = add z e +end +ret z +end +fn rowpv i ulong n ulong d ulong z f32 to void +for c ulong d +acc = 0.0f32 +for j ulong n +x = get sr j +acc = add acc mul x get fc add mul j d c +end +put fo add mul i d c div acc z +end +end +fn kern to void +t = get kt 0 +d = get kd 0 +for i ulong t +n = add i 1 +m = -1.0e30f32 +for j ulong n +s = mul dotqk mul i d mul j d d 0.125f32 +put sr j s +m = fmax m s +end +z = rowexp n m +rowpv i n d z +end +end +fn main to int +oal_begin +put kt 0 ulong oal_p 0 +put kd 0 ulong oal_p 1 +if gt get kt 0 65536 +trap 9 +end +a = oal_fa 0 +b = oal_fb 1 +c = oal_fc 2 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get kt 0 get kd 0 +oal_end +ret 0 +end diff --git a/workloads/attention/reference.py b/workloads/attention/reference.py new file mode 100644 index 0000000..5c564ba --- /dev/null +++ b/workloads/attention/reference.py @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Single-head causal attention O = softmax(mask(Q K^T * 0.125)) V, with the elementwise error bound. + +The bound (see workload.json "why") is computed per element, so the scale returned for "o" is the +whole bound and the manifest uses rtol 1. Notation for row i, n = i + 1 unmasked columns j: + s_j = 0.125 sum_c q_c k_jc (exact), a_j = 0.125 sum_c |q_c k_jc|, e_j = gamma(Dh) a_j, E = max_j e_j, + d_j = s_j - max s, p_j = exp(d_j) / sum exp(d), tau_j = e_j + E + u (|d_j| + e_j + E), + theta_j = exp(tau_j) (1 + EXP) - 1 relative error of each exp(score - max) + K = sum_j p_j ((1 + theta_j)(1 + gamma(n - 1)) - 1) relative error of the softmax denominator + c_j = (1 + theta_j)(1 + gamma(n + 1))(1 + u) / (1 - K) - 1 + bound_ic = sum_j p_j |v_jc| c_j +""" +import numpy as np + +U = 2.0 ** -24 +EXP = 6.0 * U # OpenCL exp <= 3 ulp (OpenCL C 3.0 s7.4); 1 ulp <= 2u relative, so <= 6u + + +def _gamma(n): + return n * U / (1.0 - n * U) + + +def reference(p, x): + t, d = p["T"], p["Dh"] + q = x["q"].astype(np.float64).reshape(t, d) + k = x["k"].astype(np.float64).reshape(t, d) + v = x["v"].astype(np.float64).reshape(t, d) + s_all = 0.125 * (q @ k.T) + a_all = 0.125 * (np.abs(q) @ np.abs(k).T) + g = _gamma(d) + o = np.zeros((t, d)) + bound = np.zeros((t, d)) + for i in range(t): + n = i + 1 + s = s_all[i, :n] + e = g * a_all[i, :n] + big_e = e.max() + dj = s - s.max() + w = np.exp(dj) + pj = w / w.sum() + tau = e + big_e + U * (np.abs(dj) + e + big_e) + theta = np.expm1(tau) * (1.0 + EXP) + EXP + kk = float(np.sum(pj * ((1.0 + theta) * (1.0 + _gamma(n - 1)) - 1.0))) + c = (1.0 + theta) * (1.0 + _gamma(n + 1)) * (1.0 + U) / (1.0 - kk) - 1.0 + o[i] = pj @ v[:n] + bound[i] = (pj * c) @ np.abs(v[:n]) + return {"o": (o, bound)} diff --git a/workloads/attention/triton_kernel.py b/workloads/attention/triton_kernel.py new file mode 100644 index 0000000..db861cf --- /dev/null +++ b/workloads/attention/triton_kernel.py @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _attention(q, k, v, o, D: tl.constexpr, BJ: tl.constexpr): + i = tl.program_id(0) + j = tl.arange(0, BJ) + c = tl.arange(0, D) + live = j <= i + qv = tl.load(q + i * D + c) + kv = tl.load(k + j[:, None] * D + c[None, :], mask=live[:, None], other=0.0) + s = tl.where(live, tl.sum(kv * qv[None, :], axis=1) * 0.125, -1e30) + m = tl.max(s, axis=0) + e = tl.where(live, tl.exp(s - m), 0.0) + pw = e / tl.sum(e, axis=0) + vv = tl.load(v + j[:, None] * D + c[None, :], mask=live[:, None], other=0.0) + tl.store(o + i * D + c, tl.sum(pw[:, None] * vv, axis=0)) + + +def launch(p, t): + n = p["T"] + _attention[(n,)](t["q"], t["k"], t["v"], t["o"], D=p["Dh"], BJ=triton.next_power_of_2(n)) diff --git a/workloads/attention/workload.json b/workloads/attention/workload.json new file mode 100644 index 0000000..d3818ae --- /dev/null +++ b/workloads/attention/workload.json @@ -0,0 +1,146 @@ +{ + "name": "attention", + "family": "attention", + "summary": "single-head causal attention O = softmax(mask(Q K^T * 0.125)) V; Q, K, V are T x Dh with Dh = 64; softmax subtracts the row max (Q and K have mean 3.5, so unshifted scores near 98 overflow binary32 exp)", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "T": 48, + "Dh": 64 + }, + "cases": [ + {}, + { + "T": 1 + }, + { + "T": 17 + } + ], + "shrink": { + "T": { + "min": 1 + }, + "Dh": { + "min": 64, + "multiple_of": 64 + } + }, + "inputs": [ + { + "name": "q", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 3.5, + "std": 1.0 + } + }, + { + "name": "k", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 3.5, + "std": 1.0 + } + }, + { + "name": "v", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 0.0, + "std": 1.0 + } + } + ], + "outputs": [ + { + "name": "o", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ] + } + ], + "scratch": [ + { + "name": "pw", + "dtype": "f32", + "shape": [ + "T", + "T" + ] + } + ], + "tolerance": { + "o": { + "kind": "bound", + "rtol": 1, + "atol": 1e-35, + "why": "reference.py returns the whole bound as the scale, per element: for row i with n = i+1 terms, bound = sum_j p_j |v_jc| c_j. Algorithm covered: scores, row max, exp(score - max), sum, then either p_j = e_j/sum and O = sum_j p_j v_j or O = (sum_j e_j v_j)/sum, every sum in any order, with or without FMA. Each score is within e_j = gamma(Dh) a_j, a_j = 0.125 sum_c |q_c k_jc| (Higham Thm 3.1; 0.125 exact); the row max within E = max_j e_j; the subtraction adds u|s_j - max|; so exp's argument is within tau_j = e_j + E + u(|d_j| + e_j + E), and with exp budgeted at 3 ulp <= 6u relative (OpenCL C 3.0 s7.4; CUDA expf 2 ulp = 4u is inside it) each exp(score - max) has relative error theta_j = e^tau_j (1 + 6u) - 1. The positive denominator sum has relative error K = sum_j p_j((1+theta_j)(1+gamma(n-1)) - 1); the numerator dot, including the p_j division, is within gamma(n+1) and a final division adds u, giving c_j = (1+theta_j)(1+gamma(n+1))(1+u)/(1-K) - 1. WolframLanguageEvaluator: u=2^-24; g[n_]:=n u/(1-n u); N[g[64],10] -> 3.814711818*10^-6; N[g[49],10] -> 2.920636124*10^-6; N[g[47],10] -> 2.801426152*10^-6; N[3*2^-23/u] -> 6.; N[2*2^-23/u] -> 4.; N[64*2^-24/(1-64*2^-24)*98*2,10] -> 0.0007476835162 (2 gamma(64) a with a near 8*3.5^2 = 98: the order of c_j, so a dropped term or a missing mask fails). atol covers exp, p_j and p_j v_j results flushed or rounded below 2^-126: at most 3 n of them, each < 2^-126 max|v| with max|v| <= Sqrt[12] (normal4 range) and the denominator >= 1: N[3*48*2^-126*Sqrt[12],10] -> 5.863725906*10^-36 <= 1e-35. Without the max subtraction exp overflows: N[Log[2^128],10] -> 88.72283911 is below scores near 98, so O becomes NaN." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "attn_p", + "global": [ + "T" + ], + "local": null, + "args": [ + "q", + "k", + "pw", + "T", + "Dh" + ] + }, + { + "kernel": "attn_o", + "global": [ + "T", + "Dh" + ], + "local": null, + "args": [ + "pw", + "v", + "o", + "T", + "Dh" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/attn_scores/kernel.cl b/workloads/attn_scores/kernel.cl new file mode 100644 index 0000000..8676a94 --- /dev/null +++ b/workloads/attn_scores/kernel.cl @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +__kernel void attn_scores(__global const float *q, __global const float *k, __global float *s, + const int T, const int D) +{ + int i = get_global_id(0); + int j = get_global_id(1); + if (i >= T || j >= T) + return; + if (j > i) { + s[i * T + j] = -1e30f; + return; + } + float acc = 0.0f; + for (int c = 0; c < D; c++) + acc += q[i * D + c] * k[j * D + c]; + s[i * T + j] = acc * 0.125f; +} diff --git a/workloads/attn_scores/kernel.cu b/workloads/attn_scores/kernel.cu new file mode 100644 index 0000000..f202206 --- /dev/null +++ b/workloads/attn_scores/kernel.cu @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +__global__ void attn_scores(const float *q, const float *k, float *s, int T, int D) +{ + int j = blockIdx.x * blockDim.x + threadIdx.x; + int i = blockIdx.y * blockDim.y + threadIdx.y; + if (i >= T || j >= T) + return; + if (j > i) { + s[i * T + j] = -1e30f; + return; + } + float acc = 0.0f; + for (int c = 0; c < D; c++) + acc += q[i * D + c] * k[j * D + c]; + s[i * T + j] = acc * 0.125f; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int T = (int)p[0]; + int D = (int)p[1]; + dim3 block(16, 16); + dim3 grid((T + 15) / 16, (T + 15) / 16); + attn_scores<<>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], T, D); +} diff --git a/workloads/attn_scores/omega.om b/workloads/attn_scores/omega.om new file mode 100644 index 0000000..77c8ec5 --- /dev/null +++ b/workloads/attn_scores/omega.om @@ -0,0 +1,43 @@ +global kt ulong 1 +global kd ulong 1 +fn dotqk qi ulong kj ulong d ulong to f32 +acc = 0.0f32 +for c ulong d +x = get fa add qi c +acc = add acc mul x get fb add kj c +end +ret acc +end +fn kern to void +t = get kt 0 +d = get kd 0 +for i ulong t +for j ulong t +o = add mul i t j +if gt j i +put fo o -1.0e30f32 +else +put fo o mul dotqk mul i d mul j d d 0.125f32 +end +end +end +end +fn main to int +oal_begin +put kt 0 ulong oal_p 0 +put kd 0 ulong oal_p 1 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get kt 0 get kt 0 +oal_end +ret 0 +end diff --git a/workloads/attn_scores/reference.py b/workloads/attn_scores/reference.py new file mode 100644 index 0000000..e97f0eb --- /dev/null +++ b/workloads/attn_scores/reference.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + +MASKED = float(np.float32(-1e30)) + + +def reference(p, x): + t, d = p["T"], p["Dh"] + q = x["q"].astype(np.float64).reshape(t, d) + k = x["k"].astype(np.float64).reshape(t, d) + s = 0.125 * (q @ k.T) + scale = 0.125 * (np.abs(q) @ np.abs(k).T) + masked = np.triu(np.ones((t, t), dtype=bool), 1) + s[masked] = MASKED + scale[masked] = 0.0 + return {"s": (s, scale)} diff --git a/workloads/attn_scores/triton_kernel.py b/workloads/attn_scores/triton_kernel.py new file mode 100644 index 0000000..99fc690 --- /dev/null +++ b/workloads/attn_scores/triton_kernel.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _attn_scores(q, k, s, T, D: tl.constexpr, BJ: tl.constexpr): + i = tl.program_id(0) + j = tl.arange(0, BJ) + c = tl.arange(0, D) + qv = tl.load(q + i * D + c) + kv = tl.load(k + j[:, None] * D + c[None, :], mask=j[:, None] < T, other=0.0) + acc = tl.sum(kv * qv[None, :], axis=1) * 0.125 + out = tl.where(j <= i, acc, -1e30) + tl.store(s + i * T + j, out, mask=j < T) + + +def launch(p, t): + n = p["T"] + _attn_scores[(n,)](t["q"], t["k"], t["s"], n, D=p["Dh"], BJ=triton.next_power_of_2(n)) diff --git a/workloads/attn_scores/workload.json b/workloads/attn_scores/workload.json new file mode 100644 index 0000000..c16b751 --- /dev/null +++ b/workloads/attn_scores/workload.json @@ -0,0 +1,109 @@ +{ + "name": "attn_scores", + "family": "attention", + "summary": "causal attention scores S[i][j] = 0.125 * sum_c Q[i][c] K[j][c] for j <= i, S[i][j] = -1e30f for j > i; Q, K are T x Dh with Dh = 64 so 1/sqrt(Dh) = 0.125 is exact", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "T": 48, + "Dh": 64 + }, + "cases": [ + {}, + { + "T": 1 + }, + { + "T": 17 + } + ], + "shrink": { + "T": { + "min": 1 + }, + "Dh": { + "min": 64, + "multiple_of": 64 + } + }, + "inputs": [ + { + "name": "q", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 0.0, + "std": 1.0 + } + }, + { + "name": "k", + "dtype": "f32", + "shape": [ + "T", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 0.0, + "std": 1.0 + } + } + ], + "outputs": [ + { + "name": "s", + "dtype": "f32", + "shape": [ + "T", + "T" + ] + } + ], + "tolerance": { + "s": { + "kind": "bound", + "rtol": "gamma(Dh)", + "atol": 0, + "why": "unmasked entry: a length-Dh dot product in any order, with or without FMA, is within gamma(Dh) * sum_c |q_c k_c| of the exact value (Higham Thm 3.1/3.5); the scale 0.125 = 2^-3 is exact both before and after the sum, so reference.py passes 0.125 * sum_c |q_c k_c| as the scale. WolframLanguageEvaluator: u=2^-24; g[n_]:=n u/(1-n u); N[g[64],10] -> 3.814711818*10^-6. Masked entry (j > i): scale 0 and atol 0, so it must equal float32(-1e30) exactly. A dropped term moves an entry by |q_c k_c|, far above 3.8e-6 of the row sum." + } + }, + "timing": { + "warmup": 2, + "repeats": 10 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "attn_scores", + "global": [ + "T", + "T" + ], + "local": null, + "args": [ + "q", + "k", + "s", + "T", + "Dh" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/batched_gemm/kernel.cl b/workloads/batched_gemm/kernel.cl new file mode 100644 index 0000000..ae74b52 --- /dev/null +++ b/workloads/batched_gemm/kernel.cl @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: Apache-2.0 +// One work-group per 16x16 tile of one batch member (dimension 2 is the batch index). Tiles of A and B +// are staged in __local memory; out-of-range tile elements load as 0.0f, adding exact zeros. +#define TS 16 +__kernel void batched_gemm(__global const float *A, __global const float *B, __global float *C, + const int M, const int N, const int K) +{ + __local float As[TS][TS]; + __local float Bs[TS][TS]; + int bt = get_global_id(2); + __global const float *Ab = A + bt * M * K; + __global const float *Bb = B + bt * K * N; + int tx = get_local_id(0), ty = get_local_id(1); + int row = get_group_id(1) * TS + ty, col = get_group_id(0) * TS + tx; + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? Ab[row * K + k0 + tx] : 0.0f; + Bs[ty][tx] = (k0 + ty < K && col < N) ? Bb[(k0 + ty) * N + col] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (row < M && col < N) + C[(bt * M + row) * N + col] = acc; +} diff --git a/workloads/batched_gemm/kernel.cu b/workloads/batched_gemm/kernel.cu new file mode 100644 index 0000000..2e92129 --- /dev/null +++ b/workloads/batched_gemm/kernel.cu @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define TS 16 + +// One block per 16x16 tile of one batch member (blockIdx.z is the batch index). Tiles of A and B are +// staged in static shared memory; out-of-range tile elements load as 0.0f, adding exact zeros. +__global__ void batched_gemm(const float *A, const float *B, float *C, int M, int N, int K) +{ + __shared__ float As[TS][TS]; + __shared__ float Bs[TS][TS]; + long long bt = blockIdx.z; + const float *Ab = A + bt * M * K; + const float *Bb = B + bt * K * N; + int tx = threadIdx.x, ty = threadIdx.y; + int row = blockIdx.y * TS + ty, col = blockIdx.x * TS + tx; + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? Ab[(long long)row * K + k0 + tx] : 0.0f; + Bs[ty][tx] = (k0 + ty < K && col < N) ? Bb[(long long)(k0 + ty) * N + col] : 0.0f; + __syncthreads(); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + __syncthreads(); + } + if (row < M && col < N) + C[(bt * M + row) * N + col] = acc; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int Bt = (int)p[0], M = (int)p[1], N = (int)p[2], K = (int)p[3]; + dim3 grid((unsigned)((N + TS - 1) / TS), (unsigned)((M + TS - 1) / TS), (unsigned)Bt); + dim3 block(TS, TS); + batched_gemm<<>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], M, N, K); +} diff --git a/workloads/batched_gemm/omega.om b/workloads/batched_gemm/omega.om new file mode 100644 index 0000000..2304956 --- /dev/null +++ b/workloads/batched_gemm/omega.om @@ -0,0 +1,50 @@ +note batched_gemm: fo[(b*M + i)*N + j] = sum_p fa[(b*M + i)*K + p] * fb[(b*K + p)*N + j], f32 in p order +note one function per output element keeps each function within omc's 16 registers (error 12) +global dm ulong 4 +fn bgm_el b ulong i ulong j ulong to f32 +n = get dm 2 +k = get dm 3 +ar = mul add mul b get dm 1 i k +bj = add mul mul b k n j +s = 0.0f32 +for p ulong k +x = get fa add ar p +y = get fb add bj mul p n +s = add s mul x y +end +ret s +end +fn kern to void +m = get dm 1 +n = get dm 2 +for b ulong get dm 0 +for i ulong m +ro = mul add mul b m i n +for j ulong n +v = bgm_el b i j +put fo add ro j v +end +end +end +end +fn main to int +oal_begin +put dm 0 ulong oal_p 0 +put dm 1 ulong oal_p 1 +put dm 2 ulong oal_p 2 +put dm 3 ulong oal_p 3 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul mul get dm 0 get dm 1 get dm 2 +oal_end +ret 0 +end diff --git a/workloads/batched_gemm/reference.py b/workloads/batched_gemm/reference.py new file mode 100644 index 0000000..9ef47c1 --- /dev/null +++ b/workloads/batched_gemm/reference.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + Bt, M, N, K = p["BATCH"], p["M"], p["N"], p["K"] + a = x["A"].astype(np.float64).reshape(Bt, M, K) + b = x["B"].astype(np.float64).reshape(Bt, K, N) + return {"C": (a @ b, np.abs(a) @ np.abs(b))} diff --git a/workloads/batched_gemm/triton_kernel.py b/workloads/batched_gemm/triton_kernel.py new file mode 100644 index 0000000..b83ee9c --- /dev/null +++ b/workloads/batched_gemm/triton_kernel.py @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 +# Grid axis 2 is the batch index. tl.dot with input_precision="ieee": full f32 products and f32 +# accumulation (the interpreter runs np.matmul in float32; on a GPU this forbids TF32). +import triton +import triton.language as tl + + +@triton.jit +def _batched_gemm(A, B, C, M, N, K, BM: tl.constexpr, BN: tl.constexpr, BK: tl.constexpr): + bt = tl.program_id(2) + A = A + bt * M * K + B = B + bt * K * N + C = C + bt * M * N + rm = tl.program_id(0) * BM + tl.arange(0, BM) + rn = tl.program_id(1) * BN + tl.arange(0, BN) + rk = tl.arange(0, BK) + acc = tl.zeros((BM, BN), dtype=tl.float32) + for k0 in range(0, K, BK): + kk = k0 + rk + a = tl.load(A + rm[:, None] * K + kk[None, :], mask=(rm[:, None] < M) & (kk[None, :] < K), other=0.0) + b = tl.load(B + kk[:, None] * N + rn[None, :], mask=(kk[:, None] < K) & (rn[None, :] < N), other=0.0) + acc = tl.dot(a, b, acc, input_precision="ieee") + tl.store(C + rm[:, None] * N + rn[None, :], acc, mask=(rm[:, None] < M) & (rn[None, :] < N)) + + +def launch(p, t): + Bt, M, N, K = p["BATCH"], p["M"], p["N"], p["K"] + grid = (triton.cdiv(M, 16), triton.cdiv(N, 16), Bt) + _batched_gemm[grid](t["A"], t["B"], t["C"], M, N, K, BM=16, BN=16, BK=16) diff --git a/workloads/batched_gemm/workload.json b/workloads/batched_gemm/workload.json new file mode 100644 index 0000000..dc09b94 --- /dev/null +++ b/workloads/batched_gemm/workload.json @@ -0,0 +1,28 @@ +{ + "name": "batched_gemm", + "family": "compute-bound", + "summary": "C[b] = A[b] B[b] for b < BATCH with A BATCH x M x K, B BATCH x K x N, C BATCH x M x N, all f32 row-major", + "provenance": "authored for OpenAccel Lab (Apache-2.0); strided-batched SGEMM NN semantics with alpha=1, beta=0", + "params": {"BATCH": 3, "M": 24, "N": 20, "K": 36}, + "cases": [{}, {"BATCH": 2, "M": 9, "N": 7, "K": 11}], + "shrink": {"BATCH": {"min": 1}, "M": {"min": 1}, "N": {"min": 1}, "K": {"min": 1}}, + "inputs": [ + {"name": "A", "dtype": "f32", "shape": ["BATCH", "M", "K"], "gen": {"kind": "uniform", "lo": -1.0, "hi": 1.0}}, + {"name": "B", "dtype": "f32", "shape": ["BATCH", "K", "N"], "gen": {"kind": "normal4", "std": 1.0}} + ], + "outputs": [{"name": "C", "dtype": "f32", "shape": ["BATCH", "M", "N"]}], + "tolerance": { + "C": {"kind": "bound", "rtol": "gamma(K)", "atol": 0, + "why": "each C[b][i][j] is a length-K dot product; in any summation order, fused or not, |err| <= gamma(K)*sum_k |A[b][i][k] B[b][k][j]| (Higham Thm 3.1/3.5); reference.py passes that sum as scale. WolframLanguageEvaluator: g[n_]:=n 2^-24/(1-n 2^-24); N[g[36],6] -> 2.14577*10^-6, N[g[11],6] -> 6.55652*10^-7"} + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": {"src": "kernel.cl", "launches": [ + {"kernel": "batched_gemm", "global": ["(N + 15) // 16 * 16", "(M + 15) // 16 * 16", "BATCH"], "local": [16, 16, 1], + "args": ["A", "B", "C", "M", "N", "K"]} + ]}, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/dequant_int4/kernel.cl b/workloads/dequant_int4/kernel.cl new file mode 100644 index 0000000..d92dfd0 --- /dev/null +++ b/workloads/dequant_int4/kernel.cl @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 +__kernel void dequant_int4(__global const uchar *w, __global const float *s, __global float *y, + const int R, const int C, const int G, const int NB) +{ + int r = get_global_id(0); + int c = get_global_id(1); + if (r >= R || c >= C) + return; + int b = w[r * NB + c / 2]; + int nib = (c & 1) ? (b >> 4) : (b & 15); + nib = nib >= 8 ? nib - 16 : nib; + y[r * C + c] = (float)nib * s[r * G + c / 32]; +} diff --git a/workloads/dequant_int4/kernel.cu b/workloads/dequant_int4/kernel.cu new file mode 100644 index 0000000..46e308a --- /dev/null +++ b/workloads/dequant_int4/kernel.cu @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +__global__ void dequant_int4(const unsigned char *w, const float *s, float *y, int R, int C, int G, int NB) +{ + long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; + if (i >= (long long)R * C) + return; + int r = (int)(i / C); + int c = (int)(i % C); + int b = w[r * NB + c / 2]; + int nib = (c & 1) ? (b >> 4) : (b & 15); + nib = nib >= 8 ? nib - 16 : nib; + y[i] = (float)nib * s[r * G + c / 32]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0] * p[1]; + dequant_int4<<<(unsigned)((n + 255) / 256), 256>>>((const unsigned char *)buf[0], (const float *)buf[1], + (float *)buf[2], (int)p[0], (int)p[1], (int)p[2], (int)p[3]); +} diff --git a/workloads/dequant_int4/omega.om b/workloads/dequant_int4/omega.om new file mode 100644 index 0000000..d2323a8 --- /dev/null +++ b/workloads/dequant_int4/omega.om @@ -0,0 +1,52 @@ +note dequant_int4: oal_qa gives bytes as -128..127, so add 256 for the u8 value, then take the nibble +global kr ulong 1 +global kc ulong 1 +global kg ulong 1 +global kb ulong 1 +fn nib4 v long hi ulong to f32 +if lt v 0 +v = add v 256 +end +n = and v 15 +if eq hi 1 +n = shr v 4 +end +if ge n 8 +n = sub n 16 +end +ret f32 n +end +fn drow i ulong c ulong g ulong nb ulong to void +for j ulong c +v = long get qa add mul i nb div j 2 +sc = get fa add mul i g div j 32 +put fo add mul i c j mul nib4 v rem j 2 sc +end +end +fn kern to void +r = get kr 0 +for i ulong r +drow i get kc 0 get kg 0 get kb 0 +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kc 0 ulong oal_p 1 +put kg 0 ulong oal_p 2 +put kb 0 ulong oal_p 3 +n = oal_qa 0 +a = oal_fa 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get kr 0 get kc 0 +oal_end +ret 0 +end diff --git a/workloads/dequant_int4/reference.py b/workloads/dequant_int4/reference.py new file mode 100644 index 0000000..c718644 --- /dev/null +++ b/workloads/dequant_int4/reference.py @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + r, c, g, nb = p["R"], p["C"], p["G"], p["NB"] + w = x["w"].astype(np.int64).reshape(r, nb) + s = x["s"].astype(np.float64).reshape(r, g) + nib = np.empty((r, c), dtype=np.int64) + nib[:, 0::2] = w & 15 + nib[:, 1::2] = w >> 4 + nib = np.where(nib >= 8, nib - 16, nib) + return {"y": nib.astype(np.float64) * s[:, np.arange(c) // 32]} diff --git a/workloads/dequant_int4/triton_kernel.py b/workloads/dequant_int4/triton_kernel.py new file mode 100644 index 0000000..957c7b2 --- /dev/null +++ b/workloads/dequant_int4/triton_kernel.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _dequant_int4(w, s, y, C, G, NB, BC: tl.constexpr): + r = tl.program_id(0) + c = tl.arange(0, BC) + live = c < C + b = tl.load(w + r * NB + c // 2, mask=live, other=0).to(tl.int32) + nib = tl.where((c % 2) == 1, b >> 4, b & 15) + nib = tl.where(nib >= 8, nib - 16, nib) + sc = tl.load(s + r * G + c // 32, mask=live, other=0.0) + tl.store(y + r * C + c, nib.to(tl.float32) * sc, mask=live) + + +def launch(p, t): + _dequant_int4[(p["R"],)](t["w"], t["s"], t["y"], p["C"], p["G"], p["NB"], BC=triton.next_power_of_2(p["C"])) diff --git a/workloads/dequant_int4/workload.json b/workloads/dequant_int4/workload.json new file mode 100644 index 0000000..cb1e56d --- /dev/null +++ b/workloads/dequant_int4/workload.json @@ -0,0 +1,115 @@ +{ + "name": "dequant_int4", + "family": "quantization", + "summary": "group-wise int4 dequantization: w is R x C/2 packed u8 (element 2k in the low nibble, 2k+1 in the high nibble, each a 4-bit two's complement value -8..7); y[r][c] = nibble * s[r][c / 32] with one f32 scale per group of 32 columns", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the packed signed-nibble, group-32 layout of common 4-bit weight formats", + "params": { + "R": 64, + "C": 256 + }, + "derived": { + "G": "(C + 31) // 32", + "NB": "C // 2" + }, + "cases": [ + {}, + { + "R": 1, + "C": 2 + }, + { + "R": 5, + "C": 70 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "C": { + "min": 2, + "multiple_of": 2 + } + }, + "inputs": [ + { + "name": "w", + "dtype": "u8", + "shape": [ + "R", + "NB" + ], + "gen": { + "kind": "int", + "lo": 0, + "hi": 255 + } + }, + { + "name": "s", + "dtype": "f32", + "shape": [ + "R", + "G" + ], + "gen": { + "kind": "uniform", + "lo": 0.001, + "hi": 0.05 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "R", + "C" + ] + } + ], + "tolerance": { + "y": { + "kind": "exact", + "why": "the nibble is an exact integer -8..7, converts to f32 exactly, then one correctly rounded f32 multiply per element" + } + }, + "timing": { + "warmup": 2, + "repeats": 10 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "dequant_int4", + "global": [ + "R", + "C" + ], + "local": null, + "args": [ + "w", + "s", + "y", + "R", + "C", + "G", + "NB" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/dequant_int8/kernel.cl b/workloads/dequant_int8/kernel.cl new file mode 100644 index 0000000..64de972 --- /dev/null +++ b/workloads/dequant_int8/kernel.cl @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: Apache-2.0 +__kernel void dequant_int8(__global const char *q, __global const float *s, __global float *y, + const int R, const int C) +{ + int r = get_global_id(0); + int c = get_global_id(1); + if (r >= R || c >= C) + return; + y[r * C + c] = (float)q[r * C + c] * s[r]; +} diff --git a/workloads/dequant_int8/kernel.cu b/workloads/dequant_int8/kernel.cu new file mode 100644 index 0000000..f317624 --- /dev/null +++ b/workloads/dequant_int8/kernel.cu @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +__global__ void dequant_int8(const signed char *q, const float *s, float *y, int R, int C) +{ + long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; + if (i >= (long long)R * C) + return; + int r = (int)(i / C); + y[i] = (float)q[i] * s[r]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0] * p[1]; + dequant_int8<<<(unsigned)((n + 255) / 256), 256>>>((const signed char *)buf[0], (const float *)buf[1], + (float *)buf[2], (int)p[0], (int)p[1]); +} diff --git a/workloads/dequant_int8/omega.om b/workloads/dequant_int8/omega.om new file mode 100644 index 0000000..918795e --- /dev/null +++ b/workloads/dequant_int8/omega.om @@ -0,0 +1,34 @@ +global kr ulong 1 +global kc ulong 1 +fn kern to void +r = get kr 0 +c = get kc 0 +for i ulong r +b = mul i c +sc = get fa i +for j ulong c +o = add b j +v = f32 get qa o +put fo o mul v sc +end +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kc 0 ulong oal_p 1 +n = oal_qa 0 +a = oal_fa 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get kr 0 get kc 0 +oal_end +ret 0 +end diff --git a/workloads/dequant_int8/reference.py b/workloads/dequant_int8/reference.py new file mode 100644 index 0000000..12205d3 --- /dev/null +++ b/workloads/dequant_int8/reference.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + r, c = p["R"], p["C"] + q = x["q"].astype(np.float64).reshape(r, c) + s = x["s"].astype(np.float64).reshape(r) + return {"y": q * s[:, None]} diff --git a/workloads/dequant_int8/triton_kernel.py b/workloads/dequant_int8/triton_kernel.py new file mode 100644 index 0000000..b64d80a --- /dev/null +++ b/workloads/dequant_int8/triton_kernel.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _dequant_int8(q, s, y, C, BC: tl.constexpr): + r = tl.program_id(0) + c = tl.arange(0, BC) + live = c < C + qv = tl.load(q + r * C + c, mask=live, other=0).to(tl.float32) + tl.store(y + r * C + c, qv * tl.load(s + r), mask=live) + + +def launch(p, t): + _dequant_int8[(p["R"],)](t["q"], t["s"], t["y"], p["C"], BC=triton.next_power_of_2(p["C"])) diff --git a/workloads/dequant_int8/workload.json b/workloads/dequant_int8/workload.json new file mode 100644 index 0000000..c4c9d9b --- /dev/null +++ b/workloads/dequant_int8/workload.json @@ -0,0 +1,107 @@ +{ + "name": "dequant_int8", + "family": "quantization", + "summary": "per-row int8 dequantization: y[r][c] = q[r][c] * s[r], q i8 in -127..127, s f32 per row", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "R": 64, + "C": 256 + }, + "cases": [ + {}, + { + "R": 1, + "C": 1 + }, + { + "R": 5, + "C": 77 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "C": { + "min": 1 + } + }, + "inputs": [ + { + "name": "q", + "dtype": "i8", + "shape": [ + "R", + "C" + ], + "gen": { + "kind": "int", + "lo": -127, + "hi": 127 + } + }, + { + "name": "s", + "dtype": "f32", + "shape": [ + "R" + ], + "gen": { + "kind": "uniform", + "lo": 0.001, + "hi": 0.05 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "R", + "C" + ] + } + ], + "tolerance": { + "y": { + "kind": "exact", + "why": "q converts to f32 exactly (|q| <= 127 < 2^24), then one correctly rounded f32 multiply per element" + } + }, + "timing": { + "warmup": 2, + "repeats": 10 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "dequant_int8", + "global": [ + "R", + "C" + ], + "local": null, + "args": [ + "q", + "s", + "y", + "R", + "C" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/dot/kernel.cl b/workloads/dot/kernel.cl new file mode 100644 index 0000000..42cf703 --- /dev/null +++ b/workloads/dot/kernel.cl @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 +// Pass 1: each work-group of 256 forms a[i]*b[i] and sums its slice in a local-memory tree. +// Pass 2: one work-group sums the nb partials (strided, then a tree) into y[0]. +__kernel void dot_part(__global const float *a, __global const float *b, __global float *part, const int n, + __local float *s) +{ + int l = get_local_id(0); + int i = get_global_id(0); + s[l] = i < n ? a[i] * b[i] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + part[get_group_id(0)] = s[0]; +} + +__kernel void dot_fin(__global const float *part, __global float *y, const int nb, __local float *s) +{ + int l = get_local_id(0); + float acc = 0.0f; + for (int j = l; j < nb; j += get_local_size(0)) + acc += part[j]; + s[l] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + y[0] = s[0]; +} diff --git a/workloads/dot/kernel.cu b/workloads/dot/kernel.cu new file mode 100644 index 0000000..df70868 --- /dev/null +++ b/workloads/dot/kernel.cu @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: Apache-2.0 +// Pass 1: each block of 256 forms a[i]*b[i] and sums its slice in a shared-memory tree. +// Pass 2: one block sums the nb partials (strided, then a tree) into y[0]. +#include + +#define OAL_B 256 + +__global__ void dot_part(const float *a, const float *b, float *part, long long n) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + long long i = (long long)blockIdx.x * OAL_B + l; + s[l] = i < n ? a[i] * b[i] : 0.0f; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + __syncthreads(); + } + if (l == 0) + part[blockIdx.x] = s[0]; +} + +__global__ void dot_fin(const float *part, float *y, long long nb) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + float acc = 0.0f; + for (long long j = l; j < nb; j += OAL_B) + acc += part[j]; + s[l] = acc; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + __syncthreads(); + } + if (l == 0) + y[0] = s[0]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0], nb = p[1]; + dot_part<<<(unsigned)nb, OAL_B>>>((const float *)buf[0], (const float *)buf[1], (float *)buf[3], n); + dot_fin<<<1, OAL_B>>>((const float *)buf[3], (float *)buf[2], nb); +} diff --git a/workloads/dot/omega.om b/workloads/dot/omega.om new file mode 100644 index 0000000..5878318 --- /dev/null +++ b/workloads/dot/omega.om @@ -0,0 +1,26 @@ +global kn ulong 1 +fn kern to void +s = 0.0f32 +for i ulong get kn 0 +s = add s mul get fa i get fb i +end +put fo 0 s +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 1 +oal_end +ret 0 +end diff --git a/workloads/dot/reference.py b/workloads/dot/reference.py new file mode 100644 index 0000000..06aa077 --- /dev/null +++ b/workloads/dot/reference.py @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + pr = x["a"].astype(np.float64) * x["b"].astype(np.float64) + return {"y": (np.array([pr.sum()]), np.array([np.abs(pr).sum()]))} diff --git a/workloads/dot/triton_kernel.py b/workloads/dot/triton_kernel.py new file mode 100644 index 0000000..1897094 --- /dev/null +++ b/workloads/dot/triton_kernel.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _dot(a, b, y, n, BLOCK: tl.constexpr): + # one program: BLOCK lane accumulators of a[i]*b[i] over the strided input, then a tree sum + lane = tl.arange(0, BLOCK) + acc = tl.zeros([BLOCK], dtype=tl.float32) + for off in range(0, n, BLOCK): + i = off + lane + m = i < n + acc += tl.load(a + i, mask=m, other=0.0) * tl.load(b + i, mask=m, other=0.0) + tl.store(y, tl.sum(acc, axis=0)) + + +def launch(p, t): + _dot[(1,)](t["a"], t["b"], t["y"], p["n"], BLOCK=4096) diff --git a/workloads/dot/workload.json b/workloads/dot/workload.json new file mode 100644 index 0000000..d171242 --- /dev/null +++ b/workloads/dot/workload.json @@ -0,0 +1,51 @@ +{ + "name": "dot", + "family": "reduction", + "summary": "y[0] = sum a[i]*b[i] over n f32 elements; OpenCL/CUDA reduce in a 256-wide local tree per block, then one block reduces the block partials", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "n": 100003 + }, + "derived": { + "nb": "(n + 255) // 256" + }, + "cases": [ + {}, + {"n": 1}, + {"n": 257} + ], + "shrink": { + "n": {"min": 1} + }, + "inputs": [ + {"name": "a", "dtype": "f32", "shape": ["n"], "gen": {"kind": "uniform", "lo": -2.0, "hi": 2.0}}, + {"name": "b", "dtype": "f32", "shape": ["n"], "gen": {"kind": "normal4", "std": 1.0}} + ], + "outputs": [ + {"name": "y", "dtype": "f32", "shape": [1]} + ], + "scratch": [ + {"name": "part", "dtype": "f32", "shape": ["nb"]} + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": "gamma(n)", + "atol": 0, + "why": "A dot product of length n in any summation order, with or without fused multiply-add, is within gamma(n)*sum|a_i b_i| of the exact value (Higham ASNA 2nd ed. eq. 3.5 and section 3.1); scale sum|a_i b_i| from reference.py. Padding adds exact zeros. WolframLanguageEvaluator: u=2^-24; g[n_]:=n u/(1-n u); N[g[100003],10] -> 0.005996385607; N[g[257],10] -> 0.00001531862836" + } + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": { + "src": "kernel.cl", + "launches": [ + {"kernel": "dot_part", "global": ["nb * 256"], "local": [256], "args": ["a", "b", "part", "n", "local:f32:256"]}, + {"kernel": "dot_fin", "global": [256], "local": [256], "args": ["part", "y", "nb", "local:f32:256"]} + ] + }, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/gemm_bias_relu/kernel.cl b/workloads/gemm_bias_relu/kernel.cl new file mode 100644 index 0000000..8974485 --- /dev/null +++ b/workloads/gemm_bias_relu/kernel.cl @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: Apache-2.0 +// C = relu(A B + bias). 16x16 tiles of A and B staged in __local memory; out-of-range tile elements +// load as 0.0f, which adds exact zeros to the accumulator. global is the tile-rounded (N, M) grid, +// local (16, 16). +#define TS 16 +__kernel void gemm_bias_relu(__global const float *A, __global const float *B, __global const float *bias, + __global float *C, const int M, const int N, const int K) +{ + __local float As[TS][TS]; + __local float Bs[TS][TS]; + int tx = get_local_id(0), ty = get_local_id(1); + int row = get_group_id(1) * TS + ty, col = get_group_id(0) * TS + tx; + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? A[row * K + k0 + tx] : 0.0f; + Bs[ty][tx] = (k0 + ty < K && col < N) ? B[(k0 + ty) * N + col] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (row < M && col < N) + C[row * N + col] = fmax(acc + bias[col], 0.0f); +} diff --git a/workloads/gemm_bias_relu/kernel.cu b/workloads/gemm_bias_relu/kernel.cu new file mode 100644 index 0000000..11d77d0 --- /dev/null +++ b/workloads/gemm_bias_relu/kernel.cu @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define TS 16 + +// C = relu(A B + bias). 16x16 tiles of A and B staged in static shared memory; out-of-range tile +// elements load as 0.0f, which adds exact zeros to the accumulator. +__global__ void gemm_bias_relu(const float *A, const float *B, const float *bias, float *C, int M, int N, int K) +{ + __shared__ float As[TS][TS]; + __shared__ float Bs[TS][TS]; + int tx = threadIdx.x, ty = threadIdx.y; + int row = blockIdx.y * TS + ty, col = blockIdx.x * TS + tx; + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? A[(long long)row * K + k0 + tx] : 0.0f; + Bs[ty][tx] = (k0 + ty < K && col < N) ? B[(long long)(k0 + ty) * N + col] : 0.0f; + __syncthreads(); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + __syncthreads(); + } + if (row < M && col < N) + C[(long long)row * N + col] = fmaxf(acc + bias[col], 0.0f); +} + +void oal_launch(const long long *p, void *const *buf) +{ + int M = (int)p[0], N = (int)p[1], K = (int)p[2]; + dim3 grid((unsigned)((N + TS - 1) / TS), (unsigned)((M + TS - 1) / TS)); + dim3 block(TS, TS); + gemm_bias_relu<<>>((const float *)buf[0], (const float *)buf[1], (const float *)buf[2], + (float *)buf[3], M, N, K); +} diff --git a/workloads/gemm_bias_relu/omega.om b/workloads/gemm_bias_relu/omega.om new file mode 100644 index 0000000..b2e2877 --- /dev/null +++ b/workloads/gemm_bias_relu/omega.om @@ -0,0 +1,45 @@ +note gemm_bias_relu: fo[i*N + j] = max(sum_p fa[i*K + p] * fb[p*N + j] + fc[j], 0), f32 in p order +note one function per output element keeps each function within omc's 16 registers (error 12) +global dm ulong 3 +fn gbr_el i ulong j ulong to f32 +n = get dm 1 +k = get dm 2 +ar = mul i k +s = 0.0f32 +for p ulong k +x = get fa add ar p +y = get fb add mul p n j +s = add s mul x y +end +s = add s get fc j +ret fmax s 0.0f32 +end +fn kern to void +n = get dm 1 +for i ulong get dm 0 +for j ulong n +put fo add mul i n j gbr_el i j +end +end +end +fn main to int +oal_begin +put dm 0 ulong oal_p 0 +put dm 1 ulong oal_p 1 +put dm 2 ulong oal_p 2 +a = oal_fa 0 +b = oal_fb 1 +c = oal_fc 2 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get dm 0 get dm 1 +oal_end +ret 0 +end diff --git a/workloads/gemm_bias_relu/reference.py b/workloads/gemm_bias_relu/reference.py new file mode 100644 index 0000000..924cc09 --- /dev/null +++ b/workloads/gemm_bias_relu/reference.py @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + M, N, K = p["M"], p["N"], p["K"] + a = x["A"].astype(np.float64).reshape(M, K) + b = x["B"].astype(np.float64).reshape(K, N) + bias = x["bias"].astype(np.float64) + pre = a @ b + bias[None, :] + scale = np.abs(a) @ np.abs(b) + np.abs(bias)[None, :] + return {"C": (np.maximum(pre, 0.0), scale)} diff --git a/workloads/gemm_bias_relu/triton_kernel.py b/workloads/gemm_bias_relu/triton_kernel.py new file mode 100644 index 0000000..e01e22d --- /dev/null +++ b/workloads/gemm_bias_relu/triton_kernel.py @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 +# tl.dot with input_precision="ieee": full f32 products and f32 accumulation (the interpreter runs +# np.matmul in float32; on a GPU this forbids TF32), then the bias add and relu epilogue. +import triton +import triton.language as tl + + +@triton.jit +def _gemm_bias_relu(A, B, bias, C, M, N, K, BM: tl.constexpr, BN: tl.constexpr, BK: tl.constexpr): + rm = tl.program_id(0) * BM + tl.arange(0, BM) + rn = tl.program_id(1) * BN + tl.arange(0, BN) + rk = tl.arange(0, BK) + acc = tl.zeros((BM, BN), dtype=tl.float32) + for k0 in range(0, K, BK): + kk = k0 + rk + a = tl.load(A + rm[:, None] * K + kk[None, :], mask=(rm[:, None] < M) & (kk[None, :] < K), other=0.0) + b = tl.load(B + kk[:, None] * N + rn[None, :], mask=(kk[:, None] < K) & (rn[None, :] < N), other=0.0) + acc = tl.dot(a, b, acc, input_precision="ieee") + bv = tl.load(bias + rn, mask=rn < N, other=0.0) + out = tl.maximum(acc + bv[None, :], 0.0) + tl.store(C + rm[:, None] * N + rn[None, :], out, mask=(rm[:, None] < M) & (rn[None, :] < N)) + + +def launch(p, t): + M, N, K = p["M"], p["N"], p["K"] + _gemm_bias_relu[(triton.cdiv(M, 16), triton.cdiv(N, 16))](t["A"], t["B"], t["bias"], t["C"], M, N, K, + BM=16, BN=16, BK=16) diff --git a/workloads/gemm_bias_relu/workload.json b/workloads/gemm_bias_relu/workload.json new file mode 100644 index 0000000..b706c1d --- /dev/null +++ b/workloads/gemm_bias_relu/workload.json @@ -0,0 +1,29 @@ +{ + "name": "gemm_bias_relu", + "family": "compute-bound", + "summary": "C = relu(A B + bias) with A M x K, B K x N, bias N broadcast over rows, all f32 row-major", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the fused linear+ReLU epilogue of a dense layer", + "params": {"M": 48, "N": 40, "K": 72}, + "cases": [{}, {"M": 17, "N": 13, "K": 19}], + "shrink": {"M": {"min": 1}, "N": {"min": 1}, "K": {"min": 1}}, + "inputs": [ + {"name": "A", "dtype": "f32", "shape": ["M", "K"], "gen": {"kind": "uniform", "lo": -1.0, "hi": 1.0}}, + {"name": "B", "dtype": "f32", "shape": ["K", "N"], "gen": {"kind": "normal4", "std": 1.0}}, + {"name": "bias", "dtype": "f32", "shape": ["N"], "gen": {"kind": "normal4", "std": 2.0}} + ], + "outputs": [{"name": "C", "dtype": "f32", "shape": ["M", "N"]}], + "tolerance": { + "C": {"kind": "bound", "rtol": "gamma(K + 1)", "atol": 0, + "why": "A[i,:]B[:,j] + bias[j] is a length-(K+1) dot product (the bias times 1), so in any order, fused or not, |err| <= gamma(K+1)*(sum_k |A[i][k] B[k][j]| + |bias[j]|) (Higham Thm 3.1/3.5); relu is 1-Lipschitz and exact, so the bound carries through it. reference.py passes that sum as scale. WolframLanguageEvaluator: g[n_]:=n 2^-24/(1-n 2^-24); N[g[73],6] -> 4.35116*10^-6, N[g[20],6] -> 1.19209*10^-6"} + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": {"src": "kernel.cl", "launches": [ + {"kernel": "gemm_bias_relu", "global": ["(N + 15) // 16 * 16", "(M + 15) // 16 * 16"], "local": [16, 16], + "args": ["A", "B", "bias", "C", "M", "N", "K"]} + ]}, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/gemm_nn/kernel.cl b/workloads/gemm_nn/kernel.cl new file mode 100644 index 0000000..590576b --- /dev/null +++ b/workloads/gemm_nn/kernel.cl @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: Apache-2.0 +// 16x16 tiles of A and B staged in __local memory; out-of-range tile elements load as 0.0f, which +// adds exact zeros to the accumulator. global is the tile-rounded (N, M) grid, local (16, 16). +#define TS 16 +__kernel void gemm_nn(__global const float *A, __global const float *B, __global float *C, + const int M, const int N, const int K) +{ + __local float As[TS][TS]; + __local float Bs[TS][TS]; + int tx = get_local_id(0), ty = get_local_id(1); + int row = get_group_id(1) * TS + ty, col = get_group_id(0) * TS + tx; + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? A[row * K + k0 + tx] : 0.0f; + Bs[ty][tx] = (k0 + ty < K && col < N) ? B[(k0 + ty) * N + col] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (row < M && col < N) + C[row * N + col] = acc; +} diff --git a/workloads/gemm_nn/kernel.cu b/workloads/gemm_nn/kernel.cu new file mode 100644 index 0000000..bad552d --- /dev/null +++ b/workloads/gemm_nn/kernel.cu @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define TS 16 + +// 16x16 tiles of A and B staged in static shared memory; out-of-range tile elements load as 0.0f, +// which adds exact zeros to the accumulator. +__global__ void gemm_nn(const float *A, const float *B, float *C, int M, int N, int K) +{ + __shared__ float As[TS][TS]; + __shared__ float Bs[TS][TS]; + int tx = threadIdx.x, ty = threadIdx.y; + int row = blockIdx.y * TS + ty, col = blockIdx.x * TS + tx; + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? A[(long long)row * K + k0 + tx] : 0.0f; + Bs[ty][tx] = (k0 + ty < K && col < N) ? B[(long long)(k0 + ty) * N + col] : 0.0f; + __syncthreads(); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + __syncthreads(); + } + if (row < M && col < N) + C[(long long)row * N + col] = acc; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int M = (int)p[0], N = (int)p[1], K = (int)p[2]; + dim3 grid((unsigned)((N + TS - 1) / TS), (unsigned)((M + TS - 1) / TS)); + dim3 block(TS, TS); + gemm_nn<<>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], M, N, K); +} diff --git a/workloads/gemm_nn/omega.om b/workloads/gemm_nn/omega.om new file mode 100644 index 0000000..7f4f1e1 --- /dev/null +++ b/workloads/gemm_nn/omega.om @@ -0,0 +1,43 @@ +note gemm_nn: fo[i*N + j] = sum_p fa[i*K + p] * fb[p*N + j], f32 accumulation in p order +note one function per output element keeps each function within omc's 16 registers (error 12) +global dm ulong 3 +fn gnn_el i ulong j ulong to f32 +n = get dm 1 +k = get dm 2 +ar = mul i k +s = 0.0f32 +for p ulong k +x = get fa add ar p +y = get fb add mul p n j +s = add s mul x y +end +ret s +end +fn kern to void +n = get dm 1 +for i ulong get dm 0 +for j ulong n +put fo add mul i n j gnn_el i j +end +end +end +fn main to int +oal_begin +put dm 0 ulong oal_p 0 +put dm 1 ulong oal_p 1 +put dm 2 ulong oal_p 2 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get dm 0 get dm 1 +oal_end +ret 0 +end diff --git a/workloads/gemm_nn/reference.py b/workloads/gemm_nn/reference.py new file mode 100644 index 0000000..7d56312 --- /dev/null +++ b/workloads/gemm_nn/reference.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + M, N, K = p["M"], p["N"], p["K"] + a = x["A"].astype(np.float64).reshape(M, K) + b = x["B"].astype(np.float64).reshape(K, N) + return {"C": (a @ b, np.abs(a) @ np.abs(b))} diff --git a/workloads/gemm_nn/triton_kernel.py b/workloads/gemm_nn/triton_kernel.py new file mode 100644 index 0000000..fa66ad1 --- /dev/null +++ b/workloads/gemm_nn/triton_kernel.py @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 +# tl.dot with input_precision="ieee": full f32 products and f32 accumulation (the interpreter runs +# np.matmul in float32; on a GPU this forbids TF32), so the gamma(K) dot-product bound applies. +import triton +import triton.language as tl + + +@triton.jit +def _gemm_nn(A, B, C, M, N, K, BM: tl.constexpr, BN: tl.constexpr, BK: tl.constexpr): + rm = tl.program_id(0) * BM + tl.arange(0, BM) + rn = tl.program_id(1) * BN + tl.arange(0, BN) + rk = tl.arange(0, BK) + acc = tl.zeros((BM, BN), dtype=tl.float32) + for k0 in range(0, K, BK): + kk = k0 + rk + a = tl.load(A + rm[:, None] * K + kk[None, :], mask=(rm[:, None] < M) & (kk[None, :] < K), other=0.0) + b = tl.load(B + kk[:, None] * N + rn[None, :], mask=(kk[:, None] < K) & (rn[None, :] < N), other=0.0) + acc = tl.dot(a, b, acc, input_precision="ieee") + tl.store(C + rm[:, None] * N + rn[None, :], acc, mask=(rm[:, None] < M) & (rn[None, :] < N)) + + +def launch(p, t): + M, N, K = p["M"], p["N"], p["K"] + _gemm_nn[(triton.cdiv(M, 16), triton.cdiv(N, 16))](t["A"], t["B"], t["C"], M, N, K, BM=16, BN=16, BK=16) diff --git a/workloads/gemm_nn/workload.json b/workloads/gemm_nn/workload.json new file mode 100644 index 0000000..81930b1 --- /dev/null +++ b/workloads/gemm_nn/workload.json @@ -0,0 +1,28 @@ +{ + "name": "gemm_nn", + "family": "compute-bound", + "summary": "C = A B with A M x K, B K x N, C M x N, all f32 row-major", + "provenance": "authored for OpenAccel Lab (Apache-2.0); BLAS SGEMM NN semantics with alpha=1, beta=0", + "params": {"M": 48, "N": 40, "K": 72}, + "cases": [{}, {"M": 17, "N": 13, "K": 19}], + "shrink": {"M": {"min": 1}, "N": {"min": 1}, "K": {"min": 1}}, + "inputs": [ + {"name": "A", "dtype": "f32", "shape": ["M", "K"], "gen": {"kind": "uniform", "lo": -1.0, "hi": 1.0}}, + {"name": "B", "dtype": "f32", "shape": ["K", "N"], "gen": {"kind": "normal4", "std": 1.0}} + ], + "outputs": [{"name": "C", "dtype": "f32", "shape": ["M", "N"]}], + "tolerance": { + "C": {"kind": "bound", "rtol": "gamma(K)", "atol": 0, + "why": "each C[i][j] is a length-K dot product; in any summation order, fused or not, |err| <= gamma(K)*sum_k |A[i][k] B[k][j]| (Higham Thm 3.1/3.5); reference.py passes that sum as scale. WolframLanguageEvaluator: g[n_]:=n 2^-24/(1-n 2^-24); N[g[72],6] -> 4.29155*10^-6, N[g[19],6] -> 1.13249*10^-6"} + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": {"src": "kernel.cl", "launches": [ + {"kernel": "gemm_nn", "global": ["(N + 15) // 16 * 16", "(M + 15) // 16 * 16"], "local": [16, 16], + "args": ["A", "B", "C", "M", "N", "K"]} + ]}, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/gemm_nt/kernel.cl b/workloads/gemm_nt/kernel.cl new file mode 100644 index 0000000..87931da --- /dev/null +++ b/workloads/gemm_nt/kernel.cl @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: Apache-2.0 +// C = A B^T. 16x16 tiles of A and of B^T staged in __local memory; out-of-range tile elements load as +// 0.0f, which adds exact zeros to the accumulator. global is the tile-rounded (N, M) grid, local (16, 16). +#define TS 16 +__kernel void gemm_nt(__global const float *A, __global const float *B, __global float *C, + const int M, const int N, const int K) +{ + __local float As[TS][TS]; + __local float Bs[TS][TS]; // Bs[k][n] = B[n][k] + int tx = get_local_id(0), ty = get_local_id(1); + int row = get_group_id(1) * TS + ty, col = get_group_id(0) * TS + tx; + int bn = get_group_id(0) * TS + ty; // B row this thread stages + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? A[row * K + k0 + tx] : 0.0f; + Bs[tx][ty] = (bn < N && k0 + tx < K) ? B[bn * K + k0 + tx] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (row < M && col < N) + C[row * N + col] = acc; +} diff --git a/workloads/gemm_nt/kernel.cu b/workloads/gemm_nt/kernel.cu new file mode 100644 index 0000000..5c7ba2b --- /dev/null +++ b/workloads/gemm_nt/kernel.cu @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define TS 16 + +// C = A B^T. 16x16 tiles of A and of B^T staged in static shared memory; out-of-range tile elements +// load as 0.0f, which adds exact zeros to the accumulator. +__global__ void gemm_nt(const float *A, const float *B, float *C, int M, int N, int K) +{ + __shared__ float As[TS][TS]; + __shared__ float Bs[TS][TS]; // Bs[k][n] = B[n][k] + int tx = threadIdx.x, ty = threadIdx.y; + int row = blockIdx.y * TS + ty, col = blockIdx.x * TS + tx; + int bn = blockIdx.x * TS + ty; // B row this thread stages + float acc = 0.0f; + for (int k0 = 0; k0 < K; k0 += TS) { + As[ty][tx] = (row < M && k0 + tx < K) ? A[(long long)row * K + k0 + tx] : 0.0f; + Bs[tx][ty] = (bn < N && k0 + tx < K) ? B[(long long)bn * K + k0 + tx] : 0.0f; + __syncthreads(); + for (int k = 0; k < TS; ++k) + acc += As[ty][k] * Bs[k][tx]; + __syncthreads(); + } + if (row < M && col < N) + C[(long long)row * N + col] = acc; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int M = (int)p[0], N = (int)p[1], K = (int)p[2]; + dim3 grid((unsigned)((N + TS - 1) / TS), (unsigned)((M + TS - 1) / TS)); + dim3 block(TS, TS); + gemm_nt<<>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], M, N, K); +} diff --git a/workloads/gemm_nt/omega.om b/workloads/gemm_nt/omega.om new file mode 100644 index 0000000..7bcb841 --- /dev/null +++ b/workloads/gemm_nt/omega.om @@ -0,0 +1,43 @@ +note gemm_nt: fo[i*N + j] = sum_p fa[i*K + p] * fb[j*K + p], f32 accumulation in p order +note one function per output element keeps each function within omc's 16 registers (error 12) +global dm ulong 3 +fn gnt_el i ulong j ulong to f32 +k = get dm 2 +ar = mul i k +br = mul j k +s = 0.0f32 +for p ulong k +x = get fa add ar p +y = get fb add br p +s = add s mul x y +end +ret s +end +fn kern to void +n = get dm 1 +for i ulong get dm 0 +for j ulong n +put fo add mul i n j gnt_el i j +end +end +end +fn main to int +oal_begin +put dm 0 ulong oal_p 0 +put dm 1 ulong oal_p 1 +put dm 2 ulong oal_p 2 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get dm 0 get dm 1 +oal_end +ret 0 +end diff --git a/workloads/gemm_nt/reference.py b/workloads/gemm_nt/reference.py new file mode 100644 index 0000000..274f8c5 --- /dev/null +++ b/workloads/gemm_nt/reference.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + M, N, K = p["M"], p["N"], p["K"] + a = x["A"].astype(np.float64).reshape(M, K) + b = x["B"].astype(np.float64).reshape(N, K) + return {"C": (a @ b.T, np.abs(a) @ np.abs(b).T)} diff --git a/workloads/gemm_nt/triton_kernel.py b/workloads/gemm_nt/triton_kernel.py new file mode 100644 index 0000000..0939eec --- /dev/null +++ b/workloads/gemm_nt/triton_kernel.py @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 +# tl.dot with input_precision="ieee": full f32 products and f32 accumulation (the interpreter runs +# np.matmul in float32; on a GPU this forbids TF32), so the gamma(K) dot-product bound applies. +import triton +import triton.language as tl + + +@triton.jit +def _gemm_nt(A, B, C, M, N, K, BM: tl.constexpr, BN: tl.constexpr, BK: tl.constexpr): + rm = tl.program_id(0) * BM + tl.arange(0, BM) + rn = tl.program_id(1) * BN + tl.arange(0, BN) + rk = tl.arange(0, BK) + acc = tl.zeros((BM, BN), dtype=tl.float32) + for k0 in range(0, K, BK): + kk = k0 + rk + a = tl.load(A + rm[:, None] * K + kk[None, :], mask=(rm[:, None] < M) & (kk[None, :] < K), other=0.0) + bt = tl.load(B + rn[None, :] * K + kk[:, None], mask=(kk[:, None] < K) & (rn[None, :] < N), other=0.0) + acc = tl.dot(a, bt, acc, input_precision="ieee") + tl.store(C + rm[:, None] * N + rn[None, :], acc, mask=(rm[:, None] < M) & (rn[None, :] < N)) + + +def launch(p, t): + M, N, K = p["M"], p["N"], p["K"] + _gemm_nt[(triton.cdiv(M, 16), triton.cdiv(N, 16))](t["A"], t["B"], t["C"], M, N, K, BM=16, BN=16, BK=16) diff --git a/workloads/gemm_nt/workload.json b/workloads/gemm_nt/workload.json new file mode 100644 index 0000000..589df20 --- /dev/null +++ b/workloads/gemm_nt/workload.json @@ -0,0 +1,28 @@ +{ + "name": "gemm_nt", + "family": "compute-bound", + "summary": "C = A B^T with A M x K, B N x K, C M x N, all f32 row-major", + "provenance": "authored for OpenAccel Lab (Apache-2.0); BLAS SGEMM NT semantics with alpha=1, beta=0", + "params": {"M": 48, "N": 40, "K": 72}, + "cases": [{}, {"M": 17, "N": 13, "K": 19}], + "shrink": {"M": {"min": 1}, "N": {"min": 1}, "K": {"min": 1}}, + "inputs": [ + {"name": "A", "dtype": "f32", "shape": ["M", "K"], "gen": {"kind": "uniform", "lo": -1.0, "hi": 1.0}}, + {"name": "B", "dtype": "f32", "shape": ["N", "K"], "gen": {"kind": "normal4", "std": 1.0}} + ], + "outputs": [{"name": "C", "dtype": "f32", "shape": ["M", "N"]}], + "tolerance": { + "C": {"kind": "bound", "rtol": "gamma(K)", "atol": 0, + "why": "each C[i][j] is a length-K dot product of row i of A and row j of B; in any summation order, fused or not, |err| <= gamma(K)*sum_k |A[i][k] B[j][k]| (Higham Thm 3.1/3.5); reference.py passes that sum as scale. WolframLanguageEvaluator: g[n_]:=n 2^-24/(1-n 2^-24); N[g[72],6] -> 4.29155*10^-6, N[g[19],6] -> 1.13249*10^-6"} + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": {"src": "kernel.cl", "launches": [ + {"kernel": "gemm_nt", "global": ["(N + 15) // 16 * 16", "(M + 15) // 16 * 16"], "local": [16, 16], + "args": ["A", "B", "C", "M", "N", "K"]} + ]}, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/gemv/kernel.cl b/workloads/gemv/kernel.cl new file mode 100644 index 0000000..6c19d9f --- /dev/null +++ b/workloads/gemv/kernel.cl @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: Apache-2.0 +// One work-item per row; x is staged through __local memory in chunks of 64 shared by the work-group. +// global is M rounded up to 64, local 64; every work-item reaches every barrier. +#define TS 64 +__kernel void gemv(__global const float *A, __global const float *x, __global float *y, const int M, const int N) +{ + __local float xs[TS]; + int i = get_global_id(0), lid = get_local_id(0); + float acc = 0.0f; + for (int j0 = 0; j0 < N; j0 += TS) { + xs[lid] = (j0 + lid < N) ? x[j0 + lid] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + if (i < M) { + int jn = min(TS, N - j0); + for (int j = 0; j < jn; ++j) + acc += A[i * N + j0 + j] * xs[j]; + } + barrier(CLK_LOCAL_MEM_FENCE); + } + if (i < M) + y[i] = acc; +} diff --git a/workloads/gemv/kernel.cu b/workloads/gemv/kernel.cu new file mode 100644 index 0000000..616475f --- /dev/null +++ b/workloads/gemv/kernel.cu @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define TS 64 + +// One thread per row; x is staged through static shared memory in chunks of 64 shared by the block. +// Every thread reaches every __syncthreads(). +__global__ void gemv(const float *A, const float *x, float *y, int M, int N) +{ + __shared__ float xs[TS]; + int i = blockIdx.x * TS + threadIdx.x, lid = threadIdx.x; + float acc = 0.0f; + for (int j0 = 0; j0 < N; j0 += TS) { + xs[lid] = (j0 + lid < N) ? x[j0 + lid] : 0.0f; + __syncthreads(); + if (i < M) { + int jn = N - j0 < TS ? N - j0 : TS; + for (int j = 0; j < jn; ++j) + acc += A[(long long)i * N + j0 + j] * xs[j]; + } + __syncthreads(); + } + if (i < M) + y[i] = acc; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int M = (int)p[0], N = (int)p[1]; + gemv<<<(unsigned)((M + TS - 1) / TS), TS>>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], M, N); +} diff --git a/workloads/gemv/omega.om b/workloads/gemv/omega.om new file mode 100644 index 0000000..0b73037 --- /dev/null +++ b/workloads/gemv/omega.om @@ -0,0 +1,38 @@ +note gemv: fo[i] = sum_j fa[i*N + j] * fb[j], f32 accumulation in j order +note one function per output row keeps each function within omc's 16 registers (error 12) +global dm ulong 2 +fn gmv_row i ulong to f32 +n = get dm 1 +ar = mul i n +s = 0.0f32 +for j ulong n +x = get fa add ar j +y = get fb j +s = add s mul x y +end +ret s +end +fn kern to void +for i ulong get dm 0 +put fo i gmv_row i +end +end +fn main to int +oal_begin +put dm 0 ulong oal_p 0 +put dm 1 ulong oal_p 1 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 get dm 0 +oal_end +ret 0 +end diff --git a/workloads/gemv/reference.py b/workloads/gemv/reference.py new file mode 100644 index 0000000..1d7053a --- /dev/null +++ b/workloads/gemv/reference.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + M, N = p["M"], p["N"] + a = x["A"].astype(np.float64).reshape(M, N) + v = x["x"].astype(np.float64) + return {"y": (a @ v, np.abs(a) @ np.abs(v))} diff --git a/workloads/gemv/triton_kernel.py b/workloads/gemv/triton_kernel.py new file mode 100644 index 0000000..6470e50 --- /dev/null +++ b/workloads/gemv/triton_kernel.py @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 +# Blocked loop: each program owns BM rows, accumulates elementwise products over BN-wide column blocks +# in f32 and reduces each row with tl.sum (a summation tree, covered by the any-order gamma(N) bound). +import triton +import triton.language as tl + + +@triton.jit +def _gemv(A, x, y, M, N, BM: tl.constexpr, BN: tl.constexpr): + rm = tl.program_id(0) * BM + tl.arange(0, BM) + rn = tl.arange(0, BN) + acc = tl.zeros((BM,), dtype=tl.float32) + for j0 in range(0, N, BN): + jj = j0 + rn + a = tl.load(A + rm[:, None] * N + jj[None, :], mask=(rm[:, None] < M) & (jj[None, :] < N), other=0.0) + v = tl.load(x + jj, mask=jj < N, other=0.0) + acc += tl.sum(a * v[None, :], axis=1) + tl.store(y + rm, acc, mask=rm < M) + + +def launch(p, t): + M, N = p["M"], p["N"] + _gemv[(triton.cdiv(M, 32),)](t["A"], t["x"], t["y"], M, N, BM=32, BN=64) diff --git a/workloads/gemv/workload.json b/workloads/gemv/workload.json new file mode 100644 index 0000000..5ce411c --- /dev/null +++ b/workloads/gemv/workload.json @@ -0,0 +1,27 @@ +{ + "name": "gemv", + "family": "memory-bound", + "summary": "y = A x with A M x N row-major, x N, y M, all f32", + "provenance": "authored for OpenAccel Lab (Apache-2.0); BLAS SGEMV (no transpose) with alpha=1, beta=0", + "params": {"M": 200, "N": 300}, + "cases": [{}, {"M": 33, "N": 17}, {"M": 1, "N": 1}], + "shrink": {"M": {"min": 1}, "N": {"min": 1}}, + "inputs": [ + {"name": "A", "dtype": "f32", "shape": ["M", "N"], "gen": {"kind": "uniform", "lo": -1.0, "hi": 1.0}}, + {"name": "x", "dtype": "f32", "shape": ["N"], "gen": {"kind": "normal4", "std": 1.0}} + ], + "outputs": [{"name": "y", "dtype": "f32", "shape": ["M"]}], + "tolerance": { + "y": {"kind": "bound", "rtol": "gamma(N)", "atol": 0, + "why": "each y[i] is a length-N dot product; in any summation order, fused or not, |err| <= gamma(N)*sum_j |A[i][j] x[j]| (Higham Thm 3.1/3.5); reference.py passes that sum as scale. WolframLanguageEvaluator: g[n_]:=n 2^-24/(1-n 2^-24); N[g[300],6] -> 1.78817*10^-5, N[g[17],6] -> 1.01328*10^-6, N[g[1],6] -> 5.96046*10^-8"} + }, + "timing": {"warmup": 2, "repeats": 10}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": {"src": "kernel.cl", "launches": [ + {"kernel": "gemv", "global": ["(M + 63) // 64 * 64"], "local": [64], "args": ["A", "x", "y", "M", "N"]} + ]}, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/layernorm/kernel.cl b/workloads/layernorm/kernel.cl new file mode 100644 index 0000000..858f6ab --- /dev/null +++ b/workloads/layernorm/kernel.cl @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: Apache-2.0 +// one work-group per row; get_local_size(0) must be a power of two +__kernel void layernorm(__global const float *x, __global const float *g, __global const float *b, + __global float *y, const int D, __local float *red) +{ + int t = get_local_id(0), nt = get_local_size(0); + __global const float *xr = x + (long)get_group_id(0) * D; + __global float *yr = y + (long)get_group_id(0) * D; + float acc = 0.0f; + for (int k = t; k < D; k += nt) + acc += xr[k]; + red[t] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int h = nt / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + barrier(CLK_LOCAL_MEM_FENCE); + } + float mu = red[0] / (float)D; + barrier(CLK_LOCAL_MEM_FENCE); + acc = 0.0f; + for (int k = t; k < D; k += nt) { + float c = xr[k] - mu; + acc += c * c; + } + red[t] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int h = nt / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + barrier(CLK_LOCAL_MEM_FENCE); + } + float rs = rsqrt(red[0] / (float)D + 1e-5f); + for (int k = t; k < D; k += nt) + yr[k] = (xr[k] - mu) * rs * g[k] + b[k]; +} diff --git a/workloads/layernorm/kernel.cu b/workloads/layernorm/kernel.cu new file mode 100644 index 0000000..8d6eb2e --- /dev/null +++ b/workloads/layernorm/kernel.cu @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define NT 128 + +// one block of NT threads per row +__global__ void layernorm(const float *x, const float *g, const float *b, float *y, long long D) +{ + __shared__ float red[NT]; + int t = threadIdx.x; + const float *xr = x + (long long)blockIdx.x * D; + float *yr = y + (long long)blockIdx.x * D; + float acc = 0.0f; + for (long long k = t; k < D; k += NT) + acc += xr[k]; + red[t] = acc; + __syncthreads(); + for (int h = NT / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + __syncthreads(); + } + float mu = red[0] / (float)D; + __syncthreads(); + acc = 0.0f; + for (long long k = t; k < D; k += NT) { + float c = xr[k] - mu; + acc += c * c; + } + red[t] = acc; + __syncthreads(); + for (int h = NT / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + __syncthreads(); + } + float rs = 1.0f / sqrtf(red[0] / (float)D + 1e-5f); + for (long long k = t; k < D; k += NT) + yr[k] = (xr[k] - mu) * rs * g[k] + b[k]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + layernorm<<<(unsigned)p[0], NT>>>((const float *)buf[0], (const float *)buf[1], (const float *)buf[2], + (float *)buf[3], p[1]); +} diff --git a/workloads/layernorm/omega.om b/workloads/layernorm/omega.om new file mode 100644 index 0000000..a8df4e0 --- /dev/null +++ b/workloads/layernorm/omega.om @@ -0,0 +1,55 @@ +note layernorm over rows of x[R][D] in f32: biased variance, eps = 1e-5, y = (x-mu) rsqrt(var+eps) gamma + beta +global kr ulong 1 +global kd ulong 1 +global kmu f32 1 +fn lnstat o ulong d ulong inv f32 to f32 +note returns rsqrt(var + eps) of the row at o; the row mean goes to kmu +s = 0.0f32 +for k ulong d +s = add s get fa add o k +end +mu = mul s inv +put kmu 0 mu +q = 0.0f32 +for k ulong d +c = sub get fa add o k mu +q = add q mul c c +end +ret div 1.0f32 fsqrt add mul q inv 0.00001f32 +end +fn lnout o ulong d ulong mu f32 rs f32 to void +for k ulong d +c = sub get fa add o k mu +p = mul mul c rs get fb k +put fo add o k add p get fc k +end +end +fn kern to void +d = get kd 0 +inv = div 1.0f32 f32 d +for i ulong get kr 0 +o = mul i d +rs = lnstat o d inv +lnout o d get kmu 0 rs +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kd 0 ulong oal_p 1 +a = oal_fa 0 +b = oal_fb 1 +c = oal_fc 2 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 a +oal_end +ret 0 +end diff --git a/workloads/layernorm/reference.py b/workloads/layernorm/reference.py new file mode 100644 index 0000000..f41ddab --- /dev/null +++ b/workloads/layernorm/reference.py @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + +U = 2.0 ** -24 +EPS = float(np.float32(1e-5)) # every entrant writes eps as the f32 constant 1e-5 + + +def _g(n): + return n * U / (1.0 - n * U) + + +def reference(p, x): + D = p["D"] + v = x["x"].astype(np.float64) + g = x["gamma"].astype(np.float64)[None, :] + b = x["beta"].astype(np.float64)[None, :] + mu = v.mean(axis=1, keepdims=True) + c = v - mu + var = (c * c).mean(axis=1, keepdims=True) + vv = var + EPS + s = 1.0 / np.sqrt(vv) + y = c * s * g + b + # error bound; derivation in workload.json tolerance.why + em = _g(D + 1) * np.abs(v).sum(axis=1, keepdims=True) / D + dc = em + U * (np.abs(c) + em) + rho = (1.0 + em * em / vv) * (1.0 + _g(D + 5)) - 1.0 + phi = (1.0 + rho) * (1.0 + 4.0 * U) - 1.0 + ag = np.abs(g) + bound = ag * s * (dc * (1.0 + phi) + np.abs(c) * phi) + bound = bound + _g(3) * (ag * s * (np.abs(c) + dc) * (1.0 + phi) + np.abs(b)) + return {"y": (y, bound)} diff --git a/workloads/layernorm/triton_kernel.py b/workloads/layernorm/triton_kernel.py new file mode 100644 index 0000000..37e4c6e --- /dev/null +++ b/workloads/layernorm/triton_kernel.py @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _layernorm(x, g, b, y, D, BLOCK: tl.constexpr): + r = tl.program_id(0) + k = tl.arange(0, BLOCK) + m = k < D + v = tl.load(x + r * D + k, mask=m, other=0.0) + mu = tl.sum(v, axis=0) / D + c = tl.where(m, v - mu, 0.0) + var = tl.sum(c * c, axis=0) / D + rs = 1.0 / tl.sqrt(var + 1e-5) + out = c * rs * tl.load(g + k, mask=m, other=0.0) + tl.load(b + k, mask=m, other=0.0) + tl.store(y + r * D + k, out, mask=m) + + +def launch(p, t): + _layernorm[(p["R"],)](t["x"], t["gamma"], t["beta"], t["y"], p["D"], BLOCK=triton.next_power_of_2(p["D"])) diff --git a/workloads/layernorm/workload.json b/workloads/layernorm/workload.json new file mode 100644 index 0000000..dfb0966 --- /dev/null +++ b/workloads/layernorm/workload.json @@ -0,0 +1,123 @@ +{ + "name": "layernorm", + "family": "row-normalization", + "summary": "per row r of x[R][D]: mu = mean(x), var = mean((x-mu)^2) (biased), y = (x-mu) / sqrt(var + eps) * gamma + beta, eps = 1e-5 written as an f32 constant", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "R": 24, + "D": 200 + }, + "cases": [ + {}, + { + "R": 1, + "D": 1 + }, + { + "R": 5, + "D": 777 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "D": { + "min": 1 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "R", + "D" + ], + "gen": { + "kind": "normal4", + "mean": 2.0, + "std": 1.5 + } + }, + { + "name": "gamma", + "dtype": "f32", + "shape": [ + "D" + ], + "gen": { + "kind": "uniform", + "lo": 0.5, + "hi": 1.5 + } + }, + { + "name": "beta", + "dtype": "f32", + "shape": [ + "D" + ], + "gen": { + "kind": "uniform", + "lo": -1.0, + "hi": 1.0 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "R", + "D" + ] + } + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": 1.0, + "atol": 0.0, + "why": "reference.py returns an absolute per-element bound B as the scale (rtol 1), evaluated in float64 from the exact inputs, with eps = f32(1e-5), A = sum|x|/D, c = x - mu, v = var + eps, s = v^-1/2, g(n) = gamma(n). (1) mean: a sum in any order plus a divide, or a multiply by f32(1/D), gives |mu^ - mu| <= Em = g(D+1) A. (2) c^ = fl(x - mu^) = (c + e)(1+d), |e| <= Em, so |c^ - c| <= Dc = Em + u(|c| + Em). (3) Sum c^2 in any order, FMA or not, within g(D) (Higham Thm 3.1/3.5); the squares' (1+d)^2 cost g(2); the 1/D step g(2); the + eps one rounding with both terms positive; and since sum(c)=0 the shift e adds exactly D e^2, so v^ = v (1 + e^2/v)(1 + theta), |theta| <= g(D+5): rho = (1 + Em^2/v)(1 + g(D+5)) - 1. (4) |(1+rho)^(-1/2) - 1| <= (2 sqrt2 - 2)|rho| <= |rho| for rho >= -1/2 (WolframLanguageEvaluator: MaxValue[{Abs[(1+r)^(-1/2)-1]/Abs[r], -1/2<=r<=10, r!=0}, r] -> 0.8284271247 = 2(Sqrt[2]-1)); rsqrt is budgeted 2 ulp (OpenCL C 3.0 s7.4 rsqrt <= 2 ulp; CUDA rsqrtf 2 ulp) = 4u relative (WolframLanguageEvaluator: 2*2^-23/2^-24 -> 4), which also covers 1/sqrt (correctly rounded sqrt then divide, WolframLanguageEvaluator: ((1+u)/(1-u)-1)/u -> 2.0000001); so r^ = s(1+phi), phi = (1+rho)(1+4u) - 1. (5) P = c^ r^ gamma: |P - c s gamma| <= |gamma| s (Dc (1+phi) + |c| phi). (6) the two products and the + beta, any order or fused, add at most g(3)(|P| + |beta|) with |P| <= |gamma| s (|c| + Dc)(1+phi). B = (5) + (6). For D=200 the dominant term is about g(205) relative (WolframLanguageEvaluator: 209u/(1-209u) -> 1.2458e-5 for the g(D+9)-sized total), so a dropped term (1/D = 5e-3), unbiased variance (1/(2D)) or a missing beta fails." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "layernorm", + "global": [ + "R*64" + ], + "local": [ + "64" + ], + "args": [ + "x", + "gamma", + "beta", + "y", + "D", + "local:f32:64" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/quant_int8/kernel.cl b/workloads/quant_int8/kernel.cl new file mode 100644 index 0000000..17af58d --- /dev/null +++ b/workloads/quant_int8/kernel.cl @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 +// One work-item per row: absmax, scale = absmax / 127, q = clamp(rint(x / scale), -127, 127). +__kernel void quant_int8(__global const float *x, __global char *q, __global float *s, + const int R, const int C) +{ + int r = get_global_id(0); + if (r >= R) + return; + float amax = 0.0f; + for (int c = 0; c < C; c++) + amax = fmax(amax, fabs(x[r * C + c])); + float sc = amax / 127.0f; + s[r] = sc; + for (int c = 0; c < C; c++) { + float y = sc > 0.0f ? x[r * C + c] / sc : 0.0f; + float v = fmin(fmax(rint(y), -127.0f), 127.0f); + q[r * C + c] = (char)(int)v; + } +} diff --git a/workloads/quant_int8/kernel.cu b/workloads/quant_int8/kernel.cu new file mode 100644 index 0000000..95a158b --- /dev/null +++ b/workloads/quant_int8/kernel.cu @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +// One thread per row: absmax, scale = absmax / 127, q = clamp(rint(x / scale), -127, 127). +__global__ void quant_int8(const float *x, signed char *q, float *s, int R, int C) +{ + int r = blockIdx.x * blockDim.x + threadIdx.x; + if (r >= R) + return; + float amax = 0.0f; + for (int c = 0; c < C; c++) + amax = fmaxf(amax, fabsf(x[r * C + c])); + float sc = amax / 127.0f; + s[r] = sc; + for (int c = 0; c < C; c++) { + float y = sc > 0.0f ? x[r * C + c] / sc : 0.0f; + float v = fminf(fmaxf(rintf(y), -127.0f), 127.0f); + q[r * C + c] = (signed char)(int)v; + } +} + +void oal_launch(const long long *p, void *const *buf) +{ + int R = (int)p[0]; + int C = (int)p[1]; + quant_int8<<<(R + 63) / 64, 64>>>((const float *)buf[0], (signed char *)buf[1], (float *)buf[2], R, C); +} diff --git a/workloads/quant_int8/omega.om b/workloads/quant_int8/omega.om new file mode 100644 index 0000000..8622c31 --- /dev/null +++ b/workloads/quant_int8/omega.om @@ -0,0 +1,68 @@ +note quant_int8: per row s = absmax / 127 (one f32 divide), q = clamp(round_half_even(x / s), -127, 127) +global kr ulong 1 +global kc ulong 1 +fn rnde y f64 to long +a = fabs y +f = long a +fr = sub a f64 f +if gt fr 0.5f64 +f = add f 1 +end +if eq fr 0.5f64 +if eq rem f 2 1 +f = add f 1 +end +end +if lt y 0.0f64 +f = neg f +end +ret f +end +fn qrow r ulong c ulong to void +b = mul r c +amax = 0.0f32 +for j ulong c +amax = fmax amax fabs get fa add b j +end +sc = div amax 127.0f32 +put fo r sc +for j ulong c +v = long 0 +if gt sc 0.0f32 +v = rnde f64 div get fa add b j sc +end +if gt v 127 +v = 127 +end +if lt v -127 +v = -127 +end +put qo add b j byte v +end +end +fn kern to void +r = get kr 0 +c = get kc 0 +for i ulong r +qrow i c +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kc 0 ulong oal_p 1 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_sqo 0 mul get kr 0 get kc 0 +oal_so 1 get kr 0 +oal_end +ret 0 +end diff --git a/workloads/quant_int8/reference.py b/workloads/quant_int8/reference.py new file mode 100644 index 0000000..49ef9d3 --- /dev/null +++ b/workloads/quant_int8/reference.py @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + r, c = p["R"], p["C"] + v = x["x"].astype(np.float64).reshape(r, c) + amax = np.abs(v).max(axis=1) + s = amax / 127.0 + y = np.zeros_like(v) + nz = amax > 0 + y[nz] = 127.0 * v[nz] / amax[nz, None] + q = np.clip(np.rint(y), -127.0, 127.0) # rint: round half to even + return {"q": q, "s": s} diff --git a/workloads/quant_int8/triton_kernel.py b/workloads/quant_int8/triton_kernel.py new file mode 100644 index 0000000..6e9ef5d --- /dev/null +++ b/workloads/quant_int8/triton_kernel.py @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _quant_int8(x, q, s, C, BC: tl.constexpr): + r = tl.program_id(0) + c = tl.arange(0, BC) + live = c < C + xv = tl.load(x + r * C + c, mask=live, other=0.0) + sc = tl.max(tl.abs(xv), axis=0) / 127.0 + tl.store(s + r, sc) + y = tl.where(sc > 0.0, xv / tl.where(sc > 0.0, sc, 1.0), 0.0) + # round half to even on |y|: |y| - floor(|y|) is exact for |y| < 2^23 + a = tl.abs(y) + f = tl.floor(a) + frac = a - f + fi = f.to(tl.int32) + up = (frac > 0.5) | ((frac == 0.5) & ((fi & 1) == 1)) + qi = tl.where(up, fi + 1, fi) + qi = tl.where(y < 0.0, -qi, qi) + qi = tl.minimum(tl.maximum(qi, -127), 127) + tl.store(q + r * C + c, qi.to(tl.int8), mask=live) + + +def launch(p, t): + _quant_int8[(p["R"],)](t["x"], t["q"], t["s"], p["C"], BC=triton.next_power_of_2(p["C"])) diff --git a/workloads/quant_int8/workload.json b/workloads/quant_int8/workload.json new file mode 100644 index 0000000..7fe0c20 --- /dev/null +++ b/workloads/quant_int8/workload.json @@ -0,0 +1,108 @@ +{ + "name": "quant_int8", + "family": "quantization", + "summary": "per-row symmetric int8 quantization of an R x C f32 matrix: s[r] = max_c |x[r][c]| / 127 (f32), q[r][c] = clamp(round_half_even(x[r][c] / s[r]), -127, 127) (i8); a zero row gives s = 0 and q = 0", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the per-row absmax scheme of LLM.int8()-style weight quantization", + "params": { + "R": 32, + "C": 256 + }, + "cases": [ + {}, + { + "R": 1, + "C": 1 + }, + { + "R": 5, + "C": 77 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "C": { + "min": 1 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "R", + "C" + ], + "gen": { + "kind": "normal4", + "mean": 0.0, + "std": 1.5 + } + } + ], + "outputs": [ + { + "name": "q", + "dtype": "i8", + "shape": [ + "R", + "C" + ] + }, + { + "name": "s", + "dtype": "f32", + "shape": [ + "R" + ] + } + ], + "tolerance": { + "q": { + "kind": "int", + "atol": 1, + "why": "the reference is round_half_even(127 x / amax) on the exact values (numpy rint in float64). An entrant divides by its own f32 scale s' = (amax/127)(1+e1) and rounds y' = (x/s')(1+e2), |e1|, |e2| <= 5u (2.5 ulp, the OpenCL C single-precision divide limit without -cl-fp32-correctly-rounded-divide-sqrt; 1 ulp <= 2u relative), so |y' - y| <= |y|((1+5u)/(1-5u)^2 - 1) with |y| <= 127: WolframLanguageEvaluator: u=2^-24; N[127*((1+5u)/(1-5u)^2-1),10] -> 0.0001135469047. That is < 1/2, so the two roundings differ by at most 1 (only when y is within 1.2e-4 of a half-integer). A wrong scale (no abs, wrong divisor) or a sign error moves q by far more than 1." + }, + "s": { + "kind": "bound", + "rtol": "5*u", + "atol": 0, + "why": "amax is exact (abs and max do not round); s = amax/127 is one division, correctly rounded on IEEE hosts and within 2.5 ulp under OpenCL C (s7.4) and Triton's GPU fdiv. 1 ulp <= 2u relative, so 2.5 ulp <= 5u: WolframLanguageEvaluator: u=2^-24; N[(5/2)*2^-23/u] -> 5.; N[5u,10] -> 2.980232239*10^-7." + } + }, + "timing": { + "warmup": 2, + "repeats": 10 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "quant_int8", + "global": [ + "R" + ], + "local": null, + "args": [ + "x", + "q", + "s", + "R", + "C" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/reduce_max/kernel.cl b/workloads/reduce_max/kernel.cl new file mode 100644 index 0000000..7d6288d --- /dev/null +++ b/workloads/reduce_max/kernel.cl @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: Apache-2.0 +// Pass 1: each work-group of 256 takes the max of its slice in a local-memory tree. +// Pass 2: one work-group takes the max of the nb partials into y[0]. Padding is -INFINITY. +__kernel void rmax_part(__global const float *x, __global float *part, const int n, __local float *s) +{ + int l = get_local_id(0); + int i = get_global_id(0); + s[l] = i < n ? x[i] : -INFINITY; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] = fmax(s[l], s[l + k]); + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + part[get_group_id(0)] = s[0]; +} + +__kernel void rmax_fin(__global const float *part, __global float *y, const int nb, __local float *s) +{ + int l = get_local_id(0); + float a = -INFINITY; + for (int j = l; j < nb; j += get_local_size(0)) + a = fmax(a, part[j]); + s[l] = a; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] = fmax(s[l], s[l + k]); + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + y[0] = s[0]; +} diff --git a/workloads/reduce_max/kernel.cu b/workloads/reduce_max/kernel.cu new file mode 100644 index 0000000..f738f7a --- /dev/null +++ b/workloads/reduce_max/kernel.cu @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: Apache-2.0 +// Pass 1: each block of 256 takes the max of its slice in a shared-memory tree. +// Pass 2: one block takes the max of the nb partials into y[0]. Padding is -INFINITY. +#include +#include + +#define OAL_B 256 + +__global__ void rmax_part(const float *x, float *part, long long n) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + long long i = (long long)blockIdx.x * OAL_B + l; + s[l] = i < n ? x[i] : -INFINITY; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] = fmaxf(s[l], s[l + k]); + __syncthreads(); + } + if (l == 0) + part[blockIdx.x] = s[0]; +} + +__global__ void rmax_fin(const float *part, float *y, long long nb) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + float a = -INFINITY; + for (long long j = l; j < nb; j += OAL_B) + a = fmaxf(a, part[j]); + s[l] = a; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] = fmaxf(s[l], s[l + k]); + __syncthreads(); + } + if (l == 0) + y[0] = s[0]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0], nb = p[1]; + rmax_part<<<(unsigned)nb, OAL_B>>>((const float *)buf[0], (float *)buf[2], n); + rmax_fin<<<1, OAL_B>>>((const float *)buf[2], (float *)buf[1], nb); +} diff --git a/workloads/reduce_max/omega.om b/workloads/reduce_max/omega.om new file mode 100644 index 0000000..8fb11ee --- /dev/null +++ b/workloads/reduce_max/omega.om @@ -0,0 +1,25 @@ +global kn ulong 1 +fn kern to void +m = get fa 0 +for i ulong get kn 0 +m = fmax m get fa i +end +put fo 0 m +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 1 +oal_end +ret 0 +end diff --git a/workloads/reduce_max/reference.py b/workloads/reduce_max/reference.py new file mode 100644 index 0000000..d7c7668 --- /dev/null +++ b/workloads/reduce_max/reference.py @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + return {"y": np.array([x["x"].astype(np.float64).max()])} diff --git a/workloads/reduce_max/triton_kernel.py b/workloads/reduce_max/triton_kernel.py new file mode 100644 index 0000000..7946329 --- /dev/null +++ b/workloads/reduce_max/triton_kernel.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _rmax(x, y, n, BLOCK: tl.constexpr): + # one program: BLOCK lane maxima over the strided input, then a tree max of the lanes + lane = tl.arange(0, BLOCK) + acc = tl.full([BLOCK], float("-inf"), dtype=tl.float32) + for off in range(0, n, BLOCK): + i = off + lane + acc = tl.maximum(acc, tl.load(x + i, mask=i < n, other=float("-inf"))) + tl.store(y, tl.max(acc, axis=0)) + + +def launch(p, t): + _rmax[(1,)](t["x"], t["y"], p["n"], BLOCK=4096) diff --git a/workloads/reduce_max/workload.json b/workloads/reduce_max/workload.json new file mode 100644 index 0000000..b22d744 --- /dev/null +++ b/workloads/reduce_max/workload.json @@ -0,0 +1,48 @@ +{ + "name": "reduce_max", + "family": "reduction", + "summary": "y[0] = max of n f32 elements; OpenCL/CUDA reduce in a 256-wide local tree per block, then one block reduces the block partials", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "n": 100003 + }, + "derived": { + "nb": "(n + 255) // 256" + }, + "cases": [ + {}, + {"n": 1}, + {"n": 257} + ], + "shrink": { + "n": {"min": 1} + }, + "inputs": [ + {"name": "x", "dtype": "f32", "shape": ["n"], "gen": {"kind": "normal4", "mean": -3.0, "std": 2.0}} + ], + "outputs": [ + {"name": "y", "dtype": "f32", "shape": [1]} + ], + "scratch": [ + {"name": "part", "dtype": "f32", "shape": ["nb"]} + ], + "tolerance": { + "y": { + "kind": "exact", + "why": "max does no rounding: the result is one of the inputs, whatever the order" + } + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": { + "src": "kernel.cl", + "launches": [ + {"kernel": "rmax_part", "global": ["nb * 256"], "local": [256], "args": ["x", "part", "n", "local:f32:256"]}, + {"kernel": "rmax_fin", "global": [256], "local": [256], "args": ["part", "y", "nb", "local:f32:256"]} + ] + }, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/reduce_sum/kernel.cl b/workloads/reduce_sum/kernel.cl new file mode 100644 index 0000000..de41b9a --- /dev/null +++ b/workloads/reduce_sum/kernel.cl @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: Apache-2.0 +// Pass 1: each work-group of 256 sums its slice in a local-memory tree and writes one partial. +// Pass 2: one work-group sums the nb partials (strided, then a tree) into y[0]. +__kernel void rsum_part(__global const float *x, __global float *part, const int n, __local float *s) +{ + int l = get_local_id(0); + int i = get_global_id(0); + s[l] = i < n ? x[i] : 0.0f; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + part[get_group_id(0)] = s[0]; +} + +__kernel void rsum_fin(__global const float *part, __global float *y, const int nb, __local float *s) +{ + int l = get_local_id(0); + float a = 0.0f; + for (int j = l; j < nb; j += get_local_size(0)) + a += part[j]; + s[l] = a; + barrier(CLK_LOCAL_MEM_FENCE); + for (int k = get_local_size(0) / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + barrier(CLK_LOCAL_MEM_FENCE); + } + if (l == 0) + y[0] = s[0]; +} diff --git a/workloads/reduce_sum/kernel.cu b/workloads/reduce_sum/kernel.cu new file mode 100644 index 0000000..c728be6 --- /dev/null +++ b/workloads/reduce_sum/kernel.cu @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: Apache-2.0 +// Pass 1: each block of 256 sums its slice in a shared-memory tree and writes one partial. +// Pass 2: one block sums the nb partials (strided, then a tree) into y[0]. +#include + +#define OAL_B 256 + +__global__ void rsum_part(const float *x, float *part, long long n) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + long long i = (long long)blockIdx.x * OAL_B + l; + s[l] = i < n ? x[i] : 0.0f; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + __syncthreads(); + } + if (l == 0) + part[blockIdx.x] = s[0]; +} + +__global__ void rsum_fin(const float *part, float *y, long long nb) +{ + __shared__ float s[OAL_B]; + int l = threadIdx.x; + float a = 0.0f; + for (long long j = l; j < nb; j += OAL_B) + a += part[j]; + s[l] = a; + __syncthreads(); + for (int k = OAL_B / 2; k > 0; k >>= 1) { + if (l < k) + s[l] += s[l + k]; + __syncthreads(); + } + if (l == 0) + y[0] = s[0]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0], nb = p[1]; + rsum_part<<<(unsigned)nb, OAL_B>>>((const float *)buf[0], (float *)buf[2], n); + rsum_fin<<<1, OAL_B>>>((const float *)buf[2], (float *)buf[1], nb); +} diff --git a/workloads/reduce_sum/omega.om b/workloads/reduce_sum/omega.om new file mode 100644 index 0000000..2fa9670 --- /dev/null +++ b/workloads/reduce_sum/omega.om @@ -0,0 +1,25 @@ +global kn ulong 1 +fn kern to void +s = 0.0f32 +for i ulong get kn 0 +s = add s get fa i +end +put fo 0 s +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 1 +oal_end +ret 0 +end diff --git a/workloads/reduce_sum/reference.py b/workloads/reduce_sum/reference.py new file mode 100644 index 0000000..ac3dff4 --- /dev/null +++ b/workloads/reduce_sum/reference.py @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + a = x["x"].astype(np.float64) + return {"y": (np.array([a.sum()]), np.array([np.abs(a).sum()]))} diff --git a/workloads/reduce_sum/triton_kernel.py b/workloads/reduce_sum/triton_kernel.py new file mode 100644 index 0000000..1ab8e52 --- /dev/null +++ b/workloads/reduce_sum/triton_kernel.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _rsum(x, y, n, BLOCK: tl.constexpr): + # one program: BLOCK lane accumulators over the strided input, then a tree sum of the lanes + lane = tl.arange(0, BLOCK) + acc = tl.zeros([BLOCK], dtype=tl.float32) + for off in range(0, n, BLOCK): + i = off + lane + acc += tl.load(x + i, mask=i < n, other=0.0) + tl.store(y, tl.sum(acc, axis=0)) + + +def launch(p, t): + _rsum[(1,)](t["x"], t["y"], p["n"], BLOCK=4096) diff --git a/workloads/reduce_sum/workload.json b/workloads/reduce_sum/workload.json new file mode 100644 index 0000000..0ca5ef7 --- /dev/null +++ b/workloads/reduce_sum/workload.json @@ -0,0 +1,50 @@ +{ + "name": "reduce_sum", + "family": "reduction", + "summary": "y[0] = sum of n f32 elements; OpenCL/CUDA reduce in a 256-wide local tree per block, then one block reduces the block partials", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "n": 100003 + }, + "derived": { + "nb": "(n + 255) // 256" + }, + "cases": [ + {}, + {"n": 1}, + {"n": 257} + ], + "shrink": { + "n": {"min": 1} + }, + "inputs": [ + {"name": "x", "dtype": "f32", "shape": ["n"], "gen": {"kind": "uniform", "lo": -1.0, "hi": 1.0}} + ], + "outputs": [ + {"name": "y", "dtype": "f32", "shape": [1]} + ], + "scratch": [ + {"name": "part", "dtype": "f32", "shape": ["nb"]} + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": "gamma(n)", + "atol": 0, + "why": "Recursive summation of n terms in any order (sequential, tree, blocked) is within gamma(n-1)*sum|x_i| of the exact sum (Higham ASNA 2nd ed. eq. 4.4); gamma(n) is used, scale sum|x_i| from reference.py. Padding adds exact zeros. At the default n: WolframLanguageEvaluator: u=2^-24; g[n_]:=n u/(1-n u); N[g[100003],10] -> 0.005996385607; N[g[257],10] -> 0.00001531862836. Control reduce_drop_last checks that one missing element fails." + } + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": { + "src": "kernel.cl", + "launches": [ + {"kernel": "rsum_part", "global": ["nb * 256"], "local": [256], "args": ["x", "part", "n", "local:f32:256"]}, + {"kernel": "rsum_fin", "global": [256], "local": [256], "args": ["part", "y", "nb", "local:f32:256"]} + ] + }, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/rmsnorm/kernel.cl b/workloads/rmsnorm/kernel.cl new file mode 100644 index 0000000..eda38c9 --- /dev/null +++ b/workloads/rmsnorm/kernel.cl @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: Apache-2.0 +// one work-group per row; get_local_size(0) must be a power of two +__kernel void rmsnorm(__global const float *x, __global const float *w, __global float *y, const int D, + __local float *red) +{ + int t = get_local_id(0), nt = get_local_size(0); + __global const float *xr = x + (long)get_group_id(0) * D; + __global float *yr = y + (long)get_group_id(0) * D; + float acc = 0.0f; + for (int k = t; k < D; k += nt) + acc += xr[k] * xr[k]; + red[t] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int h = nt / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + barrier(CLK_LOCAL_MEM_FENCE); + } + float rs = rsqrt(red[0] / (float)D + 1e-6f); + for (int k = t; k < D; k += nt) + yr[k] = xr[k] * rs * w[k]; +} diff --git a/workloads/rmsnorm/kernel.cu b/workloads/rmsnorm/kernel.cu new file mode 100644 index 0000000..7c1be90 --- /dev/null +++ b/workloads/rmsnorm/kernel.cu @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define NT 128 + +// one block of NT threads per row +__global__ void rmsnorm(const float *x, const float *w, float *y, long long D) +{ + __shared__ float red[NT]; + int t = threadIdx.x; + const float *xr = x + (long long)blockIdx.x * D; + float *yr = y + (long long)blockIdx.x * D; + float acc = 0.0f; + for (long long k = t; k < D; k += NT) + acc += xr[k] * xr[k]; + red[t] = acc; + __syncthreads(); + for (int h = NT / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + __syncthreads(); + } + float rs = 1.0f / sqrtf(red[0] / (float)D + 1e-6f); + for (long long k = t; k < D; k += NT) + yr[k] = xr[k] * rs * w[k]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + rmsnorm<<<(unsigned)p[0], NT>>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], p[1]); +} diff --git a/workloads/rmsnorm/omega.om b/workloads/rmsnorm/omega.om new file mode 100644 index 0000000..b4fca4b --- /dev/null +++ b/workloads/rmsnorm/omega.om @@ -0,0 +1,41 @@ +note rmsnorm over rows of x[R][D] in f32: y = x rsqrt(mean(x^2) + 1e-6) w +global kr ulong 1 +global kd ulong 1 +fn rmsrow o ulong d ulong inv f32 to void +q = 0.0f32 +for k ulong d +v = get fa add o k +q = add q mul v v +end +rs = div 1.0f32 fsqrt add mul q inv 0.000001f32 +for k ulong d +p = mul get fa add o k rs +put fo add o k mul p get fb k +end +end +fn kern to void +d = get kd 0 +inv = div 1.0f32 f32 d +for i ulong get kr 0 +rmsrow mul i d d inv +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kd 0 ulong oal_p 1 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 a +oal_end +ret 0 +end diff --git a/workloads/rmsnorm/reference.py b/workloads/rmsnorm/reference.py new file mode 100644 index 0000000..6664703 --- /dev/null +++ b/workloads/rmsnorm/reference.py @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + +EPS = float(np.float32(1e-6)) # every entrant writes eps as the f32 constant 1e-6 + + +def reference(p, x): + v = x["x"].astype(np.float64) + w = x["w"].astype(np.float64)[None, :] + ms = (v * v).mean(axis=1, keepdims=True) + return {"y": v / np.sqrt(ms + EPS) * w} diff --git a/workloads/rmsnorm/triton_kernel.py b/workloads/rmsnorm/triton_kernel.py new file mode 100644 index 0000000..e7298f5 --- /dev/null +++ b/workloads/rmsnorm/triton_kernel.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _rmsnorm(x, w, y, D, BLOCK: tl.constexpr): + r = tl.program_id(0) + k = tl.arange(0, BLOCK) + m = k < D + v = tl.load(x + r * D + k, mask=m, other=0.0) + rs = 1.0 / tl.sqrt(tl.sum(v * v, axis=0) / D + 1e-6) + tl.store(y + r * D + k, v * rs * tl.load(w + k, mask=m, other=0.0), mask=m) + + +def launch(p, t): + _rmsnorm[(p["R"],)](t["x"], t["w"], t["y"], p["D"], BLOCK=triton.next_power_of_2(p["D"])) diff --git a/workloads/rmsnorm/workload.json b/workloads/rmsnorm/workload.json new file mode 100644 index 0000000..7fc6a1f --- /dev/null +++ b/workloads/rmsnorm/workload.json @@ -0,0 +1,110 @@ +{ + "name": "rmsnorm", + "family": "row-normalization", + "summary": "per row r of x[R][D]: y = x / sqrt(mean(x^2) + eps) * w, eps = 1e-6 written as an f32 constant", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "R": 24, + "D": 256 + }, + "cases": [ + {}, + { + "R": 1, + "D": 1 + }, + { + "R": 7, + "D": 999 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "D": { + "min": 1 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "R", + "D" + ], + "gen": { + "kind": "uniform", + "lo": -2.0, + "hi": 2.0 + } + }, + { + "name": "w", + "dtype": "f32", + "shape": [ + "D" + ], + "gen": { + "kind": "uniform", + "lo": 0.5, + "hi": 1.5 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "R", + "D" + ] + } + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": "gamma(D+9)", + "atol": 0.0, + "why": "every step is multiplicative on positive quantities. sum x^2 in any order, FMA or not: (1+theta_D) (Higham Thm 3.1/3.5); times f32(1/D) or divided by D: theta_2 more; + eps (both terms positive): one more, so v^ = v(1+rho), |rho| <= gamma(D+3), eps = f32(1e-6) in the reference. |(1+rho)^(-1/2) - 1| <= (2 sqrt2 - 2)|rho| <= gamma(D+3) (WolframLanguageEvaluator: MaxValue[{Abs[(1+r)^(-1/2)-1]/Abs[r], -1/2<=r<=10, r!=0}, r] -> 0.8284271247). rsqrt budget 2 ulp (OpenCL C 3.0 s7.4, CUDA rsqrtf) = 4u <= gamma(4) (WolframLanguageEvaluator: 2*2^-23/2^-24 -> 4), also covering sqrt + divide (WolframLanguageEvaluator: ((1+u)/(1-u)-1)/u -> 2.0000001). x * r * w: two roundings. Lemma 3.3 gives y^ = y(1+theta), |theta| <= gamma(D+9); for D=256, gamma(265) (WolframLanguageEvaluator: 265u/(1-265u), u=2^-24 -> 1.5795e-5). A dropped term changes y by ~1/(2D) relative and fails." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "rmsnorm", + "global": [ + "R*64" + ], + "local": [ + "64" + ], + "args": [ + "x", + "w", + "y", + "D", + "local:f32:64" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/rope/kernel.cl b/workloads/rope/kernel.cl new file mode 100644 index 0000000..0c40139 --- /dev/null +++ b/workloads/rope/kernel.cl @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +// one work-item per rotated pair; n = T*H*h pairs +__kernel void rope(__global const float *x, __global const float *cs, __global const float *sn, + __global float *y, const int n, const int h, const int H) +{ + int g = get_global_id(0); + if (g < n) { + int i = g % h; + int th = g / h; // t*H + j + int t = th / H; + int o = th * 2 * h + i; + float c = cs[t * h + i], s = sn[t * h + i]; + float x1 = x[o], x2 = x[o + h]; + y[o] = x1 * c - x2 * s; + y[o + h] = x1 * s + x2 * c; + } +} diff --git a/workloads/rope/kernel.cu b/workloads/rope/kernel.cu new file mode 100644 index 0000000..3134a57 --- /dev/null +++ b/workloads/rope/kernel.cu @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +// one thread per rotated pair; n = T*H*h pairs +__global__ void rope(const float *x, const float *cs, const float *sn, float *y, long long n, long long h, + long long H) +{ + long long g = (long long)blockIdx.x * blockDim.x + threadIdx.x; + if (g < n) { + long long i = g % h; + long long th = g / h; + long long t = th / H; + long long o = th * 2 * h + i; + float c = cs[t * h + i], s = sn[t * h + i]; + float x1 = x[o], x2 = x[o + h]; + y[o] = x1 * c - x2 * s; + y[o + h] = x1 * s + x2 * c; + } +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long T = p[0], H = p[1], h = p[3]; + long long n = T * H * h; + rope<<<(unsigned)((n + 255) / 256), 256>>>((const float *)buf[0], (const float *)buf[1], + (const float *)buf[2], (float *)buf[3], n, h, H); +} diff --git a/workloads/rope/omega.om b/workloads/rope/omega.om new file mode 100644 index 0000000..c2a8217 --- /dev/null +++ b/workloads/rope/omega.om @@ -0,0 +1,48 @@ +note rope: half-split rotary rotation over x[T][H][Dh] with cos/sin tables [T][Dh/2] +global kt ulong 1 +global kh ulong 1 +global khf ulong 1 +fn pair o ulong cb ulong to void +note rotate the h pairs of one (t, head) row at x offset o with table offset cb +hf = get khf 0 +for i ulong hf +x1 = get fa add o i +x2 = get fa add add o hf i +c = get fb add cb i +s = get fc add cb i +put fo add o i sub mul x1 c mul x2 s +put fo add add o hf i add mul x1 s mul x2 c +end +end +fn kern to void +nh = get kh 0 +hf = get khf 0 +for t ulong get kt 0 +cb = mul t hf +for j ulong nh +o = mul add mul t nh j mul 2 hf +pair o cb +end +end +end +fn main to int +oal_begin +put kt 0 ulong oal_p 0 +put kh 0 ulong oal_p 1 +put khf 0 ulong oal_p 3 +a = oal_fa 0 +b = oal_fb 1 +c = oal_fc 2 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 a +oal_end +ret 0 +end diff --git a/workloads/rope/reference.py b/workloads/rope/reference.py new file mode 100644 index 0000000..06824f1 --- /dev/null +++ b/workloads/rope/reference.py @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + h = p["h"] + v = x["x"].astype(np.float64) + c = x["cos"].astype(np.float64)[:, None, :] + s = x["sin"].astype(np.float64)[:, None, :] + x1, x2 = v[..., :h], v[..., h:] + y = np.concatenate([x1 * c - x2 * s, x1 * s + x2 * c], axis=-1) + sc = np.concatenate([np.abs(x1 * c) + np.abs(x2 * s), np.abs(x1 * s) + np.abs(x2 * c)], axis=-1) + return {"y": (y, sc)} diff --git a/workloads/rope/triton_kernel.py b/workloads/rope/triton_kernel.py new file mode 100644 index 0000000..51bca33 --- /dev/null +++ b/workloads/rope/triton_kernel.py @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _rope(x, cs, sn, y, H, h, BLOCK: tl.constexpr): + th = tl.program_id(0) # t*H + j + t = th // H + i = tl.arange(0, BLOCK) + m = i < h + o = th * 2 * h + i + c = tl.load(cs + t * h + i, mask=m, other=0.0) + s = tl.load(sn + t * h + i, mask=m, other=0.0) + x1 = tl.load(x + o, mask=m, other=0.0) + x2 = tl.load(x + o + h, mask=m, other=0.0) + tl.store(y + o, x1 * c - x2 * s, mask=m) + tl.store(y + o + h, x1 * s + x2 * c, mask=m) + + +def launch(p, t): + _rope[(p["T"] * p["H"],)](t["x"], t["cos"], t["sin"], t["y"], p["H"], p["h"], + BLOCK=triton.next_power_of_2(p["h"])) diff --git a/workloads/rope/workload.json b/workloads/rope/workload.json new file mode 100644 index 0000000..509edd0 --- /dev/null +++ b/workloads/rope/workload.json @@ -0,0 +1,136 @@ +{ + "name": "rope", + "family": "elementwise-rotation", + "summary": "rotary embedding, half-split pairing: x is T x H x Dh (Dh even), h = Dh/2; for i < h, x1 = x[t,j,i], x2 = x[t,j,i+h], c = cos[t,i], s = sin[t,i]: y[t,j,i] = x1 c - x2 s, y[t,j,i+h] = x1 s + x2 c", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the rotation is the GPT-NeoX/LLaMA half-split form. The cos and sin tables are inputs generated independently uniform in [-1,1]: the workload checks the rotation arithmetic only, table semantics (theta base 10000, positions 0..T-1) are out of scope because not every entrant has cos/sin.", + "params": { + "T": 16, + "H": 4, + "Dh": 64 + }, + "derived": { + "h": "Dh // 2" + }, + "cases": [ + {}, + { + "T": 1, + "H": 1, + "Dh": 2 + }, + { + "T": 7, + "H": 5, + "Dh": 34 + } + ], + "shrink": { + "T": { + "min": 1 + }, + "H": { + "min": 1 + }, + "Dh": { + "min": 2, + "multiple_of": 2 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "T", + "H", + "Dh" + ], + "gen": { + "kind": "normal4", + "mean": 0.0, + "std": 2.0 + } + }, + { + "name": "cos", + "dtype": "f32", + "shape": [ + "T", + "h" + ], + "gen": { + "kind": "uniform", + "lo": -1.0, + "hi": 1.0 + } + }, + { + "name": "sin", + "dtype": "f32", + "shape": [ + "T", + "h" + ], + "gen": { + "kind": "uniform", + "lo": -1.0, + "hi": 1.0 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "T", + "H", + "Dh" + ] + } + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": "gamma(2)", + "atol": 0.0, + "why": "each output is a length-2 dot product (x1 c - x2 s or x1 s + x2 c) of exact f32 inputs; with or without fused multiply-add and in either order it is within gamma(2) * (|x1 c| + |x2 s|) (Higham Thm 3.1/3.5), and reference.py passes that sum as the scale (WolframLanguageEvaluator: 2u/(1-2u), u=2^-24 -> 1.192e-7)." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "rope", + "global": [ + "T*H*h" + ], + "local": null, + "args": [ + "x", + "cos", + "sin", + "y", + "T*H*h", + "h", + "H" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/saxpy/kernel.cl b/workloads/saxpy/kernel.cl new file mode 100644 index 0000000..3c20a6e --- /dev/null +++ b/workloads/saxpy/kernel.cl @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: Apache-2.0 +__kernel void saxpy(__global const float *alpha, __global const float *x, __global const float *y_in, + __global float *y, const int n) +{ + int i = get_global_id(0); + if (i < n) + y[i] = alpha[0] * x[i] + y_in[i]; +} diff --git a/workloads/saxpy/kernel.cu b/workloads/saxpy/kernel.cu new file mode 100644 index 0000000..b30ff32 --- /dev/null +++ b/workloads/saxpy/kernel.cu @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +__global__ void saxpy(const float *alpha, const float *x, const float *y_in, float *y, long long n) +{ + long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; + if (i < n) + y[i] = alpha[0] * x[i] + y_in[i]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0]; + saxpy<<<(unsigned)((n + 255) / 256), 256>>>((const float *)buf[0], (const float *)buf[1], + (const float *)buf[2], (float *)buf[3], n); +} diff --git a/workloads/saxpy/omega.om b/workloads/saxpy/omega.om new file mode 100644 index 0000000..055cfbe --- /dev/null +++ b/workloads/saxpy/omega.om @@ -0,0 +1,27 @@ +note saxpy: fo[i] = alpha * fb[i] + fc[i]; alpha is fa[0]; a separate mul then add (two roundings) +global kn ulong 1 +fn kern to void +al = get fa 0 +for i ulong get kn 0 +put fo i add mul al get fb i get fc i +end +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +b = oal_fb 1 +c = oal_fc 2 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 get kn 0 +oal_end +ret 0 +end diff --git a/workloads/saxpy/reference.py b/workloads/saxpy/reference.py new file mode 100644 index 0000000..80be153 --- /dev/null +++ b/workloads/saxpy/reference.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + alpha = x["alpha"].astype(np.float64)[0] + ax = alpha * x["x"].astype(np.float64) + y = x["y_in"].astype(np.float64) + return {"y": (ax + y, np.abs(ax) + np.abs(y))} diff --git a/workloads/saxpy/triton_kernel.py b/workloads/saxpy/triton_kernel.py new file mode 100644 index 0000000..2349591 --- /dev/null +++ b/workloads/saxpy/triton_kernel.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _saxpy(alpha, x, y_in, y, n, BLOCK: tl.constexpr): + i = tl.program_id(0) * BLOCK + tl.arange(0, BLOCK) + m = i < n + a = tl.load(alpha) + tl.store(y + i, a * tl.load(x + i, mask=m) + tl.load(y_in + i, mask=m), mask=m) + + +def launch(p, t): + n = p["n"] + _saxpy[(triton.cdiv(n, 1024),)](t["alpha"], t["x"], t["y_in"], t["y"], n, BLOCK=1024) diff --git a/workloads/saxpy/workload.json b/workloads/saxpy/workload.json new file mode 100644 index 0000000..14e55a5 --- /dev/null +++ b/workloads/saxpy/workload.json @@ -0,0 +1,28 @@ +{ + "name": "saxpy", + "family": "memory-bound", + "summary": "y[i] = alpha * x[i] + y_in[i] over n f32 elements; alpha is a one-element f32 input", + "provenance": "authored for OpenAccel Lab (Apache-2.0); BLAS level-1 SAXPY semantics", + "params": {"n": 100003}, + "cases": [{}, {"n": 1}, {"n": 4099}], + "shrink": {"n": {"min": 1}}, + "inputs": [ + {"name": "alpha", "dtype": "f32", "shape": [1], "gen": {"kind": "uniform", "lo": -2.0, "hi": 2.0}}, + {"name": "x", "dtype": "f32", "shape": ["n"], "gen": {"kind": "uniform", "lo": -4.0, "hi": 4.0}}, + {"name": "y_in", "dtype": "f32", "shape": ["n"], "gen": {"kind": "normal4", "std": 2.0}} + ], + "outputs": [{"name": "y", "dtype": "f32", "shape": ["n"]}], + "tolerance": { + "y": {"kind": "bound", "rtol": "gamma(2)", "atol": 0, + "why": "alpha*x+y is a length-2 dot product (alpha,1).(x,y): unfused it is two roundings, fused one, so |err| <= gamma(2)*(|alpha x|+|y|) (Higham Thm 3.1); reference.py passes |alpha x|+|y| as scale. WolframLanguageEvaluator: g[n_]:=n 2^-24/(1-n 2^-24); N[g[2],6] -> 1.19209*10^-7"} + }, + "timing": {"warmup": 2, "repeats": 10}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": {"src": "kernel.cl", "launches": [ + {"kernel": "saxpy", "global": ["n"], "local": null, "args": ["alpha", "x", "y_in", "y", "n"]} + ]}, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/scan_i32/kernel.cl b/workloads/scan_i32/kernel.cl new file mode 100644 index 0000000..f34a39e --- /dev/null +++ b/workloads/scan_i32/kernel.cl @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: Apache-2.0 +// Launch 1: each work-group of 256 scans its slice in local memory (Hillis-Steele), writes the +// block-local inclusive prefix to y and the block total to bsum[g]. +// Launch 2: one work-group scans bsum in place (chunks of 256 with a running carry). +// Launch 3: every element of block g > 0 adds bsum[g - 1]. + +static void scan_tree(__local int *s, int l) +{ + for (int off = 1; off < (int)get_local_size(0); off <<= 1) { + int t = l >= off ? s[l - off] : 0; + barrier(CLK_LOCAL_MEM_FENCE); + s[l] += t; + barrier(CLK_LOCAL_MEM_FENCE); + } +} + +__kernel void scan_blk(__global const int *x, __global int *y, __global int *bsum, const int n, __local int *s) +{ + int l = get_local_id(0); + int i = get_global_id(0); + s[l] = i < n ? x[i] : 0; + barrier(CLK_LOCAL_MEM_FENCE); + scan_tree(s, l); + if (i < n) + y[i] = s[l]; + if (l == get_local_size(0) - 1) + bsum[get_group_id(0)] = s[l]; +} + +__kernel void scan_sums(__global int *bsum, const int nb, __local int *s) +{ + int l = get_local_id(0); + int w = get_local_size(0); + int carry = 0; + for (int base = 0; base < nb; base += w) { + int j = base + l; + s[l] = j < nb ? bsum[j] : 0; + barrier(CLK_LOCAL_MEM_FENCE); + scan_tree(s, l); + if (j < nb) + bsum[j] = s[l] + carry; + carry += s[w - 1]; + barrier(CLK_LOCAL_MEM_FENCE); + } +} + +__kernel void scan_add(__global int *y, __global const int *bsum, const int n) +{ + int i = get_global_id(0); + int g = get_group_id(0); + if (g > 0 && i < n) + y[i] += bsum[g - 1]; +} diff --git a/workloads/scan_i32/kernel.cu b/workloads/scan_i32/kernel.cu new file mode 100644 index 0000000..4b34b1a --- /dev/null +++ b/workloads/scan_i32/kernel.cu @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: Apache-2.0 +// Launch 1: each block of 256 scans its slice in shared memory (Hillis-Steele), writes the +// block-local inclusive prefix to y and the block total to bsum[g]. +// Launch 2: one block scans bsum in place (chunks of 256 with a running carry). +// Launch 3: every element of block g > 0 adds bsum[g - 1]. +#include + +#define OAL_B 256 + +__global__ void scan_blk(const int *x, int *y, int *bsum, long long n) +{ + __shared__ int s[OAL_B]; + int l = threadIdx.x; + long long i = (long long)blockIdx.x * OAL_B + l; + s[l] = i < n ? x[i] : 0; + __syncthreads(); + for (int off = 1; off < OAL_B; off <<= 1) { + int t = l >= off ? s[l - off] : 0; + __syncthreads(); + s[l] += t; + __syncthreads(); + } + if (i < n) + y[i] = s[l]; + if (l == OAL_B - 1) + bsum[blockIdx.x] = s[l]; +} + +__global__ void scan_sums(int *bsum, long long nb) +{ + __shared__ int s[OAL_B]; + int l = threadIdx.x; + int carry = 0; + for (long long base = 0; base < nb; base += OAL_B) { + long long j = base + l; + s[l] = j < nb ? bsum[j] : 0; + __syncthreads(); + for (int off = 1; off < OAL_B; off <<= 1) { + int t = l >= off ? s[l - off] : 0; + __syncthreads(); + s[l] += t; + __syncthreads(); + } + if (j < nb) + bsum[j] = s[l] + carry; + carry += s[OAL_B - 1]; + __syncthreads(); + } +} + +__global__ void scan_add(int *y, const int *bsum, long long n) +{ + long long i = (long long)blockIdx.x * OAL_B + threadIdx.x; + if (blockIdx.x > 0 && i < n) + y[i] += bsum[blockIdx.x - 1]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0], nb = p[1]; + int *x = (int *)buf[0], *y = (int *)buf[1], *bsum = (int *)buf[2]; + scan_blk<<<(unsigned)nb, OAL_B>>>(x, y, bsum, n); + scan_sums<<<1, OAL_B>>>(bsum, nb); + scan_add<<<(unsigned)nb, OAL_B>>>(y, bsum, n); +} diff --git a/workloads/scan_i32/omega.om b/workloads/scan_i32/omega.om new file mode 100644 index 0000000..12f97d5 --- /dev/null +++ b/workloads/scan_i32/omega.om @@ -0,0 +1,25 @@ +global kn ulong 1 +fn kern to void +s = int 0 +for i ulong get kn 0 +s = add s get ia i +put io i s +end +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_ia 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_sio 0 get kn 0 +oal_end +ret 0 +end diff --git a/workloads/scan_i32/reference.py b/workloads/scan_i32/reference.py new file mode 100644 index 0000000..a9c4b65 --- /dev/null +++ b/workloads/scan_i32/reference.py @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + return {"y": np.cumsum(x["x"].astype(np.int64)).astype(np.float64)} diff --git a/workloads/scan_i32/triton_kernel.py b/workloads/scan_i32/triton_kernel.py new file mode 100644 index 0000000..034af80 --- /dev/null +++ b/workloads/scan_i32/triton_kernel.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _scan(x, y, n, BLOCK: tl.constexpr): + # one program walks the input in blocks: block-local inclusive cumsum plus the running carry + lane = tl.arange(0, BLOCK) + carry = tl.sum(tl.zeros([BLOCK], dtype=tl.int32), axis=0) + for off in range(0, n, BLOCK): + i = off + lane + m = i < n + v = tl.load(x + i, mask=m, other=0) + tl.store(y + i, tl.cumsum(v, axis=0) + carry, mask=m) + carry += tl.sum(v, axis=0) + + +def launch(p, t): + _scan[(1,)](t["x"], t["y"], p["n"], BLOCK=4096) diff --git a/workloads/scan_i32/workload.json b/workloads/scan_i32/workload.json new file mode 100644 index 0000000..791e50c --- /dev/null +++ b/workloads/scan_i32/workload.json @@ -0,0 +1,50 @@ +{ + "name": "scan_i32", + "family": "scan", + "summary": "y[i] = x[0] + ... + x[i] (inclusive prefix sum) over n i32 elements; OpenCL/CUDA scan 256-wide blocks in local memory, scan the block sums in one block, then add each block's offset", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "n": 100003 + }, + "derived": { + "nb": "(n + 255) // 256" + }, + "cases": [ + {}, + {"n": 1}, + {"n": 257} + ], + "shrink": { + "n": {"min": 1} + }, + "inputs": [ + {"name": "x", "dtype": "i32", "shape": ["n"], "gen": {"kind": "int", "lo": -9, "hi": 9}} + ], + "outputs": [ + {"name": "y", "dtype": "i32", "shape": ["n"]} + ], + "scratch": [ + {"name": "bsum", "dtype": "i32", "shape": ["nb"]} + ], + "tolerance": { + "y": { + "kind": "int", + "atol": 0, + "why": "integer additions are exact: |x_i| <= 9, so every prefix is at most 9*n in magnitude, far inside i32 for the cases run" + } + }, + "timing": {"warmup": 1, "repeats": 5}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": { + "src": "kernel.cl", + "launches": [ + {"kernel": "scan_blk", "global": ["nb * 256"], "local": [256], "args": ["x", "y", "bsum", "n", "local:i32:256"]}, + {"kernel": "scan_sums", "global": [256], "local": [256], "args": ["bsum", "nb", "local:i32:256"]}, + {"kernel": "scan_add", "global": ["nb * 256"], "local": [256], "args": ["y", "bsum", "n"]} + ] + }, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/silu/kernel.cl b/workloads/silu/kernel.cl new file mode 100644 index 0000000..bab0921 --- /dev/null +++ b/workloads/silu/kernel.cl @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: Apache-2.0 +__kernel void silu(__global const float *x, __global float *y, const int n) +{ + int i = get_global_id(0); + if (i < n) { + float v = x[i]; + y[i] = v / (1.0f + exp(-v)); + } +} diff --git a/workloads/silu/kernel.cu b/workloads/silu/kernel.cu new file mode 100644 index 0000000..f96f45d --- /dev/null +++ b/workloads/silu/kernel.cu @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +__global__ void silu(const float *x, float *y, long long n) +{ + long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; + if (i < n) { + float v = x[i]; + y[i] = v / (1.0f + expf(-v)); + } +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0]; + silu<<<(unsigned)((n + 255) / 256), 256>>>((const float *)buf[0], (float *)buf[1], n); +} diff --git a/workloads/silu/omega.om b/workloads/silu/omega.om new file mode 100644 index 0000000..ab1bc45 --- /dev/null +++ b/workloads/silu/omega.om @@ -0,0 +1,26 @@ +note silu: y = x / (1 + exp(-x)) in f32; exp via oal_expf in binary64, rounded once to f32 +global kn ulong 1 +fn kern to void +for i ulong get kn 0 +v = get fa i +e = f32 oal_expf f64 neg v +put fo i div v add 1.0f32 e +end +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 get kn 0 +oal_end +ret 0 +end diff --git a/workloads/silu/reference.py b/workloads/silu/reference.py new file mode 100644 index 0000000..2399c7c --- /dev/null +++ b/workloads/silu/reference.py @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + v = x["x"].astype(np.float64) + return {"y": v / (1.0 + np.exp(-v))} diff --git a/workloads/silu/triton_kernel.py b/workloads/silu/triton_kernel.py new file mode 100644 index 0000000..f0515ba --- /dev/null +++ b/workloads/silu/triton_kernel.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _silu(x, y, n, BLOCK: tl.constexpr): + i = tl.program_id(0) * BLOCK + tl.arange(0, BLOCK) + m = i < n + v = tl.load(x + i, mask=m, other=0.0) + tl.store(y + i, v / (1.0 + tl.exp(-v)), mask=m) + + +def launch(p, t): + n = p["n"] + _silu[(triton.cdiv(n, 1024),)](t["x"], t["y"], n, BLOCK=1024) diff --git a/workloads/silu/workload.json b/workloads/silu/workload.json new file mode 100644 index 0000000..52cc38f --- /dev/null +++ b/workloads/silu/workload.json @@ -0,0 +1,86 @@ +{ + "name": "silu", + "family": "elementwise-transcendental", + "summary": "y[i] = x[i] * sigmoid(x[i]) = x[i] / (1 + exp(-x[i])) over n f32 elements", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "n": 100003 + }, + "cases": [ + {}, + { + "n": 1 + }, + { + "n": 4097 + } + ], + "shrink": { + "n": { + "min": 1 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "n" + ], + "gen": { + "kind": "uniform", + "lo": -16.0, + "hi": 16.0 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "n" + ] + } + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": "gamma(8)", + "atol": 0.0, + "why": "y = x / (1 + E), E = exp(-x) computed in f32 (negation exact). exp budget: OpenCL exp <= 3 ulp (OpenCL C 3.0 s7.4), CUDA expf <= 2 ulp; 1 ulp <= 2u relative, so 3 ulp <= 6u (WolframLanguageEvaluator: 3*2^-23/2^-24 -> 6). Since E/(1+E) < 1, the relative error of 1+E is at most that of E, <= 6u <= gamma(6); the add and the divide add one rounding each, so by Higham Lemma 3.3 y = x/(1+e^-x) * (1+theta_8), |theta_8| <= gamma(8) (WolframLanguageEvaluator: 8u/(1-8u), u=2^-24 -> 4.768e-7). Omega computes exp in binary64 and rounds once (<= u + binary64 error). Inputs in [-16,16] keep E and y normal in f32." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "silu", + "global": [ + "n" + ], + "local": null, + "args": [ + "x", + "y", + "n" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/softmax/kernel.cl b/workloads/softmax/kernel.cl new file mode 100644 index 0000000..a17cafb --- /dev/null +++ b/workloads/softmax/kernel.cl @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: Apache-2.0 +// one work-group per row; get_local_size(0) must be a power of two +__kernel void softmax(__global const float *x, __global float *y, const int D, __local float *red) +{ + int t = get_local_id(0), nt = get_local_size(0); + __global const float *xr = x + (long)get_group_id(0) * D; + __global float *yr = y + (long)get_group_id(0) * D; + float acc = -INFINITY; + for (int k = t; k < D; k += nt) + acc = fmax(acc, xr[k]); + red[t] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int h = nt / 2; h > 0; h >>= 1) { + if (t < h) + red[t] = fmax(red[t], red[t + h]); + barrier(CLK_LOCAL_MEM_FENCE); + } + float m = red[0]; + barrier(CLK_LOCAL_MEM_FENCE); + acc = 0.0f; + for (int k = t; k < D; k += nt) { + float e = exp(xr[k] - m); + yr[k] = e; + acc += e; + } + red[t] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int h = nt / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + barrier(CLK_LOCAL_MEM_FENCE); + } + float s = red[0]; + for (int k = t; k < D; k += nt) + yr[k] = yr[k] / s; +} diff --git a/workloads/softmax/kernel.cu b/workloads/softmax/kernel.cu new file mode 100644 index 0000000..de958be --- /dev/null +++ b/workloads/softmax/kernel.cu @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: Apache-2.0 +#include +#include + +#define NT 128 + +// one block of NT threads per row +__global__ void softmax(const float *x, float *y, long long D) +{ + __shared__ float red[NT]; + int t = threadIdx.x; + const float *xr = x + (long long)blockIdx.x * D; + float *yr = y + (long long)blockIdx.x * D; + float acc = -INFINITY; + for (long long k = t; k < D; k += NT) + acc = fmaxf(acc, xr[k]); + red[t] = acc; + __syncthreads(); + for (int h = NT / 2; h > 0; h >>= 1) { + if (t < h) + red[t] = fmaxf(red[t], red[t + h]); + __syncthreads(); + } + float m = red[0]; + __syncthreads(); + acc = 0.0f; + for (long long k = t; k < D; k += NT) { + float e = expf(xr[k] - m); + yr[k] = e; + acc += e; + } + red[t] = acc; + __syncthreads(); + for (int h = NT / 2; h > 0; h >>= 1) { + if (t < h) + red[t] += red[t + h]; + __syncthreads(); + } + float s = red[0]; + for (long long k = t; k < D; k += NT) + yr[k] = yr[k] / s; +} + +void oal_launch(const long long *p, void *const *buf) +{ + softmax<<<(unsigned)p[0], NT>>>((const float *)buf[0], (float *)buf[1], p[1]); +} diff --git a/workloads/softmax/omega.om b/workloads/softmax/omega.om new file mode 100644 index 0000000..0a2ea73 --- /dev/null +++ b/workloads/softmax/omega.om @@ -0,0 +1,42 @@ +note softmax over rows of x[R][D] in f32: e = exp(x - max) via oal_expf rounded to f32, y = e / sum e +global kr ulong 1 +global kd ulong 1 +fn smrow o ulong d ulong to void +m = get fa o +for k ulong d +m = fmax m get fa add o k +end +s = 0.0f32 +for k ulong d +e = f32 oal_expf f64 sub get fa add o k m +put fo add o k e +s = add s e +end +for k ulong d +put fo add o k div get fo add o k s +end +end +fn kern to void +d = get kd 0 +for i ulong get kr 0 +smrow mul i d d +end +end +fn main to int +oal_begin +put kr 0 ulong oal_p 0 +put kd 0 ulong oal_p 1 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 a +oal_end +ret 0 +end diff --git a/workloads/softmax/reference.py b/workloads/softmax/reference.py new file mode 100644 index 0000000..98985d8 --- /dev/null +++ b/workloads/softmax/reference.py @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + +U = 2.0 ** -24 + + +def _g(n): + return n * U / (1.0 - n * U) + + +def reference(p, x): + D = p["D"] + v = x["x"].astype(np.float64) + a = v - v.max(axis=1, keepdims=True) + e = np.exp(a) + y = e / e.sum(axis=1, keepdims=True) + # error bound; derivation in workload.json tolerance.why + eps = (1.0 + 6.0 * U) * np.exp(U * np.abs(a)) - 1.0 + E = eps.max(axis=1, keepdims=True) + gs, g2 = _g(D - 1), _g(2) + hi = (1.0 + eps) * (1.0 + g2) / ((1.0 - E) * (1.0 - gs)) - 1.0 + lo = 1.0 - (1.0 - eps) * (1.0 - g2) / ((1.0 + E) * (1.0 + gs)) + return {"y": (y, y * np.maximum(hi, lo))} diff --git a/workloads/softmax/triton_kernel.py b/workloads/softmax/triton_kernel.py new file mode 100644 index 0000000..a26e56f --- /dev/null +++ b/workloads/softmax/triton_kernel.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _softmax(x, y, D, BLOCK: tl.constexpr): + r = tl.program_id(0) + k = tl.arange(0, BLOCK) + m = k < D + v = tl.load(x + r * D + k, mask=m, other=-float("inf")) + e = tl.exp(v - tl.max(v, axis=0)) + tl.store(y + r * D + k, e / tl.sum(e, axis=0), mask=m) + + +def launch(p, t): + _softmax[(p["R"],)](t["x"], t["y"], p["D"], BLOCK=triton.next_power_of_2(p["D"])) diff --git a/workloads/softmax/workload.json b/workloads/softmax/workload.json new file mode 100644 index 0000000..cb7cb05 --- /dev/null +++ b/workloads/softmax/workload.json @@ -0,0 +1,97 @@ +{ + "name": "softmax", + "family": "row-reduction-transcendental", + "summary": "row softmax of x[R][D]: y = exp(x - max) / sum(exp(x - max))", + "provenance": "authored for OpenAccel Lab (Apache-2.0)", + "params": { + "R": 24, + "D": 200 + }, + "cases": [ + {}, + { + "R": 3, + "D": 1 + }, + { + "R": 5, + "D": 1023 + } + ], + "shrink": { + "R": { + "min": 1 + }, + "D": { + "min": 1 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "R", + "D" + ], + "gen": { + "kind": "uniform", + "lo": -30.0, + "hi": 30.0 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "R", + "D" + ] + } + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": 1.0, + "atol": 0.0, + "why": "reference.py returns an absolute per-element bound y_j R_j as the scale (rtol 1), in float64 from the exact inputs. a_k = x_k - m (m the row max, exact). The f32 subtraction rounds once: d_k = a_k(1+delta), so exp(d_k) = exp(a_k) exp(a_k delta) with |exp(a_k delta) - 1| <= exp(u|a_k|) - 1 (|a_k| <= 60 here: WolframLanguageEvaluator: (Exp[60 u]-1)/u, u=2^-24 -> 60.0001). exp budget 3 ulp (OpenCL C 3.0 s7.4; CUDA expf 2 ulp; Omega rounds a binary64 exp once) = 6u relative (WolframLanguageEvaluator: 3*2^-23/2^-24 -> 6), so e_k^ = e_k(1+eta_k), |eta_k| <= eps_k = (1+6u)exp(u|a_k|) - 1, E = max_k eps_k. The sum of D positive terms in any order: S^ = S(1+theta), |theta| <= (1+E)(1+gamma(D-1)) - 1. The normalisation (divide, or reciprocal then multiply) costs gamma(2). R_j = max((1+eps_j)(1+gamma(2)) / ((1-E)(1-gamma(D-1))) - 1, 1 - (1-eps_j)(1-gamma(2)) / ((1+E)(1+gamma(D-1)))). Inputs are uniform in [-30,30], so every e_k >= exp(-60) is a normal f32 (WolframLanguageEvaluator: Exp[-60] -> 8.7565e-27 > 2^-126 = 1.1755e-38). A kernel without max subtraction is wrong on the softmax_unstable control (inputs in [80,100])." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "softmax", + "global": [ + "R*64" + ], + "local": [ + "64" + ], + "args": [ + "x", + "y", + "D", + "local:f32:64" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/tmatmul16/kernel.cl b/workloads/tmatmul16/kernel.cl new file mode 100644 index 0000000..812d63f --- /dev/null +++ b/workloads/tmatmul16/kernel.cl @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +// One work-group of 256 per 16x16 tile; A and B are staged in local memory, C[i][j] = sum_k A[i][k] B[k][j]. +__kernel void tmatmul16(__global const float *a, __global const float *b, __global float *c, const int tiles) +{ + __local float la[256]; + __local float lb[256]; + int t = get_group_id(0); + int l = get_local_id(0); + int i = l / 16, j = l % 16; + la[l] = a[t * 256 + l]; + lb[l] = b[t * 256 + l]; + barrier(CLK_LOCAL_MEM_FENCE); + float s = 0.0f; + for (int k = 0; k < 16; k++) + s += la[i * 16 + k] * lb[k * 16 + j]; + c[t * 256 + l] = s; +} diff --git a/workloads/tmatmul16/kernel.cu b/workloads/tmatmul16/kernel.cu new file mode 100644 index 0000000..f18fbd7 --- /dev/null +++ b/workloads/tmatmul16/kernel.cu @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +// One 16x16 block per tile; A and B are staged in shared memory, C[i][j] = sum_k A[i][k] B[k][j]. +__global__ void tmatmul16(const float *a, const float *b, float *c) +{ + __shared__ float la[256]; + __shared__ float lb[256]; + long long t = blockIdx.x; + int i = threadIdx.y, j = threadIdx.x, l = i * 16 + j; + la[l] = a[t * 256 + l]; + lb[l] = b[t * 256 + l]; + __syncthreads(); + float s = 0.0f; + for (int k = 0; k < 16; k++) + s += la[i * 16 + k] * lb[k * 16 + j]; + c[t * 256 + l] = s; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long tiles = p[0]; + tmatmul16<<<(unsigned)tiles, dim3(16, 16)>>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2]); +} diff --git a/workloads/tmatmul16/omega.om b/workloads/tmatmul16/omega.om new file mode 100644 index 0000000..f6f62d8 --- /dev/null +++ b/workloads/tmatmul16/omega.om @@ -0,0 +1,38 @@ +global tn ulong 1 +fn kern to void +nt = get tn 0 +for t ulong nt +for i ulong 16 +ai = add mul t 256 mul i 16 +for j ulong 16 +pb = add mul t 256 j +s = 0.0f32 +for k ulong 16 +x = get fa add ai k +y = get fb pb +s = add s mul x y +pb = add pb 16 +end +put fo add ai j s +end +end +end +end +fn main to int +oal_begin +put tn 0 ulong oal_p 0 +na = oal_fa 0 +nb = oal_fb 1 +w = oal_warm +for r ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge r w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get tn 0 256 +oal_end +ret 0 +end diff --git a/workloads/tmatmul16/reference.py b/workloads/tmatmul16/reference.py new file mode 100644 index 0000000..e21ab64 --- /dev/null +++ b/workloads/tmatmul16/reference.py @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + a = x["a"].astype(np.float64) + b = x["b"].astype(np.float64) + c = np.einsum("tik,tkj->tij", a, b) + scale = np.einsum("tik,tkj->tij", np.abs(a), np.abs(b)) + return {"c": (c, scale)} diff --git a/workloads/tmatmul16/triton_kernel.py b/workloads/tmatmul16/triton_kernel.py new file mode 100644 index 0000000..ed0eddf --- /dev/null +++ b/workloads/tmatmul16/triton_kernel.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _tmatmul16(a, b, c, KN: tl.constexpr): + t = tl.program_id(0) + r = tl.arange(0, 16) + km = r < KN + av = tl.load(a + t * 256 + r[:, None] * 16 + r[None, :], mask=km[None, :], other=0.0) + bv = tl.load(b + t * 256 + r[:, None] * 16 + r[None, :], mask=km[:, None], other=0.0) + acc = tl.dot(av, bv, input_precision="ieee", out_dtype=tl.float32) + tl.store(c + t * 256 + r[:, None] * 16 + r[None, :], acc) + + +def launch(p, t): + _tmatmul16[(p["TILES"],)](t["a"], t["b"], t["c"], KN=16) diff --git a/workloads/tmatmul16/workload.json b/workloads/tmatmul16/workload.json new file mode 100644 index 0000000..2187bc7 --- /dev/null +++ b/workloads/tmatmul16/workload.json @@ -0,0 +1,109 @@ +{ + "name": "tmatmul16", + "family": "tile-matmul", + "summary": "C[t] = A[t] B[t] for TILES independent 16x16x16 tiles, f16-grid f32 inputs, f32 accumulate", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the shape follows the tile kernels of aien-dev/omega-mv PR #869 (unmerged, head 6d08fd9c, seed/kflow/specs/tmatmul16.spec and seed/kflow/sm121/tmatmul16.s2)", + "params": { + "TILES": 64 + }, + "cases": [ + {}, + { + "TILES": 1 + }, + { + "TILES": 3 + } + ], + "shrink": { + "TILES": { + "min": 1 + } + }, + "inputs": [ + { + "name": "a", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 16 + ], + "gen": { + "kind": "grid", + "klo": -1024, + "khi": 1024, + "shift": 10 + } + }, + { + "name": "b", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 16 + ], + "gen": { + "kind": "grid", + "klo": -1024, + "khi": 1024, + "shift": 10 + } + } + ], + "outputs": [ + { + "name": "c", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 16 + ] + } + ], + "tolerance": { + "c": { + "kind": "bound", + "rtol": "gamma(15)", + "atol": 0.0, + "why": "Inputs are k*2^-10 with |k|<=1024, so every value is exact in f16 and in f32, every product a*b is an integer multiple of 2^-20 with |a*b|<=1 and is exact in f32, and with or without FMA a length-16 dot product starting from 0 takes at most 15 rounded additions (the first product enters exactly). Higham Thm 3.1/3.5 for any summation order with round-to-nearest (u=2^-24): |d-ref| <= gamma(15)*sum_k |a_ik b_kj|; reference.py passes that sum as scale. WolframLanguageEvaluator: u=2^-24; gam[n_]:=n u/(1-n u); N[gam[15],12] -> 8.94070470992e-7 (PR #869 quotes gamma_15 = 1.78814254071e-6 with u=2^-23 to allow any rounding mode; every entrant here rounds to nearest, so u=2^-24). On this grid the bound is not the binding fact: every partial sum is an integer multiple of 2^-20 of magnitude <= 16*2^20 = 2^24 (WolframLanguageEvaluator: 16*1024*1024==2^24 -> True), hence exact in f32, so a correct entrant's observed error is 0; the bound is what the contract guarantees for general f16 tiles. One dropped k term changes an element by |a_ik b_kj| up to 1, far above the bound, so gemm_offbyone fails." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "tmatmul16", + "global": [ + "TILES*256" + ], + "local": [ + 256 + ], + "args": [ + "a", + "b", + "c", + "TILES" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/transpose/kernel.cl b/workloads/transpose/kernel.cl new file mode 100644 index 0000000..5804a27 --- /dev/null +++ b/workloads/transpose/kernel.cl @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +// 16x16 tile through __local memory (one padding column against bank conflicts); global is the +// tile-rounded (C, R) grid, local (16, 16). +#define TS 16 +__kernel void transpose(__global const float *a, __global float *b, const int R, const int C) +{ + __local float tile[TS][TS + 1]; + int tx = get_local_id(0), ty = get_local_id(1); + int c0 = get_group_id(0) * TS, r0 = get_group_id(1) * TS; + int r = r0 + ty, c = c0 + tx; + if (r < R && c < C) + tile[ty][tx] = a[r * C + c]; + barrier(CLK_LOCAL_MEM_FENCE); + int orow = c0 + ty, ocol = r0 + tx; // output b is C x R + if (orow < C && ocol < R) + b[orow * R + ocol] = tile[tx][ty]; +} diff --git a/workloads/transpose/kernel.cu b/workloads/transpose/kernel.cu new file mode 100644 index 0000000..db6fe52 --- /dev/null +++ b/workloads/transpose/kernel.cu @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#define TS 16 + +// 16x16 tile through static shared memory (one padding column against bank conflicts). +__global__ void transpose(const float *a, float *b, int R, int C) +{ + __shared__ float tile[TS][TS + 1]; + int tx = threadIdx.x, ty = threadIdx.y; + int c0 = blockIdx.x * TS, r0 = blockIdx.y * TS; + int r = r0 + ty, c = c0 + tx; + if (r < R && c < C) + tile[ty][tx] = a[(long long)r * C + c]; + __syncthreads(); + int orow = c0 + ty, ocol = r0 + tx; // output b is C x R + if (orow < C && ocol < R) + b[(long long)orow * R + ocol] = tile[tx][ty]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + int R = (int)p[0], C = (int)p[1]; + dim3 grid((unsigned)((C + TS - 1) / TS), (unsigned)((R + TS - 1) / TS)); + dim3 block(TS, TS); + transpose<<>>((const float *)buf[0], (float *)buf[1], R, C); +} diff --git a/workloads/transpose/omega.om b/workloads/transpose/omega.om new file mode 100644 index 0000000..9c42d35 --- /dev/null +++ b/workloads/transpose/omega.om @@ -0,0 +1,29 @@ +note transpose: fo[j*R + i] = fa[i*C + j] for an R x C row-major fa +global dm ulong 2 +fn kern to void +r = get dm 0 +c = get dm 1 +for i ulong r +for j ulong c +put fo add mul j r i get fa add mul i c j +end +end +end +fn main to int +oal_begin +put dm 0 ulong oal_p 0 +put dm 1 ulong oal_p 1 +a = oal_fa 0 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get dm 0 get dm 1 +oal_end +ret 0 +end diff --git a/workloads/transpose/reference.py b/workloads/transpose/reference.py new file mode 100644 index 0000000..634109c --- /dev/null +++ b/workloads/transpose/reference.py @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + a = x["a"].astype(np.float64).reshape(p["R"], p["C"]) + return {"b": np.ascontiguousarray(a.T)} diff --git a/workloads/transpose/triton_kernel.py b/workloads/transpose/triton_kernel.py new file mode 100644 index 0000000..ddefcad --- /dev/null +++ b/workloads/transpose/triton_kernel.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _transpose(a, b, R, C, BR: tl.constexpr, BC: tl.constexpr): + r = tl.program_id(0) * BR + tl.arange(0, BR) + c = tl.program_id(1) * BC + tl.arange(0, BC) + m = (r[:, None] < R) & (c[None, :] < C) + tile = tl.load(a + r[:, None] * C + c[None, :], mask=m) + tl.store(b + c[None, :] * R + r[:, None], tile, mask=m) + + +def launch(p, t): + R, C = p["R"], p["C"] + _transpose[(triton.cdiv(R, 32), triton.cdiv(C, 32))](t["a"], t["b"], R, C, BR=32, BC=32) diff --git a/workloads/transpose/workload.json b/workloads/transpose/workload.json new file mode 100644 index 0000000..b0e90bf --- /dev/null +++ b/workloads/transpose/workload.json @@ -0,0 +1,26 @@ +{ + "name": "transpose", + "family": "memory-bound", + "summary": "b[j][i] = a[i][j]: f32 R x C row-major in, C x R row-major out", + "provenance": "authored for OpenAccel Lab (Apache-2.0); 16x16 tiled transpose through shared/local memory", + "params": {"R": 96, "C": 80}, + "cases": [{}, {"R": 33, "C": 7}, {"R": 1, "C": 1}], + "shrink": {"R": {"min": 1}, "C": {"min": 1}}, + "inputs": [ + {"name": "a", "dtype": "f32", "shape": ["R", "C"], "gen": {"kind": "uniform", "lo": -4.0, "hi": 4.0}} + ], + "outputs": [{"name": "b", "dtype": "f32", "shape": ["C", "R"]}], + "tolerance": { + "b": {"kind": "exact", "why": "pure copy, no arithmetic"} + }, + "timing": {"warmup": 2, "repeats": 10}, + "backends": { + "omega": {"src": "omega.om"}, + "opencl": {"src": "kernel.cl", "launches": [ + {"kernel": "transpose", "global": ["(C + 15) // 16 * 16", "(R + 15) // 16 * 16"], "local": [16, 16], + "args": ["a", "b", "R", "C"]} + ]}, + "triton": {"src": "triton_kernel.py"}, + "cuda": {"src": "kernel.cu"} + } +} diff --git a/workloads/tsoftmax16/kernel.cl b/workloads/tsoftmax16/kernel.cl new file mode 100644 index 0000000..30cf361 --- /dev/null +++ b/workloads/tsoftmax16/kernel.cl @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 +// One work-item per 32-column row: max, exp(x - max) with its sum, then divide. +__kernel void tsoftmax16(__global const float *x, __global float *y, const int tiles) +{ + int r = get_global_id(0); + if (r >= tiles * 16) + return; + __global const float *xr = x + r * 32; + __global float *yr = y + r * 32; + float m = xr[0]; + for (int j = 1; j < 32; j++) + m = fmax(m, xr[j]); + float s = 0.0f; + for (int j = 0; j < 32; j++) { + float e = exp(xr[j] - m); + yr[j] = e; + s += e; + } + for (int j = 0; j < 32; j++) + yr[j] = yr[j] / s; +} diff --git a/workloads/tsoftmax16/kernel.cu b/workloads/tsoftmax16/kernel.cu new file mode 100644 index 0000000..c758970 --- /dev/null +++ b/workloads/tsoftmax16/kernel.cu @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +// One block of 32 threads per row; max and sum by a shared-memory tree, every thread reaches every barrier. +__global__ void tsoftmax16(const float *x, float *y) +{ + __shared__ float sh[32]; + long long r = blockIdx.x; + int j = threadIdx.x; + float v = x[r * 32 + j]; + sh[j] = v; + __syncthreads(); + for (int w = 16; w > 0; w /= 2) { + float o = 0.0f; + if (j < w) + o = fmaxf(sh[j], sh[j + w]); + __syncthreads(); + if (j < w) + sh[j] = o; + __syncthreads(); + } + float m = sh[0]; + __syncthreads(); + float e = expf(v - m); + sh[j] = e; + __syncthreads(); + for (int w = 16; w > 0; w /= 2) { + float o = 0.0f; + if (j < w) + o = sh[j] + sh[j + w]; + __syncthreads(); + if (j < w) + sh[j] = o; + __syncthreads(); + } + y[r * 32 + j] = e / sh[0]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long tiles = p[0]; + tsoftmax16<<<(unsigned)(tiles * 16), 32>>>((const float *)buf[0], (float *)buf[1]); +} diff --git a/workloads/tsoftmax16/omega.om b/workloads/tsoftmax16/omega.om new file mode 100644 index 0000000..d9399ab --- /dev/null +++ b/workloads/tsoftmax16/omega.om @@ -0,0 +1,37 @@ +global tn ulong 1 +fn kern to void +nr = mul get tn 0 16 +for r ulong nr +b = mul r 32 +m = get fa b +for j ulong 32 +m = fmax m get fa add b j +end +s = 0.0f32 +for j ulong 32 +e = f32 oal_expf f64 sub get fa add b j m +put fo add b j e +s = add s e +end +for j ulong 32 +put fo add b j div get fo add b j s +end +end +end +fn main to int +oal_begin +put tn 0 ulong oal_p 0 +nx = oal_fa 0 +w = oal_warm +for r ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge r w +oal_tick sub t1 t0 +end +end +oal_so 0 mul get tn 0 512 +oal_end +ret 0 +end diff --git a/workloads/tsoftmax16/reference.py b/workloads/tsoftmax16/reference.py new file mode 100644 index 0000000..083cb8f --- /dev/null +++ b/workloads/tsoftmax16/reference.py @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + v = x["x"].astype(np.float64) + e = np.exp(v - v.max(axis=2, keepdims=True)) + return {"y": e / e.sum(axis=2, keepdims=True)} diff --git a/workloads/tsoftmax16/triton_kernel.py b/workloads/tsoftmax16/triton_kernel.py new file mode 100644 index 0000000..e394893 --- /dev/null +++ b/workloads/tsoftmax16/triton_kernel.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _tsoftmax16(x, y, NR: tl.constexpr): + r = tl.program_id(0) * NR + tl.arange(0, NR) + c = tl.arange(0, 32) + v = tl.load(x + r[:, None] * 32 + c[None, :]) + m = tl.max(v, axis=1) + e = tl.exp(v - m[:, None]) + s = tl.sum(e, axis=1) + tl.store(y + r[:, None] * 32 + c[None, :], e / s[:, None]) + + +def launch(p, t): + _tsoftmax16[(p["TILES"],)](t["x"], t["y"], NR=16) diff --git a/workloads/tsoftmax16/workload.json b/workloads/tsoftmax16/workload.json new file mode 100644 index 0000000..37ca2a3 --- /dev/null +++ b/workloads/tsoftmax16/workload.json @@ -0,0 +1,90 @@ +{ + "name": "tsoftmax16", + "family": "tile-softmax", + "summary": "row softmax over TILES tiles of 16 rows x 32 f32 columns, max-subtracted", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the shape follows the tile kernels of aien-dev/omega-mv PR #869 (unmerged, head 6d08fd9c, seed/kflow/specs/tsoftmax.spec and seed/kflow/sm121/tsoftmax.s2)", + "params": { + "TILES": 64 + }, + "cases": [ + {}, + { + "TILES": 1 + }, + { + "TILES": 3 + } + ], + "shrink": { + "TILES": { + "min": 1 + } + }, + "inputs": [ + { + "name": "x", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 32 + ], + "gen": { + "kind": "uniform", + "lo": 60.0, + "hi": 100.0 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "TILES", + 16, + 32 + ] + } + ], + "tolerance": { + "y": { + "kind": "bound", + "rtol": "(1+6*u)*(1+5*u)/((1-6*u)*(1-gamma(31)))-1", + "atol": 0.0, + "why": "Inputs lie in [60,100], so for any x and row max m, m/2 <= x <= m and x-m is exact in f32 (Sterbenz; WolframLanguageEvaluator: 100/60<2 -> True), |x-m| <= 40. Per element y = e/s with e = exp(x-m) within 3 ulp (OpenCL C 3.0 sec 7.4; covers CUDA expf 2 ulp, glibc expf, numpy float32 exp and the Omega binary64 exp rounded to f32), i.e. relative eps_e = 3*2^-23 = 6u; s = sum of 32 positive terms in any order within gamma(31) relative (Higham Thm 3.1, u=2^-24); the divide within 2.5 ulp (OpenCL single-precision x/y), i.e. 5u. Hence |y-ref| <= ((1+6u)(1+5u)/((1-6u)(1-gamma(31)))-1)*|ref|. WolframLanguageEvaluator: u=2^-24; gam[n_]:=n u/(1-n u); rt=(1+3*2^-23)(1+5/2*2^-23)/((1-3*2^-23)(1-gam[31]))-1; N[{gam[31],rt,rt/2^-23},12] -> {1.84774740220e-6, 2.86103211881e-6, 24.0000769201}. This re-derives PR #869's softmax bound (2.29976200922e-6, one warp butterfly of 5 additions and ex2.approx/rcp.approx) for 31 additions in any order and per-backend exp and divide accuracy. Outputs stay normal: WolframLanguageEvaluator: N[Exp[-40]/32 > 2^-126] -> True. Without max subtraction exp(x) overflows for x > 88.72 (WolframLanguageEvaluator: N[Log[(2-2^-23)*2^127],12] -> 88.7228390521), giving inf/NaN; one dropped column changes the row sum by e^(x-m)/s, above the bound in some row." + } + }, + "timing": { + "warmup": 1, + "repeats": 5 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "tsoftmax16", + "global": [ + "TILES*16" + ], + "local": null, + "args": [ + "x", + "y", + "TILES" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +} diff --git a/workloads/vecadd/kernel.cl b/workloads/vecadd/kernel.cl new file mode 100644 index 0000000..403a352 --- /dev/null +++ b/workloads/vecadd/kernel.cl @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 +__kernel void vecadd(__global const float *a, __global const float *b, __global float *y, const int n) +{ + int i = get_global_id(0); + if (i < n) + y[i] = a[i] + b[i]; +} diff --git a/workloads/vecadd/kernel.cu b/workloads/vecadd/kernel.cu new file mode 100644 index 0000000..09b0c64 --- /dev/null +++ b/workloads/vecadd/kernel.cu @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +__global__ void vecadd(const float *a, const float *b, float *y, long long n) +{ + long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; + if (i < n) + y[i] = a[i] + b[i]; +} + +void oal_launch(const long long *p, void *const *buf) +{ + long long n = p[0]; + vecadd<<<(unsigned)((n + 255) / 256), 256>>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], n); +} diff --git a/workloads/vecadd/omega.om b/workloads/vecadd/omega.om new file mode 100644 index 0000000..93ec084 --- /dev/null +++ b/workloads/vecadd/omega.om @@ -0,0 +1,24 @@ +global kn ulong 1 +fn kern to void +for i ulong get kn 0 +put fo i add get fa i get fb i +end +end +fn main to int +oal_begin +put kn 0 ulong oal_p 0 +a = oal_fa 0 +b = oal_fb 1 +w = oal_warm +for i ulong add w oal_reps +t0 = monons +kern +t1 = monons +if ge i w +oal_tick sub t1 t0 +end +end +oal_so 0 get kn 0 +oal_end +ret 0 +end diff --git a/workloads/vecadd/reference.py b/workloads/vecadd/reference.py new file mode 100644 index 0000000..8604638 --- /dev/null +++ b/workloads/vecadd/reference.py @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 +import numpy as np + + +def reference(p, x): + return {"y": x["a"].astype(np.float64) + x["b"].astype(np.float64)} diff --git a/workloads/vecadd/triton_kernel.py b/workloads/vecadd/triton_kernel.py new file mode 100644 index 0000000..a225c0d --- /dev/null +++ b/workloads/vecadd/triton_kernel.py @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: Apache-2.0 +import triton +import triton.language as tl + + +@triton.jit +def _vecadd(a, b, y, n, BLOCK: tl.constexpr): + i = tl.program_id(0) * BLOCK + tl.arange(0, BLOCK) + m = i < n + tl.store(y + i, tl.load(a + i, mask=m) + tl.load(b + i, mask=m), mask=m) + + +def launch(p, t): + n = p["n"] + _vecadd[(triton.cdiv(n, 1024),)](t["a"], t["b"], t["y"], n, BLOCK=1024) diff --git a/workloads/vecadd/workload.json b/workloads/vecadd/workload.json new file mode 100644 index 0000000..56c673b --- /dev/null +++ b/workloads/vecadd/workload.json @@ -0,0 +1,96 @@ +{ + "name": "vecadd", + "family": "memory-bound", + "summary": "y[i] = a[i] + b[i] over n f32 elements", + "provenance": "authored for OpenAccel Lab (Apache-2.0); the GPU form matches aien-dev/omega-gpu-bench vecadd", + "params": { + "n": 100003 + }, + "cases": [ + {}, + { + "n": 1 + }, + { + "n": 4096 + } + ], + "shrink": { + "n": { + "min": 1 + } + }, + "inputs": [ + { + "name": "a", + "dtype": "f32", + "shape": [ + "n" + ], + "gen": { + "kind": "uniform", + "lo": -4.0, + "hi": 4.0 + } + }, + { + "name": "b", + "dtype": "f32", + "shape": [ + "n" + ], + "gen": { + "kind": "normal4", + "std": 2.0 + } + } + ], + "outputs": [ + { + "name": "y", + "dtype": "f32", + "shape": [ + "n" + ] + } + ], + "tolerance": { + "y": { + "kind": "exact", + "why": "one correctly rounded f32 add per element" + } + }, + "timing": { + "warmup": 2, + "repeats": 10 + }, + "backends": { + "omega": { + "src": "omega.om" + }, + "opencl": { + "src": "kernel.cl", + "launches": [ + { + "kernel": "vecadd", + "global": [ + "n" + ], + "local": null, + "args": [ + "a", + "b", + "y", + "n" + ] + } + ] + }, + "triton": { + "src": "triton_kernel.py" + }, + "cuda": { + "src": "kernel.cu" + } + } +}