[PR #9202] [CLOSED] model: add a test for model forward pass during implementation #38760

Closed
opened 2026-04-22 23:25:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/9202
Author: @BruceMacD
Created: 2/18/2025
Status: Closed

Base: mainHead: brucemacd/forward-test


📝 Commits (1)

  • 31d04eb model: add a test for model forward pass during implementation

📊 Changes

4 files changed (+158 additions, -0 deletions)

View changed files

📝 .gitignore (+3 -0)
model/model_external_test.go (+138 -0)
model/testdata/models/README.md (+10 -0)
model/testdata/models/qwen2_5.json (+7 -0)

📄 Description

This PR introduces a new testing framework for validating model forward pass behavior using JSON-specified test cases. It helps developers verify their model implementations by running simple prompts through the model and checking the output matches expected patterns, without doing a full re-build and serve.

How to use

  1. Add your model file (.gguf) to model/testdata/models/
  2. Create a corresponding JSON file with the same name (e.g. mymodel.gguf -> mymodel.json) containing:
    {
      "prompt": "your test prompt",
      "output_contains_one": ["expected substring 1", "expected substring 2"]
    }
    
  3. Run tests with go test ./model -run TestForwardSimple

The test will load each model file found, run the specified prompt through a forward pass using greedy sampling, and verify the output contains at least one of the expected substrings.

Why this is useful

When implementing support for a new model architecture, this provides a way to quickly verify the forward pass is working correctly before integrating it into the full system. The JSON test specification makes it easy to add new test cases without modifying code.

The current example demonstrates this with a Qwen 2.5 test that verifies the model can properly handle the greeting "hi" and respond appropriately.


🔄 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/9202 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 2/18/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `brucemacd/forward-test` --- ### 📝 Commits (1) - [`31d04eb`](https://github.com/ollama/ollama/commit/31d04eb7950e058c598f997c51bac1391b715ca5) model: add a test for model forward pass during implementation ### 📊 Changes **4 files changed** (+158 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+3 -0) ➕ `model/model_external_test.go` (+138 -0) ➕ `model/testdata/models/README.md` (+10 -0) ➕ `model/testdata/models/qwen2_5.json` (+7 -0) </details> ### 📄 Description This PR introduces a new testing framework for validating model forward pass behavior using JSON-specified test cases. It helps developers verify their model implementations by running simple prompts through the model and checking the output matches expected patterns, without doing a full re-build and serve. ## How to use 1. Add your model file (`.gguf`) to `model/testdata/models/` 2. Create a corresponding JSON file with the same name (e.g. `mymodel.gguf` -> `mymodel.json`) containing: ```json { "prompt": "your test prompt", "output_contains_one": ["expected substring 1", "expected substring 2"] } ``` 3. Run tests with `go test ./model -run TestForwardSimple` The test will load each model file found, run the specified prompt through a forward pass using greedy sampling, and verify the output contains at least one of the expected substrings. ## Why this is useful When implementing support for a new model architecture, this provides a way to quickly verify the forward pass is working correctly before integrating it into the full system. The JSON test specification makes it easy to add new test cases without modifying code. The current example demonstrates this with a Qwen 2.5 test that verifies the model can properly handle the greeting "hi" and respond appropriately. --- <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-22 23:25:35 -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#38760