Conversation
…ttention Recurrent lightning attention with an indexed state pool: S <- exp(-slope) * S + k^T v ; out = q @ S. Includes the operator interface, a CPU reference implementation, an NVIDIA CUDA kernel, and pytest coverage for float32/float16/bfloat16 on both backends (validated on sm_120).
Compose aclnn Mul, Matmul and Add over a per-request workspace row. The source state row is staged before the recurrence and written back only after all tokens, preserving the read-only source-row contract for MiniMax lightning attention on Ascend.
Use KEEP_DTYPE for float32 aclnnMatmul so the 910B output projection does not silently downcast FP32 and exceed the operator tolerance.
Author
|
Closing this PR because the source branch does not follow the required Reopening from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
LightningAttentionInfinilm, an InfiniLM-specific indexed-pool lightning attention operator.Add the shared operator interface and metadata in
src/base/lightning_attention_infinilm.h.Add a CPU reference implementation in
src/native/cpu/ops/lightning_attention_infinilm/lightning_attention_infinilm.h.Add CUDA device kernel, launcher, and NVIDIA vendor binding under
src/native/cuda/andsrc/native/cuda/nvidia/.Add an Ascend ACLNN implementation in
src/native/ascend/ops/lightning_attention_infinilm/kernel.h.Add pytest coverage in
tests/test_lightning_attention_infinilm.py.Motivation
MiniMax-style linear attention uses a recurrent lightning-attention state with a per-head decay and an indexed state pool:
ratio = exp(-slope)
state = ratio * state + outer(k_t, v_t)
out_t = q_t @ state
PyTorch has no directly corresponding operator. The closest public reference is Flash-Linear-Attention's
fused_recurrent_lightning_attn, but this implementation also has the InfiniLM-specific indexed state-pool contract.The operator is needed by the MiniMax model support work in InfiniLM.
Closes #
Type of Change
feat— new feature / new operator / new platformfix— bug fixperf— performance improvement (no behavioral change)refactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changes!in the Conventional Commits prefix or aBREAKING CHANGE:footer)Platforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Affected-platform builds succeeded.
Operator-specific smoke commands and results: