mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #214] Pascal (sm_6x): build with three guards, cache global loads in L1 (-dlcm=ca) - P40 decode 1.7-3x, same answers #398
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#398
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?
Original Pull Request: https://github.com/mw00/project-maya/pull/214
State: closed
Merged: Yes
Follow-up to #212 (and possibly the answer to #189's first question). Maya builds for Pascal (sm_6x, e.g. the Tesla P40) with three small guards. With global loads cached in L1 it decodes 1.7-3x as fast there, with the same answers. Builds for sm_70 and newer are unchanged.
This does not change the setup:
MIN_CCstill refuses compute capability 6.x, so whether Pascal is offered stays your decision. It lets a hand-made Pascal build,CMAKE_CUDA_ARCHITECTURES=nativeasarch_setting()asks for below sm_75, compile and run at the card's speed.The change (38 lines, one topic)
glm_batch.cu: the bodies ofmla_attn_tc_kernelandmla_attn_tc_reg_kernel(nvcuda::wmma, sm_70+) compile to nothing for__CUDA_ARCH__ < 700.mla_attnalready picks the F32 kernel whenmajor < 7(tc_ok = -1, andmajor >= 7short-circuits thefits()check), so neither is ever launched there.elementwise.cu(doorbell_wait_kernel) andverify_kernels.cu(wait_flag_ge_kernel,wait_flag_ge_or_kernel):__nanosleepis sm_70+, so below that the wait is a plain spin.CMakeLists.txt: when the CUDA architectures include an sm_6x one (CMAKE_CUDA_ARCHITECTURES, orCMAKE_CUDA_ARCHITECTURES_NATIVEfornative),-Xptxas -dlcm=cais appended toCMAKE_CUDA_FLAGS, and the configure says so. GP102 / GP104 cache global loads in L2 only unless the code asks for L1 too; Volta and newer cache them in L1 by default. The GEMVs' many small loads (get_int_b2, scales, the q8_1 activations every warp of a block reads) starved there._base LESS 75refuses61), the setup, the HIP path.All three guards are under
__CUDA_ARCH__ < 700, which a build for sm_70+ never defines, and the flag needs an sm_6x architecture. Configuring on an RTX 3090 Ti withnativeand with86, the flag is in none of the compile commands. On a P40 withnative, it is in all 86 CUDA compile commands and the configure printsStrata: Pascal (sm_61): global loads cached in L1 (-Xptxas -dlcm=ca).Why: the profile
nsys profile -t cudaaround./maya.sh --bench, Maya-L on one P40, without the flag:mv_kernel_t<14>(Q6_K) was 51% of GPU time: about 150 calls a token at 563 µs, so ~84 ms of a ~150 ms token. That is a quarter of what the P40's 347 GB/s allows for the dense weights, or less.moe_fetch_kernel(17%),moe_cpu_wait_kernel(7%) andmoe_gate_up_kernel<21>(7%).Before and after:
./maya.sh --bench3x Tesla P40 24 GB (driver 580.126.20, CUDA 12.8), EPYC 7302P as a KVM guest with 32 vCPUs (no SMT siblings visible), 184 GB RAM, Debian 12, kernel 6.1. Context 32768,
--prefill auto,--kv-streaming on, the shipped expert profile, no vision. One and two GPUs use the cards at x16.-dlcm=caPrefill stays at 160-210 tok/s with or without the flag (the prompt attention runs on the F32 cores). Per-question numbers, the split lines and the report are in #212.
Same answers: I checked greedy chat answers from the builds with and without the flag (Maya-S24, one P40, three prompts of up to 200 tokens). All three are identical to the character, at 5.3-5.5 and 14.9-16.7 tok/s. The flag changes where loads are cached, not the arithmetic.
This branch's build is the measured engine:
CMAKE_CUDA_FLAGS=-Xptxas -dlcm=capassed by hand.cuobjdump -sassof both binaries is identical once the path-dependent anonymous-namespace hashes (_GLOBAL__N__<hash>) are normalised (2,944,748 lines, 0 different).Checks
On the P40 box (Linux), with the CI commands, on this branch:
tools/check_hip_compat.py: every CUDA name has a mapping (no new CUDA calls).python -m unittest discover -s serve -p "test_*.py" -t .: 189 tests OK (3 skipped).python -m unittest discover -s tools -p "test_*.py": 266 tests OK (27 skipped).The engine was built for sm_61 (P40). The 3090 Ti box only configured the branch, for
nativeand86.Not measured
glm_*_parity --selftest) on sm_61.__CUDA_ARCH__(hip_compat/leaves it undefined), so every guard is false there and today's code compiles. The wmma kernels are inside#if !defined(STRATA_USE_HIP)anyway, and the CMake change only reads CUDA architectures.🤖 Generated with Claude Code