[BUG FIX] tuners/lora/eva: fix label mask guard using 'in' instead of hasattr for dict#3247
Open
Dev-X25874 wants to merge 2 commits into
Open
[BUG FIX] tuners/lora/eva: fix label mask guard using 'in' instead of hasattr for dict#3247Dev-X25874 wants to merge 2 commits into
Dev-X25874 wants to merge 2 commits into
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
BenjaminBossan
approved these changes
May 20, 2026
Member
BenjaminBossan
left a comment
There was a problem hiding this comment.
Okay, looks good from my side. Let's wait a week or so to see if Sirluk has time to check. Otherwise, I'll go ahead and merge.
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.
What
This is a clean re-open of #3233 (closed due to formatting issues across commits).
All review comments from @BenjaminBossan have been addressed from the
start in this PR.
In
prepare_model_inputs_fn_language_modeling, the label mask guard useshasattr(model_input, "labels")to check whether labels are present. However,model_inputis a plain Pythondict(enforced by theisinstancecheck threelines above), and
hasattron a plain dict always returnsFalseregardless ofits keys — dict keys are not exposed as object attributes.
This means the label masking branch (
use_label_mask=True) has silently neverexecuted, even though it is the default in
EvaConfig. As a result, ignored /padding positions (label value
−100) were included in the SVD computationduring EVA initialization.
Fix
Replace
hasattr(model_input, "labels")with("labels" in model_input), whichis the correct Python idiom for dict key membership. The body of the branch
already uses
model_input["labels"](subscript access), so only the guard waswrong. No downstream side-effects for callers that do not include a
"labels"key.Tests
Added
test_eva_label_mask, parametrized overuse_label_mask=True/False, whichruns
get_eva_state_dicton a dataset augmented with alabelscolumn andasserts the returned state dict is non-empty in both cases. This directly exercises
the previously dead code path.
cc @BenjaminBossan @sirluk