Skip to content

Fix LiveCodeBench crashes with type safety and list conversion#137

Merged
neginraoof merged 1 commit intomlfoundations:mainfrom
dkimds:fix/livecodebench-type-check-debug
Dec 23, 2025
Merged

Fix LiveCodeBench crashes with type safety and list conversion#137
neginraoof merged 1 commit intomlfoundations:mainfrom
dkimds:fix/livecodebench-type-check-debug

Conversation

@dkimds
Copy link
Contributor

@dkimds dkimds commented Jul 1, 2025

Summary

Fixes #136 by adding robust type checking and ensuring dataset is properly converted to list format.

Problem Solved

LiveCodeBench variants could crash or behave unexpectedly due to:

  • Dataset iteration issues when not converted to list
  • Missing type validation causing runtime errors

Changes

Files Modified:

  • eval/chat_benchmarks/LiveCodeBench/eval_instruct.py
  • eval/chat_benchmarks/LiveCodeBenchv5/eval_instruct.py
  • eval/chat_benchmarks/LiveCodeBenchv5_official/eval_instruct.py

Key Improvements:

  1. Explicit list conversion: examples = list(examples_dataset)
  2. Type safety: Added isinstance(example, dict) checks
  3. Error logging: Non-dict examples logged and skipped instead of crashing

Code Changes

# Before
examples_dataset = self.load_questions()
for idx, example in enumerate(examples_dataset):
    # Could crash if example is not dict

# After  
examples = list(self.load_questions())
for idx, example in enumerate(examples):
    if not isinstance(example, dict):
        self.logger.error(f"Example {idx} not dict: {type(example)}")
        continue
    # Safe to process

## Testing
```bash
# Test all LiveCodeBench variants work without crashes
python -m eval.eval --model hf --tasks LiveCodeBench --debug --model_args "pretrained=microsoft/DialoGPT-medium"
python -m eval.eval --model hf --tasks LiveCodeBenchv5 --debug --model_args "pretrained=microsoft/DialoGPT-medium"

Impact

✅ Prevents runtime crashes from type mismatches
✅ More robust error handling and logging
✅ Better debugging experience
✅ No functional changes to working cases

LiveCodeBench, LiveCodeBenchv5, LiveCodeBenchv5_official
@dkimds
Copy link
Contributor Author

dkimds commented Jul 4, 2025

Hi @neginraoof, could you please take a quick look at my PR when you have time? Thanks!

@dkimds dkimds changed the title fix: add type check and list conversion for LiveCodeBenchs Fix LiveCodeBench crashes with type safety and list conversion Jul 8, 2025
@neginraoof neginraoof merged commit 568160a into mlfoundations:main Dec 23, 2025
@dkimds dkimds deleted the fix/livecodebench-type-check-debug branch January 4, 2026 23:08
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.

LiveCodeBench crashes on iteration due to dataset type inconsistency

2 participants