Fix LMEval ONNX evaluator device assignment with recent lm-eval#2517
Open
justinchuby wants to merge 4 commits into
Open
Fix LMEval ONNX evaluator device assignment with recent lm-eval#2517justinchuby wants to merge 4 commits into
device assignment with recent lm-eval#2517justinchuby wants to merge 4 commits into
Conversation
lm-eval's `LM` base class exposes `device` as a read-only property
(backed by `_device`). The ONNX evaluators (`LMEvalORTEvaluator`,
`LMEvalORTGenAIEvaluator`) assign `self.device` in `__init__`, which
raises `AttributeError: property 'device' ... has no setter` with recent
lm-eval versions (e.g. 0.4.12), breaking `get_model('ortgenai')` and
`get_model('ort')` based evaluation.
Add a `device` property with a setter to the shared `LMEvalOnnxBase` so
the existing `self.device = ...` assignments work regardless of lm-eval
version. Add a regression test for the settable property.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores compatibility between Olive’s lm-eval ONNX backends and newer lm-eval releases where LM.device is a read-only property, by overriding device on Olive’s shared ONNX lm-eval base class with a setter-backed property.
Changes:
- Add a
deviceproperty (getter + setter backed by_device) toLMEvalOnnxBaseto avoidAttributeErroronself.device = ...assignments. - Add regression tests to ensure the
deviceproperty has a setter and that it correctly round-trips stored values.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
olive/evaluator/lmeval_ort.py |
Overrides lm-eval’s read-only device property in LMEvalOnnxBase by adding a setter backed by _device. |
test/evaluator/test_lmeval_ort.py |
Adds regression tests verifying device has a setter and that the property stores/returns values correctly. |
Contributor
Author
|
@copilot fix lint |
Contributor
Fixed in the latest commit. Added |
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.
Problem
get_model("ortgenai")/get_model("ort")based evaluation crashes with recentlm-evalversions (reproduced onlm-eval==0.4.12):Root cause
lm-eval's
LMbase class exposesdeviceas a read-only property (backed byself._device). Olive's ONNX evaluators inolive/evaluator/lmeval_ort.pyassignself.device = ...in__init__:LMEvalORTEvaluator.__init__—self.device = "cuda" if ep == "CUDAExecutionProvider" else "cpu"LMEvalORTGenAIEvaluator.__init__—self.device = deviceWith the read-only property inherited from lm-eval, both assignments raise
AttributeError, so evaluation never starts.Fix
Add a
deviceproperty with a setter to the sharedLMEvalOnnxBase(backed by_device), overriding lm-eval's read-only property. The existingself.device = ...assignments keep working across lm-eval versions, and reads ofself.device(used for IOBinding placement and.to(self.device)) are unchanged.Testing
test/evaluator/test_lmeval_ort.py(guarded bypytest.importorskip("lm_eval")) verifying thedeviceproperty has a setter and round-trips. Both tests pass.get_model("ortgenai")on a CUDA INT4 ONNX model (Gemma 4 12B) — evaluation now runs to completion and reports a score (previously crashed at model init).ruff checkclean on the changed files.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com