Repository navigation
Conversation
Signed-off-by: TianHao65 <[email protected]>
… entrypoints Signed-off-by: TianHao65 <[email protected]>
| layout = (16, 16) | ||
| # keep the weight as (N, K) | ||
| layer.weight = Parameter( | ||
| shuffle_weight(weight, (16, 16)), requires_grad=False | ||
| shuffle_weight(weight, layout), requires_grad=False | ||
| ) |
There was a problem hiding this comment.
revert format only change.
| @@ -0,0 +1,2 @@ | |||
| gfx,cu_num,M,N,K,q_dtype_w,libtype,kernelId,splitK,us,kernelName,tflops,bw,errRatio | |||
| gfx942,80,4,2560,3072,torch.float8_e4m3fnuz,ck,10,0,7.1939,a8w8_bpreshuffle_128x16x32x512_16x16_16x16_32x4x1_32x4x1_1x16x1x8_4x4x1_1x1_intrawave_v1,8.75,1097.75,0.0 | |||
There was a problem hiding this comment.
CK GEMM related change It should be move to https://github.com/apinge/aiter, example: apinge/aiter#2
Existing aiter A8W8 tuned config with same M/N/K shape use libtype cktile a8w8_bpreshuffle_cktile_0x0x8x4x1x0x0x0x0x3_16x64x512_1x4x1_16x16x64_default, latency 7.4758 us.
Current PR107 aiter A8W8 tuned config use libtype ck a8w8_bpreshuffle_128x16x32x512_16x16_16x16_32x4x1_32x4x1_1x16x1x8_4x4x1_1x1_intrawave_v1, latency (7.1939us), reduce latency by (7.4758 - 7.1939) / 7.4758 = 3.7%
| gfx | cu_num | M | N | K | q_dtype_w | libtype | kernelId | splitK | us | kernelName | tflops | bw | errRatio |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| gfx942 | 80 | 4 | 2560 | 3072 | torch.float8_e4m3fnuz | cktile | 143 | 0 | 7.4758 | a8w8_bpreshuffle_cktile_0x0x8x4x1x0x0x0x0x3_16x64x512_1x4x1_16x16x64_default | 8.42 | 1056.35 | 0.0 |
| @@ -0,0 +1,5 @@ | |||
| gfx,cu_num,M,N,K,bias,dtype,outdtype,scaleAB,bpreshuffle,libtype,solidx,splitK,us,kernelName,err_ratio,tflops,bw | |||
There was a problem hiding this comment.
You may need specify export AITER_CONFIG_GEMM_BF16="$PTPC_TABLE.csv" in server launch scripts in https://github.com/apinge/sglang/tree/qwen4_v0.5.21/evaluation to invoke the tuned tgemm config for model serving.
Otherwise, CI perf run will not use tuned tgemm, hence it shows no obvious perf gain.
| if len(input) not in (2, 3): | ||
| raise ValueError("FP8 PTPC input must be a two- or three-element tuple") | ||
| q_input, x_scale = input[:2] | ||
| if not isinstance(q_input, torch.Tensor) or q_input.ndim == 0: | ||
| raise ValueError("FP8 PTPC input must have a hidden dimension") | ||
| if weight.ndim != 2 or q_input.shape[-1] != weight.shape[1]: | ||
| raise ValueError("FP8 PTPC packed weight must have shape [N, K]") | ||
| leading_shape = q_input.shape[:-1] | ||
| out_dtype = input[2] if len(input) > 2 else torch.bfloat16 | ||
| q_input = q_input.reshape(-1, q_input.shape[-1]).contiguous() | ||
| num_tokens = q_input.shape[0] | ||
| if not isinstance(x_scale, torch.Tensor): | ||
| raise ValueError("FP8 PTPC activation scale must be a tensor") | ||
| # Remember the producer's scale layout before broadcasting a scalar. | ||
| per_token_scales = x_scale.numel() == num_tokens | ||
| if x_scale.numel() == 1 and num_tokens > 1: | ||
| x_scale = x_scale.reshape(1, 1).expand(num_tokens, 1).contiguous() | ||
| elif not per_token_scales: | ||
| raise ValueError("FP8 PTPC activation scale must be scalar or per-token") | ||
| elif x_scale.shape != (num_tokens, 1) or not x_scale.is_contiguous(): | ||
| x_scale = x_scale.reshape(num_tokens, 1).contiguous() | ||
| if ( | ||
| not isinstance(weight_scale, torch.Tensor) | ||
| or weight_scale.numel() != weight.shape[0] | ||
| ): | ||
| raise ValueError("FP8 PTPC weight scale must have one value per channel") | ||
| if ( | ||
| weight_scale.shape != (weight.shape[0], 1) | ||
| or not weight_scale.is_contiguous() | ||
| ): | ||
| weight_scale = weight_scale.reshape(-1, 1).contiguous() | ||
| output_shape = [*leading_shape, weight.shape[0]] |
There was a problem hiding this comment.
Can we simplify this precondition check logic?
What
Closes #88; follows #63 on
qwen4_v0.5.21(9ac4ebe). Route supported FP8/BF16 prefill through AITER tgemm, retain CK for FP8M <= 16decode, and preserve dense BF16 weights for DFlash. Include validated tuning and reproduction tools.f315e8d05cd615The two linear flags default off. Use the tuning kit to merge selected rows into complete AITER tables.
Data
Nov12 local prototype CI: PR63
8511084989b4→ same source plus tgemm and accepted tables. MI308X/PTL34 and PTL52; Torch 2.12 / ROCm 7.14, AITER514c166, pyhip8027faa, clientfc6ddbb. Con1, random inputs, configured 12000/350 for Qwen3.8 and 8000/500 for Qwen3.5; 10 warmups,128 performance requests and200 GSM8K questions per case/arm. One startup/arm; cross-start noise unestimated. Both arms use the flags above. These results predate final integration/tuple fixes; percentages use unrounded values.35B/TP4's +10.29% mean ETE regression includes a sustained late slowdown; its trigger remains unresolved.
Follow-ups: two starts/arm in ABBA order, con1. Nov10 changes only tuning tables on image
4d63dea/ PTL34: Qwen3.8 TP2, generator means 11000/350, sigma=4, prefix=0.35, MTP/radix on. Nov16 repeats the frozen851 source pair on PTL52: 35B TP4, 8000/500, seed42, radix off, decode Graph on. Both use pool262144; values average the two startup metrics.The initial untuned Qwen3.8 TP2 prototype regressed ETE by 3.52% versus transplanted PR63. The after-only large-pool 35B control measured 2620.343ms ETE; it does not establish the old slowdown's cause. Full comparisons, QPS/acceptance, gates and protocols retain these distinct baselines, all tuning candidates and unmeasured configurations. Custom 11K/350 specifies generator means, not exact token lengths or cache hit rates.
Benchmarking and Profiling
Complete original traces: frozen851 before/prototype after, Quark Qwen3.5-35B, TP1/rank0/PTL52 GPU6, identical 8000 input IDs/64 output tokens, con1, two warmups/start, decode Graph on, radix off. These operator samples are separate from model ETE and final-head CI.
Prefill shapes use CPU/GPU External-id matching; decode shapes/layer attribution are inferred from the original graph/source order. Read each GPU row, not summed overlapping scopes.
Prefill
Before:
Open prefill before in Perfetto.
After:
Open prefill after in Perfetto.
Decode
Before:
Open decode before in Perfetto.
After:
Open decode after in Perfetto.
Complete originals, sample positions and SHA256.
Validation
f315e8d, unchanged in05cd615: 8 CPU regressions,16 native caller cases/32 changed-input Graph replays passed (max relative L2 0.002740). The tuning kit's 10 CPU checks and changed-file syntax/isort/Ruff/registry checks passed. Repository-wide registry retains an unchanged base taxonomy error intest_pyhip_qsa.py.Final-head six-model GPU CI, daily pressure and full 1319-question GSM8K remain unmeasured.