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

Enhance and optimize the model ops test generation and script for updating failures reason for the failed models ops test #1198

Merged

Conversation

chandrasekaranpradeep
Copy link
Contributor

@chandrasekaranpradeep chandrasekaranpradeep commented Feb 7, 2025

Fixes #1122
Removed the dependency of pt files in Model ops test generation pipeline which resolve space issue in CI and local machines by avoid storing pt files.
Fixes #1199
Created a script for updating the model ops test failures with xfail marker and failures reason by using pytest logs files which is saved as artifacts in CI

Fixes #795
Enabled the option for recording properties such as frontend, op_name, model_name and op_params
TODO:
Need to update other record properties, will work on adding it in separate PR.

  1. The below screenshoot represent the generated model ops test pytest params before script run
Screenshot 2025-02-07 at 7 58 31 PM
  1. The below screenshoot represent the generated model ops test pytest params after script run which adds xfail marker with failure reason by analysing the pytest logs.
Screenshot 2025-02-07 at 7 55 15 PM

Attached the generated model ops test folder before and after the model ops test failure update script.

models_ops_before_xfail_update.zip
models_ops_after_xfail_update.zip

Note:
Added the verification between framework outputs and generated forge module outputs before extract_and_generate_unique_ops_tests function in forge/forge/tvm_to_python.py which is used for extracting the unique ops configuration and generated unique ops test but in the current commit lots of models are failling in the verification so need to check on the latest main.

Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests590 ran465 passed125 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests590 ran465 passed125 skipped0 failed
TestResult
No test annotations available

Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests648 ran508 passed140 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests648 ran508 passed140 skipped0 failed
TestResult
No test annotations available

@chandrasekaranpradeep chandrasekaranpradeep force-pushed the pchandrasekaran/enhance_models_ops_test_gen branch from 7474899 to 3ccbbd1 Compare February 7, 2025 14:34
@chandrasekaranpradeep chandrasekaranpradeep marked this pull request as ready for review February 7, 2025 14:37
@chandrasekaranpradeep chandrasekaranpradeep self-assigned this Feb 7, 2025
Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests590 ran465 passed125 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests590 ran465 passed125 skipped0 failed
TestResult
No test annotations available

Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests648 ran508 passed140 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

github-actions bot commented Feb 7, 2025

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests648 ran508 passed140 skipped0 failed
TestResult
No test annotations available

self.indent -= 1
self.wl("")
if "pcc" not in exclude_record_property:
self.wl("pcc = 0.99")
if "integer_tensor_high_value" not in exclude_record_property:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's think about having these hard-codded configurations as part of the separated configuration file. E.g. specific config object for this tool.

I assume that we'll have more of this kind, so it might be good to think about how to manage. Also, as this PR is quite big, let's create issues for this and tackle it as separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay Nikola.
Can you give some idea on config object functionalities like whether it is should be used inside the generated models ops test or it is utility used by the write_pytest_method method in ForgeWritter?

@@ -2784,7 +2762,23 @@ def delete_unneeded_outputs(ops, returns):
# Generate unique op tests based on requested model. Currently only supported
# for PyTorch framework.
if compiler_cfg.extract_tvm_unique_ops_config or compiler_cfg.tvm_generate_unique_ops_tests:

# Commenting the below verification between framework outputs and generated forge module outputs
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, the majority of them are failing during framework vs codegen?

@dgolubovicTT something to think about during initial support for verifications after different compile stages. Maybe we should review TVM side of verification as well during this push, before pushing next stage of intermediate verification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, I have tried generating models ops test in latest main for the below 20 models, out of the 20 models, 2 models test cases are failing with framework vs codegen verification
Screenshot 2025-02-10 at 4 44 12 PM
Failed models test:

forge/test/models/pytorch/text/codegen/test_codegen.py::test_codegen[Salesforce/codegen-350M-mono]
forge/test/models/pytorch/text/gptneo/test_gptneo.py::test_gptneo_causal_lm[EleutherAI/gpt-neo-125M]

