fla-core 0.3.2__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fla_core-0.3.2 → fla_core-0.4.0}/PKG-INFO +16 -11
- {fla_core-0.3.2 → fla_core-0.4.0}/README.md +15 -10
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/__init__.py +1 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/activations.py +17 -9
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/convolution.py +35 -10
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/fused_bitlinear.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/fused_norm_gate.py +5 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/grpo.py +5 -3
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/l2norm.py +9 -5
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/layernorm.py +5 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/rotary.py +2 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/token_shift.py +7 -3
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/__init__.py +2 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/attn/decoding.py +2 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/comba/utils.py +5 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/comba/wy_fast.py +5 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/chunk_delta_h.py +54 -46
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/chunk_h.py +9 -7
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/chunk_h_parallel.py +11 -6
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/chunk_h_split.py +5 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/chunk_o.py +46 -36
- fla_core-0.4.0/fla/ops/common/chunk_scaled_dot_kkt.py +126 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/fused_chunk.py +10 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/fused_recurrent.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/delta_rule/parallel.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/delta_rule/wy_fast.py +3 -1
- fla_core-0.4.0/fla/ops/deltaformer/__init__.py +9 -0
- fla_core-0.4.0/fla/ops/deltaformer/invcum.py +38 -0
- fla_core-0.4.0/fla/ops/deltaformer/naive.py +152 -0
- fla_core-0.4.0/fla/ops/deltaformer/parallel.py +993 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_product/chunk_deltaproduct_h.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_product/chunk_deltaproduct_o.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_rule/chunk.py +5 -20
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_rule/fused_recurrent.py +8 -6
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_rule/wy_fast.py +112 -105
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/chunk.py +16 -19
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/chunk_A_bwd.py +4 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/chunk_A_fwd.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/chunk_h_bwd.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/chunk_h_fwd.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/chunk_o_bwd.py +7 -4
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/chunk_o_fwd.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/fused_recurrent.py +2 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/wy_fast_bwd.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/wy_fast_fwd.py +6 -3
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/iplr/chunk.py +16 -10
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/iplr/fused_recurrent.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/iplr/wy_fast.py +9 -6
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gla/chunk.py +172 -148
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gsa/chunk.py +10 -8
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/hgrn/chunk.py +5 -3
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/hgrn/fused_recurrent.py +5 -3
- fla_core-0.4.0/fla/ops/kda/__init__.py +7 -0
- fla_core-0.4.0/fla/ops/kda/chunk.py +351 -0
- fla_core-0.4.0/fla/ops/kda/chunk_inter.py +188 -0
- fla_core-0.4.0/fla/ops/kda/chunk_intra.py +540 -0
- fla_core-0.4.0/fla/ops/kda/fused_recurrent.py +114 -0
- fla_core-0.4.0/fla/ops/kda/gate.py +349 -0
- fla_core-0.4.0/fla/ops/kda/naive.py +102 -0
- fla_core-0.4.0/fla/ops/kda/wy_fast.py +304 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/linear_attn/utils.py +2 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/log_linear_attn/chunk.py +7 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/chunk_h_fwd.py +5 -3
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/chunk_h_kv_intra_bwd.py +2 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/chunk_h_kv_intra_bwd_separate.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/nsa/compression.py +4 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/nsa/parallel.py +5 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/cumprod_householder_bwd.py +0 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/cumprod_householder_fwd.py +1 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/intra_chunk_preprocess_bwd.py +5 -4
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/intra_chunk_preprocess_bwd_prepare.py +15 -27
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/intra_chunk_preprocess_fwd.py +17 -15
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/parallel.py +19 -10
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv6/chunk.py +20 -5
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv6/fused_recurrent.py +9 -5
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv7/channel_mixing.py +10 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv7/fused_addcmul.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv7/fused_k_update.py +9 -5
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv7/fused_recurrent.py +2 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv7/gate_output_correction.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/simple_gla/parallel.py +3 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/ttt/chunk.py +8 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/ttt/fused_chunk.py +4 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/cumsum.py +9 -5
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/index.py +2 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/logcumsumexp.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/logsumexp.py +3 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/matmul.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/pack.py +3 -2
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/pooling.py +5 -3
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/softmax.py +5 -3
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/solve_tril.py +4 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/utils.py +6 -1
- {fla_core-0.3.2 → fla_core-0.4.0}/fla_core.egg-info/PKG-INFO +16 -11
- {fla_core-0.3.2 → fla_core-0.4.0}/fla_core.egg-info/SOURCES.txt +12 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/pyproject.toml +1 -1
- fla_core-0.3.2/fla/ops/common/chunk_scaled_dot_kkt.py +0 -305
- {fla_core-0.3.2 → fla_core-0.4.0}/LICENSE +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/feature_map.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/fused_cross_entropy.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/fused_kl_div.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/fused_linear_cross_entropy.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/l2warp.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/layernorm_gated.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/mlp.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/modules/parallel.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/abc/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/abc/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/abc/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/attn/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/attn/parallel.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/based/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/based/fused_chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/based/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/based/parallel.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/comba/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/comba/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/comba/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/common/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/delta_rule/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/delta_rule/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/delta_rule/fused_chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/delta_rule/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/delta_rule/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/forgetting_attn/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/forgetting_attn/parallel.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_product/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_product/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_product/chunk_ref.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_product/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gated_delta_rule/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/dplr/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/iplr/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/generalized_delta_rule/iplr/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gla/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gla/fused_chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gla/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gla/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gsa/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gsa/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/gsa/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/hgrn/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/hgrn/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/lightning_attn/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/lightning_attn/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/lightning_attn/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/linear_attn/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/linear_attn/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/linear_attn/fused_chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/linear_attn/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/linear_attn/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/log_linear_attn/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/log_linear_attn/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/chunk_cg_solver_bwd.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/chunk_cg_solver_fwd.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/chunk_h_kk_intra_bwd.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/decoding_one_step.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/mesa_net/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/nsa/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/nsa/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/nsa/utils.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/parallel_path_bwd_inter_dkv.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/parallel_path_bwd_inter_dqh.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/parallel_path_bwd_intra.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/parallel_path_fwd.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/prepare_k_cache.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/path_attn/transform_q.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rebased/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rebased/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rebased/parallel.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/retention/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/retention/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/retention/fused_chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/retention/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/retention/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/retention/parallel.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv4/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv4/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv6/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv6/chunk_naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv6/recurrent_naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv7/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/rwkv7/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/simple_gla/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/simple_gla/chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/simple_gla/fused_chunk.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/simple_gla/fused_recurrent.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/simple_gla/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/titans/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/titans/log_impl.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/titans/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/ttt/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/ttt/naive.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/__init__.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/constant.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla/ops/utils/op.py +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla_core.egg-info/dependency_links.txt +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla_core.egg-info/requires.txt +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/fla_core.egg-info/top_level.txt +0 -0
- {fla_core-0.3.2 → fla_core-0.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fla-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Core operations for flash-linear-attention
|
|
5
5
|
Project-URL: Homepage, https://github.com/fla-org/flash-linear-attention
|
|
6
6
|
Project-URL: Repository, https://github.com/fla-org/flash-linear-attention
|
|
@@ -38,12 +38,13 @@ This repo aims at providing a collection of efficient Triton-based implementatio
|
|
|
38
38
|
* [Benchmarks](#benchmarks)
|
|
39
39
|
* [Citation](#citation)
|
|
40
40
|
* [Star History](#star-history)
|
|
41
|
-
* [
|
|
41
|
+
* [Acknowledgements](#acknowledgements)
|
|
42
42
|
|
|
43
43
|
## News
|
|
44
44
|
|
|
45
|
-
- **$\texttt{[2025-
|
|
46
|
-
|
|
45
|
+
- **$\texttt{[2025-10]}$:** 🌑 Add Kimi Delta Attention implementation to `fla`.
|
|
46
|
+
- **$\texttt{[2025-09]}$:** 🌲 Add DeltaFormer implementation to `fla` ([paper](https://arxiv.org/abs/2505.19488v1)).
|
|
47
|
+
- **$\texttt{[2025-09]}$:** 🐻 Thrilled to announce that [GDN](fla/ops/gated_delta_rule) has been integrated into Qwen3-Next. Check out their [blog post](https://qwen.ai/blog?id=4074cca80393150c248e508aa62983f9cb7d27cd&from=research.latest-advancements-list) for more infos!
|
|
47
48
|
- **$\texttt{[2025-08]}$:** 🌲 Add Log-Linear Attention implementation to `fla` ([paper](https://arxiv.org/abs/2506.04761)).
|
|
48
49
|
- **$\texttt{[2025-08]}$:** 🎓 Add MoM implementation to `fla` ([paper](https://arxiv.org/abs/2502.13685)).
|
|
49
50
|
- **$\texttt{[2025-07]}$:** 🐳 Add MLA implementation to `fla` ([paper](https://arxiv.org/abs/2405.04434)).
|
|
@@ -99,6 +100,7 @@ Roughly sorted according to the timeline supported in `fla`. The recommended tra
|
|
|
99
100
|
| 2025 | | PaTH | [PaTH Attention: Position Encoding via Accumulating Householder Transformations](https://arxiv.org/abs/2505.16381) | | [fla](https://github.com/fla-org/flash-linear-attention/blob/main/fla/layers/path_attn.py) |
|
|
100
101
|
| 2025 | | MoM | [MoM: Linear Sequence Modeling with Mixture-of-Memories](https://arxiv.org/abs/2502.13685) | [official](https://github.com/OpenSparseLLMs/MoM) | [fla](https://github.com/fla-org/flash-linear-attention/blob/main/fla/layers/mom.py) |
|
|
101
102
|
| 2025 | | Log-Linear Attention | [Log-Linear Attention](https://arxiv.org/abs/2506.04761) | [official](https://github.com/HanGuo97/log-linear-attention) | [fla](https://github.com/fla-org/flash-linear-attention/tree/main/fla/ops/log_linear_attn) |
|
|
103
|
+
| 2025 | | DeltaFormer | [Understanding Transformer from the Perspective of Associative Memory](https://arxiv.org/abs/2505.19488v1) | | [fla](https://github.com/fla-org/flash-linear-attention/blob/main/fla/layers/deltaformer.py) |
|
|
102
104
|
|
|
103
105
|
## Installation
|
|
104
106
|
|
|
@@ -110,16 +112,18 @@ The following requirements should be satisfied
|
|
|
110
112
|
- [einops](https://einops.rocks/)
|
|
111
113
|
- [transformers](https://github.com/huggingface/transformers) >=4.45.0
|
|
112
114
|
- [datasets](https://github.com/huggingface/datasets) >=3.3.0
|
|
113
|
-
|
|
115
|
+
|
|
116
|
+
Starting from v0.3.2, the packages published on PyPI are `fla-core` and `flash-linear-attention`. The former contains all our customized kernels and only depends on PyTorch, Triton, and einops. The latter is an extension package of the former, containing `fla/layers` and `fla/models`, and depends on transformers. We also provide Triton implementations for conv1d operations, so causal-conv1d is not required.
|
|
114
117
|
|
|
115
118
|
You can install `fla` with pip:
|
|
116
119
|
```sh
|
|
117
120
|
pip install flash-linear-attention
|
|
118
121
|
```
|
|
119
|
-
|
|
122
|
+
|
|
123
|
+
As `fla` is actively developed now, for the latest features and updates, an alternative way is to install the package from source. Note that installing from git uses the default mode, so you need to uninstall both `fla-core` and `flash-linear-attention` first:
|
|
120
124
|
```sh
|
|
121
|
-
# uninstall
|
|
122
|
-
pip uninstall flash-linear-attention && pip install -U git+https://github.com/fla-org/flash-linear-attention
|
|
125
|
+
# uninstall both packages first to ensure a successful upgrade
|
|
126
|
+
pip uninstall fla-core flash-linear-attention -y && pip install -U git+https://github.com/fla-org/flash-linear-attention
|
|
123
127
|
```
|
|
124
128
|
or manage `fla` with submodules
|
|
125
129
|
```sh
|
|
@@ -130,7 +134,8 @@ ln -s 3rdparty/flash-linear-attention/fla fla
|
|
|
130
134
|
If you have installed `triton-nightly` and `torch` pre version, please use the following command:
|
|
131
135
|
```sh
|
|
132
136
|
pip install einops ninja datasets transformers numpy
|
|
133
|
-
|
|
137
|
+
# uninstall both packages first to ensure a successful upgrade
|
|
138
|
+
pip uninstall fla-core flash-linear-attention -y && pip install -U --no-use-pep517 git+https://github.com/fla-org/flash-linear-attention --no-deps
|
|
134
139
|
```
|
|
135
140
|
|
|
136
141
|
|
|
@@ -570,6 +575,6 @@ If you find this repository helpful, please cite our work:
|
|
|
570
575
|
|
|
571
576
|
[](https://star-history.com/#fla-org/flash-linear-attention&Date)
|
|
572
577
|
|
|
573
|
-
##
|
|
578
|
+
## Acknowledgements
|
|
574
579
|
|
|
575
|
-
We extend our gratitude to [Bitdeer](https://www.bitdeer.com/) for
|
|
580
|
+
We extend our gratitude to [Bitdeer](https://www.bitdeer.com/) and [Moonshot AI](https://www.moonshot.ai/) for their support in maintaining and powering our project infrastructure.
|
|
@@ -25,12 +25,13 @@ This repo aims at providing a collection of efficient Triton-based implementatio
|
|
|
25
25
|
* [Benchmarks](#benchmarks)
|
|
26
26
|
* [Citation](#citation)
|
|
27
27
|
* [Star History](#star-history)
|
|
28
|
-
* [
|
|
28
|
+
* [Acknowledgements](#acknowledgements)
|
|
29
29
|
|
|
30
30
|
## News
|
|
31
31
|
|
|
32
|
-
- **$\texttt{[2025-
|
|
33
|
-
|
|
32
|
+
- **$\texttt{[2025-10]}$:** 🌑 Add Kimi Delta Attention implementation to `fla`.
|
|
33
|
+
- **$\texttt{[2025-09]}$:** 🌲 Add DeltaFormer implementation to `fla` ([paper](https://arxiv.org/abs/2505.19488v1)).
|
|
34
|
+
- **$\texttt{[2025-09]}$:** 🐻 Thrilled to announce that [GDN](fla/ops/gated_delta_rule) has been integrated into Qwen3-Next. Check out their [blog post](https://qwen.ai/blog?id=4074cca80393150c248e508aa62983f9cb7d27cd&from=research.latest-advancements-list) for more infos!
|
|
34
35
|
- **$\texttt{[2025-08]}$:** 🌲 Add Log-Linear Attention implementation to `fla` ([paper](https://arxiv.org/abs/2506.04761)).
|
|
35
36
|
- **$\texttt{[2025-08]}$:** 🎓 Add MoM implementation to `fla` ([paper](https://arxiv.org/abs/2502.13685)).
|
|
36
37
|
- **$\texttt{[2025-07]}$:** 🐳 Add MLA implementation to `fla` ([paper](https://arxiv.org/abs/2405.04434)).
|
|
@@ -86,6 +87,7 @@ Roughly sorted according to the timeline supported in `fla`. The recommended tra
|
|
|
86
87
|
| 2025 | | PaTH | [PaTH Attention: Position Encoding via Accumulating Householder Transformations](https://arxiv.org/abs/2505.16381) | | [fla](https://github.com/fla-org/flash-linear-attention/blob/main/fla/layers/path_attn.py) |
|
|
87
88
|
| 2025 | | MoM | [MoM: Linear Sequence Modeling with Mixture-of-Memories](https://arxiv.org/abs/2502.13685) | [official](https://github.com/OpenSparseLLMs/MoM) | [fla](https://github.com/fla-org/flash-linear-attention/blob/main/fla/layers/mom.py) |
|
|
88
89
|
| 2025 | | Log-Linear Attention | [Log-Linear Attention](https://arxiv.org/abs/2506.04761) | [official](https://github.com/HanGuo97/log-linear-attention) | [fla](https://github.com/fla-org/flash-linear-attention/tree/main/fla/ops/log_linear_attn) |
|
|
90
|
+
| 2025 | | DeltaFormer | [Understanding Transformer from the Perspective of Associative Memory](https://arxiv.org/abs/2505.19488v1) | | [fla](https://github.com/fla-org/flash-linear-attention/blob/main/fla/layers/deltaformer.py) |
|
|
89
91
|
|
|
90
92
|
## Installation
|
|
91
93
|
|
|
@@ -97,16 +99,18 @@ The following requirements should be satisfied
|
|
|
97
99
|
- [einops](https://einops.rocks/)
|
|
98
100
|
- [transformers](https://github.com/huggingface/transformers) >=4.45.0
|
|
99
101
|
- [datasets](https://github.com/huggingface/datasets) >=3.3.0
|
|
100
|
-
|
|
102
|
+
|
|
103
|
+
Starting from v0.3.2, the packages published on PyPI are `fla-core` and `flash-linear-attention`. The former contains all our customized kernels and only depends on PyTorch, Triton, and einops. The latter is an extension package of the former, containing `fla/layers` and `fla/models`, and depends on transformers. We also provide Triton implementations for conv1d operations, so causal-conv1d is not required.
|
|
101
104
|
|
|
102
105
|
You can install `fla` with pip:
|
|
103
106
|
```sh
|
|
104
107
|
pip install flash-linear-attention
|
|
105
108
|
```
|
|
106
|
-
|
|
109
|
+
|
|
110
|
+
As `fla` is actively developed now, for the latest features and updates, an alternative way is to install the package from source. Note that installing from git uses the default mode, so you need to uninstall both `fla-core` and `flash-linear-attention` first:
|
|
107
111
|
```sh
|
|
108
|
-
# uninstall
|
|
109
|
-
pip uninstall flash-linear-attention && pip install -U git+https://github.com/fla-org/flash-linear-attention
|
|
112
|
+
# uninstall both packages first to ensure a successful upgrade
|
|
113
|
+
pip uninstall fla-core flash-linear-attention -y && pip install -U git+https://github.com/fla-org/flash-linear-attention
|
|
110
114
|
```
|
|
111
115
|
or manage `fla` with submodules
|
|
112
116
|
```sh
|
|
@@ -117,7 +121,8 @@ ln -s 3rdparty/flash-linear-attention/fla fla
|
|
|
117
121
|
If you have installed `triton-nightly` and `torch` pre version, please use the following command:
|
|
118
122
|
```sh
|
|
119
123
|
pip install einops ninja datasets transformers numpy
|
|
120
|
-
|
|
124
|
+
# uninstall both packages first to ensure a successful upgrade
|
|
125
|
+
pip uninstall fla-core flash-linear-attention -y && pip install -U --no-use-pep517 git+https://github.com/fla-org/flash-linear-attention --no-deps
|
|
121
126
|
```
|
|
122
127
|
|
|
123
128
|
|
|
@@ -557,6 +562,6 @@ If you find this repository helpful, please cite our work:
|
|
|
557
562
|
|
|
558
563
|
[](https://star-history.com/#fla-org/flash-linear-attention&Date)
|
|
559
564
|
|
|
560
|
-
##
|
|
565
|
+
## Acknowledgements
|
|
561
566
|
|
|
562
|
-
We extend our gratitude to [Bitdeer](https://www.bitdeer.com/) for
|
|
567
|
+
We extend our gratitude to [Bitdeer](https://www.bitdeer.com/) and [Moonshot AI](https://www.moonshot.ai/) for their support in maintaining and powering our project infrastructure.
|
|
@@ -7,7 +7,7 @@ import triton
|
|
|
7
7
|
import triton.language as tl
|
|
8
8
|
|
|
9
9
|
from fla.ops.utils.op import exp, log
|
|
10
|
-
from fla.utils import autocast_custom_bwd, autocast_custom_fwd, input_guard, is_amd
|
|
10
|
+
from fla.utils import autocast_custom_bwd, autocast_custom_fwd, autotune_cache_kwargs, input_guard, is_amd
|
|
11
11
|
|
|
12
12
|
try:
|
|
13
13
|
from torch.distributed.tensor import DTensor
|
|
@@ -23,7 +23,8 @@ NUM_WARPS_AUTOTUNE = [1, 2, 4, 8, 16] if is_amd else [1, 2, 4, 8, 16, 32]
|
|
|
23
23
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
24
24
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
25
25
|
],
|
|
26
|
-
key=['D']
|
|
26
|
+
key=['D'],
|
|
27
|
+
**autotune_cache_kwargs
|
|
27
28
|
)
|
|
28
29
|
@triton.jit(do_not_specialize=['T'])
|
|
29
30
|
def sigmoid_fwd_kernel(
|
|
@@ -46,7 +47,8 @@ def sigmoid_fwd_kernel(
|
|
|
46
47
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
47
48
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
48
49
|
],
|
|
49
|
-
key=['D']
|
|
50
|
+
key=['D'],
|
|
51
|
+
**autotune_cache_kwargs
|
|
50
52
|
)
|
|
51
53
|
@triton.jit(do_not_specialize=['T'])
|
|
52
54
|
def sigmoid_bwd_kernel(
|
|
@@ -101,7 +103,8 @@ sigmoid = SigmoidFunction.apply
|
|
|
101
103
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
102
104
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
103
105
|
],
|
|
104
|
-
key=['D']
|
|
106
|
+
key=['D'],
|
|
107
|
+
**autotune_cache_kwargs
|
|
105
108
|
)
|
|
106
109
|
@triton.jit(do_not_specialize=['T'])
|
|
107
110
|
def logsigmoid_fwd_kernel(
|
|
@@ -129,7 +132,8 @@ def logsigmoid_fwd_kernel(
|
|
|
129
132
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
130
133
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
131
134
|
],
|
|
132
|
-
key=['D']
|
|
135
|
+
key=['D'],
|
|
136
|
+
**autotune_cache_kwargs
|
|
133
137
|
)
|
|
134
138
|
@triton.jit(do_not_specialize=['T'])
|
|
135
139
|
def logsigmoid_bwd_kernel(
|
|
@@ -204,7 +208,8 @@ def logsigmoid(x: torch.Tensor, temperature: float = 1.) -> torch.Tensor:
|
|
|
204
208
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
205
209
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
206
210
|
],
|
|
207
|
-
key=['D']
|
|
211
|
+
key=['D'],
|
|
212
|
+
**autotune_cache_kwargs
|
|
208
213
|
)
|
|
209
214
|
@triton.jit(do_not_specialize=['T'])
|
|
210
215
|
def swish_fwd_kernel(
|
|
@@ -228,7 +233,8 @@ def swish_fwd_kernel(
|
|
|
228
233
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
229
234
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
230
235
|
],
|
|
231
|
-
key=['D']
|
|
236
|
+
key=['D'],
|
|
237
|
+
**autotune_cache_kwargs
|
|
232
238
|
)
|
|
233
239
|
@triton.jit(do_not_specialize=['T'])
|
|
234
240
|
def swish_bwd_kernel(
|
|
@@ -400,7 +406,8 @@ sqrelu = SquaredReLUFunction.apply
|
|
|
400
406
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
401
407
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
402
408
|
],
|
|
403
|
-
key=['D']
|
|
409
|
+
key=['D'],
|
|
410
|
+
**autotune_cache_kwargs
|
|
404
411
|
)
|
|
405
412
|
@triton.jit(do_not_specialize=['T'])
|
|
406
413
|
def swiglu_fwd_kernel(
|
|
@@ -428,7 +435,8 @@ def swiglu_fwd_kernel(
|
|
|
428
435
|
for bs in [512, 1024, 2048, 4096, 8192]
|
|
429
436
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
430
437
|
],
|
|
431
|
-
key=['D']
|
|
438
|
+
key=['D'],
|
|
439
|
+
**autotune_cache_kwargs
|
|
432
440
|
)
|
|
433
441
|
@triton.jit(do_not_specialize=['T'])
|
|
434
442
|
def swiglu_fwdbwd_kernel(
|
|
@@ -13,7 +13,7 @@ import triton.language as tl
|
|
|
13
13
|
from einops import rearrange
|
|
14
14
|
|
|
15
15
|
from fla.ops.utils import prepare_chunk_indices, prepare_sequence_ids
|
|
16
|
-
from fla.utils import get_multiprocessor_count, input_guard, is_amd
|
|
16
|
+
from fla.utils import autotune_cache_kwargs, get_multiprocessor_count, input_guard, is_amd
|
|
17
17
|
|
|
18
18
|
NUM_WARPS_AUTOTUNE = [2, 4, 8, 16] if is_amd else [4, 8, 16, 32]
|
|
19
19
|
STATIC_WARPS = 32 if not is_amd else 16
|
|
@@ -41,6 +41,7 @@ except ImportError:
|
|
|
41
41
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
42
42
|
],
|
|
43
43
|
key=['D', 'W', 'NB'],
|
|
44
|
+
**autotune_cache_kwargs
|
|
44
45
|
)
|
|
45
46
|
@triton.jit
|
|
46
47
|
def causal_conv1d_fwd_kernel(
|
|
@@ -71,11 +72,11 @@ def causal_conv1d_fwd_kernel(
|
|
|
71
72
|
|
|
72
73
|
if IS_VARLEN:
|
|
73
74
|
i_n, i_t = tl.load(chunk_indices + i_t * 2).to(tl.int32), tl.load(chunk_indices + i_t * 2 + 1).to(tl.int32)
|
|
74
|
-
bos, eos = tl.load(cu_seqlens + i_n), tl.load(cu_seqlens + i_n + 1)
|
|
75
|
+
bos, eos = tl.load(cu_seqlens + i_n).to(tl.int64), tl.load(cu_seqlens + i_n + 1).to(tl.int64)
|
|
75
76
|
T = eos - bos
|
|
76
77
|
else:
|
|
77
78
|
i_n = i_b
|
|
78
|
-
bos, eos = i_b * T, i_b * T + T
|
|
79
|
+
bos, eos = (i_b * T).to(tl.int64), (i_b * T + T).to(tl.int64)
|
|
79
80
|
|
|
80
81
|
o_d = i_d * BD + tl.arange(0, BD)
|
|
81
82
|
o_w = tl.arange(0, BW) + W - BW
|
|
@@ -148,6 +149,7 @@ def causal_conv1d_fwd_kernel(
|
|
|
148
149
|
for num_warps in [4, 8, 16, 32]
|
|
149
150
|
],
|
|
150
151
|
key=['D', 'W', 'NB'],
|
|
152
|
+
**autotune_cache_kwargs
|
|
151
153
|
)
|
|
152
154
|
@triton.jit
|
|
153
155
|
def causal_conv1d_bwd_kernel(
|
|
@@ -182,12 +184,12 @@ def causal_conv1d_bwd_kernel(
|
|
|
182
184
|
if IS_VARLEN:
|
|
183
185
|
i_tg = i_t
|
|
184
186
|
i_n, i_t = tl.load(chunk_indices + i_t * 2).to(tl.int32), tl.load(chunk_indices + i_t * 2 + 1).to(tl.int32)
|
|
185
|
-
bos, eos = tl.load(cu_seqlens + i_n), tl.load(cu_seqlens + i_n + 1)
|
|
187
|
+
bos, eos = tl.load(cu_seqlens + i_n).to(tl.int64), tl.load(cu_seqlens + i_n + 1).to(tl.int64)
|
|
186
188
|
T = eos - bos
|
|
187
189
|
else:
|
|
188
190
|
i_tg = i_b * tl.num_programs(1) + i_t
|
|
189
191
|
i_n = i_b
|
|
190
|
-
bos, eos = i_b * T, i_b * T + T
|
|
192
|
+
bos, eos = (i_b * T).to(tl.int64), (i_b * T + T).to(tl.int64)
|
|
191
193
|
|
|
192
194
|
o_d = i_d * BD + tl.arange(0, BD)
|
|
193
195
|
o_w = tl.arange(0, BW) + W - BW
|
|
@@ -542,10 +544,10 @@ def causal_conv1d_states_fwd_kernel(
|
|
|
542
544
|
):
|
|
543
545
|
i_d, i_n = tl.program_id(0), tl.program_id(1)
|
|
544
546
|
if IS_VARLEN:
|
|
545
|
-
bos, eos = tl.load(cu_seqlens + i_n), tl.load(cu_seqlens + i_n + 1)
|
|
547
|
+
bos, eos = tl.load(cu_seqlens + i_n).to(tl.int64), tl.load(cu_seqlens + i_n + 1).to(tl.int64)
|
|
546
548
|
T = eos - bos
|
|
547
549
|
else:
|
|
548
|
-
bos, eos = i_n * T, i_n * T + T
|
|
550
|
+
bos, eos = (i_n * T).to(tl.int64), (i_n * T + T).to(tl.int64)
|
|
549
551
|
|
|
550
552
|
o_t = eos - BW + tl.arange(0, BW)
|
|
551
553
|
o_d = i_d * BD + tl.arange(0, BD)
|
|
@@ -790,8 +792,31 @@ def causal_conv1d(
|
|
|
790
792
|
|
|
791
793
|
|
|
792
794
|
class ShortConvolution(nn.Conv1d):
|
|
793
|
-
"""
|
|
794
|
-
|
|
795
|
+
"""Short convolution layer for efficient causal convolution operations.
|
|
796
|
+
|
|
797
|
+
This class implements a depthwise separable 1D convolution with causal padding,
|
|
798
|
+
designed for efficient sequence processing. It supports multiple backends (Triton/CUDA)
|
|
799
|
+
and optional activation functions.
|
|
800
|
+
|
|
801
|
+
Args:
|
|
802
|
+
hidden_size (int): Number of input/output channels (must be equal for depthwise conv)
|
|
803
|
+
kernel_size (int): Size of the convolution kernel
|
|
804
|
+
bias (bool, optional): Whether to include learnable bias. Defaults to False.
|
|
805
|
+
activation (Optional[str], optional): Activation function ('silu' or 'swish'). Defaults to 'silu'.
|
|
806
|
+
backend (Optional[str], optional): Backend implementation ('triton' or 'cuda'). Defaults to 'triton'.
|
|
807
|
+
device (Optional[torch.device], optional): Device to place the layer on. Defaults to None.
|
|
808
|
+
dtype (Optional[torch.dtype], optional): Data type for layer parameters. Defaults to None.
|
|
809
|
+
**kwargs: Additional keyword arguments (deprecated 'use_fast_conv1d' supported for compatibility)
|
|
810
|
+
|
|
811
|
+
Attributes:
|
|
812
|
+
hidden_size (int): Number of channels
|
|
813
|
+
activation (Optional[str]): Selected activation function
|
|
814
|
+
backend (str): Actual backend being used (may differ from input due to availability)
|
|
815
|
+
|
|
816
|
+
Note:
|
|
817
|
+
- Uses depthwise convolution (groups=hidden_size) for efficiency
|
|
818
|
+
- Applies causal padding (kernel_size-1) to ensure no future information leakage
|
|
819
|
+
- Falls back to Triton backend if CUDA backend is unavailable
|
|
795
820
|
"""
|
|
796
821
|
|
|
797
822
|
def __init__(
|
|
@@ -800,7 +825,7 @@ class ShortConvolution(nn.Conv1d):
|
|
|
800
825
|
kernel_size: int,
|
|
801
826
|
bias: bool = False,
|
|
802
827
|
activation: Optional[str] = 'silu',
|
|
803
|
-
backend: Optional[str] = '
|
|
828
|
+
backend: Optional[str] = 'triton',
|
|
804
829
|
device: Optional[torch.device] = None,
|
|
805
830
|
dtype: Optional[torch.dtype] = None,
|
|
806
831
|
**kwargs,
|
|
@@ -18,7 +18,7 @@ import triton
|
|
|
18
18
|
import triton.language as tl
|
|
19
19
|
|
|
20
20
|
from fla.modules.layernorm import RMSNorm
|
|
21
|
-
from fla.utils import get_multiprocessor_count, input_guard, is_amd, require_version
|
|
21
|
+
from fla.utils import autotune_cache_kwargs, get_multiprocessor_count, input_guard, is_amd, require_version
|
|
22
22
|
|
|
23
23
|
NUM_WARPS_AUTOTUNE = [1, 2, 4, 8, 16] if is_amd else [1, 2, 4, 8, 16, 32]
|
|
24
24
|
|
|
@@ -63,6 +63,7 @@ def weight_quant(w):
|
|
|
63
63
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
64
64
|
],
|
|
65
65
|
key=["N", "HAS_RESIDUAL", "STORE_RESIDUAL_OUT", "IS_RMS_NORM", "HAS_BIAS"],
|
|
66
|
+
**autotune_cache_kwargs
|
|
66
67
|
)
|
|
67
68
|
@triton.jit
|
|
68
69
|
def layer_norm_fwd_kernel_quant(
|
|
@@ -197,6 +198,7 @@ def layer_norm_fwd_quant(
|
|
|
197
198
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
198
199
|
],
|
|
199
200
|
key=["N", "HAS_DRESIDUAL", "STORE_DRESIDUAL", "IS_RMS_NORM", "HAS_BIAS"],
|
|
201
|
+
**autotune_cache_kwargs
|
|
200
202
|
)
|
|
201
203
|
@triton.jit
|
|
202
204
|
def layer_norm_bwd_kernel(
|
|
@@ -12,7 +12,7 @@ import torch.nn.functional as F
|
|
|
12
12
|
import triton
|
|
13
13
|
import triton.language as tl
|
|
14
14
|
|
|
15
|
-
from fla.utils import get_multiprocessor_count, input_guard
|
|
15
|
+
from fla.utils import autotune_cache_kwargs, get_multiprocessor_count, input_guard
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@triton.heuristics({
|
|
@@ -28,6 +28,7 @@ from fla.utils import get_multiprocessor_count, input_guard
|
|
|
28
28
|
for num_warps in [4, 8, 16]
|
|
29
29
|
],
|
|
30
30
|
key=['D', 'NB', 'IS_RMS_NORM', 'STORE_RESIDUAL_OUT', 'HAS_RESIDUAL', 'HAS_WEIGHT'],
|
|
31
|
+
**autotune_cache_kwargs
|
|
31
32
|
)
|
|
32
33
|
@triton.jit
|
|
33
34
|
def layer_norm_gated_fwd_kernel(
|
|
@@ -116,6 +117,7 @@ def layer_norm_gated_fwd_kernel(
|
|
|
116
117
|
for num_warps in [2, 4, 8, 16]
|
|
117
118
|
],
|
|
118
119
|
key=['D', 'IS_RMS_NORM', 'STORE_RESIDUAL_OUT', 'HAS_RESIDUAL', 'HAS_WEIGHT'],
|
|
120
|
+
**autotune_cache_kwargs
|
|
119
121
|
)
|
|
120
122
|
@triton.jit
|
|
121
123
|
def layer_norm_gated_fwd_kernel1(
|
|
@@ -200,6 +202,7 @@ def layer_norm_gated_fwd_kernel1(
|
|
|
200
202
|
for num_warps in [4, 8, 16]
|
|
201
203
|
],
|
|
202
204
|
key=['D', 'NB', 'IS_RMS_NORM', 'HAS_DRESIDUAL', 'HAS_WEIGHT'],
|
|
205
|
+
**autotune_cache_kwargs
|
|
203
206
|
)
|
|
204
207
|
@triton.jit
|
|
205
208
|
def layer_norm_gated_bwd_kernel(
|
|
@@ -325,6 +328,7 @@ def layer_norm_gated_bwd_kernel(
|
|
|
325
328
|
for num_warps in [2, 4, 8, 16]
|
|
326
329
|
],
|
|
327
330
|
key=['D', 'IS_RMS_NORM', 'STORE_DRESIDUAL', 'HAS_DRESIDUAL', 'HAS_WEIGHT'],
|
|
331
|
+
**autotune_cache_kwargs
|
|
328
332
|
)
|
|
329
333
|
@triton.jit
|
|
330
334
|
def layer_norm_gated_bwd_kernel1(
|
|
@@ -55,7 +55,7 @@ import triton
|
|
|
55
55
|
import triton.language as tl
|
|
56
56
|
|
|
57
57
|
from fla.ops.utils.op import exp, log
|
|
58
|
-
from fla.utils import input_guard, is_amd
|
|
58
|
+
from fla.utils import autotune_cache_kwargs, input_guard, is_amd
|
|
59
59
|
|
|
60
60
|
NUM_WARPS_AUTOTUNE = [4, 8, 16] if is_amd else [4, 8, 16, 32]
|
|
61
61
|
|
|
@@ -67,7 +67,8 @@ NUM_WARPS_AUTOTUNE = [4, 8, 16] if is_amd else [4, 8, 16, 32]
|
|
|
67
67
|
for NUM_WARPS in NUM_WARPS_AUTOTUNE
|
|
68
68
|
for NUM_STAGES in [1, 2, 4]
|
|
69
69
|
],
|
|
70
|
-
key=['B', 'N']
|
|
70
|
+
key=['B', 'N'],
|
|
71
|
+
**autotune_cache_kwargs
|
|
71
72
|
)
|
|
72
73
|
@triton.jit
|
|
73
74
|
def grpo_fwd_kernel(
|
|
@@ -142,7 +143,8 @@ def grpo_fwd_kernel(
|
|
|
142
143
|
for NUM_WARPS in [32]
|
|
143
144
|
for NUM_STAGES in [4]
|
|
144
145
|
],
|
|
145
|
-
key=['B', 'N']
|
|
146
|
+
key=['B', 'N'],
|
|
147
|
+
**autotune_cache_kwargs
|
|
146
148
|
)
|
|
147
149
|
@triton.jit
|
|
148
150
|
def grpo_bwd_kernel(
|
|
@@ -8,7 +8,7 @@ import torch.nn as nn
|
|
|
8
8
|
import triton
|
|
9
9
|
import triton.language as tl
|
|
10
10
|
|
|
11
|
-
from fla.utils import input_guard, is_amd
|
|
11
|
+
from fla.utils import autotune_cache_kwargs, input_guard, is_amd
|
|
12
12
|
|
|
13
13
|
BT_LIST = [8, 16, 32, 64, 128]
|
|
14
14
|
NUM_WARPS_AUTOTUNE = [1, 2, 4, 8, 16] if is_amd else [1, 2, 4, 8, 16, 32]
|
|
@@ -19,7 +19,8 @@ NUM_WARPS_AUTOTUNE = [1, 2, 4, 8, 16] if is_amd else [1, 2, 4, 8, 16, 32]
|
|
|
19
19
|
triton.Config({}, num_warps=num_warps)
|
|
20
20
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
21
21
|
],
|
|
22
|
-
key=['D']
|
|
22
|
+
key=['D'],
|
|
23
|
+
**autotune_cache_kwargs
|
|
23
24
|
)
|
|
24
25
|
@triton.jit
|
|
25
26
|
def l2norm_fwd_kernel1(
|
|
@@ -49,7 +50,8 @@ def l2norm_fwd_kernel1(
|
|
|
49
50
|
triton.Config({}, num_warps=num_warps)
|
|
50
51
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
51
52
|
],
|
|
52
|
-
key=['D']
|
|
53
|
+
key=['D'],
|
|
54
|
+
**autotune_cache_kwargs
|
|
53
55
|
)
|
|
54
56
|
@triton.jit
|
|
55
57
|
def l2norm_bwd_kernel1(
|
|
@@ -81,7 +83,8 @@ def l2norm_bwd_kernel1(
|
|
|
81
83
|
for num_warps in [1, 2, 4, 8, 16]
|
|
82
84
|
for BT in BT_LIST
|
|
83
85
|
],
|
|
84
|
-
key=['D', 'NB']
|
|
86
|
+
key=['D', 'NB'],
|
|
87
|
+
**autotune_cache_kwargs
|
|
85
88
|
)
|
|
86
89
|
@triton.jit
|
|
87
90
|
def l2norm_fwd_kernel(
|
|
@@ -114,7 +117,8 @@ def l2norm_fwd_kernel(
|
|
|
114
117
|
for num_warps in [1, 2, 4, 8, 16]
|
|
115
118
|
for BT in BT_LIST
|
|
116
119
|
],
|
|
117
|
-
key=['D', 'NB']
|
|
120
|
+
key=['D', 'NB'],
|
|
121
|
+
**autotune_cache_kwargs
|
|
118
122
|
)
|
|
119
123
|
@triton.jit
|
|
120
124
|
def l2norm_bwd_kernel(
|
|
@@ -24,7 +24,7 @@ from torch.distributed import DeviceMesh
|
|
|
24
24
|
from torch.distributed.tensor import Replicate, Shard, distribute_module
|
|
25
25
|
from torch.distributed.tensor.parallel import ParallelStyle
|
|
26
26
|
|
|
27
|
-
from fla.utils import get_multiprocessor_count, input_guard
|
|
27
|
+
from fla.utils import autotune_cache_kwargs, get_multiprocessor_count, input_guard
|
|
28
28
|
|
|
29
29
|
try:
|
|
30
30
|
from torch.distributed.tensor import DTensor
|
|
@@ -184,6 +184,7 @@ class GroupNormRef(nn.Module):
|
|
|
184
184
|
for num_warps in [2, 4, 8]
|
|
185
185
|
],
|
|
186
186
|
key=['D', 'NB', 'HAS_RESIDUAL', 'STORE_RESIDUAL_OUT', 'IS_RMS_NORM'],
|
|
187
|
+
**autotune_cache_kwargs
|
|
187
188
|
)
|
|
188
189
|
@triton.jit
|
|
189
190
|
def layer_norm_fwd_kernel(
|
|
@@ -257,6 +258,7 @@ def layer_norm_fwd_kernel(
|
|
|
257
258
|
for num_warps in [2, 4, 8, 16]
|
|
258
259
|
],
|
|
259
260
|
key=['D', 'HAS_RESIDUAL', 'STORE_RESIDUAL_OUT', 'IS_RMS_NORM'],
|
|
261
|
+
**autotune_cache_kwargs
|
|
260
262
|
)
|
|
261
263
|
@triton.jit
|
|
262
264
|
def layer_norm_fwd_kernel1(
|
|
@@ -329,6 +331,7 @@ def layer_norm_fwd_kernel1(
|
|
|
329
331
|
for num_warps in [2, 4, 8]
|
|
330
332
|
],
|
|
331
333
|
key=['D', 'NB', 'HAS_DRESIDUAL', 'STORE_DRESIDUAL', 'IS_RMS_NORM'],
|
|
334
|
+
**autotune_cache_kwargs
|
|
332
335
|
)
|
|
333
336
|
@triton.jit
|
|
334
337
|
def layer_norm_bwd_kernel(
|
|
@@ -438,6 +441,7 @@ def layer_norm_bwd_kernel(
|
|
|
438
441
|
for num_warps in [2, 4, 8]
|
|
439
442
|
],
|
|
440
443
|
key=['D', 'HAS_DRESIDUAL', 'STORE_DRESIDUAL', 'IS_RMS_NORM'],
|
|
444
|
+
**autotune_cache_kwargs
|
|
441
445
|
)
|
|
442
446
|
@triton.jit
|
|
443
447
|
def layer_norm_bwd_kernel1(
|
|
@@ -10,7 +10,7 @@ import triton.language as tl
|
|
|
10
10
|
from einops import rearrange, repeat
|
|
11
11
|
|
|
12
12
|
from fla.ops.utils import prepare_chunk_indices
|
|
13
|
-
from fla.utils import get_multiprocessor_count, input_guard, is_amd
|
|
13
|
+
from fla.utils import autotune_cache_kwargs, get_multiprocessor_count, input_guard, is_amd
|
|
14
14
|
|
|
15
15
|
NUM_WARPS_AUTOTUNE = [2, 4, 8, 16] if is_amd else [2, 4, 8, 16, 32]
|
|
16
16
|
|
|
@@ -39,6 +39,7 @@ def rotary_embedding_ref(x, cos, sin, interleaved=False):
|
|
|
39
39
|
for num_stages in [2, 3, 4]
|
|
40
40
|
],
|
|
41
41
|
key=['B', 'H', 'D', 'INTERLEAVED'],
|
|
42
|
+
**autotune_cache_kwargs
|
|
42
43
|
)
|
|
43
44
|
@triton.jit(do_not_specialize=['T'])
|
|
44
45
|
def rotary_embedding_kernel(
|
|
@@ -7,7 +7,7 @@ import triton
|
|
|
7
7
|
import triton.language as tl
|
|
8
8
|
|
|
9
9
|
from fla.ops.utils import prepare_chunk_indices
|
|
10
|
-
from fla.utils import get_multiprocessor_count, input_guard, is_amd, tensor_cache
|
|
10
|
+
from fla.utils import autotune_cache_kwargs, get_multiprocessor_count, input_guard, is_amd, tensor_cache
|
|
11
11
|
|
|
12
12
|
NUM_WARPS_AUTOTUNE = [2, 4, 8, 16] if is_amd else [2, 4, 8, 16, 32]
|
|
13
13
|
|
|
@@ -59,6 +59,7 @@ def token_shift_ref(
|
|
|
59
59
|
for num_stages in [1, 2, 3]
|
|
60
60
|
],
|
|
61
61
|
key=['BD'],
|
|
62
|
+
**autotune_cache_kwargs
|
|
62
63
|
)
|
|
63
64
|
@triton.jit
|
|
64
65
|
def token_shift_fwd_kernel_short(
|
|
@@ -149,7 +150,8 @@ def token_shift_fwd_kernel_short(
|
|
|
149
150
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
150
151
|
for num_stages in [1, 2, 3]
|
|
151
152
|
],
|
|
152
|
-
key=['BD', 'NB']
|
|
153
|
+
key=['BD', 'NB'],
|
|
154
|
+
**autotune_cache_kwargs
|
|
153
155
|
)
|
|
154
156
|
@triton.jit
|
|
155
157
|
def token_shift_fwd_kernel_long(
|
|
@@ -223,6 +225,7 @@ def token_shift_fwd_kernel_long(
|
|
|
223
225
|
for num_stages in [1, 2, 3]
|
|
224
226
|
],
|
|
225
227
|
key=['BD'],
|
|
228
|
+
**autotune_cache_kwargs
|
|
226
229
|
)
|
|
227
230
|
@triton.jit
|
|
228
231
|
def token_shift_bwd_kernel_short(
|
|
@@ -299,7 +302,8 @@ def token_shift_bwd_kernel_short(
|
|
|
299
302
|
for num_warps in NUM_WARPS_AUTOTUNE
|
|
300
303
|
for num_stages in [1, 2, 3]
|
|
301
304
|
],
|
|
302
|
-
key=['BD', 'NB']
|
|
305
|
+
key=['BD', 'NB'],
|
|
306
|
+
**autotune_cache_kwargs
|
|
303
307
|
)
|
|
304
308
|
@triton.jit
|
|
305
309
|
def token_shift_bwd_kernel_long(
|
|
@@ -16,6 +16,7 @@ from .generalized_delta_rule import (
|
|
|
16
16
|
from .gla import chunk_gla, fused_chunk_gla, fused_recurrent_gla
|
|
17
17
|
from .gsa import chunk_gsa, fused_recurrent_gsa
|
|
18
18
|
from .hgrn import fused_recurrent_hgrn
|
|
19
|
+
from .kda import chunk_kda, fused_recurrent_kda
|
|
19
20
|
from .lightning_attn import chunk_lightning_attn, fused_recurrent_lightning_attn
|
|
20
21
|
from .linear_attn import chunk_linear_attn, fused_chunk_linear_attn, fused_recurrent_linear_attn
|
|
21
22
|
from .log_linear_attn import chunk_log_linear_attn
|
|
@@ -37,6 +38,7 @@ __all__ = [
|
|
|
37
38
|
'chunk_comba', 'fused_recurrent_comba',
|
|
38
39
|
'chunk_dplr_delta_rule', 'chunk_iplr_delta_rule',
|
|
39
40
|
'fused_recurrent_dplr_delta_rule', 'fused_recurrent_iplr_delta_rule',
|
|
41
|
+
'chunk_kda', 'fused_recurrent_kda',
|
|
40
42
|
'chunk_gla', 'fused_chunk_gla', 'fused_recurrent_gla',
|
|
41
43
|
'chunk_gsa', 'fused_recurrent_gsa',
|
|
42
44
|
'fused_recurrent_hgrn',
|
|
@@ -9,7 +9,7 @@ import triton.language as tl
|
|
|
9
9
|
|
|
10
10
|
from fla.ops.utils.cumsum import chunk_global_cumsum
|
|
11
11
|
from fla.ops.utils.op import exp
|
|
12
|
-
from fla.utils import check_shared_mem
|
|
12
|
+
from fla.utils import autotune_cache_kwargs, check_shared_mem
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
@triton.heuristics({
|
|
@@ -22,6 +22,7 @@ from fla.utils import check_shared_mem
|
|
|
22
22
|
for num_stages in [2, 3, 4, 5]
|
|
23
23
|
],
|
|
24
24
|
key=['H', 'G', 'K', 'V', 'BK', 'BV', 'USE_G'],
|
|
25
|
+
**autotune_cache_kwargs
|
|
25
26
|
)
|
|
26
27
|
@triton.jit
|
|
27
28
|
def naive_attn_decoding_kernel(
|
|
@@ -5,6 +5,7 @@ import triton
|
|
|
5
5
|
import triton.language as tl
|
|
6
6
|
|
|
7
7
|
from fla.ops.utils.index import prepare_chunk_indices
|
|
8
|
+
from fla.utils import autotune_cache_kwargs
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
@triton.heuristics({
|
|
@@ -15,7 +16,8 @@ from fla.ops.utils.index import prepare_chunk_indices
|
|
|
15
16
|
triton.Config({}, num_warps=num_warps)
|
|
16
17
|
for num_warps in [1, 2, 4, 8]
|
|
17
18
|
],
|
|
18
|
-
key=['B', 'H', 'BT', 'IS_VARLEN']
|
|
19
|
+
key=['B', 'H', 'BT', 'IS_VARLEN'],
|
|
20
|
+
**autotune_cache_kwargs
|
|
19
21
|
)
|
|
20
22
|
@triton.jit(do_not_specialize=['T'])
|
|
21
23
|
def chunk_comba_cumsum_scalar_fwd_kernel(
|
|
@@ -96,7 +98,8 @@ def chunk_comba_cumsum_scalar_fwd(
|
|
|
96
98
|
triton.Config({}, num_warps=num_warps)
|
|
97
99
|
for num_warps in [1, 2, 4, 8]
|
|
98
100
|
],
|
|
99
|
-
key=['B', 'H', 'BT', 'IS_VARLEN']
|
|
101
|
+
key=['B', 'H', 'BT', 'IS_VARLEN'],
|
|
102
|
+
**autotune_cache_kwargs
|
|
100
103
|
)
|
|
101
104
|
@triton.jit(do_not_specialize=['T'])
|
|
102
105
|
def chunk_comba_cumsum_scalar_bwd_kernel(
|