Repository navigation
model(lfm2): reorder short conv reshaping to avoid multiple gemv launches - #30831
anthonymaltsev wants to merge 1 commit into
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
|
can you check if |
I tried this and get very close to the exact same results as the current implementation above. At batch size 1, the reordering implementation in the PR right now is better by 1-2%, and at higher batch sizes they are within noise (+- 0.2%). I profiled this on the MI325X |
|
I think we prefer |
|
@anthonymaltsev could you please address comments? |
f4d1db5 to
6d7d32f
Compare
|
Ok double checked more carefully, and i think ggml_build_forward_order does not suffice for these changes. As I understand it, ggml_build_forward_order only reorders execution of nodes so long as data dependencies are not changed (eg ordering of computational branches), where this PR changes the order of nodes along one branch of the graph, so that the matmul operates on a 2d tensor, instead of a 3d tensor. This induces a data dependency change that is not possible to achieve with a ggml_build_forward_order change. My previous reply which suggested it was possible was actually the current reshape order swap PLUS the ggml_build_forward_order, which did nothing except defer graph node additions -- sorry for the confusion there. Can you clarify how you envisioned |
Overview
Reorder reshaping so that short conv block runs as a single gemm over all sequences instead of many separate gemv per sequences (reading weights each time). This affects batched decode primarily. Prefill is unchanged for quantized weights, but it's faster for F16/BF16 with several sequences, because it enables those to go through hipBLAS or cuBLAS.
Additional Information
Here are some benchmarking results from AMD MI325X and NVIDIA H100 comparing the base commit (0ce8cd1) against the branch, using
llama-batched-benchfor text generation (-npp 128 -ntg 128 -c 16384 -b 2048 -ub 512)MI325X:
H100:
Perplexity over wikitext remained unchanged.
Requirements