Skip to content

Commit 07279c8

Browse files
committed
Patch HiddenAct::Swiglu to use SiLU activation
1 parent 11ffc60 commit 07279c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backends/candle/src/layers/linear.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ impl HiddenAct {
1616
match self {
1717
Self::Gelu => x.gelu(),
1818
Self::Relu => x.relu(),
19-
Self::Swiglu => candle_nn::ops::swiglu(x),
19+
// NOTE: use SiLU instead candle's SwiGLU, as SwiGLU is SiLU + down projection
20+
// to half size since we split on intermediate dimension
21+
Self::Swiglu => x.silu(),
2022
}
2123
}
2224
}
@@ -80,7 +82,9 @@ impl Linear {
8082
match act {
8183
HiddenAct::Gelu => x.gelu(),
8284
HiddenAct::Relu => x.relu(),
83-
HiddenAct::Swiglu => candle_nn::ops::swiglu(&x),
85+
// NOTE: use SiLU instead candle's SwiGLU, as SwiGLU is SiLU + down projection
86+
// to half size since we split on intermediate dimension
87+
HiddenAct::Swiglu => x.silu(),
8488
}
8589
} else {
8690
Ok(x)

0 commit comments

Comments
 (0)