Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copies main ci #29979

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/models/qwen2_moe/test_modeling_qwen2_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def test_flash_attn_2_generate_use_cache(self):
@require_torch_gpu
@pytest.mark.flash_attn_test
@slow
def test_flash_attn_2_inference_padding_right(self):
def test_flash_attn_2_inference_equivalence_right_padding(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actual fix

self.skipTest("Qwen2Moe flash attention does not support right padding")

# Ignore copy
Expand Down
27 changes: 22 additions & 5 deletions utils/check_copies.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,12 @@ def split_code_into_blocks(
target_block_name = re.search(
rf"^{' ' * (indent - 4)}((class|def)\s+\S+)(\(|\:)", lines[start_index]
).groups()[0]
except ValueError:
except Exception:
start_context = min(start_index - 10, 0)
end_context = min(end_index + 10, len(lines))
raise ValueError(
f"Tried to split a class or function. It did not work. Error comes from line {start_index}: ```\n"
+ "".join(lines[start_index:end_index])
f"Tried to split a class or function. It did not work. Error comes from line {start_index}: \n```\n"
+ "".join(lines[start_context:end_context])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just adding some context can help a lot!

+ "```\n"
)

Expand Down Expand Up @@ -602,8 +604,23 @@ def check_codes_match(observed_code: str, theoretical_code: str) -> Optional[int
_re_func_match = re.compile(r"def\s+([^\(]+)\(")
for re_pattern in [_re_class_match, _re_func_match]:
if re_pattern.match(observed_code_header) is not None:
observed_obj_name = re_pattern.search(observed_code_header).groups()[0]
theoretical_name = re_pattern.search(theoretical_code_header).groups()[0]
try:
observed_obj_name = re_pattern.search(observed_code_header).groups()[0]
except Exception:
raise ValueError(
"Tried to split a class or function. It did not work. Error comes from: \n```\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message is a bit confusing here. The re_pattern is used to extract the class or function name, not to split the blocks (unlike the above one)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to update it. 😄

+ observed_code_header
+ "\n```\n"
)

try:
theoretical_name = re_pattern.search(theoretical_code_header).groups()[0]
except Exception:
raise ValueError(
"Tried to split a class or function. It did not work. Error comes from: \n```\n"
+ theoretical_code_header
+ "\n```\n"
)
theoretical_code_header = theoretical_code_header.replace(theoretical_name, observed_obj_name)

# Find the first diff. Line 0 is special since we need to compare with the function/class names ignored.
Expand Down
Loading