Skip to content

Commit f114c58

Browse files
authored
Disable inplace norm to avoid GLM talking nonsense (#139)
1 parent b9a2388 commit f114c58

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

chatglm.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,14 +886,15 @@ using GLMAttention = BasicAttention<true, true, true, GLMRoper, false, GLMContex
886886

887887
using GLMMLP = BasicMLP<ACT_TYPE_GELU>;
888888

889+
// NOTE: disable inplace norm since it causes nonsense on cuda when sequence length >= 144
889890
class GLMBlock : public BasicBlock<LayerNorm, GLMAttention, GLMMLP> {
890891
public:
891892
GLMBlock() = default;
892893
GLMBlock(ModelContext *ctx, int hidden_size, int num_attention_heads, int num_kv_heads, int intermediate_size,
893894
int max_length, float norm_eps)
894-
: BasicBlock(LayerNorm(ctx, hidden_size, true, norm_eps),
895+
: BasicBlock(LayerNorm(ctx, hidden_size, false, norm_eps),
895896
GLMAttention(ctx, hidden_size, num_attention_heads, num_attention_heads, max_length),
896-
LayerNorm(ctx, hidden_size, true, norm_eps), GLMMLP(ctx, hidden_size, intermediate_size)),
897+
LayerNorm(ctx, hidden_size, false, norm_eps), GLMMLP(ctx, hidden_size, intermediate_size)),
897898
alpha_value(std::sqrt(2.f * 28)) {}
898899

899900
ggml_tensor *forward(ModelContext *ctx, ggml_tensor *hidden_states, ggml_tensor *position_ids, int n_past,

0 commit comments

Comments
 (0)