Fix issue 3355 assertion error - #3356
Merged
baberabb merged 8 commits intoNov 9, 2025
Merged
Conversation
…rse_logprobs Fixes the AssertionError in Collator.get_original() that occurred when API responses contain None values. The issue was that the code skipped None values when building the result list, causing a mismatch between the expected number of items and actual items, triggering the assertion. Changes: - generate_until: Always append results, converting None to empty string - _loglikelihood_tokens: Always append results, converting None to (-inf, False) - Applied fix to both sequential and concurrent code paths The fix ensures: 1. Result lists always have the correct number of items for reordering 2. None values are converted to sensible defaults instead of being skipped 3. Progress bars update correctly for all requests 4. Only successful results are cached Resolves EleutherAI#3355
Only fix generate_until, which has confirmed evidence of the bug from issue EleutherAI#3355. The loglikelihood methods have no evidence of this issue: - No failures reported in issue EleutherAI#3355 - Different code structure in parse_logprobs (no gap creation) - Stack traces only show generate_until failures Keep the fix minimal and evidence-based.
Log concise warnings when parse_generations returns None to help users diagnose issues with API responses that have 'content': null. Warning message suggests checking: - reasoning_content field (for reasoning models) - generation limits (max_tokens, length) Includes first 50 chars of context in sequential path for debugging.
Contributor
Author
|
The PR has been out for two weeks now without any response, I hope this can be resolved soon 🙏 |
Contributor
Author
|
@baberabb please let me know if there's anything I can do to make the process / reviewing easier or faster. |
Collaborator
Sorry for the delay. LGTM! |
baberabb
approved these changes
Nov 9, 2025
Ismail-Hossain-1
pushed a commit
to Ismail-Hossain-1/lm-evaluation-harness
that referenced
this pull request
Dec 9, 2025
* update tests * Add test to reproduce issue EleutherAI#3355 AssertionError * update tests * Fix issue EleutherAI#3355: Handle None values in parse_generations/parse_logprobs Fixes the AssertionError in Collator.get_original() that occurred when API responses contain None values. The issue was that the code skipped None values when building the result list, causing a mismatch between the expected number of items and actual items, triggering the assertion. Changes: - generate_until: Always append results, converting None to empty string - _loglikelihood_tokens: Always append results, converting None to (-inf, False) - Applied fix to both sequential and concurrent code paths The fix ensures: 1. Result lists always have the correct number of items for reordering 2. None values are converted to sensible defaults instead of being skipped 3. Progress bars update correctly for all requests 4. Only successful results are cached Resolves EleutherAI#3355 * remove irrelevant test * Remove speculative loglikelihood fixes Only fix generate_until, which has confirmed evidence of the bug from issue EleutherAI#3355. The loglikelihood methods have no evidence of this issue: - No failures reported in issue EleutherAI#3355 - Different code structure in parse_logprobs (no gap creation) - Stack traces only show generate_until failures Keep the fix minimal and evidence-based. * Add warning logs when API returns null content Log concise warnings when parse_generations returns None to help users diagnose issues with API responses that have 'content': null. Warning message suggests checking: - reasoning_content field (for reasoning models) - generation limits (max_tokens, length) Includes first 50 chars of context in sequential path for debugging. * remove context log
JessicaOjo
pushed a commit
to JessicaOjo/lm-evaluation-harness
that referenced
this pull request
Dec 10, 2025
* update tests * Add test to reproduce issue EleutherAI#3355 AssertionError * update tests * Fix issue EleutherAI#3355: Handle None values in parse_generations/parse_logprobs Fixes the AssertionError in Collator.get_original() that occurred when API responses contain None values. The issue was that the code skipped None values when building the result list, causing a mismatch between the expected number of items and actual items, triggering the assertion. Changes: - generate_until: Always append results, converting None to empty string - _loglikelihood_tokens: Always append results, converting None to (-inf, False) - Applied fix to both sequential and concurrent code paths The fix ensures: 1. Result lists always have the correct number of items for reordering 2. None values are converted to sensible defaults instead of being skipped 3. Progress bars update correctly for all requests 4. Only successful results are cached Resolves EleutherAI#3355 * remove irrelevant test * Remove speculative loglikelihood fixes Only fix generate_until, which has confirmed evidence of the bug from issue EleutherAI#3355. The loglikelihood methods have no evidence of this issue: - No failures reported in issue EleutherAI#3355 - Different code structure in parse_logprobs (no gap creation) - Stack traces only show generate_until failures Keep the fix minimal and evidence-based. * Add warning logs when API returns null content Log concise warnings when parse_generations returns None to help users diagnose issues with API responses that have 'content': null. Warning message suggests checking: - reasoning_content field (for reasoning models) - generation limits (max_tokens, length) Includes first 50 chars of context in sequential path for debugging. * remove context log
JessicaOjo
pushed a commit
to JessicaOjo/lm-evaluation-harness
that referenced
this pull request
Dec 10, 2025
* update tests * Add test to reproduce issue EleutherAI#3355 AssertionError * update tests * Fix issue EleutherAI#3355: Handle None values in parse_generations/parse_logprobs Fixes the AssertionError in Collator.get_original() that occurred when API responses contain None values. The issue was that the code skipped None values when building the result list, causing a mismatch between the expected number of items and actual items, triggering the assertion. Changes: - generate_until: Always append results, converting None to empty string - _loglikelihood_tokens: Always append results, converting None to (-inf, False) - Applied fix to both sequential and concurrent code paths The fix ensures: 1. Result lists always have the correct number of items for reordering 2. None values are converted to sensible defaults instead of being skipped 3. Progress bars update correctly for all requests 4. Only successful results are cached Resolves EleutherAI#3355 * remove irrelevant test * Remove speculative loglikelihood fixes Only fix generate_until, which has confirmed evidence of the bug from issue EleutherAI#3355. The loglikelihood methods have no evidence of this issue: - No failures reported in issue EleutherAI#3355 - Different code structure in parse_logprobs (no gap creation) - Stack traces only show generate_until failures Keep the fix minimal and evidence-based. * Add warning logs when API returns null content Log concise warnings when parse_generations returns None to help users diagnose issues with API responses that have 'content': null. Warning message suggests checking: - reasoning_content field (for reasoning models) - generation limits (max_tokens, length) Includes first 50 chars of context in sequential path for debugging. * remove context log
alexliap
pushed a commit
to alexliap/lm-evaluation-harness
that referenced
this pull request
Jul 12, 2026
* update tests * Add test to reproduce issue EleutherAI#3355 AssertionError * update tests * Fix issue EleutherAI#3355: Handle None values in parse_generations/parse_logprobs Fixes the AssertionError in Collator.get_original() that occurred when API responses contain None values. The issue was that the code skipped None values when building the result list, causing a mismatch between the expected number of items and actual items, triggering the assertion. Changes: - generate_until: Always append results, converting None to empty string - _loglikelihood_tokens: Always append results, converting None to (-inf, False) - Applied fix to both sequential and concurrent code paths The fix ensures: 1. Result lists always have the correct number of items for reordering 2. None values are converted to sensible defaults instead of being skipped 3. Progress bars update correctly for all requests 4. Only successful results are cached Resolves EleutherAI#3355 * remove irrelevant test * Remove speculative loglikelihood fixes Only fix generate_until, which has confirmed evidence of the bug from issue EleutherAI#3355. The loglikelihood methods have no evidence of this issue: - No failures reported in issue EleutherAI#3355 - Different code structure in parse_logprobs (no gap creation) - Stack traces only show generate_until failures Keep the fix minimal and evidence-based. * Add warning logs when API returns null content Log concise warnings when parse_generations returns None to help users diagnose issues with API responses that have 'content': null. Warning message suggests checking: - reasoning_content field (for reasoning models) - generation limits (max_tokens, length) Includes first 50 chars of context in sequential path for debugging. * remove context log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #3355, which caused an
AssertionErrorwhen running evaluations with OpenAI-compatible endpoints when API responses have"content": null. This happens with vllm if using a reasoning model (GPT-OSS-20b) and running out of tokens before the non-think response is generated. It is solved by treating the response as an empty string while logging a warning.Reproducing the error
# start a local vllm instance of gpt-oss-20b vllm serve openai/gpt-oss-20b --port 7000Details
The issue occurred in
lm_eval/models/utils.py:541in theCollator.get_original()method:The problem: When
parse_generations()returnedNonevalues (from API responses with"content": null), the original code would skip these values:This caused a mismatch:
Collatortracked that it had N requests to process (_size = N)resonly had M items (where M < N, skipping the None values)get_original()tried to restore the original order, not all positions were filledassert all(cov)failed because some positions remained uncoveredBased on real API logs from the issue, this happens when vllm OpenAI-compatible endpoint return:
{ "choices": [{ "index": 0, "message": { "content": null, // ← NULL content! "reasoning_content": "The user..." // ← Actual text here } }] }Note that caching still only happens for successful results (None values not cached)
Resolves #3355
*this PR was created with the assistance of AI tools