Skip to content

Commit 3d5b342

Browse files
committed
fix: added comments to the logits scaling calculation in eval_llm_1GPU
Signed-off-by: omobayode.fagbohungbe <[email protected]>
1 parent 6c1da4c commit 3d5b342

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fms_mo/utils/eval_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def eval_llm_1GPU(qcfg, model, test_dataset, pre_cache_func=None, **kwargs): #
9898
logger.info("All blocks are computed for evaluation")
9999

100100
nlls = []
101+
102+
# Required by Granite-3.X (and potentially other models) to scale their logits
101103
logits_scaling = getattr(model.config, "logits_scaling", 1)
104+
102105
# for i, data_mb in enumerate(dloader): #if using dloader.
103106
for i in tqdm(range(qcfg["n_samples"]), desc="Final Evaluating..."):
104107
hidden_states = qcfg["cached_input"][i].to(dev)
@@ -107,6 +110,8 @@ def eval_llm_1GPU(qcfg, model, test_dataset, pre_cache_func=None, **kwargs): #
107110
hidden_states = ln_f(hidden_states)
108111
lm_head.to(dev)
109112
lm_logits = lm_head(hidden_states)
113+
114+
# Scaling of the lm_head outputs to obtain the correct logits
110115
lm_logits /= logits_scaling
111116

112117
# Shift so that tokens < n predict n

0 commit comments

Comments
 (0)