Skip to content

Commit 898bf59

Browse files
madiatorclaude
andcommitted
fix: correct top_k=0 truthiness check and deduplicate loss_history entries
- Use `is not None` instead of truthiness check for top_k so that top_k=0 is passed through correctly instead of being replaced with -1 - Skip appending to loss_history at epoch end when the last step was already logged by per-step logging, preventing duplicate entries Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5ffddb7 commit 898bf59

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/bespokelabs/curator/finetune/trainer/tinker_trainer.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ def train(self, dataset: Any) -> TrainingResult:
339339

340340
if epoch_steps > 0:
341341
avg_epoch_loss = epoch_loss / epoch_steps
342-
loss_history.append(avg_epoch_loss)
342+
# Only append if the last step wasn't already logged by per-step logging
343+
if current_step % self.config.log_every_n_steps != 0:
344+
loss_history.append(avg_epoch_loss)
343345
logger.info(f"Epoch {epoch}/{self.config.epochs} complete. Average loss: {avg_epoch_loss:.4f}")
344346
else:
345347
avg_epoch_loss = 0.0
@@ -597,7 +599,7 @@ def sample(
597599
max_tokens=sampling_config.max_tokens,
598600
temperature=sampling_config.temperature,
599601
top_p=sampling_config.top_p,
600-
top_k=sampling_config.top_k if sampling_config.top_k else -1,
602+
top_k=sampling_config.top_k if sampling_config.top_k is not None else -1,
601603
stop=sampling_config.stop_sequences if sampling_config.stop_sequences else None,
602604
)
603605
sample_result = sampling_client.sample(prompt_input, num_samples=1, sampling_params=sample_params).result()

0 commit comments

Comments
 (0)