Note: I haven't triggered the models ops test generation pipeline for all the models in the forge, I have test for sample of 20 text based models for checking the behaviour of pipeline.

forge/forge/tvm_unique_op_generation.py Outdated Show resolved Hide resolved
forge/forge/tvm_unique_op_generation.py Outdated Show resolved Hide resolved
@@ -1011,6 +1033,27 @@ def generate_models_ops_test(unique_operations: UniqueOperations, models_ops_tes
pytest_input_shapes_dtypes.append((operand_shape, operand_dtype))
pytest_input_shapes_and_dtypes_list.append(pytest_input_shapes_dtypes)

# To avoid recording pcc in record_property pytest fixture and add the pcc to the exclude metadata property list
exclude_record_property = ["pcc"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Also a candidate for tooling configuration object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will include it.

if op_name == "embedding":
# Calculate embedding op indicies tensor maximum value based upon the num_embeddings of the weight tensor.
pytest_metadata["integer_tensor_high_value"] = int(operand_shapes[1][0]) - 1
exclude_record_property.append("integer_tensor_high_value")
Copy link
Contributor

Choose a reason for hiding this comment

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

This can probably be generally excluded as part of the configuration object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

@chandrasekaranpradeep chandrasekaranpradeep force-pushed the pchandrasekaran/enhance_models_ops_test_gen branch from 3ccbbd1 to 9c85e4f Compare February 10, 2025 08:20
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests592 ran466 passed126 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests592 ran466 passed126 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests650 ran509 passed141 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests650 ran509 passed141 skipped0 failed
TestResult
No test annotations available

@chandrasekaranpradeep chandrasekaranpradeep force-pushed the pchandrasekaran/enhance_models_ops_test_gen branch from 9c85e4f to 2c4932e Compare February 10, 2025 11:06
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests592 ran466 passed126 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests592 ran466 passed126 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests650 ran509 passed141 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests650 ran509 passed141 skipped0 failed
TestResult
No test annotations available

@chandrasekaranpradeep
Copy link
Contributor Author

@nvukobratTT FYI,

  1. Added option for specify maximum and minimum value for random integer tensor generation in create_torch_tensor class method in Tensor class, because in the embedding op test, there is cases where the indicies tensor shape is (1, 128), and weight tensor shape is (1, 768) and for generating random indices tensor max_int is calculated like num_embeddings(i.e dim=0 of weight tensor) - 1, in this cases max_int and min_int are same value(i.e 0) and in the torch.randint low and high value shouldn't be same. So, modified the create_torch_tensor class method accordingly
  2. Fixed issue in extracting meaningful error message for the fatal error in ErrorMessageUpdater class.

@chandrasekaranpradeep chandrasekaranpradeep force-pushed the pchandrasekaran/enhance_models_ops_test_gen branch from 2c4932e to e1f0e2c Compare February 11, 2025 10:46
…ating failures reason for the failed models ops test
@chandrasekaranpradeep chandrasekaranpradeep force-pushed the pchandrasekaran/enhance_models_ops_test_gen branch from e1f0e2c to aa85b55 Compare February 11, 2025 10:52
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests650 ran509 passed141 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests592 ran466 passed126 skipped0 failed
TestResult
No test annotations available

1 similar comment
Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests592 ran466 passed126 skipped0 failed
TestResult
No test annotations available

Copy link

TestsPassed ✅Skipped ⚠️Failed
TT-Forge-FE Tests650 ran509 passed141 skipped0 failed
TestResult
No test annotations available

@chandrasekaranpradeep chandrasekaranpradeep merged commit 2102aff into main Feb 11, 2025
10 checks passed
@chandrasekaranpradeep chandrasekaranpradeep deleted the pchandrasekaran/enhance_models_ops_test_gen branch February 11, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants