-
Notifications
You must be signed in to change notification settings - Fork 6.7k
[wip] switch to transformers main again. #12976
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
base: main
Are you sure you want to change the base?
Conversation
| - "tests/pipelines/test_pipelines_common.py" | ||
| - "tests/models/test_modeling_common.py" | ||
| - "examples/**/*.py" | ||
| - ".github/**.yml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporary. For this PR.
|
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. |
| logger.addHandler(stream_handler) | ||
|
|
||
|
|
||
| @unittest.skipIf(is_transformers_version(">=", "4.57.5"), "Size mismatch") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal discussion: https://huggingface.slack.com/archives/C014N4749J9/p1768474502541349
| torch.nn.ConvTranspose2d, | ||
| torch.nn.ConvTranspose3d, | ||
| torch.nn.Linear, | ||
| torch.nn.Embedding, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happening because of the way weight loading is done in v5.
| model = AutoModel.from_pretrained( | ||
| "hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder", use_safetensors=False | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal discussion: https://huggingface.slack.com/archives/C014N4749J9/p1768462040821759
| input_ids = ( | ||
| input_ids["input_ids"] if not isinstance(input_ids, list) and "input_ids" in input_ids else input_ids | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal discussion https://huggingface.slack.com/archives/C014N4749J9/p1768537424692669
| inputs = { | ||
| "prompt": "dance monkey", | ||
| "negative_prompt": "", | ||
| "negative_prompt": "bad", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, the corresponding tokenizer outputs:
negative_prompt=[' ']
prompt=[' ']
text_input_ids=tensor([], size=(1, 0), dtype=torch.int64)which leads to:
E RuntimeError: cannot reshape tensor of 0 elements into shape [1, 0, -1, 8] because the unspecified dimension size -1 can be any value and is ambiguous| if is_transformers_version("<=", "4.58.0"): | ||
| token = tokenizer._added_tokens_decoder[token_id] | ||
| tokenizer._added_tokens_decoder[last_special_token_id + key_id] = token | ||
| del tokenizer._added_tokens_decoder[token_id] | ||
| elif is_transformers_version(">", "4.58.0"): | ||
| token = tokenizer.added_tokens_decoder[token_id] | ||
| tokenizer.added_tokens_decoder[last_special_token_id + key_id] = token | ||
| del tokenizer.added_tokens_decoder[token_id] | ||
| if is_transformers_version("<=", "4.58.0"): | ||
| tokenizer._added_tokens_encoder[token.content] = last_special_token_id + key_id | ||
| elif is_transformers_version(">", "4.58.0"): | ||
| tokenizer.added_tokens_encoder[token.content] = last_special_token_id + key_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still doesn't solve the following issue:
FAILED tests/pipelines/test_pipelines.py::DownloadTests::test_textual_inversion_unload - AttributeError: CLIPTokenizer has no attribute _added_tokens_decoder. Did you mean: 'added_tokens_decoder'?Internal thread: https://huggingface.slack.com/archives/C014N4749J9/p1768536480412119
|
@DN6 I have fixed a majority of the issues that were being caused by v5 / |
| config = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-t5") | ||
| text_encoder_2 = T5EncoderModel(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
A bunch of tests actually fail on Diffusers UnravelFAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_cfg - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_attention_slicing_forward_pass - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_callback_inputs - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_dict_tuple_outputs_equivalent - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_inference_batch_single_identical - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_pipeline_with_accelerator_device_map - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_save_load_float16 - AssertionError: False is not true : `safety_checker.dtype` switched from `float16` to torch.float32 after loading.
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_sequential_cpu_offload_forward_pass - AssertionError: False is not true : Not offloaded: ['safety_checker']
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_sequential_offload_forward_pass_twice - AssertionError: False is not true : Not offloaded: ['safety_checker']
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_cfg - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_attention_slicing_forward_pass - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_callback_inputs - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_dict_tuple_outputs_equivalent - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_inference_batch_single_identical - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_pipeline_with_accelerator_device_map - RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0 (when che...
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_save_load_float16 - AssertionError: False is not true : `safety_checker.dtype` switched from `float16` to torch.float32 after loading.
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_sequential_cpu_offload_forward_pass - AssertionError: False is not true : Not offloaded: ['safety_checker']
FAILED tests/pipelines/cosmos/test_cosmos_video2world.py::CosmosVideoToWorldPipelineFastTests::test_sequential_offload_forward_pass_twice - AssertionError: False is not true : Not offloaded: ['safety_checker'] |
|
As we can see here and here, some tests fail across both To summarize things a bit, With 4.7.3, we have a total of 132 failures and 157 with main. 93 new test failures. Common: 64 Unfold to see the failures with main
Little utility to obtain these reports: Unravelimport re
import argparse
def extract_failed_tests(log_file_path):
"""
Parses a pytest log file and returns a list of fully qualified
paths for all failed tests.
"""
failed_tests = []
# This regex looks for the 'FAILED ' prefix used in pytest's
# 'short test summary info' section.
failure_pattern = re.compile(r'^FAILED\s+(.*)$')
with open(log_file_path, 'r') as file:
for line in file:
line = line.strip()
match = failure_pattern.match(line)
if match:
# The first group contains the full path:
# script_path.py::ClassName::test_name
failed_tests.append(match.group(1))
return failed_tests
if __name__ == "__main__":
path1 = "/Users/sayakpaul/Downloads/pr_pytorch_pipelines_torch_cpu_pipelines_transformers_4.57.3_test_reports/tests_torch_cpu_pipelines_summary_short_4_57_3.txt"
path2 = "/Users/sayakpaul/Downloads/pr_pytorch_pipelines_torch_cpu_pipelines_transformers_main_test_reports/tests_torch_cpu_pipelines_summary_short_main.txt"
failures_one = set(extract_failed_tests(path1))
failures_two = set(extract_failed_tests(path2))
print(f"Old: {len(failures_one)}, New: {len(failures_two)}")
difference = failures_two.difference(failures_one)
intersection = failures_two.intersection(failures_one)
print(f"{len(difference)} new test failures. Common: {len(intersection)}")
diff_list = "\n".join(f"- `{diff}`" for diff in difference)
print(diff_list)
Will work on fixing the new ones where possible. |
What does this PR do?
This PR is to assess if we can move to
transformersmain again for our CI. This will also help us migrate totransformersv5 successfully.Notes
For the
FAILED tests/pipelines/test_pipelines.py::DownloadTests::test_textual_inversion_unload - AttributeError: CLIPTokenizer has no attribute _added_tokens_decoder. Did you mean: 'added_tokens_decoder'?error, see this internal discussion.