mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
repository paths inside tests.
engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.
No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
61 lines
2.9 KiB
C++
61 lines
2.9 KiB
C++
// gemm_launch: what does one expert-sized FP16 GEMM (oneMKL, half in, float out) cost back to back, by row count?
|
|
// The prompt path issues one gate/up and one down GEMM per routed expert (~25k experts per 4K prompt on the 48 layers); if the
|
|
// per-call time barely moves with the rows, the path is bound by launches, not by the XMX units.
|
|
// gemm_launch [calls=2000]
|
|
#include <sycl/sycl.hpp>
|
|
#include <oneapi/mkl.hpp>
|
|
#include <dpct/dpct.hpp>
|
|
#include <dpct/blas_utils.hpp>
|
|
#include <chrono>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <vector>
|
|
|
|
int main(int argc, char** argv) {
|
|
const int calls = argc > 1 ? std::atoi(argv[1]) : 2000;
|
|
sycl::queue q{sycl::gpu_selector_v, sycl::property::queue::in_order{}};
|
|
const int64_t N = 2560;
|
|
struct Shape { const char* name; int64_t n, k; };
|
|
const Shape shapes[] = {{"gate/up 1280x2560", 1280, N}, {"down 2560x640", N, 640}};
|
|
const int64_t Ts[] = {8, 32, 80, 160, 320, 640, 1280};
|
|
const int64_t maxT = 1280;
|
|
using half = sycl::half;
|
|
half* X = sycl::malloc_device<half>(maxT * N, q);
|
|
half* W = sycl::malloc_device<half>(N * 1280 * 4, q);
|
|
float* Y = sycl::malloc_device<float>(maxT * N, q);
|
|
q.memset(X, 0, maxT * N * sizeof(half));
|
|
q.memset(W, 0, N * 1280 * 4 * sizeof(half));
|
|
q.wait();
|
|
for (const Shape& s : shapes) {
|
|
for (int64_t T : Ts) {
|
|
auto run = [&](int n) {
|
|
for (int i = 0; i < n; ++i)
|
|
oneapi::mkl::blas::column_major::gemm(q, oneapi::mkl::transpose::trans, oneapi::mkl::transpose::nontrans, s.n, T, s.k, 1.0f,
|
|
W, s.k, X, s.k, 0.0f, Y, s.n);
|
|
q.wait();
|
|
};
|
|
run(50);
|
|
const auto t0 = std::chrono::steady_clock::now();
|
|
run(calls);
|
|
const double us = std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - t0).count() / calls;
|
|
auto* h = new dpct::blas::descriptor();
|
|
h->set_queue(&q);
|
|
const float alpha = 1.0f, beta = 0.0f;
|
|
auto run2 = [&](int cnt) {
|
|
for (int i = 0; i < cnt; ++i)
|
|
dpct::blas::gemm(h, oneapi::mkl::transpose::trans, oneapi::mkl::transpose::nontrans, (int) s.n, (int) T, (int) s.k, &alpha, W,
|
|
dpct::library_data_t::real_half, (int) s.k, X, dpct::library_data_t::real_half, (int) s.k, &beta, Y,
|
|
dpct::library_data_t::real_float, (int) s.n, dpct::compute_type::f32);
|
|
q.wait();
|
|
};
|
|
run2(50);
|
|
const auto t1 = std::chrono::steady_clock::now();
|
|
run2(calls);
|
|
const double us2 = std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - t1).count() / calls;
|
|
delete h;
|
|
std::printf("%-20s T=%5lld: mkl %7.1f us/call dpct::blas::gemm %7.1f us/call\n", s.name, (long long) T, us, us2);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|