Use _cast_input_dtype in vera Linear.forward#3172
Closed
Chessing234 wants to merge 1 commit into
Closed
Conversation
`vera/layer.py` Linear.forward casts the input to the adapter's dtype with a raw `x.to(lambda_d.dtype)` call, bypassing `BaseTunerLayer._cast_input_dtype` — the helper that consults `cast_input_dtype_enabled` (toggled by `peft.helpers.disable_lora_input_dtype_casting`, introduced in huggingface#2353 and generalized to non-LoRA tuners in huggingface#2433). Every other additive tuner routes the cast through `self._cast_input_dtype`: - `lora/layer.py:967` — `x = self._cast_input_dtype(x, lora_A.weight.dtype)` - `fourierft/layer.py:183` (after huggingface#3170) - `waveft/layer.py:283` — `x = self._cast_input_dtype(x, delta_w.dtype)` - `psoft/layer.py:447` — `x_cast = self._cast_input_dtype(x, A.dtype)` - `hra/layer.py:260,445` — `x = self._cast_input_dtype(x, new_weight.dtype)` VeRA was missed when huggingface#2433 consolidated that helper. Switch the raw cast to `self._cast_input_dtype` to match the established pattern so users can opt out via the documented context manager. Behavior is unchanged when the context manager isn't used (both code paths call `x.to(dtype)`).
This was referenced May 2, 2026
|
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. |
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.
Bug
Linear.forwardinsrc/peft/tuners/vera/layer.py:283casts the input to the adapter's dtype with a rawx.to(lambda_d.dtype):This bypasses
BaseTunerLayer._cast_input_dtype, which is the method that consultscast_input_dtype_enabled(toggled by thepeft.helpers.disable_lora_input_dtype_castingcontext manager introduced in #2353 and generalized to non-LoRA tuners in #2433).Root cause
#2433 consolidated dtype handling across additive tuners onto
self._cast_input_dtype. Every comparable tuner's forward uses the helper:lora/layer.py:967—x = self._cast_input_dtype(x, lora_A.weight.dtype)fourierft/layer.py:183(after Use _cast_input_dtype in FourierFTLinear.forward #3170)waveft/layer.py:283—x = self._cast_input_dtype(x, delta_w.dtype)psoft/layer.py:447—x_cast = self._cast_input_dtype(x, A.dtype)hra/layer.py:260, 445—x = self._cast_input_dtype(x, new_weight.dtype)VeRA was missed in that sweep, so toggling
disable_lora_input_dtype_castingsilently has no effect on VeRA layers — the cast still happens unconditionally.Fix
Route the cast through
self._cast_input_dtypeto match the established pattern. Behavior is identical when the context manager is not used (both callx.to(dtype)); the difference is that users can now opt out as documented.