mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #261] [MERGED] Pascal sm_60 (Tesla P100, GP100): the engine builds - __dp4a as four vmad below sm_61, __grid_constant__ from sm_70 - and four GP100 decode kernels, Maya-M on four GP100 dies 21.0 -> 28.2 tok/s, the same answers #432
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#432
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mw00/project-maya/pull/261
Author: @ruibeikaa
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @mw00
Base:
main← Head:sm60-p100📝 Commits (5)
a7f3375Pascal sm_60 (Tesla P100, GP100) builds: __dp4a by name maps to four vmad below sm_61 and grid_constant drops below sm_70 - v1.1.15 stopped in six files on a P100dcd004asm_60 decode: the routed experts' IQ2_S / IQ3_XXS / IQ3_S signs from a table in shared memory - Maya-M on four GP100 dies 21.04 -> 21.58 tok/s, the same answersab8c5c5sm_60 decode: the one-column Q6_K GEMV as aligned word loads handed out by shuffles (mv_q6_p100_kernel) - Maya-M on four GP100 dies 20.99 -> 26.65 tok/s with the sign tables, the same answers8c98d09sm_60 decode: Q6_K's integer steps as exact rewrites (q - 32 in two instructions, one mul.wide.s16, the int -> float through 1.5 * 2^23) - the Q6_K GEMV 9% faster on a GP100 die, the same sumse08067csm_60 decode: moe_gate_up stages the layer input in shared memory (MAYA_GLM_GU_STAGE=0 reads it from global) - with the integer rewrites, Maya-M on four GP100 dies 26.55 -> 28.34 tok/s, the same answers📊 Changes
10 files changed (+556 additions, -30 deletions)
View changed files
📝
CMakeLists.txt(+7 -0)📝
docs/SETTINGS.md(+2 -0)➕
include/strata/kernels/dp4a.hpp(+37 -0)📝
src/kernels/cuda/exl3.cu(+1 -0)📝
src/kernels/cuda/exl3_legacy.cu(+1 -0)📝
src/kernels/cuda/glm_fast.cu(+389 -30)📝
src/kernels/cuda/iq_kernels.cu(+1 -0)📝
src/kernels/cuda/native_mmvq.cu(+1 -0)📝
src/kernels/cuda/s2_expert_grouped.cu(+1 -0)➕
tests/dp4a_sm60_test.cu(+116 -0)📄 Description
The setup accepts compute capability 6.0 since #212 and the v1.1.15 notes name the P100, but the engine does not build for one: with CUDA 12.9 and maya.py's own configure (
CMAKE_CUDA_ARCHITECTURES=native,CUDA_VISIBLE_DEVICES= the P100s) six files stop. GP100 has no dp4a (that is sm_61 and newer), andglm_fast.cu,native_mmvq.cu,s2_expert_grouped.cu,iq_kernels.cu(itsggml_cuda_dp4a),exl3.cuandexl3_legacy.cucall__dp4a("identifier__dp4ais undefined", 67 times); and nvcc refusesglm_fast.cu's 22__grid_constant__kernel arguments in any Pascal pass ("__grid_constant__annotation is only allowed for architecture compute_70 or later" - an sm_61 pass, a P40's, too). The first commit makes it build; the other four make GP100's decode faster with kernels that run on compute capability 6.0 only and give the same tokens.1. The build -
include/strata/kernels/dp4a.hppdefines__dp4abelow__CUDA_ARCH__610 as an overload set that mirrors CUDA's two integer forms - signed bytes into int (four PTXvmad.s32.s32.s32with byte selectors,VMAD.S8.S8in the SASS), unsigned bytes into unsigned (fourvmad.u32.u32.u32) - and the six files include it aftercuda_runtime.h, so their call sites compile unchanged.glm_fast.cu's kernel arguments takeSTRATA_GRID_CONSTANT:__grid_constant__from sm_70, nothing below (the same guard as on hengwen1's P40 branch). sm_61 and newer, and HIP, compile what they did: the header is empty there andSTRATA_GRID_CONSTANTis__grid_constant__(hip_compat's empty one on HIP).tests/dp4a_sm60_test.cu(registered with the GPU tests) checks__dp4aas the kernels see it against the byte-wise definition, both forms, ~1.07e9 cases each - every edge byte against every edge byte, every lane x a byte x b byte once, the rest random: 0 differ on a GP100 die (the signed form 2.1x the byte loop's speed) and on an RTX 3090 Ti (the hardware instruction).2. IQ2_S / IQ3_XXS / IQ3_S signs from a table in shared memory -
dw<T>'s__vcmpne4/__vsub4are SIMD-in-word intrinsics GP100 emulates in ~10 instructions each, in the inner loop of every routed expert. On cc 6.0moe_gate_up_kernel/moe_down_kernelload each sign byte's byte masks (and their +1s) once a block and take(g ^ m) + (m & 0x01010101)for__vsub4(g ^ m, m)- every grid byte of those types is nonzero, so the negation never carries: the same bytes. One die, 8 experts at Maya-M's decode shapes: IQ2_S gate/up 312 -> 273 us, IQ3_XXS down 167 -> 156, IQ3_S down 195 -> 185.3. The one-column Q6_K GEMV as aligned word loads (
mv_q6_p100_kernel) - Maya-M's dense weights are Q6_K (~2/3 of a decode token's bytes).mv_kernel_tran them at 135-150 GB/s of GP100's 732, bound by its loads: a lane reads its weights in seven 8- and 16-bit pieces (the 210-byte blocks are only 2-aligned). The new kernel takes R rows a warp (2 below 4096 rows in the launch, else 4), reads each row's block as 53 aligned words (two coalesced loads a lane, nothing outside the block) and hands every lane its call's fields with six shuffles, the activation staged in shared memory; each lane then makesdot_q6_K's calls inrow_dot's order with the same ints and floats. One die, us: KDA q/k/v 24576 x 4096 561 -> 389, attn_output 4096 x 16384 406 -> 279, q_b 142 -> 105, shared expert gate/up 106 -> 79, q_a + kv_a 59 -> 48, FFN 287 -> 204, the head 3466 -> 2362. It runs where the device reports compute capability 6.0 only (asked once a device);STRATA_GLM_MV_P100=0keepsmv_kernel_t,STRATA_GLM_MV_P100_R=2|4forces R (docs/SETTINGS.md).4. Q6_K's integer steps as exact rewrites (sm_60 pass only) -
q - 32per byte as(q + 0x60) ^ 0x80(q in [0, 63]: no carry) for__vsubss4's emulation,dp4a * scaleas onemul.wide.s16, the product (|p| <= 2^21) to float through the bits of 1.5 * 2^23, which is exact. Nothing while the GEMV was load-bound; with commit 3: KDA q/k/v 390 -> 352 us, attn_output 277 -> 253, the head 2285 -> 2088.5.
moe_gate_upstages the layer input in shared memory - every block reads the same q8_1 input (4.6 KB); on cc 6.0 the launch gives the kernel the room and it stages the input before the__syncthreadsit already has. IQ2_S gate/up 274 -> 256 us.STRATA_GLM_GU_STAGE=0turns it off (docs/SETTINGS.md).Every kernel was checked against the one it replaces on real shapes with synthetic data, every output compared: 0 differ.
Measured
Two PH402 SKU 200 boards - each two GP100 dies with 32 GB of HBM2 on one card (sm_60, 732 GB/s a die; this vBIOS caps a die at 1050 MHz / 140 W, below a P100's clocks) - four dies, Windows 11, driver 581.80 (TCC), CUDA 12.9, MSVC 2022. Maya-M, maya.py --bench's requests: three questions, 256 tokens each, greedy, thinking off, and prompts of 2K / 8K tokens; the engine's defaults (
--expert-cache auto,--prefill auto, the automatic layer split - every expert in VRAM) withSTRATA_GLM_RAM_GB=1. "answers" hashes the three answers' token ids together; the prompts' first tokens were [220] / [9093] in every row.mv_q6_p100_kernelOn this branch: decode 21.01 -> 28.24 tok/s, +34% (+34.0 / +34.5 / +34.8% the three questions), prompts unchanged, every answer the same token for token.
The rows for commits 2-5 were measured while the kernels were written, on the same kernel code over v1.1.15 with an equivalent sm_60 build fix (its
glm_fast.cudiffers from commit 1's in one comment), the "+ 4 + 5" row with the ggml change under "Not in this PR" built in - it touches prompts only, so that row's prompt numbers are left out; the first and last rows were measured again on this branch, one after the other. WithSTRATA_GLM_DSA_ALL=0that earlier sm_60 build gave the tokens a v1.1.11 build gave on the same machine (DSA_ALL's short-context shortcut changes them on every GPU, as its notes say).The same kernels in a longer conversation (a 12K-token prompt, then two turns adding ~1.8K tokens each, 256 tokens out each;
--prefill 1024, layer split 14,25,36,STRATA_GLM_COMPLETE_POOL=1,STRATA_GLM_RESIDENT_SKIP=1): the decode after each prompt 18.7 / 18.7 / 19.5 -> 24.3 / 24.2 / 25.2 tok/s, the same tokens.Checked
glm_fast.cualone fails for sm_61 with the 22__grid_constant__errors).tests/dp4a_sm60_test.cuon a GP100 die and an RTX 3090 Ti: 0 differ (above).__CUDA_ARCH__< 610, which HIP leaves undefined, or returns 0 / false underSTRATA_USE_HIP).Not in this PR
p40branch: theSTRATA_EXPERIMENTAL_SM60CMake option for explicit sm_6x builds, the INT8 latent records' F32 product,STRATA_DENSE_F32, IQ4_XS in the wide dequant, the draft attention's per-device shared-memory ceiling, the vision build's fatbin compression): P40-specific or not needed to build or run on a P100 with MTP drafts; the__grid_constant__guard here is the same as theirs. The shared-memory ceiling matters to GP100 too (48 KB a block) once DFlash2 drafts are used.ggml_cuda_dp4aon sm_60. A PRMT +mad.wide.s16form of that fallback (the same sums) read Maya-M's 2K / 8K prompts 7.7% / 9.3% faster on the same four dies (67.0 / 85.9 -> 72.4 / 93.9 tok/s), with the same tokens - but it is a change to ggml'scommon.cuh, so it belongs in llama.cpp, not here.-dlcm=ca(#214) changes nothing on GP100: it caches global loads in L1 by default, and the sm_60 SASS is the same with and without the flag.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.