Skip to content

Commit 78390ba

Browse files
committed
llama: add n_embd_inp_enc encoder-input hparams (DFlash dependency; extracted from upstream ggml-org#24707 minus the unrelated eagle3 fix)
1 parent 558c6b7 commit 78390ba

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/llama-context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ int llama_context::encode(const llama_batch & batch_inp) {
13831383
const auto & hparams = model.hparams;
13841384

13851385
// eagle3/DFlash: features as encoder input, and non-draft paths fall back to model's input dim
1386-
const int64_t n_embd = hparams.n_embd_inp();
1386+
const int64_t n_embd = hparams.n_embd_inp_enc();
13871387
const int64_t n_vocab = model.vocab.n_tokens();
13881388

13891389
// note: during encode, we always pass the full sequence starting from pos = 0

src/llama-hparams.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ uint32_t llama_hparams::n_embd_inp() const {
104104
return n_embd_inp;
105105
}
106106

107+
uint32_t llama_hparams::n_embd_inp_enc() const {
108+
return n_embd_inp_enc_impl > 0 ? n_embd_inp_enc_impl : n_embd_inp();
109+
}
110+
107111
uint32_t llama_hparams::n_embd_out() const {
108112
return n_embd_out_impl > 0 ? n_embd_out_impl : n_embd;
109113
}

src/llama-hparams.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ struct llama_hparams {
189189
// input embedding dimension (0 = use n_embd)
190190
uint32_t n_embd_inp_impl = 0;
191191

192+
// encoder input embedding dimension (0 = use n_embd_inp())
193+
// e.g. the eagle3 encoder fuses target_layers * target_hidden features
194+
uint32_t n_embd_inp_enc_impl = 0;
195+
192196
// output embedding dimension (0 = use n_embd)
193197
uint32_t n_embd_out_impl = 0;
194198

@@ -303,6 +307,9 @@ struct llama_hparams {
303307
// dimension of main + auxiliary input embeddings
304308
uint32_t n_embd_inp() const;
305309

310+
// dimension of the encoder input embeddings
311+
uint32_t n_embd_inp_enc() const;
312+
306313
// dimension of output embeddings
307314
uint32_t n_embd_out() const;
308315

0 commit comments

Comments
 (0)