Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

Add prefil decode in expectations#452

Open
nirajkamal wants to merge 22 commits intofoundation-model-stack:mainfoundation-model-stack/foundation-model-stack:mainfrom
nirajkamal:Add_Prefil_Decode_in_Expectationsnirajkamal/foundation-model-stack:Add_Prefil_Decode_in_ExpectationsCopy head branch name to clipboard
Open

Add prefil decode in expectations#452
nirajkamal wants to merge 22 commits intofoundation-model-stack:mainfoundation-model-stack/foundation-model-stack:mainfrom
nirajkamal:Add_Prefil_Decode_in_Expectationsnirajkamal/foundation-model-stack:Add_Prefil_Decode_in_ExpectationsCopy head branch name to clipboard

Conversation

@nirajkamal
Copy link

@nirajkamal nirajkamal commented Jul 15, 2025

Overview

This PR introduces a modular and approach to model testing by separating forward pass and generation tests. It adds the handling of generative models (e.g., causal language models like LLaMA) while maintaining compatibility for non-generative models.


Changes

1. Test Structure Refactoring

  • test_model_forward(): Tests only the forward pass signature (renamed from test_model_output).
  • test_model_generation(): New dedicated test for generation testing (1 prefill + 1 decode).
  • test_model_output(): Maintained for backward compatibility, delegates to test_model_forward().

2. Generation Testing

  • _supports_generation: Class attribute to enable generation testing (set to True in test classes).
  • _get_generation_signature():
    • Performs 2-token generation using generate() with greedy sampling.
    • Captures logits for prefill and decode steps.
    • Applies the same signature compression as get_signature() (max-min normalization).
  • Generation signature: Concatenates prefill + decode logits, uses consistent signature pattern.

3. Independent Expectation Files

  • Forward pass: models.test_llama.TestLlama2.test_model_forward.
  • Generation: models.test_llama.TestLlama2.test_model_generation.
  • Each test maintains separate expectations for cleaner separation of concerns.

Usage

Capture New Expectations

# Capture forward pass expectations
CUDA_VISIBLE_DEVICES=-1 python -m pytest tests/models/test_llama.py::TestLlama2::test_model_forward -v -s --capture_expectation

# Capture generation expectations  
CUDA_VISIBLE_DEVICES=-1 python -m pytest tests/models/test_llama.py::TestLlama2::test_model_generation -v -s --capture_expectation

Test

# Forward pass test
CUDA_VISIBLE_DEVICES=-1 python -m pytest tests/models/test_llama.py::TestLlama2::test_model_forward -v -s 

# Generation test
CUDA_VISIBLE_DEVICES=-1 python -m pytest tests/models/test_llama.py::TestLlama2::test_model_generation -v -s 

@spzala @JRosenkranz

fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@JRosenkranz JRosenkranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirajkamal This is a great start, I think we will want to separate test_model_output and test_model_generation into 2 separate tests that both capture different output. test_model_output would continue to get the signature from model forward, whereas test_model_generation would get some compressed form of the logits from prefill + decode.

fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
tests/models/test_llama.py Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@JRosenkranz JRosenkranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once a new model test is added specifically for generation, as part of this PR can you capture expectations for the generation test

fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
fms/testing/_internal/model_test_suite.py Outdated Show resolved Hide resolved
tests/models/test_llama.py Show resolved Hide resolved
@nirajkamal
Copy link
Author

nirajkamal commented Sep 12, 2025

@JRosenkranz @ani300 I tried to resolve all the comments - If possible please look into it. Also need help capturing logits with bamba model. If possible please try. (was moving cities and school start thus the delay)

Ill add captured logits once everything is okay!

@nirajkamal nirajkamal force-pushed the Add_Prefil_Decode_in_Expectations branch from ede30f8 to 06e8ad8 Compare September 15, 2025 02:18
@nirajkamal nirajkamal marked this pull request as ready for review September 15, 2025 02:22
@nirajkamal
Copy link
Author

nirajkamal commented Sep 15, 2025

I tried to rebase to resolve a signoff check - seems like it messes up the PR. Please let me know if the code looks okay, will make a clean branch from main to push the changes.

@nirajkamal nirajkamal force-pushed the Add_Prefil_Decode_in_Expectations branch from 06e8ad8 to ede30f8 Compare September 15, 2025 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.