C.W.K.
Stream
Lesson 02 of 05 · published

Hyena Operator

~14 min · hyena, operator, icml-2023

Level 0Observer
0 XP0/50 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

한 paragraph 안의 operator

Hyena (Poli et al., 2023.2, ICML 2023, arXiv:2302.10866) 는 multiplicative gating 과 implicit long convolution 을 interleave 하는 operator 로 build. order-N Hyena operator 가 alternating sequence 로 N convolution 과 N gate 적용. 각 filter 가 positional encoding 받는 작은 FFN 으로 implicit 하게 생성.

Complexity 는 O(L · D · (log L + D)), L 은 sequence length, D 는 model dimension. log L 항이 FFT 에서. Short sequence 에서는 attention 의 O(L² · D) cost 와 비슷 (L ~ D 에 대략 비교 가능). Hyena advantage 가 sequence length 따라 scale: 8K 토큰에서 Hyena 는 attention 보다 약 2× 빠름; 64K 토큰에서 100× 빠름. Sequence 가 길수록 gap 커.

Multiplicative gating 부분

Convolution 만으로는 모델한테 attention 과 경쟁할 충분한 nonlinear capacity 안 줘. Hyena 가 convolution layer 사이에 multiplicative gating 추가: x ← x * gate(v), v 는 학습된 per-token modulator. GLU 와 SwiGLU activation 에서 보는 같은 종류 gating, 그냥 Hyena operator 안 적용. 이게 Hyena 한테 language task 에 경쟁력 있을 만한 expressive power 주는 것.

Speed 가 실제 어디서 중요한가

8K 에서 2× speedup 은 흥미롭지만 transformative 하지 않아 — FlashAttention 이 naive attention 대비 비교 가능 speedup 사. 64K 에서 100× speedup 이 Hyena 가 deployment 선택으로 중요해지기 시작하는 곳. 그리고 megabase-scale genomic sequence 에서는 비교 자체가 안 돼 — Transformer 가 그 length 에서 전혀 못 돌아, Hyena 는 가능.

Code

Hyena operator 구조 (pseudocode)·python
def hyena_operator(x, order=3):
    # x: (batch, seq_len, d_model)
    L = x.shape[1]
    positions = positional_encoding(L)
    for i in range(order):
        # Position 에서 implicit filter 생성 (작은 FFN, fixed param)
        h_i = filter_ffn(positions)         # (L,) or (L, d)
        # FFT 통해 적용 — filter 당 O(L log L)
        x = fft_conv(x, h_i)
        # per-token learned vector 사용한 multiplicative gate
        x = x * silu(linear_gate_i(x))
    return x

External links

Exercise

single-order Hyena operator (implicit-filter convolution 하나 + gate 하나) 구현하고 single GPU 에서 sequence length 1K, 8K, 32K, 128K 에서 torch.nn.MultiheadAttention 대비 벤치. wall-clock latency 그래프. ~8K 어딘가에서 Hyena 와 attention 교차 봐야 하고, 32K 에서 Hyena 가 명확히 앞서. 이게 Hyena 가 사용 가치 있을 때 결정하는 실용 curve.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.