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

add-new-model-like: fix broken script #32460

Closed
wants to merge 4 commits into from

Conversation

RUFFY-369
Copy link
Contributor

What does this PR do?

transformers-cli add-new-model-like seems to be currently broken for creating model similar to any present model.This is the error being presented:

warnings.warn("Can't initialize NVML")
2024-08-05 21:55:54.618004: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-08-05 21:55:54.842235: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-08-05 21:55:54.842320: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-08-05 21:55:54.883042: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-08-05 21:55:55.074847: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-08-05 21:55:56.341011: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
What is the model you would like to duplicate? Please provide the lowercase `model_type` (e.g. roberta): dummy
dummy is not a valid model type.
What is the model you would like to duplicate? Please provide the lowercase `model_type` (e.g. roberta): vit
What is the name (with no special casing) for your new model in the paper (e.g. RoBERTa)? dummy
What identifier would you like to use for the `model_type` of this model?  [dummy] dummy
What lowercase name would you like to use for the module (folder) of this model?  [dummy] dummy
What prefix (camel-cased) would you like to use for the model classes of this model (e.g. Roberta)?  [Dummy] Dummy
What prefix (upper-cased) would you like to use for the constants relative to this model?  [DUMMY] DUMMY
What will be the name of the config class for this model?  [DummyConfig] DummyConfig
Please give a checkpoint identifier (on the model Hub) for this new model (e.g. facebook/FacebookAI/roberta-base): dummy/dummy
Will your new model use the same processing class as vit (ViTImageProcessor, ViTImageProcessorFast, ViTFeatureExtractor) (yes/no)? yes
Should we add # Copied from statements when creating the new modeling file (yes/no)?  [yes] yes
Should we add a version of your new model in all the frameworks implemented by vit (['pt', 'tf', 'flax']) (yes/no)?  [yes] no
Please enter the list of framworks you want (pt, tf, flax) separated by spaces pt
Traceback (most recent call last):
  File "/home/ruffy-369/HuggingFace/iris/.iristransformers/bin/transformers-cli", line 8, in <module>
    sys.exit(main())
  File "/home/ruffy-369/HuggingFace/transformers/src/transformers/commands/transformers_cli.py", line 53, in main
    service.run()
  File "/home/ruffy-369/HuggingFace/transformers/src/transformers/commands/add_new_model_like.py", line 1495, in run
    create_new_model_like(
  File "/home/ruffy-369/HuggingFace/transformers/src/transformers/commands/add_new_model_like.py", line 1335, in create_new_model_like
    duplicate_module(
  File "/home/ruffy-369/HuggingFace/transformers/src/transformers/commands/add_new_model_like.py", line 543, in duplicate_module
    obj, replacement = replace_model_patterns(obj, old_model_patterns, new_model_patterns)
  File "/home/ruffy-369/HuggingFace/transformers/src/transformers/commands/add_new_model_like.py", line 371, in replace_model_patterns
    text = text.replace(getattr(old_model_patterns, attr), ATTRIBUTE_TO_PLACEHOLDER[attr])
TypeError: replace() argument 1 must be str, not tuple

There are two commits in this PR:

  • FIrst is regarding building or adding up on the PR handle (processor_class, None) returned by ModelPatterns #31753 where old_image_processor_class first element is being chosen when it is an instance of tuple as second element is None. But as ViTImageProcessorFast BaseImageProcessorFast has been implemented so for vit model and the models that map their image processor to ViTImageProcessor and ViTImageProcessorFast they have second element as ViTImageProcessorFast instead of None. So, in the question Will your new model use the same processing class as vit (ViTImageProcessor..... ViTImageProcessorFast is not being displayed for creating models similar to those models.
    This commit fix that.
  • Second commit fix the above error mentioned(TypeError: replace() argument 1 must be str, not tuple) which is breaking the model creation script

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.
@amyeroberts @ArthurZucker @LysandreJik

@SangbumChoi
Copy link
Contributor

#31773

@RUFFY-369
Copy link
Contributor Author

#31773

Missed the PR. Thanks for mentioning 👍

@RUFFY-369 RUFFY-369 closed this Aug 6, 2024
@RUFFY-369 RUFFY-369 deleted the fix_add_model branch August 6, 2024 11:09
@ArthurZucker
Copy link
Collaborator

thanks for your contribution anyways! 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants