From f4a165090852e36d7c86b87dd954eb6644d20fe6 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Sun, 21 Apr 2024 18:12:30 -0700 Subject: [PATCH] Run pre-submit on all files. --- LICENSE | 1 - README.md | 4 ++-- examples/llama2_inference/README.md | 4 ++-- .../llama2_inference/llama2_state_schema.json | 2 +- examples/resnet-18/README.md | 2 +- examples/resnet-18/requirements.txt | 2 +- iree-requirements.txt | 2 +- .../aot/support/procedural/globals.py | 10 ++------- .../transforms/quantization/mm_group_quant.py | 22 +++++++++---------- tests/generated/extract_unimpl_ops.sh | 2 +- tests/generated/running_tests.md | 2 +- .../testdata/custom_op_string_attr.mlir | 2 +- version_info.json | 2 +- 13 files changed, 25 insertions(+), 32 deletions(-) diff --git a/LICENSE b/LICENSE index f9dc50615..bd8b243df 100644 --- a/LICENSE +++ b/LICENSE @@ -216,4 +216,3 @@ conflicts with the conditions of the GPLv2, you may retroactively and prospectively choose to deem waived or otherwise exclude such Section(s) of the License, but only in their entirety and only with respect to the Combined Software. - diff --git a/README.md b/README.md index 9c89f371e..4d0d0c223 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Turbine provides a collection of tools: ## Contact Us -Turbine is under active development. Feel free to reach out on one of -[IREE's communication channels](https://github.com/iree-org/iree?tab=readme-ov-file#communication-channels) (specifically, we monitor the +Turbine is under active development. Feel free to reach out on one of +[IREE's communication channels](https://github.com/iree-org/iree?tab=readme-ov-file#communication-channels) (specifically, we monitor the #pytorch channel on the IREE Discord server). ## Quick Start for Users diff --git a/examples/llama2_inference/README.md b/examples/llama2_inference/README.md index 1d377727b..50bc65373 100644 --- a/examples/llama2_inference/README.md +++ b/examples/llama2_inference/README.md @@ -10,7 +10,7 @@ Don't forget to put in your huggingface token from https://huggingface.co/settin # if you don't insert it, you will be prompted to log in later; # you may need to rerun this script after logging in -YOUR_HF_TOKEN="insert token for headless" +YOUR_HF_TOKEN="insert token for headless" # clone and install dependencies sudo apt install -y git @@ -29,7 +29,7 @@ if [[ $YOUR_HF_TOKEN == hf_* ]]; then elif [ -f ~/.cache/huggingface/token ]; then # Read token from the file TOKEN_CONTENT=$(cat ~/.cache/huggingface/token) - + # Check if the token starts with "hf_" if [[ $TOKEN_CONTENT == hf_* ]]; then echo "Already logged in with a Hugging Face token." diff --git a/examples/llama2_inference/llama2_state_schema.json b/examples/llama2_inference/llama2_state_schema.json index e4e55dfd1..b5506055f 100644 --- a/examples/llama2_inference/llama2_state_schema.json +++ b/examples/llama2_inference/llama2_state_schema.json @@ -1 +1 @@ -[1, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}]}] \ No newline at end of file +[1, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}, {"type": "builtins.tuple", "context": "null", "children_spec": [{"type": null, "context": null, "children_spec": []}, {"type": null, "context": null, "children_spec": []}]}]}] diff --git a/examples/resnet-18/README.md b/examples/resnet-18/README.md index aaf8ce7bb..cbb45539c 100644 --- a/examples/resnet-18/README.md +++ b/examples/resnet-18/README.md @@ -16,4 +16,4 @@ Once the requirements are installed, you should be able to run the example. ```bash python resnet-18.py -``` \ No newline at end of file +``` diff --git a/examples/resnet-18/requirements.txt b/examples/resnet-18/requirements.txt index a6ca4b760..a5123e970 100644 --- a/examples/resnet-18/requirements.txt +++ b/examples/resnet-18/requirements.txt @@ -1,2 +1,2 @@ transformers -shark_turbine==0.9.2 \ No newline at end of file +shark_turbine==0.9.2 diff --git a/iree-requirements.txt b/iree-requirements.txt index eaa171b4e..da59aeae6 100644 --- a/iree-requirements.txt +++ b/iree-requirements.txt @@ -1,2 +1,2 @@ iree-compiler==20240410.859 -iree-runtime==20240410.859 \ No newline at end of file +iree-runtime==20240410.859 diff --git a/shark_turbine/aot/support/procedural/globals.py b/shark_turbine/aot/support/procedural/globals.py index 250a8d600..5d24cf295 100644 --- a/shark_turbine/aot/support/procedural/globals.py +++ b/shark_turbine/aot/support/procedural/globals.py @@ -142,10 +142,7 @@ def track(self, module_builder: ModuleBuilder, export_namespace: str) -> Any: continue elif isinstance(value, AbstractTensor): global_type = value.get_ir_type(module_builder) - ( - actual_symbol_name, - global_op, - ) = module_builder.create_typed_global( + (actual_symbol_name, global_op,) = module_builder.create_typed_global( f"_{fq_name}", global_type, attrs=self._attrs, @@ -164,10 +161,7 @@ def track(self, module_builder: ModuleBuilder, export_namespace: str) -> Any: continue elif isinstance(value, AbstractScalar): global_type = value.get_ir_type(module_builder) - ( - actual_symbol_name, - global_op, - ) = module_builder.create_typed_global( + (actual_symbol_name, global_op,) = module_builder.create_typed_global( f"_{fq_name}", global_type, attrs=self._attrs, diff --git a/shark_turbine/transforms/quantization/mm_group_quant.py b/shark_turbine/transforms/quantization/mm_group_quant.py index bb4d96a85..bd33c91a5 100644 --- a/shark_turbine/transforms/quantization/mm_group_quant.py +++ b/shark_turbine/transforms/quantization/mm_group_quant.py @@ -75,7 +75,7 @@ def match(self, op: Operation): util.global private @{param_name}.quant.zero_point {{noinline}} = #stream.parameter.named<"model"::"{param_name}_zp"> : tensor<{k}x{group0}x{element_type}> func.func private @compute_mm_group_quant(%a : tensor<{m}x{n}x{element_type}>) -> tensor<{m}x{k}x{element_type}> {{ - %c0 = arith.constant 0 : index + %c0 = arith.constant 0 : index %weight_raw = util.global.load @{param_name} : tensor<{k}x{n_div}xi8> %m = tensor.dim %a, %c0 : tensor<{m}x{n}x{element_type}> %k = tensor.dim %weight_raw, %c0 : tensor<{k}x{n_div}xi8> @@ -87,12 +87,12 @@ def match(self, op: Operation): %empty_0 = tensor.empty() : tensor<{k}x{group0}x{group1}x{element_type}> %weight_cast = linalg.generic {{ indexing_maps = [ - affine_map<(d0, d1, d2) -> (d0, d1, d2)>, - affine_map<(d0, d1, d2) -> (d0, d1)>, - affine_map<(d0, d1, d2) -> (d0, d1)>, - affine_map<(d0, d1, d2) -> (d0, d1, d2)>], - iterator_types = ["parallel", "parallel", "parallel"] }} - ins(%weight_exp, %scale, %zp : tensor<{k}x{group0}x{group1}x{lowp_type}>, tensor<{k}x{group0}x{element_type}>, tensor<{k}x{group0}x{element_type}>) + affine_map<(d0, d1, d2) -> (d0, d1, d2)>, + affine_map<(d0, d1, d2) -> (d0, d1)>, + affine_map<(d0, d1, d2) -> (d0, d1)>, + affine_map<(d0, d1, d2) -> (d0, d1, d2)>], + iterator_types = ["parallel", "parallel", "parallel"] }} + ins(%weight_exp, %scale, %zp : tensor<{k}x{group0}x{group1}x{lowp_type}>, tensor<{k}x{group0}x{element_type}>, tensor<{k}x{group0}x{element_type}>) outs(%empty_0 : tensor<{k}x{group0}x{group1}x{element_type}>) {{ ^bb0(%in: {lowp_type}, %in_1: {element_type}, %in_2: {element_type}, %out: {element_type}): %16 = arith.extui %in : {lowp_type} to i32 @@ -108,10 +108,10 @@ def match(self, op: Operation): %result = linalg.generic {{ indexing_maps = [ affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>, - affine_map<(d0, d1, d2, d3) -> (d1, d2, d3)>, - affine_map<(d0, d1, d2, d3) -> (d0, d1)>], - iterator_types = ["parallel", "parallel", "reduction", "reduction"] }} - ins(%a_exp, %weight_cast : tensor<{m}x{group0}x{group1}x{element_type}>, tensor<{k}x{group0}x{group1}x{element_type}>) + affine_map<(d0, d1, d2, d3) -> (d1, d2, d3)>, + affine_map<(d0, d1, d2, d3) -> (d0, d1)>], + iterator_types = ["parallel", "parallel", "reduction", "reduction"] }} + ins(%a_exp, %weight_cast : tensor<{m}x{group0}x{group1}x{element_type}>, tensor<{k}x{group0}x{group1}x{element_type}>) outs(%zero_init : tensor<{m}x{k}x{element_type}>) {{ ^bb0(%in: {element_type}, %in_1: {element_type}, %out: {element_type}): %16 = arith.mulf %in, %in_1 : {element_type} diff --git a/tests/generated/extract_unimpl_ops.sh b/tests/generated/extract_unimpl_ops.sh index ace9134eb..65e207d87 100644 --- a/tests/generated/extract_unimpl_ops.sh +++ b/tests/generated/extract_unimpl_ops.sh @@ -1,3 +1,3 @@ #!/bin/bash -python main.py --limit 500 -j 8 | grep "NotImplementedError: Unimplemented torch op in the IREE compiler" | grep -o "'[^']*'" | sed "s/'//g" > unimplemented_torch_ops.txt \ No newline at end of file +python main.py --limit 500 -j 8 | grep "NotImplementedError: Unimplemented torch op in the IREE compiler" | grep -o "'[^']*'" | sed "s/'//g" > unimplemented_torch_ops.txt diff --git a/tests/generated/running_tests.md b/tests/generated/running_tests.md index 6c42cc31f..fbcd071d7 100644 --- a/tests/generated/running_tests.md +++ b/tests/generated/running_tests.md @@ -48,4 +48,4 @@ options: # Known Issues On Mac, setting resource limits via a python shell is finicky/not allowed this can cause issues with the jit parity-bench tests as they utilize the `resource` package to set an optional resource limit [here](https://github.com/jansel/pytorch-jit-paritybench/blob/7e55a422588c1d1e00f35a3d3a3ff896cce59e18/paritybench/utils.py#L57) - the simplest fix is to simply comment those lines out in your local `jit-paritybench` repo. -Getting unknown symbol errors associated with a shared library (commonly a torch library) often occurs because of mixing conda installed dependencies with pip installed dependencies because of possible differences in how certain shared libraries are linked, if possible use pip for all of your dependencies (especially when they have a dependence on one another like torch, torchvision, and torchaudio) \ No newline at end of file +Getting unknown symbol errors associated with a shared library (commonly a torch library) often occurs because of mixing conda installed dependencies with pip installed dependencies because of possible differences in how certain shared libraries are linked, if possible use pip for all of your dependencies (especially when they have a dependence on one another like torch, torchvision, and torchaudio) diff --git a/tests/transforms/general/testdata/custom_op_string_attr.mlir b/tests/transforms/general/testdata/custom_op_string_attr.mlir index c534a0745..34c560bef 100644 --- a/tests/transforms/general/testdata/custom_op_string_attr.mlir +++ b/tests/transforms/general/testdata/custom_op_string_attr.mlir @@ -3,7 +3,7 @@ builtin.module { func.func @forward() { %str = torch.constant.str "TEST_VALUE" torch.operator "torch.expand_custom_op_pass_test.print_string_attr"(%str) : (!torch.str) -> () - return + return } } diff --git a/version_info.json b/version_info.json index b5b8bc304..09a31b684 100644 --- a/version_info.json +++ b/version_info.json @@ -1 +1 @@ -{"core-version": "2.3.0rc20240410", "package-version": "0.9.7.dev1"} \ No newline at end of file +{"core-version": "2.3.0rc20240410", "package-version": "0.9.7.dev1"}