[PR #14896] runner/ollamarunner: handle sampling errors gracefully #14904

Open
opened 2026-04-13 01:05:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14896
Author: @BillionClaw
Created: 3/17/2026
Status: 🔄 Open

Base: mainHead: clawoss/fix/14882-sample-token-panic


📝 Commits (1)

  • 7d1a114 runner/ollamarunner: handle sampling errors gracefully instead of panicking

📊 Changes

1 file changed (+6 additions, -2 deletions)

View changed files

📝 runner/ollamarunner/runner.go (+6 -2)

📄 Description

Fixes #14882

Replace panics with proper error handling when token sampling or decoding fails. Previously, the server would crash with "panic: failed to sample token" when models like nemotron-3-nano returned invalid logits (e.g., NaN values).

Changes:

  • Log the error with context instead of panicking
  • Remove the sequence gracefully using DoneReasonStop
  • Continue processing other sequences normally

This prevents the entire server from crashing when a single sequence encounters a sampling error, which can happen with certain models or under specific conditions.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14896 **Author:** [@BillionClaw](https://github.com/BillionClaw) **Created:** 3/17/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `clawoss/fix/14882-sample-token-panic` --- ### 📝 Commits (1) - [`7d1a114`](https://github.com/ollama/ollama/commit/7d1a114ac2cfd70425b533142ea100528792e359) runner/ollamarunner: handle sampling errors gracefully instead of panicking ### 📊 Changes **1 file changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runner/ollamarunner/runner.go` (+6 -2) </details> ### 📄 Description Fixes #14882 Replace panics with proper error handling when token sampling or decoding fails. Previously, the server would crash with "panic: failed to sample token" when models like nemotron-3-nano returned invalid logits (e.g., NaN values). Changes: - Log the error with context instead of panicking - Remove the sequence gracefully using DoneReasonStop - Continue processing other sequences normally This prevents the entire server from crashing when a single sequence encounters a sampling error, which can happen with certain models or under specific conditions. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 01:05:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#14904