fix(deberta-v2): move "Copied from" comments above @torch.jit.script for Python 3.13 compat#44916
Closed
s-zx wants to merge 2 commits intohuggingface:mainfrom
Closed
fix(deberta-v2): move "Copied from" comments above @torch.jit.script for Python 3.13 compat#44916s-zx wants to merge 2 commits intohuggingface:mainfrom
s-zx wants to merge 2 commits intohuggingface:mainfrom
Conversation
Python 3.13's stricter AST parser (PEP 701 and related parser tightening) raises IndentationError when ast.parse() encounters a comment between a decorator and a def statement. Three functions in modeling_deberta_v2.py had this pattern: @torch.jit.script # Copied from ... def fn(...): Move each comment to the line immediately above @torch.jit.script to fix the IndentationError on Python 3.13. Fixes huggingface#44855
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: deberta_v2, gpt_neox |
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
Importing
DebertaV2Model(or anything that depends on it, e.g.gliner) raisesIndentationErroron Python 3.13 becausetorch.jit.scriptcallsinspect.getsource(),dedents the snippet, and passes it to
ast.parse(). Python 3.13's stricter parser rejectsa comment placed between a decorator and the
defstatement.Root Cause
Three functions in
modeling_deberta_v2.pyhad a# Copied from ...comment between@torch.jit.scriptanddef:Fix
Move each
# Copied fromcomment to the line above its@torch.jit.scriptdecorator:Applied to all three affected functions (
c2p_dynamic_expand,p2c_dynamic_expand,pos_dynamic_expand).Fixes #44855