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

Refactor chakra_converter and Add Tests #61

Merged
merged 7 commits into from
May 15, 2024
Merged

Conversation

TaekyungHeo
Copy link
Contributor

@TaekyungHeo TaekyungHeo commented May 14, 2024

Summary

  • Refactor code
  • Add tests using pytest
  • Set up GitHub Actions for pytest

Test Plan

1. Pytests

$ python -m pytest -vv tests                           
=========================================================================== test session starts ===========================================================================
platform darwin -- Python 3.10.2, pytest-8.1.1, pluggy-1.5.0 -- /Users/theo/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/theo/chakra
configfile: pyproject.toml
plugins: typeguard-2.13.3, mock-3.14.0, anyio-4.2.0
collected 6 items                                                                                                                                                         

tests/converter/test_pytorch_node.py::test_pytorch_node_parsing PASSED                                                                                              [ 16%]
tests/converter/test_pytorch_tensor.py::test_pytorch_tensor_initialization PASSED                                                                                   [ 33%]
tests/converter/test_pytorch_tensor.py::test_pytorch_tensor_is_valid PASSED                                                                                         [ 50%]
tests/converter/test_pytorch_tensor.py::test_pytorch_tensor_properties PASSED                                                                                       [ 66%]
tests/converter/test_pytorch_tensor.py::test_pytorch_tensor_has_valid_storage_id PASSED                                                                             [ 83%]
tests/converter/test_pytorch_tensor.py::test_list_to_pytorch_tensor PASSED                                                                                          [100%]

============================================================================ 6 passed in 0.07s ============================================================================

2. Correlation
2.1 Run trace_link

chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_0.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_0.json --output-file ~/megatron_0.json &
chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_1.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_1.json --output-file ~/megatron_1.json &
chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_2.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_2.json --output-file ~/megatron_2.json &
chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_3.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_3.json --output-file ~/megatron_3.json &
chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_4.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_4.json --output-file ~/megatron_4.json &
chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_5.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_5.json --output-file ~/megatron_5.json &
chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_6.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_6.json --output-file ~/megatron_6.json &
chakra_trace_link --pytorch-et-file /Users/theo/Downloads/llama_pytorch24.05/megatron_et_7.json --kineto-file /Users/theo/Downloads/llama_pytorch24.05/megatron_kineto_7.json --output-file ~/megatron_7.json &

2.2 Run et_converter

chakra_converter --input_filename ~/megatron_0.json --output_filename megatron_0.chakra --input_type PyTorch > /tmp/rank_0 &
chakra_converter --input_filename ~/megatron_1.json --output_filename megatron_1.chakra --input_type PyTorch > /tmp/rank_1 &
chakra_converter --input_filename ~/megatron_2.json --output_filename megatron_2.chakra --input_type PyTorch > /tmp/rank_2 &
chakra_converter --input_filename ~/megatron_3.json --output_filename megatron_3.chakra --input_type PyTorch > /tmp/rank_3 &
chakra_converter --input_filename ~/megatron_4.json --output_filename megatron_4.chakra --input_type PyTorch > /tmp/rank_4 &
chakra_converter --input_filename ~/megatron_5.json --output_filename megatron_5.chakra --input_type PyTorch > /tmp/rank_5 &
chakra_converter --input_filename ~/megatron_6.json --output_filename megatron_6.chakra --input_type PyTorch > /tmp/rank_6 &
chakra_converter --input_filename ~/megatron_7.json --output_filename megatron_7.chakra --input_type PyTorch > /tmp/rank_7 &

2.3 Results
Screenshot 2024-05-08 at 7 42 27 PM

Copy link

github-actions bot commented May 14, 2024

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@TaekyungHeo TaekyungHeo force-pushed the pytest-converter branch 4 times, most recently from 992e8e6 to 03f1f8b Compare May 15, 2024 01:12
@TaekyungHeo TaekyungHeo changed the title Pytest converter Refactor Codes and Add Tests May 15, 2024
@TaekyungHeo TaekyungHeo marked this pull request as ready for review May 15, 2024 01:30
@TaekyungHeo TaekyungHeo requested a review from a team as a code owner May 15, 2024 01:30
@TaekyungHeo TaekyungHeo changed the title Refactor Codes and Add Tests Refactor chakra_converter and Add Tests May 15, 2024
@TaekyungHeo TaekyungHeo marked this pull request as draft May 15, 2024 15:58
@TaekyungHeo
Copy link
Contributor Author

Converting to draft because I am unsure whether it is acceptable to add a trace as is without using Git LFS.

@TaekyungHeo TaekyungHeo marked this pull request as ready for review May 15, 2024 17:00
Copy link
Contributor

@srinivas212 srinivas212 left a comment

Choose a reason for hiding this comment

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

lgtm. discussed offline.

@srinivas212 srinivas212 merged commit 17d446f into main May 15, 2024
5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2024
@TaekyungHeo TaekyungHeo deleted the pytest-converter branch May 15, 2024 17:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants