Archived
libxe2: m2xfp4 verify GEMM on register DPAS -- no local-memory round trip
SPV_INTEL_subgroup_matrix_multiply_accumulate gives DPAS on operands in registers (dpas_f16 in xe2_common.h; libxe2's link enables the extension). Its B operand is a lane's column as dwords of fp16 pairs, which is what a lane decodes from its codes, so the 2 <= M <= 16 m2xfp4 GEMM no longer writes the decoded weights to local memory and reads them back as a joint_matrix tile; the activation is transposed once so a lane's A column is one 16-byte load. 15-20% a call at M = 8 (N=34816 K=5120 518 -> 463 us, N=5120 K=17408 312 -> 249 us). Same products: rel_l2 at most 1.46e-3 as before (185/185 model cases). XE2_M2_JM=1 keeps the local-memory form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
1 parent
84732432c0
commit
b0e34c6324
3 files changed
+114
-5
No files matched your search
@@ -18,6 +18,13 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
/* The SPIR-V builtin behind dpas_f16 below, declared at global scope so it keeps its name. */
|
||||
typedef short xe2_short8 __attribute__((ext_vector_type(8)));
|
||||
typedef int xe2_int8 __attribute__((ext_vector_type(8)));
|
||||
typedef float xe2_float8 __attribute__((ext_vector_type(8)));
|
||||
extern SYCL_EXTERNAL xe2_float8 __spirv_SubgroupMatrixMultiplyAccumulateINTEL(int, xe2_short8, xe2_int8,
|
||||
xe2_float8, int);
|
||||
|
||||
namespace xe2 {
|
||||
|
||||
namespace syclex = sycl::ext::oneapi::experimental;
|
||||
@@ -64,6 +71,14 @@ int xmx_f16_scaled(sycl::queue& q, const sycl::half* ab, int64_t ars, const sycl
|
||||
char* yb, uint32_t ydt, int64_t yrs, int64_t ycs, int64_t M, int64_t mpad, int64_t N,
|
||||
int64_t K, const float* rs, const float* cs);
|
||||
|
||||
/* One DPAS on operands held in registers (SPV_INTEL_subgroup_matrix_multiply_accumulate; libxe2's
|
||||
* link enables it), sub-group 16, fp16 8x16 by 16x16 into f32: lane k holds A[0..7][k] in `a`, lane
|
||||
* n holds B's column n as eight dwords of pairs (B[2i][n], B[2i+1][n]) in `b`, and C[0..7][n] in
|
||||
* `c`. joint_matrix reaches the same instruction only through memory. */
|
||||
inline xe2_float8 dpas_f16(xe2_short8 a, xe2_int8 b, xe2_float8 c) {
|
||||
return __spirv_SubgroupMatrixMultiplyAccumulateINTEL(16, a, b, c, 0xC00); /* A, B packed fp16 */
|
||||
}
|
||||
|
||||
/* Runs `submit`, turning a SYCL exception into RAD_E_DEVICE with its message. */
|
||||
template <typename F>
|
||||
int submit(F&& f) {
|
||||
|
||||
Reference in new issue
Block a user