diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79824e1061..4bf3a56bc5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,3 +28,12 @@ repos: - --isolated - --select - F821,F823,W191 + + - repo: local + hooks: + - id: privacy-policy-check + name: Check Privacy Policy Headers + entry: python scripts/check_copyright_header.py + language: python + types_or: [python, c, c++, shell, text] + files: \.(py|cu|h|cuh|sh|metal)$ diff --git a/benchmarks/bench_galore_fused_kernels.py b/benchmarks/bench_galore_fused_kernels.py index 261c98acb1..76f373164b 100644 --- a/benchmarks/bench_galore_fused_kernels.py +++ b/benchmarks/bench_galore_fused_kernels.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import os diff --git a/benchmarks/benchmark_aq.py b/benchmarks/benchmark_aq.py index e0ab170bd0..cdc6f6fe5a 100644 --- a/benchmarks/benchmark_aq.py +++ b/benchmarks/benchmark_aq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """Benchmarks for affine quantized tensor, this includes int8 dynamic quant, int8 weight only quant and int4 weight only quant APIs""" import copy diff --git a/benchmarks/benchmark_fp6.py b/benchmarks/benchmark_fp6.py index c20599532c..c22eba9e1a 100644 --- a/benchmarks/benchmark_fp6.py +++ b/benchmarks/benchmark_fp6.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pandas as pd import torch import torch.nn.functional as F diff --git a/benchmarks/benchmark_gpu_sparsity.py b/benchmarks/benchmark_gpu_sparsity.py index 9e22f6d43a..e1577243da 100644 --- a/benchmarks/benchmark_gpu_sparsity.py +++ b/benchmarks/benchmark_gpu_sparsity.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import pandas as pd diff --git a/benchmarks/benchmark_hqq.py b/benchmarks/benchmark_hqq.py index d86f16cb57..c19fce0885 100644 --- a/benchmarks/benchmark_hqq.py +++ b/benchmarks/benchmark_hqq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. try: import hqq # noqa: F401 import triton diff --git a/benchmarks/benchmark_low_bit_adam.py b/benchmarks/benchmark_low_bit_adam.py index 0ea60901a0..211d7c1009 100644 --- a/benchmarks/benchmark_low_bit_adam.py +++ b/benchmarks/benchmark_low_bit_adam.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # pip install timm wandb tqdm datasets bitsandbytes # # optional: diff --git a/benchmarks/benchmark_marlin_qqq.py b/benchmarks/benchmark_marlin_qqq.py index 51df84abe4..bb2f951d74 100644 --- a/benchmarks/benchmark_marlin_qqq.py +++ b/benchmarks/benchmark_marlin_qqq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pandas as pd import torch from tqdm import tqdm diff --git a/benchmarks/benchmark_rowwise_scaled_linear_cutlass.py b/benchmarks/benchmark_rowwise_scaled_linear_cutlass.py index b96a744d11..4e7223e8ba 100644 --- a/benchmarks/benchmark_rowwise_scaled_linear_cutlass.py +++ b/benchmarks/benchmark_rowwise_scaled_linear_cutlass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pandas as pd import torch from tqdm import tqdm diff --git a/benchmarks/benchmark_rowwise_scaled_linear_sparse_cutlass.py b/benchmarks/benchmark_rowwise_scaled_linear_sparse_cutlass.py index eef2d0d4d6..40e2918805 100644 --- a/benchmarks/benchmark_rowwise_scaled_linear_sparse_cutlass.py +++ b/benchmarks/benchmark_rowwise_scaled_linear_sparse_cutlass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pandas as pd import torch from tqdm import tqdm diff --git a/benchmarks/benchmark_uintx.py b/benchmarks/benchmark_uintx.py index 78debbca82..9cfb3be134 100644 --- a/benchmarks/benchmark_uintx.py +++ b/benchmarks/benchmark_uintx.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from copy import deepcopy import torch @@ -62,16 +67,16 @@ def profile_bitpack(): prof.export_chrome_trace("trace.json") """ CPU perf: - unpack_gpu + unpack_gpu Self CPU time total: 602.501ms - - unpack_cpu + + unpack_cpu Self CPU time total: 415.469ms GPU perf: - unpack_gpu on gpu: + unpack_gpu on gpu: Self CPU time total: 58.512ms Self CUDA time total: 5.083ms - + unpack_cpu: Self CPU time total: 96.947ms Self CUDA time total: 5.253ms diff --git a/benchmarks/float8/bench_padding.py b/benchmarks/float8/bench_padding.py index 7fc451641e..eed8a5b542 100644 --- a/benchmarks/float8/bench_padding.py +++ b/benchmarks/float8/bench_padding.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional diff --git a/benchmarks/float8/training/float8_training_benchmark.sh b/benchmarks/float8/training/float8_training_benchmark.sh index 2b43d47554..da81c667bd 100755 --- a/benchmarks/float8/training/float8_training_benchmark.sh +++ b/benchmarks/float8/training/float8_training_benchmark.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash # This script can be used to launch a torchtitan float8 training run # with the given parameters, diff --git a/benchmarks/float8/training/parse_torchtitan_logs.py b/benchmarks/float8/training/parse_torchtitan_logs.py index 60f6b2acc7..0ad939983e 100644 --- a/benchmarks/float8/training/parse_torchtitan_logs.py +++ b/benchmarks/float8/training/parse_torchtitan_logs.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/usr/bin/env python3 """ Script which can be used to parse the log file generated by the torchtitan, diff --git a/benchmarks/fused_benchmark_utils.py b/benchmarks/fused_benchmark_utils.py index da0cf99ec3..c1ae0bfac2 100644 --- a/benchmarks/fused_benchmark_utils.py +++ b/benchmarks/fused_benchmark_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import triton from triton.testing import do_bench diff --git a/benchmarks/intmm.py b/benchmarks/intmm.py index ffad3cc27a..fa309b54e0 100644 --- a/benchmarks/intmm.py +++ b/benchmarks/intmm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import csv import itertools diff --git a/benchmarks/print_config_shapes.py b/benchmarks/print_config_shapes.py index 4cf232c862..0d742e6815 100644 --- a/benchmarks/print_config_shapes.py +++ b/benchmarks/print_config_shapes.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.kernel import autotuner configs = autotuner._load_best_configs() diff --git a/benchmarks/quantized_training/benchmark_int8mm.py b/benchmarks/quantized_training/benchmark_int8mm.py index cc2d5cf0db..6d6a8956cb 100644 --- a/benchmarks/quantized_training/benchmark_int8mm.py +++ b/benchmarks/quantized_training/benchmark_int8mm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pandas as pd import torch from triton.testing import do_bench diff --git a/benchmarks/quantized_training/pretrain_llama2.py b/benchmarks/quantized_training/pretrain_llama2.py index cfb3051630..6a1f4e8efb 100644 --- a/benchmarks/quantized_training/pretrain_llama2.py +++ b/benchmarks/quantized_training/pretrain_llama2.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # pre-train a mini Llama2 on TinyStories with INT8 quantized training # pip install huggingface_hub sentencepiece wandb # diff --git a/docs/source/tutorials_source/template_tutorial.py b/docs/source/tutorials_source/template_tutorial.py index e91251e1ec..a7de6e1bfb 100644 --- a/docs/source/tutorials_source/template_tutorial.py +++ b/docs/source/tutorials_source/template_tutorial.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # -*- coding: utf-8 -*- """ diff --git a/examples/sam2_amg_server/amg_example.py b/examples/sam2_amg_server/amg_example.py index d970c3bc51..d764cd3014 100644 --- a/examples/sam2_amg_server/amg_example.py +++ b/examples/sam2_amg_server/amg_example.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import cv2 import matplotlib.pyplot as plt import numpy as np diff --git a/examples/sam2_amg_server/annotate_with_rle.py b/examples/sam2_amg_server/annotate_with_rle.py index 55e5512011..db75cb4215 100644 --- a/examples/sam2_amg_server/annotate_with_rle.py +++ b/examples/sam2_amg_server/annotate_with_rle.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import json from datetime import datetime from io import BytesIO diff --git a/examples/sam2_amg_server/cli.py b/examples/sam2_amg_server/cli.py index 2f6758b7d3..8c8db0c5b6 100644 --- a/examples/sam2_amg_server/cli.py +++ b/examples/sam2_amg_server/cli.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from io import BytesIO import fire diff --git a/examples/sam2_amg_server/cli_on_modal.py b/examples/sam2_amg_server/cli_on_modal.py index 5fe56eeb1a..3f2b8d3b1f 100644 --- a/examples/sam2_amg_server/cli_on_modal.py +++ b/examples/sam2_amg_server/cli_on_modal.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import asyncio import json from pathlib import Path diff --git a/examples/sam2_amg_server/compare_rle_lists.py b/examples/sam2_amg_server/compare_rle_lists.py index 7a1c78b846..c83a6a8d2b 100644 --- a/examples/sam2_amg_server/compare_rle_lists.py +++ b/examples/sam2_amg_server/compare_rle_lists.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import json from pathlib import Path from typing import Any, Dict diff --git a/examples/sam2_amg_server/compile_export_utils.py b/examples/sam2_amg_server/compile_export_utils.py index d1c6fc06fa..4ed41d195d 100644 --- a/examples/sam2_amg_server/compile_export_utils.py +++ b/examples/sam2_amg_server/compile_export_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import time from pathlib import Path from typing import Optional diff --git a/examples/sam2_amg_server/generate_data.py b/examples/sam2_amg_server/generate_data.py index 50eeccb912..0143259d3e 100644 --- a/examples/sam2_amg_server/generate_data.py +++ b/examples/sam2_amg_server/generate_data.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import json import time from collections import OrderedDict diff --git a/examples/sam2_amg_server/modal_experiments.sh b/examples/sam2_amg_server/modal_experiments.sh index 2d7d8c1ab2..83949955b2 100755 --- a/examples/sam2_amg_server/modal_experiments.sh +++ b/examples/sam2_amg_server/modal_experiments.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash set -ex @@ -40,7 +45,7 @@ modal app stop torchao-sam-2-cli-mps echo "amg vs baseline" python compare_rle_lists.py ~/blogs/outputs/amg ~/blogs/outputs/amg_baseline --compare-folders --strict -echo "sps vs baseline" +echo "sps vs baseline" python compare_rle_lists.py ~/blogs/outputs/sps ~/blogs/outputs/sps_baseline --compare-folders --strict -echo "mps vs baseline" +echo "mps vs baseline" python compare_rle_lists.py ~/blogs/outputs/mps ~/blogs/outputs/mps_baseline --compare-folders --strict diff --git a/examples/sam2_amg_server/reproduce_experiments.py b/examples/sam2_amg_server/reproduce_experiments.py index c6799cd815..940568fcb2 100644 --- a/examples/sam2_amg_server/reproduce_experiments.py +++ b/examples/sam2_amg_server/reproduce_experiments.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import json import os import subprocess diff --git a/examples/sam2_amg_server/server.py b/examples/sam2_amg_server/server.py index 7e35858590..ceb10f791c 100644 --- a/examples/sam2_amg_server/server.py +++ b/examples/sam2_amg_server/server.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import asyncio import json import logging diff --git a/examples/sam2_vos_example/compile_export_utils.py b/examples/sam2_vos_example/compile_export_utils.py index 7d1b3eddf3..cc91e60fca 100644 --- a/examples/sam2_vos_example/compile_export_utils.py +++ b/examples/sam2_vos_example/compile_export_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import time from pathlib import Path from typing import Optional diff --git a/examples/sam2_vos_example/video_profile.py b/examples/sam2_vos_example/video_profile.py index 8ee9151cc4..340079a84d 100644 --- a/examples/sam2_vos_example/video_profile.py +++ b/examples/sam2_vos_example/video_profile.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import os import time from datetime import datetime diff --git a/scripts/check_copyright_header.py b/scripts/check_copyright_header.py new file mode 100755 index 0000000000..c0849624a9 --- /dev/null +++ b/scripts/check_copyright_header.py @@ -0,0 +1,83 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. +import argparse +import os +import re +import sys +from typing import List + +BASE_COPYRIGHT_TEXT = """Copyright (c) Meta Platforms, Inc. and affiliates. +All rights reserved. + +This source code is licensed under the BSD 3-Clause license found in the +LICENSE file in the root directory of this source tree.""" + +EXTENSIONS = {".py", ".cu", ".h", ".cuh", ".sh", ".metal"} +PRIVACY_PATTERNS = [ + r"Meta Platforms, Inc\. and affiliates", + r"Facebook, Inc(\.|,)? and its affiliates", + r"[0-9]{4}-present(\.|,)? Facebook", + r"[0-9]{4}(\.|,)? Facebook", +] + + +def get_copyright_header(file_ext: str) -> str: + if file_ext in {".cu", ".h", ".cuh", ".cpp", ".metal"}: + # C/C++ style files use // comments + return "\n".join( + "// " + line if line else "//" for line in BASE_COPYRIGHT_TEXT.split("\n") + ) + else: + # Python and shell scripts use # comments + return "\n".join( + "# " + line if line else "#" for line in BASE_COPYRIGHT_TEXT.split("\n") + ) + + +def has_copyright_header(content: str) -> bool: + # Check first 16 lines for privacy policy + first_16_lines = "\n".join(content.split("\n")[:16]) + return any(re.search(pattern, first_16_lines) for pattern in PRIVACY_PATTERNS) + + +def add_copyright_header(filename: str) -> None: + with open(filename, "r") as f: + content = f.read() + + if not has_copyright_header(content): + ext = os.path.splitext(filename)[1] + header = get_copyright_header(ext) + with open(filename, "w") as f: + f.write(header + "\n\n" + content) + + +def main(argv: List[str] = None) -> int: + parser = argparse.ArgumentParser() + parser.add_argument("filenames", nargs="*", help="Filenames to check") + args = parser.parse_args(argv) + + retval = 0 + + for filename in args.filenames: + # Skip __init__.py files + if os.path.basename(filename) == "__init__.py": + continue + + ext = os.path.splitext(filename)[1] + if ext in EXTENSIONS: + with open(filename, "r") as f: + content = f.read() + + if not has_copyright_header(content): + print(f"Adding copyright header to {filename}") + add_copyright_header(filename) + retval = 1 + + return retval + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/create_weight_map.py b/scripts/create_weight_map.py index 793af6e7ee..28c8f75346 100644 --- a/scripts/create_weight_map.py +++ b/scripts/create_weight_map.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import json from pathlib import Path diff --git a/scripts/hf_eval.py b/scripts/hf_eval.py index a6cb19309a..7b51900a20 100644 --- a/scripts/hf_eval.py +++ b/scripts/hf_eval.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from tabulate import tabulate from transformers import AutoModelForCausalLM, AutoTokenizer diff --git a/scripts/prepare.sh b/scripts/prepare.sh index fe037de296..f5360f59cc 100644 --- a/scripts/prepare.sh +++ b/scripts/prepare.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. python scripts/download.py --repo_id meta-llama/Llama-2-7b-chat-hf python scripts/download.py --repo_id meta-llama/Meta-Llama-3-8B python scripts/download.py --repo_id meta-llama/Meta-Llama-3.1-8B diff --git a/scripts/quick_start.py b/scripts/quick_start.py index f2e195fd7e..747dedcf95 100644 --- a/scripts/quick_start.py +++ b/scripts/quick_start.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import torch diff --git a/scripts/run_ruff_fix.sh b/scripts/run_ruff_fix.sh index 9a016c2a56..4b65fd8fd0 100644 --- a/scripts/run_ruff_fix.sh +++ b/scripts/run_ruff_fix.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. ruff check . --fix # --isolated is used to skip the allowlist at all so this applies to all files # please be careful when using this large changes means everyone needs to rebase diff --git a/scripts/upload_to_s3.py b/scripts/upload_to_s3.py index e3d1ff31cc..a3e908b285 100644 --- a/scripts/upload_to_s3.py +++ b/scripts/upload_to_s3.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import io import json import os diff --git a/test/dtypes/ddp/check_ddp_nf4.py b/test/dtypes/ddp/check_ddp_nf4.py index 608bcb9c02..952c7d0dbd 100644 --- a/test/dtypes/ddp/check_ddp_nf4.py +++ b/test/dtypes/ddp/check_ddp_nf4.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse from pathlib import Path diff --git a/test/dtypes/ddp/ddp_nf4.py b/test/dtypes/ddp/ddp_nf4.py index e38d0015b1..9b9af9f6c1 100644 --- a/test/dtypes/ddp/ddp_nf4.py +++ b/test/dtypes/ddp/ddp_nf4.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import math import os diff --git a/test/dtypes/ddp/run_ddp_nf4_test.sh b/test/dtypes/ddp/run_ddp_nf4_test.sh index b9a3c2929f..9f586135c1 100755 --- a/test/dtypes/ddp/run_ddp_nf4_test.sh +++ b/test/dtypes/ddp/run_ddp_nf4_test.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash set -euo pipefail diff --git a/test/dtypes/test_affine_quantized.py b/test/dtypes/test_affine_quantized.py index af01c4b428..4176c0fcf9 100644 --- a/test/dtypes/test_affine_quantized.py +++ b/test/dtypes/test_affine_quantized.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import tempfile import unittest diff --git a/test/dtypes/test_affine_quantized_float.py b/test/dtypes/test_affine_quantized_float.py index 4d8312b427..78004c6f5e 100644 --- a/test/dtypes/test_affine_quantized_float.py +++ b/test/dtypes/test_affine_quantized_float.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest from torchao.utils import ( diff --git a/test/dtypes/test_affine_quantized_tensor_parallel.py b/test/dtypes/test_affine_quantized_tensor_parallel.py index b60f3251dc..7280fd6048 100644 --- a/test/dtypes/test_affine_quantized_tensor_parallel.py +++ b/test/dtypes/test_affine_quantized_tensor_parallel.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest import pytest diff --git a/test/dtypes/test_bitpacking.py b/test/dtypes/test_bitpacking.py index 262a4d6ca6..0ed4462d5d 100644 --- a/test/dtypes/test_bitpacking.py +++ b/test/dtypes/test_bitpacking.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch from torch.utils._triton import has_triton diff --git a/test/dtypes/test_floatx.py b/test/dtypes/test_floatx.py index 0953e33b0f..956ef9a03e 100644 --- a/test/dtypes/test_floatx.py +++ b/test/dtypes/test_floatx.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import unittest diff --git a/test/dtypes/test_nf4.py b/test/dtypes/test_nf4.py index 9f56154e9c..81899cce80 100644 --- a/test/dtypes/test_nf4.py +++ b/test/dtypes/test_nf4.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import io import logging diff --git a/test/dtypes/test_uint4.py b/test/dtypes/test_uint4.py index cf4077a78c..f7656ef19e 100644 --- a/test/dtypes/test_uint4.py +++ b/test/dtypes/test_uint4.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import unittest diff --git a/test/dtypes/test_uintx.py b/test/dtypes/test_uintx.py index 9bc983885e..c48980486d 100644 --- a/test/dtypes/test_uintx.py +++ b/test/dtypes/test_uintx.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch diff --git a/test/float8/test_dtensor.sh b/test/float8/test_dtensor.sh index 585a9014b1..7966cdd802 100755 --- a/test/float8/test_dtensor.sh +++ b/test/float8/test_dtensor.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash # terminate script on first error diff --git a/test/float8/test_everything.sh b/test/float8/test_everything.sh index 5b702d6fe6..068c75de63 100755 --- a/test/float8/test_everything.sh +++ b/test/float8/test_everything.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash # terminate script on first error diff --git a/test/float8/test_float8_utils.py b/test/float8/test_float8_utils.py index 1a6a888246..b5e8be3703 100644 --- a/test/float8/test_float8_utils.py +++ b/test/float8/test_float8_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest import pytest diff --git a/test/float8/test_fsdp.sh b/test/float8/test_fsdp.sh index 6f135a2e76..3f79db0692 100755 --- a/test/float8/test_fsdp.sh +++ b/test/float8/test_fsdp.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash # terminate script on first error diff --git a/test/float8/test_fsdp2/test_fsdp2.py b/test/float8/test_fsdp2/test_fsdp2.py index 8ccdaed489..6f0cfecf41 100644 --- a/test/float8/test_fsdp2/test_fsdp2.py +++ b/test/float8/test_fsdp2/test_fsdp2.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import itertools import threading diff --git a/test/float8/test_fsdp_compile.sh b/test/float8/test_fsdp_compile.sh index 666136abac..192586cee6 100755 --- a/test/float8/test_fsdp_compile.sh +++ b/test/float8/test_fsdp_compile.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash # terminate script on first error diff --git a/test/galore/memory_analysis_utils.py b/test/galore/memory_analysis_utils.py index 6e464e8766..41f601e3a2 100644 --- a/test/galore/memory_analysis_utils.py +++ b/test/galore/memory_analysis_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from functools import partial import pandas as pd diff --git a/test/galore/model_configs.py b/test/galore/model_configs.py index 358f5a6868..1efb4a131e 100644 --- a/test/galore/model_configs.py +++ b/test/galore/model_configs.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # LLAMA100M = { # "architectures": ["LLaMAForCausalLM"], # "attention_bias": False, diff --git a/test/galore/profile_memory_usage.py b/test/galore/profile_memory_usage.py index e00a8293b9..33fd746c39 100644 --- a/test/galore/profile_memory_usage.py +++ b/test/galore/profile_memory_usage.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import contextlib import logging diff --git a/test/galore/profiling_utils.py b/test/galore/profiling_utils.py index 033d33ab5a..fc79adb65a 100644 --- a/test/galore/profiling_utils.py +++ b/test/galore/profiling_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import gc import logging import os diff --git a/test/hqq/test_hqq_affine.py b/test/hqq/test_hqq_affine.py index 7bbd52db09..a6990549a3 100644 --- a/test/hqq/test_hqq_affine.py +++ b/test/hqq/test_hqq_affine.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest import torch diff --git a/test/hqq/test_triton_mm.py b/test/hqq/test_triton_mm.py index 7298f323f2..92e670a95b 100644 --- a/test/hqq/test_triton_mm.py +++ b/test/hqq/test_triton_mm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # Skip entire test if following module not available, otherwise CI failure import pytest diff --git a/test/hqq/test_triton_qkv_fused.py b/test/hqq/test_triton_qkv_fused.py index f28972553d..015c0a2f05 100644 --- a/test/hqq/test_triton_qkv_fused.py +++ b/test/hqq/test_triton_qkv_fused.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest triton = pytest.importorskip( diff --git a/test/kernel/galore_test_utils.py b/test/kernel/galore_test_utils.py index 565cfac8fa..2810941fe1 100644 --- a/test/kernel/galore_test_utils.py +++ b/test/kernel/galore_test_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torchao.prototype.galore.kernels.adam_downproj_fused import fused_adam_mm_launcher diff --git a/test/kernel/test_fused_kernels.py b/test/kernel/test_fused_kernels.py index 9c5bc19aaf..3c51b78f1b 100644 --- a/test/kernel/test_fused_kernels.py +++ b/test/kernel/test_fused_kernels.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import itertools import pytest diff --git a/test/kernel/test_galore_downproj.py b/test/kernel/test_galore_downproj.py index fc8b784a9f..f0e135667e 100644 --- a/test/kernel/test_galore_downproj.py +++ b/test/kernel/test_galore_downproj.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest # Skip entire test if triton is not available, otherwise CI failure diff --git a/test/prototype/mx_formats/test_mx_mm.py b/test/prototype/mx_formats/test_mx_mm.py index 7c66c5d053..11d48719ec 100644 --- a/test/prototype/mx_formats/test_mx_mm.py +++ b/test/prototype/mx_formats/test_mx_mm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch diff --git a/test/prototype/test_autoround.py b/test/prototype/test_autoround.py index e8d4de444d..483704a28c 100644 --- a/test/prototype/test_autoround.py +++ b/test/prototype/test_autoround.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest from torchao.prototype.autoround.utils import is_auto_round_available diff --git a/test/prototype/test_awq.py b/test/prototype/test_awq.py index 1bfdf57aca..34ddd9c5e9 100644 --- a/test/prototype/test_awq.py +++ b/test/prototype/test_awq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import os from copy import deepcopy diff --git a/test/prototype/test_codebook_quant.py b/test/prototype/test_codebook_quant.py index 2d8d8f025f..0614fc9632 100644 --- a/test/prototype/test_codebook_quant.py +++ b/test/prototype/test_codebook_quant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest import torch diff --git a/test/prototype/test_mixed_precision.py b/test/prototype/test_mixed_precision.py index 3af56c7bf3..49f2da983f 100644 --- a/test/prototype/test_mixed_precision.py +++ b/test/prototype/test_mixed_precision.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest import torch diff --git a/test/prototype/test_parametrization.py b/test/prototype/test_parametrization.py index 19fc5737d2..40e6f2f574 100644 --- a/test/prototype/test_parametrization.py +++ b/test/prototype/test_parametrization.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import unittest diff --git a/test/prototype/test_parq.py b/test/prototype/test_parq.py index 16b232f221..d93c08e643 100644 --- a/test/prototype/test_parq.py +++ b/test/prototype/test_parq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest import torch diff --git a/test/prototype/test_quantized_training.py b/test/prototype/test_quantized_training.py index 1d53234b19..13147335e6 100644 --- a/test/prototype/test_quantized_training.py +++ b/test/prototype/test_quantized_training.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest from torchao.utils import TORCH_VERSION_AT_LEAST_2_4, TORCH_VERSION_AT_LEAST_2_6 diff --git a/test/prototype/test_scheduler.py b/test/prototype/test_scheduler.py index 6c924ed300..c5e60d2a05 100644 --- a/test/prototype/test_scheduler.py +++ b/test/prototype/test_scheduler.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest import warnings diff --git a/test/prototype/test_smoothquant.py b/test/prototype/test_smoothquant.py index 9c914eca57..a5265f7b1f 100644 --- a/test/prototype/test_smoothquant.py +++ b/test/prototype/test_smoothquant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import tempfile from copy import deepcopy diff --git a/test/prototype/test_sparsifier.py b/test/prototype/test_sparsifier.py index 26853a9dab..1d6630fc93 100644 --- a/test/prototype/test_sparsifier.py +++ b/test/prototype/test_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # Owner(s): ["module: unknown"] import itertools diff --git a/test/prototype/test_sparsity_utils.py b/test/prototype/test_sparsity_utils.py index f73ff76331..590be501a2 100644 --- a/test/prototype/test_sparsity_utils.py +++ b/test/prototype/test_sparsity_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import unittest diff --git a/test/prototype/test_spinquant.py b/test/prototype/test_spinquant.py index 42606b014e..03f0c34e20 100644 --- a/test/prototype/test_spinquant.py +++ b/test/prototype/test_spinquant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch diff --git a/test/prototype/test_structured_sparsifier.py b/test/prototype/test_structured_sparsifier.py index 3eb3954213..57f36fc3cf 100644 --- a/test/prototype/test_structured_sparsifier.py +++ b/test/prototype/test_structured_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # Owner(s): ["module: unknown"] import copy import logging diff --git a/test/quantization/test_galore_quant.py b/test/quantization/test_galore_quant.py index 6b26b948f5..a67f7775b1 100644 --- a/test/quantization/test_galore_quant.py +++ b/test/quantization/test_galore_quant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import itertools import pytest diff --git a/test/quantization/test_gptq_mt.py b/test/quantization/test_gptq_mt.py index 5d4e73ed61..d703efbd49 100644 --- a/test/quantization/test_gptq_mt.py +++ b/test/quantization/test_gptq_mt.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from pathlib import Path import pytest diff --git a/test/quantization/test_marlin_qqq.py b/test/quantization/test_marlin_qqq.py index f8581b1307..4de78a1a66 100644 --- a/test/quantization/test_marlin_qqq.py +++ b/test/quantization/test_marlin_qqq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import pytest diff --git a/test/quantization/test_observer.py b/test/quantization/test_observer.py index 4567f3baef..f51b89d6cd 100644 --- a/test/quantization/test_observer.py +++ b/test/quantization/test_observer.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import re import unittest diff --git a/test/smoke_tests/smoke_tests.py b/test/smoke_tests/smoke_tests.py index 70a0810984..09ec8a1f24 100644 --- a/test/smoke_tests/smoke_tests.py +++ b/test/smoke_tests/smoke_tests.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """Run smoke tests""" import torchao diff --git a/test/sparsity/test_fast_sparse_training.py b/test/sparsity/test_fast_sparse_training.py index e3f5626d49..804a585dd8 100644 --- a/test/sparsity/test_fast_sparse_training.py +++ b/test/sparsity/test_fast_sparse_training.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import unittest diff --git a/test/sparsity/test_marlin.py b/test/sparsity/test_marlin.py index dc4489f05e..588c208da2 100644 --- a/test/sparsity/test_marlin.py +++ b/test/sparsity/test_marlin.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import pytest diff --git a/test/sparsity/test_sparse_api.py b/test/sparsity/test_sparse_api.py index 558474714c..f0dd31fdfc 100644 --- a/test/sparsity/test_sparse_api.py +++ b/test/sparsity/test_sparse_api.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import logging import unittest diff --git a/test/sparsity/test_supermask.py b/test/sparsity/test_supermask.py index c84a152330..1ef40d12d7 100644 --- a/test/sparsity/test_supermask.py +++ b/test/sparsity/test_supermask.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import unittest diff --git a/test/sparsity/test_wanda.py b/test/sparsity/test_wanda.py index 5347e61e03..ce6e3decc9 100644 --- a/test/sparsity/test_wanda.py +++ b/test/sparsity/test_wanda.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import unittest diff --git a/test/test_ao_models.py b/test/test_ao_models.py index 49385b0a99..79e4cc3ef5 100644 --- a/test/test_ao_models.py +++ b/test/test_ao_models.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch diff --git a/test/test_low_bit_optim.py b/test/test_low_bit_optim.py index 38da2c72a5..c138f140ec 100644 --- a/test/test_low_bit_optim.py +++ b/test/test_low_bit_optim.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import shutil import tempfile diff --git a/test/test_ops.py b/test/test_ops.py index 076ab9ab16..1cdce2cd81 100644 --- a/test/test_ops.py +++ b/test/test_ops.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import itertools import sys diff --git a/test/test_ops_rowwise_scaled_linear_cutlass.py b/test/test_ops_rowwise_scaled_linear_cutlass.py index 9b57cb2132..f9b9c6a7f9 100644 --- a/test/test_ops_rowwise_scaled_linear_cutlass.py +++ b/test/test_ops_rowwise_scaled_linear_cutlass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # This actually belongs to test_ops.py, extracted here for easier # maintenance. diff --git a/test/test_ops_rowwise_scaled_linear_sparse_cutlass.py b/test/test_ops_rowwise_scaled_linear_sparse_cutlass.py index 2e31d9aa57..56bdd355f7 100644 --- a/test/test_ops_rowwise_scaled_linear_sparse_cutlass.py +++ b/test/test_ops_rowwise_scaled_linear_sparse_cutlass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # This actually belongs to test_ops.py, extracted here for easier # maintenance. diff --git a/test/test_utils.py b/test/test_utils.py index 77a8b39aae..d41168b5a7 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import unittest from unittest.mock import patch diff --git a/torchao/_executorch_ops.py b/torchao/_executorch_ops.py index 3cf94ee53d..29339bba8c 100644 --- a/torchao/_executorch_ops.py +++ b/torchao/_executorch_ops.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch diff --git a/torchao/_models/llama/benchmarks.sh b/torchao/_models/llama/benchmarks.sh index 2f50e47dcd..4c11b193d5 100644 --- a/torchao/_models/llama/benchmarks.sh +++ b/torchao/_models/llama/benchmarks.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. export CHECKPOINT_PATH=../../../checkpoints # path to checkpoints folder # README BENCHMARKS diff --git a/torchao/_models/llama/bsr_benchmarks.sh b/torchao/_models/llama/bsr_benchmarks.sh index 0baa527fef..1ce4da8759 100644 --- a/torchao/_models/llama/bsr_benchmarks.sh +++ b/torchao/_models/llama/bsr_benchmarks.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # BSR benchmarks export CHECKPOINT_PATH=../../../checkpoints # path to checkpoints folder diff --git a/torchao/_models/llama/demo_summarize.sh b/torchao/_models/llama/demo_summarize.sh index 5aeb91ee63..6a9a11e254 100644 --- a/torchao/_models/llama/demo_summarize.sh +++ b/torchao/_models/llama/demo_summarize.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # grab moby dick prompt wget -nc -O moby.txt https://gist.githubusercontent.com/jcaip/f319146bb543e92e23b2c76815b0f29f/raw/31a9cd12b0b59f323eb197c9534953bdac352986/gistfile1.txt diff --git a/torchao/_models/llama/evals.sh b/torchao/_models/llama/evals.sh index ee57c422af..b4c32644a7 100644 --- a/torchao/_models/llama/evals.sh +++ b/torchao/_models/llama/evals.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. export CHECKPOINT_PATH=../../../checkpoints # path to checkpoints folder export MODEL_REPO=meta-llama/Llama-2-7b-chat-hf diff --git a/torchao/_models/llama/tokenizer.py b/torchao/_models/llama/tokenizer.py index 9825e4d70b..1388e76c99 100644 --- a/torchao/_models/llama/tokenizer.py +++ b/torchao/_models/llama/tokenizer.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # copied from https://github.com/pytorch-labs/gpt-fast/blob/main/tokenizer.py import os diff --git a/torchao/_models/sam/benchmark.sh b/torchao/_models/sam/benchmark.sh index cfcf52792d..e446f62cbc 100755 --- a/torchao/_models/sam/benchmark.sh +++ b/torchao/_models/sam/benchmark.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # baseline python eval_combo.py --coco_root_dir datasets/coco2017 --coco_slice_name val2017 --sam_checkpoint_base_path checkpoints --sam_model_type vit_h --point_sampling_cache_dir tmp/sam_coco_mask_center_cache --mask_debug_out_dir tmp/sam_eval_masks_out --batch_size 32 --num_workers 32 --use_compile max-autotune --use_half bfloat16 --device cuda --print_header True # int8 dynamic quant (all) diff --git a/torchao/_models/sam/data.py b/torchao/_models/sam/data.py index 1af566c2fe..ab493272ff 100644 --- a/torchao/_models/sam/data.py +++ b/torchao/_models/sam/data.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import diskcache import numpy as np import skimage.color as color diff --git a/torchao/_models/sam/eval_combo.py b/torchao/_models/sam/eval_combo.py index 781c10c935..20f7f3ed2c 100644 --- a/torchao/_models/sam/eval_combo.py +++ b/torchao/_models/sam/eval_combo.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math import resource import time diff --git a/torchao/_models/sam/metrics.py b/torchao/_models/sam/metrics.py index 51b9af36e6..6a20a9f036 100644 --- a/torchao/_models/sam/metrics.py +++ b/torchao/_models/sam/metrics.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pandas as pd import torch diff --git a/torchao/_models/sam/setup.sh b/torchao/_models/sam/setup.sh index 2b92627834..3fcfa12462 100644 --- a/torchao/_models/sam/setup.sh +++ b/torchao/_models/sam/setup.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. SETUP_HOME=$(pwd) diff --git a/torchao/_models/sam2/map_tensor.py b/torchao/_models/sam2/map_tensor.py index 99cd147516..0310e7f8b6 100644 --- a/torchao/_models/sam2/map_tensor.py +++ b/torchao/_models/sam2/map_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import contextlib import functools from typing import Dict diff --git a/torchao/_models/utils.py b/torchao/_models/utils.py index 346feb57ae..2b46f06aa7 100644 --- a/torchao/_models/utils.py +++ b/torchao/_models/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import datetime import hashlib import json diff --git a/torchao/core/config.py b/torchao/core/config.py index d97ae5987c..4a5a4c5720 100644 --- a/torchao/core/config.py +++ b/torchao/core/config.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import abc import dataclasses import enum diff --git a/torchao/csrc/cuda/cutlass_extensions/common.h b/torchao/csrc/cuda/cutlass_extensions/common.h index f6024a752a..4607f40f83 100644 --- a/torchao/csrc/cuda/cutlass_extensions/common.h +++ b/torchao/csrc/cuda/cutlass_extensions/common.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include diff --git a/torchao/csrc/cuda/fp6_llm/configs.h b/torchao/csrc/cuda/fp6_llm/configs.h index 60f6745048..54d4db3a69 100644 --- a/torchao/csrc/cuda/fp6_llm/configs.h +++ b/torchao/csrc/cuda/fp6_llm/configs.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is copied from https://github.com/usyd-fsalab/fp6_llm/blob/5df6737cca32f604e957e3f63f03ccc2e4d1df0d/fp6_llm/csrc/include/configs.h #ifndef CONFIGS_H @@ -33,7 +38,7 @@ /******************** Register Allocation For GEMM ********************/ #define REG_PER_THREAD_C_TENSOR_16_16 8 // 8 for FP32 Accumulation -/********************** Memory Padding Parameters **********************/ +/********************** Memory Padding Parameters **********************/ // Eliminating bank-conflict #define PADDING_BYTES_16 16 // Padding 16 bytes each column #define PADDING_SHARED_MEM_FOR_B_8 8 // Padding 8 half each column, during CopyFromGlobalToShared() for B @@ -48,7 +53,7 @@ struct TilingConfig { // Depending on "n" dimension of the GEMM static constexpr int BLOCK_ROW_WARPS = BLOCK_ROW_WARPS_; static constexpr int BLOCK_COL_WARPS = BLOCK_COL_WARPS_; - static constexpr int WARP_COL_MMA_TENSORS = WARP_COL_MMA_TENSORS_; + static constexpr int WARP_COL_MMA_TENSORS = WARP_COL_MMA_TENSORS_; /************************* WARP Tiling part-2 *************************/ static constexpr int WARP_N = WARP_COL_MMA_TENSORS * MMA_8; /*************************Thread Block Tiling *************************/ diff --git a/torchao/csrc/cuda/fp6_llm/fp6_linear.cu b/torchao/csrc/cuda/fp6_llm/fp6_linear.cu index cc601da34b..531e1ba7e6 100644 --- a/torchao/csrc/cuda/fp6_llm/fp6_linear.cu +++ b/torchao/csrc/cuda/fp6_llm/fp6_linear.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is adapted from https://github.com/usyd-fsalab/fp6_llm/blob/5df6737cca32f604e957e3f63f03ccc2e4d1df0d/fp6_llm/csrc/fp6_linear.cu // // MODIFICATION NOTE (2024-09-25): added SM75 support (https://github.com/pytorch/ao/pull/942): @@ -52,8 +57,8 @@ static void Kernel_Ex(cudaStream_t stream, OutputDataType *C, const size_t M_Global, const size_t N_Global, - const size_t K_Global, - int Split_K) + const size_t K_Global, + int Split_K) { #ifdef DEBUG_MODE printf("\n"); @@ -86,7 +91,7 @@ void fpx_linear_kernel(cudaStream_t stream, InputDataType *C, const size_t M_Global, const size_t N_Global, - const size_t K_Global, + const size_t K_Global, float *Reduction_Workspace, // Reduction_Workspace_Size = Split_K * M_Global * N_Global * sizeof(fp32) int Split_K) { diff --git a/torchao/csrc/cuda/fp6_llm/kernel_matmul.cuh b/torchao/csrc/cuda/fp6_llm/kernel_matmul.cuh index b008971647..d4be92b227 100644 --- a/torchao/csrc/cuda/fp6_llm/kernel_matmul.cuh +++ b/torchao/csrc/cuda/fp6_llm/kernel_matmul.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is modified from https://github.com/usyd-fsalab/fp6_llm/blob/5df6737cca32f604e957e3f63f03ccc2e4d1df0d/fp6_llm/csrc/include/kernel_matmul.cuh // // MODIFICATION NOTE (2024-09-25): added SM75 support (https://github.com/pytorch/ao/pull/942): @@ -31,8 +36,8 @@ #define SMEM_SIZE_PER_WARP_1BIT (WEIGHT_PER_WARP*BIT_WIDTH_1/8) // 512 Bytes, doubleBuffer not taken into consideration #define SMEM_SIZE_PER_WARP_2BIT (WEIGHT_PER_WARP*BIT_WIDTH_2/8) // 1024 Bytes, doubleBuffer not taken into consideration #define SMEM_SIZE_PER_WARP_4BIT (WEIGHT_PER_WARP*BIT_WIDTH_4/8) // 2048 Bytes, doubleBuffer not taken into consideration -#define SMEM_SIZE_PER_TB_1BIT (SMEM_SIZE_PER_WARP_1BIT*TilingConfig::BLOCK_WARPS*PIPELINE_LEVEL_GMEM) // #WARP=4; Trible-Buffer for 3-level pipeline for A = 6 KB; double buffer for 2-level pipeline A= 4 KB. -#define SMEM_SIZE_PER_TB_2BIT (SMEM_SIZE_PER_WARP_2BIT*TilingConfig::BLOCK_WARPS*PIPELINE_LEVEL_GMEM) // #WARP=4; Trible-Buffer for 3-level pipeline for A = 12 KB; double buffer for 2-level pipeline A= 8 KB. +#define SMEM_SIZE_PER_TB_1BIT (SMEM_SIZE_PER_WARP_1BIT*TilingConfig::BLOCK_WARPS*PIPELINE_LEVEL_GMEM) // #WARP=4; Trible-Buffer for 3-level pipeline for A = 6 KB; double buffer for 2-level pipeline A= 4 KB. +#define SMEM_SIZE_PER_TB_2BIT (SMEM_SIZE_PER_WARP_2BIT*TilingConfig::BLOCK_WARPS*PIPELINE_LEVEL_GMEM) // #WARP=4; Trible-Buffer for 3-level pipeline for A = 12 KB; double buffer for 2-level pipeline A= 8 KB. #define SMEM_SIZE_PER_TB_4BIT (SMEM_SIZE_PER_WARP_4BIT*TilingConfig::BLOCK_WARPS*PIPELINE_LEVEL_GMEM) // #WARP=4; Trible-Buffer for 3-level pipeline for A = 24 KB; double buffer for 2-level pipeline A= 16 KB. #define SMEM_SIZE_PER_TB_A_TILE (SMEM_SIZE_PER_TB_1BIT+SMEM_SIZE_PER_TB_2BIT+SMEM_SIZE_PER_TB_4BIT) // used in fp6_linear.cu, Kernel_Ex(). /******************** Gloabl Memory Layout For QUANTIZED DATA *******************/ @@ -45,7 +50,7 @@ * A: row major with ahead-of-time layout transformation, FP6 * B: col major, FP16 * C: col major, FP16 - */ + */ template __global__ void QUANT_GEMM_Kernel(const uint4* Weight, const half* Scales, const half *B, @@ -71,7 +76,7 @@ __global__ void QUANT_GEMM_Kernel(const uint4* Weight, const half* Scales, const uint4* Weight_2bit = Weight_1bit + (USE_SEG_1BIT ? M_Global*K_Global*BIT_WIDTH_1/128 : 0); const uint4* Weight_4bit = Weight_2bit + (USE_SEG_2BIT ? M_Global*K_Global*BIT_WIDTH_2/128 : 0); // Dynamic shared memory for FP16 A tiles, 128 Bytes aligned - extern __shared__ __align__(128) half smem[]; + extern __shared__ __align__(128) half smem[]; half (*smem_array)[WARP_K+PADDING_SHARED_MEM_FOR_B_8] = reinterpret_cast ( smem + SMEM_SIZE_PER_TB_A_TILE/2 ); // Dynamic shared memory for FP16 B tiles __shared__ half QuantScales[64*TilingConfig::BLOCK_WARPS]; // static shared memory for quantization scales, 64 row per warp * 4 warps = 512 Bytes // Thread Block Mapping, considering SplitK @@ -85,9 +90,9 @@ __global__ void QUANT_GEMM_Kernel(const uint4* Weight, const half* Scales, const size_t AverageNumBlock_K = NumBlock_K/Split_K; const size_t ExtraNumBlock_K = NumBlock_K - AverageNumBlock_K * Split_K; size_t NumIter = AverageNumBlock_K; - size_t StartBlockID_K = AverageNumBlock_K*BatchID; + size_t StartBlockID_K = AverageNumBlock_K*BatchID; if(BatchID (smem_array+i*TilingConfig::TILE_N, BTile_GPTR, K_Global, NumColumnToCopy); - BTile_GPTR += TilingConfig::TILE_K; + BTile_GPTR += TilingConfig::TILE_K; } // Register Allocation for A,B, and C, Initilazed to Zeros ///////////////////////////////////////////////////////////////////// constexpr int NumRegSets_a = WARP_ROW_MMA_TENSORS; // 1 set = 4 registers, containing a 16*16 MMA block diff --git a/torchao/csrc/cuda/fp6_llm/kernel_reduction.cuh b/torchao/csrc/cuda/fp6_llm/kernel_reduction.cuh index d09d9b861d..5dc4d02e77 100644 --- a/torchao/csrc/cuda/fp6_llm/kernel_reduction.cuh +++ b/torchao/csrc/cuda/fp6_llm/kernel_reduction.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is copied from https://github.com/usyd-fsalab/fp6_llm/blob/ce76774bcfc26b325c1b558abcf1935026d9abbc/fp6_llm/csrc/include/kernel_reduction.cuh /*************************************************************************** diff --git a/torchao/csrc/cuda/fp6_llm/ptx_cp.async.cuh b/torchao/csrc/cuda/fp6_llm/ptx_cp.async.cuh index c1d064f32a..a99d7acb5c 100644 --- a/torchao/csrc/cuda/fp6_llm/ptx_cp.async.cuh +++ b/torchao/csrc/cuda/fp6_llm/ptx_cp.async.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is copied from https://github.com/usyd-fsalab/fp6_llm/blob/ce76774bcfc26b325c1b558abcf1935026d9abbc/fp6_llm/csrc/include/ptx_cp.async.cuh /*************************************************************************** diff --git a/torchao/csrc/cuda/fp6_llm/ptx_mma.cuh b/torchao/csrc/cuda/fp6_llm/ptx_mma.cuh index 57dd8cb53f..d5f937e207 100644 --- a/torchao/csrc/cuda/fp6_llm/ptx_mma.cuh +++ b/torchao/csrc/cuda/fp6_llm/ptx_mma.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is modified from https://github.com/usyd-fsalab/fp6_llm/blob/5df6737cca32f604e957e3f63f03ccc2e4d1df0d/fp6_llm/csrc/include/ptx_mma.cuh // // MODIFICATION NOTE (2024-09-25): added SM75 support (https://github.com/pytorch/ao/pull/942): @@ -50,14 +55,14 @@ __device__ __forceinline__ void B_FromSharedToReg(uint32_t (* __restrict__ Reg)[ #ifdef DEBUG_MODE static_assert( (TilingConfig::WARP_COL_MMA_TENSORS==1) || (TilingConfig::WARP_COL_MMA_TENSORS%2==0) ); #endif - + const int warpId = threadIdx.x / WARP_SIZE; int lane_id = threadIdx.x % WARP_SIZE; int WARP_j = warpId % TilingConfig::BLOCK_COL_WARPS; int warp_start_col = TilingConfig::WARP_COL_MMA_TENSORS * MMA_8 * WARP_j; // each warp may start from reading warp_start_col'th column of the B tile in shared memory #ifdef DEBUG_MODE assert( warp_start_col==0 ); - #endif + #endif #if __CUDA_ARCH__ == 750 if (TilingConfig::WARP_COL_MMA_TENSORS==1) { diff --git a/torchao/csrc/cuda/fp6_llm/utils_core.cuh b/torchao/csrc/cuda/fp6_llm/utils_core.cuh index 4601edb397..24231d3f88 100644 --- a/torchao/csrc/cuda/fp6_llm/utils_core.cuh +++ b/torchao/csrc/cuda/fp6_llm/utils_core.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is modified from https://github.com/usyd-fsalab/fp6_llm/blob/5df6737cca32f604e957e3f63f03ccc2e4d1df0d/fp6_llm/csrc/include/utils_core.cuh #ifndef UTILS_CORE_CUH @@ -57,7 +62,7 @@ __device__ __forceinline__ void initialize_mma_slice(uint32_t ( if(USE_SEG_1BIT) CopyFromSharedToRegister_AFrag<1> (a_1bit, A_1BIT_SPTR_read, 0); if(USE_SEG_2BIT) CopyFromSharedToRegister_AFrag<2> (a_2bit, A_2BIT_SPTR_read, 0); if(USE_SEG_4BIT) CopyFromSharedToRegister_AFrag<4> (a_4bit, A_4BIT_SPTR_read, 0); - Dequant_32FP6_4Way(a, a_1bit, a_2bit, a_4bit, RPTR_Scales); // SIMT Dequant: dequantizing FPx to FP16 at register level, dequantizing a slice each time + Dequant_32FP6_4Way(a, a_1bit, a_2bit, a_4bit, RPTR_Scales); // SIMT Dequant: dequantizing FPx to FP16 at register level, dequantizing a slice each time B_FromSharedToReg(b, B_SPTR_read, 0); // Loading B from shared to registers } @@ -91,7 +96,7 @@ __device__ __forceinline__ void core_mma_slice(float c[][REG uint32_t (*a_write)[4] = a; uint32_t (*b_read )[4] = b; uint32_t (*b_write)[4] = b; - if(slice_id%2==1) { b_write += NumRegSets_b; a_write += NumRegSets_a;} + if(slice_id%2==1) { b_write += NumRegSets_b; a_write += NumRegSets_a;} else { b_read += NumRegSets_b; a_read += NumRegSets_a;} // Reading registers and issuing core tensor core computations (a slice of A and B tile in shared memory) @@ -100,7 +105,7 @@ __device__ __forceinline__ void core_mma_slice(float c[][REG if(TilingConfig::WARP_COL_MMA_TENSORS==1) { MMA_FP16_M16N8K16( c_uint_ptr[i], a_read[i], b_read[0] ); } - else { + else { #pragma unroll for (int j = 0; j < TilingConfig::WARP_COL_MMA_TENSORS/2; j++) { MMA_FP16_M16N8K16( c_uint_ptr[i + j * WARP_ROW_MMA_TENSORS], a_read[i], b_read[j] ); @@ -116,7 +121,7 @@ __device__ __forceinline__ void core_mma_slice(float c[][REG if(USE_SEG_1BIT) CopyFromSharedToRegister_AFrag<1> (a_1bit, A_1bit_SPTR_read, slice_id); if(USE_SEG_2BIT) CopyFromSharedToRegister_AFrag<2> (a_2bit, A_2bit_SPTR_read, slice_id); if(USE_SEG_4BIT) CopyFromSharedToRegister_AFrag<4> (a_4bit, A_4bit_SPTR_read, slice_id); - Dequant_32FP6_4Way(a_write, a_1bit, a_2bit, a_4bit, RPTR_Scales); // SIMT Dequant: dequantizing FP6 to FP16 at register level, dequantizing a slice each time + Dequant_32FP6_4Way(a_write, a_1bit, a_2bit, a_4bit, RPTR_Scales); // SIMT Dequant: dequantizing FP6 to FP16 at register level, dequantizing a slice each time B_FromSharedToReg (b_write, B_SPTR_read, slice_id); // Loading B from shared to registers } diff --git a/torchao/csrc/cuda/fp6_llm/utils_gmem.cuh b/torchao/csrc/cuda/fp6_llm/utils_gmem.cuh index f2af30733f..9de9250299 100644 --- a/torchao/csrc/cuda/fp6_llm/utils_gmem.cuh +++ b/torchao/csrc/cuda/fp6_llm/utils_gmem.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is modified from https://github.com/usyd-fsalab/fp6_llm/blob/ce76774bcfc26b325c1b558abcf1935026d9abbc/fp6_llm/csrc/include/utils_gmem.cuh // // MODIFICATION NOTE (2024-09-25): added SM75 support (https://github.com/pytorch/ao/pull/942): @@ -25,12 +30,12 @@ #include "configs.h" #include "ptx_cp.async.cuh" -/* +/* * Copying A1/A2 from global memory to shared memory. * Usually 1024 or 2048 Bytes */ template -__device__ __forceinline__ void CopyFromGlobalToShared_A(uint32_t* SPTR, +__device__ __forceinline__ void CopyFromGlobalToShared_A(uint32_t* SPTR, const uint4* GPTR, bool pred_guard = true) { #ifdef DEBUG_MODE @@ -58,19 +63,19 @@ __device__ __forceinline__ void CopyFromGlobalToShared_A(uint32_t* SPTR, } -/* +/* * Copying 64 Quant Scales (FP16) from global memory to shared memory. */ __device__ __forceinline__ void CopyFromGlobalToShared_Scales(half* SPTR_QuantScales, const half* GPTR_A_Scales) { int lane_id = threadIdx.x % WARP_SIZE; - int Offset_Shared = lane_id*2; + int Offset_Shared = lane_id*2; int Offset_Global = lane_id/4 + (lane_id%4)*16; for(int i=0; i<2; i++) SPTR_QuantScales[Offset_Shared+i] = GPTR_A_Scales[Offset_Global+i*8]; } // MODIFICATION NOTE: to support MSVC, half __restrict__ (*SharedPTR)[WARP_K+PADDING_SHARED_MEM_FOR_B_8] is changed to below. -/* +/* * (1) Copying X rows * 64 columns of FP16 values, originally in row major * (2) Copying 64 rows * X columns of FP16 values, originally in column major * 16 Bytes per thread -> 512 Bytes per WARP = 4 line per WARP = 1 line per 8 Threads @@ -83,9 +88,9 @@ __device__ __forceinline__ void CopyFromGlobalToShared(half (* __restrict__ Shar bool Pred = true) { // static parameters: 1 Group (8 Threads) can copy 1 line (64 FP16) each time const int NumOfThreads = BLOCK_WARPS * WARP_SIZE; - const int NumOfGroups = NumOfThreads / 8; + const int NumOfGroups = NumOfThreads / 8; const int MaxIteration = (MaxNumOfLinesToCopy-1) / NumOfGroups + 1; - // runtime variables + // runtime variables const int line_id = threadIdx.x / 8; const int line_offset = (threadIdx.x%8) * 8; // PTR for source global memory and target shared memory diff --git a/torchao/csrc/cuda/fp6_llm/utils_parallel_dequant.cuh b/torchao/csrc/cuda/fp6_llm/utils_parallel_dequant.cuh index 7fb77f9f8b..8c5f77df9c 100644 --- a/torchao/csrc/cuda/fp6_llm/utils_parallel_dequant.cuh +++ b/torchao/csrc/cuda/fp6_llm/utils_parallel_dequant.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. // Copyright 2024 FP6-LLM authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +16,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // This file is modified from https://github.com/usyd-fsalab/fp6_llm/blob/5df6737cca32f604e957e3f63f03ccc2e4d1df0d/fp6_llm/csrc/include/utils_parallel_dequant.cuh // To support MSVC, all instances of u_int32_t are changed to uint32_t. @@ -57,7 +62,7 @@ __device__ __forceinline__ uint32_t MultScale(uint32_t PackedFP16Pair, half Scal uint32_t output; half* output_half_ptr = reinterpret_cast(&output); output_half_ptr[0] = __hmul( __hmul(*FP16_1,__float2half(1.0f*BIAS)), Scale); - output_half_ptr[1] = __hmul( __hmul(*FP16_2,__float2half(1.0f*BIAS)), Scale); + output_half_ptr[1] = __hmul( __hmul(*FP16_2,__float2half(1.0f*BIAS)), Scale); return output; } @@ -84,9 +89,9 @@ __device__ __forceinline__ uint32_t MultScale(uint32_t PackedBF16Pair, __nv_bflo // - u_int32_t __restrict__ Reg[][4] is changed to below. // - u_int32_t __restrict__ *read_RPTR_1bit is changed to below. similarly for read_RPTR_2bit and read_RPTR_4bit template -__device__ __forceinline__ void Dequant_32FP6_4Way(uint32_t (* __restrict__ Reg)[4], +__device__ __forceinline__ void Dequant_32FP6_4Way(uint32_t (* __restrict__ Reg)[4], uint32_t * __restrict__ read_RPTR_1bit, - uint32_t * __restrict__ read_RPTR_2bit, + uint32_t * __restrict__ read_RPTR_2bit, uint32_t * __restrict__ read_RPTR_4bit, uint32_t * Scales) { // 1+2+4 weight split @@ -103,7 +108,7 @@ __device__ __forceinline__ void Dequant_32FP6_4Way(uint32_t (* __restrict__ Reg) scalar_t *Scale_RPTR = reinterpret_cast(Scales); // Dequantizing 32 FP6, each Loop dequantizing 4 FP6 #pragma unroll(8) - for(int i=0; i<8; i++) { + for(int i=0; i<8; i++) { uint32_t Packed_FP6 = 0; uint32_t tmp = 0; // 1bit Frag @@ -137,11 +142,11 @@ __device__ __forceinline__ void Dequant_32FP6_4Way(uint32_t (* __restrict__ Reg) // Updating offset for FP16/BF16 scales for every two iterations if(i%2==1) Scale_RPTR += 2; } - + } /* - * + * */ __device__ __forceinline__ void ExtractFromSharedToReg_Scales(uint32_t* Scales, half* WARP_SPTR_Scales) { int lane_id = threadIdx.x % WARP_SIZE; @@ -149,8 +154,8 @@ __device__ __forceinline__ void ExtractFromSharedToReg_Scales(uint32_t* Scales, uint32_t tmpReg = SPTR_uint[lane_id]; #pragma unroll for(int i=0; i<4; i++) { - // T __shfl_sync(unsigned mask, T var, int srcLane, int width=warpSize); - Scales[i] = __shfl_sync(0xffffffff, tmpReg, i, 4); + // T __shfl_sync(unsigned mask, T var, int srcLane, int width=warpSize); + Scales[i] = __shfl_sync(0xffffffff, tmpReg, i, 4); } } diff --git a/torchao/csrc/cuda/marlin_qqq/base.h b/torchao/csrc/cuda/marlin_qqq/base.h index d184b65cce..7774a66b1d 100644 --- a/torchao/csrc/cuda/marlin_qqq/base.h +++ b/torchao/csrc/cuda/marlin_qqq/base.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. /* * Modified by HandH1998 * Modified by Neural Magic diff --git a/torchao/csrc/cuda/marlin_qqq/marlin_qqq_kernel.cu b/torchao/csrc/cuda/marlin_qqq/marlin_qqq_kernel.cu index 10c3f152bd..bd24af7a2c 100644 --- a/torchao/csrc/cuda/marlin_qqq/marlin_qqq_kernel.cu +++ b/torchao/csrc/cuda/marlin_qqq/marlin_qqq_kernel.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. /* * Adapted from * https://github.com/IST-DASLab/marlin/blob/master/marlin/marlin_cuda_kernel.cu diff --git a/torchao/csrc/cuda/marlin_qqq/mem.h b/torchao/csrc/cuda/marlin_qqq/mem.h index db88e2bc40..12b5ff23d7 100644 --- a/torchao/csrc/cuda/marlin_qqq/mem.h +++ b/torchao/csrc/cuda/marlin_qqq/mem.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. /* * Modified by HandH1998 * Modified by Neural Magic diff --git a/torchao/csrc/cuda/mx_kernels/mx_fp_cutlass_kernels.cu b/torchao/csrc/cuda/mx_kernels/mx_fp_cutlass_kernels.cu index e01d363ec3..87aa0b0501 100644 --- a/torchao/csrc/cuda/mx_kernels/mx_fp_cutlass_kernels.cu +++ b/torchao/csrc/cuda/mx_kernels/mx_fp_cutlass_kernels.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass.cuh b/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass.cuh index b0f3adda6a..058cec4ba4 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass.cuh +++ b/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s4s4.cu b/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s4s4.cu index 59f7951a63..ceca6ef0c8 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s4s4.cu +++ b/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s4s4.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include "rowwise_scaled_linear_cutlass.cuh" diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s8s4.cu b/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s8s4.cu index 419eed1073..613ec60af8 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s8s4.cu +++ b/torchao/csrc/cuda/rowwise_scaled_linear_cutlass/rowwise_scaled_linear_cutlass_s8s4.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include "rowwise_scaled_linear_cutlass.cuh" diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass.cuh b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass.cuh index 3fee557cbc..c067211a76 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass.cuh +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.cu b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.cu index a0ddf3ddd9..0d233d02cc 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.cu +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include "rowwise_scaled_linear_sparse_cutlass.cuh" #include "rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.h" diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.h b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.h index 619df8d9ef..f27b0e2423 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.h +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.cu b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.cu index 83c2451907..d8fa7b6929 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.cu +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include "rowwise_scaled_linear_sparse_cutlass.cuh" #include "rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.h" diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.h b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.h index 96fcbab89a..7a5824b5dc 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.h +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e4m3e5m2.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.cu b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.cu index f5c261dc04..0188b550ef 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.cu +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include "rowwise_scaled_linear_sparse_cutlass.cuh" #include "rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.h" diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.h b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.h index 7981b50f15..d3dff12e56 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.h +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e4m3.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.cu b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.cu index 05bfd24ff6..bee9069406 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.cu +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include "rowwise_scaled_linear_sparse_cutlass.cuh" #include "rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.h" diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.h b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.h index 21d26e75ea..0c440b8301 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.h +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_e5m2e5m2.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include diff --git a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_f8f8.cu b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_f8f8.cu index 33aa6a882d..492d682d6a 100644 --- a/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_f8f8.cu +++ b/torchao/csrc/cuda/rowwise_scaled_linear_sparse_cutlass/rowwise_scaled_linear_sparse_cutlass_f8f8.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include "rowwise_scaled_linear_sparse_cutlass_e4m3e4m3.h" diff --git a/torchao/csrc/cuda/sparse_marlin/base.h b/torchao/csrc/cuda/sparse_marlin/base.h index 513c53df3a..1a679df043 100644 --- a/torchao/csrc/cuda/sparse_marlin/base.h +++ b/torchao/csrc/cuda/sparse_marlin/base.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. /* * Copyright (C) 2024 Roberto Lopez Castro (roberto.lopez.castro@udc.es). All * Rights Reserved. diff --git a/torchao/csrc/cuda/sparse_marlin/marlin_kernel_nm.cu b/torchao/csrc/cuda/sparse_marlin/marlin_kernel_nm.cu index 4f6980f29a..bd64930c4b 100644 --- a/torchao/csrc/cuda/sparse_marlin/marlin_kernel_nm.cu +++ b/torchao/csrc/cuda/sparse_marlin/marlin_kernel_nm.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. /* * Notice: This file was modified by Neuralmagic inc to include 8-bit support * diff --git a/torchao/csrc/cuda/sparse_marlin/mem.h b/torchao/csrc/cuda/sparse_marlin/mem.h index 1569e3cdda..3043ec6435 100644 --- a/torchao/csrc/cuda/sparse_marlin/mem.h +++ b/torchao/csrc/cuda/sparse_marlin/mem.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. /* * Copyright (C) 2024 Roberto Lopez Castro (roberto.lopez.castro@udc.es). All * Rights Reserved. @@ -28,7 +33,7 @@ template __device__ __forceinline__ uint32_t cvta_to_shared(const T* ptr) { // First get the address as a size_t to handle all pointer sizes size_t addr = reinterpret_cast(ptr); - + // Extract the lower 32 bits which represent the shared memory offset // This is safe because shared memory addresses are always within 32-bit range return static_cast(addr & 0xFFFFFFFF); diff --git a/torchao/csrc/cuda/sparse_marlin/mma.h b/torchao/csrc/cuda/sparse_marlin/mma.h index 9e9a9be519..40f2dc30e1 100644 --- a/torchao/csrc/cuda/sparse_marlin/mma.h +++ b/torchao/csrc/cuda/sparse_marlin/mma.h @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. /* * Copyright (C) 2024 Roberto Lopez Castro (roberto.lopez.castro@udc.es). All * Rights Reserved. diff --git a/torchao/csrc/cuda/tensor_core_tiled_layout/tensor_core_tiled_layout.cu b/torchao/csrc/cuda/tensor_core_tiled_layout/tensor_core_tiled_layout.cu index 1fc96f60ec..cfbabf08dd 100644 --- a/torchao/csrc/cuda/tensor_core_tiled_layout/tensor_core_tiled_layout.cu +++ b/torchao/csrc/cuda/tensor_core_tiled_layout/tensor_core_tiled_layout.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #if (defined(USE_ROCM) && ROCM_VERSION >= 60200) || !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800 #include @@ -174,7 +179,7 @@ __global__ void _dequantize_int4_kernel( if (scales_and_zeros) { const auto& sz = *scales_and_zeros; const __nv_bfloat16* pSZ = reinterpret_cast(&sz[qgroup][n0][0]); - + scale2 = __bfloat162bfloat162(pSZ[0]); zero2 = __bfloat162bfloat162(pSZ[1]); } diff --git a/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x.cuh b/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x.cuh index 24a9371593..6c725b833f 100644 --- a/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x.cuh +++ b/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x.cuh @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #pragma once #include @@ -34,7 +39,7 @@ std::tuple to_sparse_semi_structured_kernel_cutlass_sm9x(const at::Tensor& W) { // The kernel doesn't check, but assumes instead, that the input // tensor is a structured sparse tensor. - + static_assert(std::is_same_v || std::is_same_v); @@ -124,7 +129,7 @@ to_sparse_semi_structured_kernel_cutlass_sm9x(const at::Tensor& W) { return std::make_tuple(W_compressed, W_meta); } - + template void to_sparse_semi_structured_cutlass_sm9x_check_inputs(const at::Tensor& W) { @@ -170,5 +175,5 @@ to_sparse_semi_structured_cutlass_sm9x(const at::Tensor& W) { return std::make_tuple(at::Tensor{}, at::Tensor{}); #endif } - + } // namespace torchao diff --git a/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x_f8.cu b/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x_f8.cu index 1a4ab285b6..cbca3e0333 100644 --- a/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x_f8.cu +++ b/torchao/csrc/cuda/to_sparse_semi_structured_cutlass_sm9x/to_sparse_semi_structured_cutlass_sm9x_f8.cu @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include "to_sparse_semi_structured_cutlass_sm9x.cuh" diff --git a/torchao/dtypes/_nf4tensor_api.py b/torchao/dtypes/_nf4tensor_api.py index 6402c0d4bc..2726185670 100644 --- a/torchao/dtypes/_nf4tensor_api.py +++ b/torchao/dtypes/_nf4tensor_api.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torchao.core.config import AOBaseConfig diff --git a/torchao/dtypes/affine_quantized_tensor.py b/torchao/dtypes/affine_quantized_tensor.py index cd7404de28..24ac56fc7f 100644 --- a/torchao/dtypes/affine_quantized_tensor.py +++ b/torchao/dtypes/affine_quantized_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import math from typing import Optional, Tuple, Union diff --git a/torchao/dtypes/affine_quantized_tensor_ops.py b/torchao/dtypes/affine_quantized_tensor_ops.py index 9ed9a4fd84..fc4c3a817b 100644 --- a/torchao/dtypes/affine_quantized_tensor_ops.py +++ b/torchao/dtypes/affine_quantized_tensor_ops.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import torch diff --git a/torchao/dtypes/floatx/cutlass_semi_sparse_layout.py b/torchao/dtypes/floatx/cutlass_semi_sparse_layout.py index 229f4a0c53..f13d916a90 100644 --- a/torchao/dtypes/floatx/cutlass_semi_sparse_layout.py +++ b/torchao/dtypes/floatx/cutlass_semi_sparse_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional diff --git a/torchao/dtypes/floatx/float8_layout.py b/torchao/dtypes/floatx/float8_layout.py index 60aedf032f..cd1d9a8ac0 100644 --- a/torchao/dtypes/floatx/float8_layout.py +++ b/torchao/dtypes/floatx/float8_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional, Tuple, Union diff --git a/torchao/dtypes/floatx/floatx_tensor_core_layout.py b/torchao/dtypes/floatx/floatx_tensor_core_layout.py index beaa2e536e..6871033f1a 100644 --- a/torchao/dtypes/floatx/floatx_tensor_core_layout.py +++ b/torchao/dtypes/floatx/floatx_tensor_core_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from functools import reduce from typing import Optional, Tuple diff --git a/torchao/dtypes/nf4tensor.py b/torchao/dtypes/nf4tensor.py index 41c8cf122a..ca4e0fdf1f 100644 --- a/torchao/dtypes/nf4tensor.py +++ b/torchao/dtypes/nf4tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import functools import math import sys diff --git a/torchao/dtypes/uintx/bitpacking.py b/torchao/dtypes/uintx/bitpacking.py index fdff6ef9fb..4c88643b0e 100644 --- a/torchao/dtypes/uintx/bitpacking.py +++ b/torchao/dtypes/uintx/bitpacking.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from functools import reduce from typing import List, Optional diff --git a/torchao/dtypes/uintx/block_sparse_layout.py b/torchao/dtypes/uintx/block_sparse_layout.py index 6681847608..0c6046c313 100644 --- a/torchao/dtypes/uintx/block_sparse_layout.py +++ b/torchao/dtypes/uintx/block_sparse_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging from dataclasses import dataclass from typing import Optional, Tuple diff --git a/torchao/dtypes/uintx/cutlass_int4_packed_layout.py b/torchao/dtypes/uintx/cutlass_int4_packed_layout.py index 34e3594b5e..d2fcaf9045 100644 --- a/torchao/dtypes/uintx/cutlass_int4_packed_layout.py +++ b/torchao/dtypes/uintx/cutlass_int4_packed_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional diff --git a/torchao/dtypes/uintx/gemlite_layout.py b/torchao/dtypes/uintx/gemlite_layout.py index 9233ce6ee7..0370006bca 100644 --- a/torchao/dtypes/uintx/gemlite_layout.py +++ b/torchao/dtypes/uintx/gemlite_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import warnings from dataclasses import dataclass from typing import Dict, Optional, Tuple diff --git a/torchao/dtypes/uintx/int4_cpu_layout.py b/torchao/dtypes/uintx/int4_cpu_layout.py index d587591ccc..f37e5a0684 100644 --- a/torchao/dtypes/uintx/int4_cpu_layout.py +++ b/torchao/dtypes/uintx/int4_cpu_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional, Tuple diff --git a/torchao/dtypes/uintx/marlin_qqq_tensor.py b/torchao/dtypes/uintx/marlin_qqq_tensor.py index abf09cd2f9..3c87714d86 100644 --- a/torchao/dtypes/uintx/marlin_qqq_tensor.py +++ b/torchao/dtypes/uintx/marlin_qqq_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import math from dataclasses import dataclass diff --git a/torchao/dtypes/uintx/marlin_sparse_layout.py b/torchao/dtypes/uintx/marlin_sparse_layout.py index 01d4562b7f..b22c7d186c 100644 --- a/torchao/dtypes/uintx/marlin_sparse_layout.py +++ b/torchao/dtypes/uintx/marlin_sparse_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass import torch diff --git a/torchao/dtypes/uintx/plain_layout.py b/torchao/dtypes/uintx/plain_layout.py index 9220ce3270..b4b9e06f1a 100644 --- a/torchao/dtypes/uintx/plain_layout.py +++ b/torchao/dtypes/uintx/plain_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Optional, Tuple import torch diff --git a/torchao/dtypes/uintx/semi_sparse_layout.py b/torchao/dtypes/uintx/semi_sparse_layout.py index 3c35a4d8cd..30bf4dacbd 100644 --- a/torchao/dtypes/uintx/semi_sparse_layout.py +++ b/torchao/dtypes/uintx/semi_sparse_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional diff --git a/torchao/dtypes/uintx/tensor_core_tiled_layout.py b/torchao/dtypes/uintx/tensor_core_tiled_layout.py index 7d1ea35a08..8e77a6db2b 100644 --- a/torchao/dtypes/uintx/tensor_core_tiled_layout.py +++ b/torchao/dtypes/uintx/tensor_core_tiled_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional, Tuple diff --git a/torchao/dtypes/uintx/uint4_layout.py b/torchao/dtypes/uintx/uint4_layout.py index 0b6512640e..9ff498b314 100644 --- a/torchao/dtypes/uintx/uint4_layout.py +++ b/torchao/dtypes/uintx/uint4_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import torch._prims_common as utils import torch.utils._pytree as pytree diff --git a/torchao/dtypes/uintx/uintx_layout.py b/torchao/dtypes/uintx/uintx_layout.py index ef85319cd5..a783e62a44 100644 --- a/torchao/dtypes/uintx/uintx_layout.py +++ b/torchao/dtypes/uintx/uintx_layout.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import List, Tuple diff --git a/torchao/dtypes/utils.py b/torchao/dtypes/utils.py index 45a0b4312d..beec9f0bb7 100644 --- a/torchao/dtypes/utils.py +++ b/torchao/dtypes/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional, Tuple, Union diff --git a/torchao/experimental/benchmark_infra/ios/output_redirect.h b/torchao/experimental/benchmark_infra/ios/output_redirect.h index e69de29bb2..27506acf19 100644 --- a/torchao/experimental/benchmark_infra/ios/output_redirect.h +++ b/torchao/experimental/benchmark_infra/ios/output_redirect.h @@ -0,0 +1,5 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. diff --git a/torchao/experimental/kernels/mps/metal/common.metal b/torchao/experimental/kernels/mps/metal/common.metal index 69fff8133e..899c559978 100644 --- a/torchao/experimental/kernels/mps/metal/common.metal +++ b/torchao/experimental/kernels/mps/metal/common.metal @@ -1,3 +1,9 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. + template struct Vec4Type {}; template <> struct Vec4Type { diff --git a/torchao/experimental/kernels/mps/metal/int1mm.metal b/torchao/experimental/kernels/mps/metal/int1mm.metal index 15b7f19138..a76d66041b 100644 --- a/torchao/experimental/kernels/mps/metal/int1mm.metal +++ b/torchao/experimental/kernels/mps/metal/int1mm.metal @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include using namespace metal; diff --git a/torchao/experimental/kernels/mps/metal/int2mm_opt.metal b/torchao/experimental/kernels/mps/metal/int2mm_opt.metal index 465b74ed2b..6008de6730 100644 --- a/torchao/experimental/kernels/mps/metal/int2mm_opt.metal +++ b/torchao/experimental/kernels/mps/metal/int2mm_opt.metal @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include using namespace metal; diff --git a/torchao/experimental/kernels/mps/metal/int3mm_opt.metal b/torchao/experimental/kernels/mps/metal/int3mm_opt.metal index 713c05dfe8..8ab9862d03 100644 --- a/torchao/experimental/kernels/mps/metal/int3mm_opt.metal +++ b/torchao/experimental/kernels/mps/metal/int3mm_opt.metal @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include using namespace metal; diff --git a/torchao/experimental/kernels/mps/metal/int4mm_opt.metal b/torchao/experimental/kernels/mps/metal/int4mm_opt.metal index 4d9f18f984..edee43ec14 100644 --- a/torchao/experimental/kernels/mps/metal/int4mm_opt.metal +++ b/torchao/experimental/kernels/mps/metal/int4mm_opt.metal @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include #include using namespace metal; diff --git a/torchao/experimental/kernels/mps/metal/int5mm.metal b/torchao/experimental/kernels/mps/metal/int5mm.metal index 0298ba5482..206786b038 100644 --- a/torchao/experimental/kernels/mps/metal/int5mm.metal +++ b/torchao/experimental/kernels/mps/metal/int5mm.metal @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include using namespace metal; diff --git a/torchao/experimental/kernels/mps/metal/int6mm.metal b/torchao/experimental/kernels/mps/metal/int6mm.metal index d8d874c46e..55d359a6ba 100644 --- a/torchao/experimental/kernels/mps/metal/int6mm.metal +++ b/torchao/experimental/kernels/mps/metal/int6mm.metal @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include using namespace metal; diff --git a/torchao/experimental/kernels/mps/metal/int7mm.metal b/torchao/experimental/kernels/mps/metal/int7mm.metal index dbde6e4e95..b97800b448 100644 --- a/torchao/experimental/kernels/mps/metal/int7mm.metal +++ b/torchao/experimental/kernels/mps/metal/int7mm.metal @@ -1,3 +1,8 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the BSD 3-Clause license found in the +// LICENSE file in the root directory of this source tree. #include using namespace metal; diff --git a/torchao/float8/__init__.py b/torchao/float8/__init__.py index 18ef82a507..8d4d58fd6b 100644 --- a/torchao/float8/__init__.py +++ b/torchao/float8/__init__.py @@ -1,8 +1,3 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# -# This source code is licensed under the BSD 3-Clause license found in the -# LICENSE file in the root directory of this source tree. # Lets define a few top level things here from torchao.float8.config import ( CastConfig, diff --git a/torchao/float8/float8_tensor_parallel.py b/torchao/float8/float8_tensor_parallel.py index abc74e3ff6..a509a79ddb 100644 --- a/torchao/float8/float8_tensor_parallel.py +++ b/torchao/float8/float8_tensor_parallel.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from torch.distributed._tensor import DTensor diff --git a/torchao/kernel/autotuner.py b/torchao/kernel/autotuner.py index 87d644b26c..6c95e9a4dc 100644 --- a/torchao/kernel/autotuner.py +++ b/torchao/kernel/autotuner.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import os import pathlib diff --git a/torchao/kernel/bsr_triton_ops.py b/torchao/kernel/bsr_triton_ops.py index 2dcdead966..18cfba9ad9 100644 --- a/torchao/kernel/bsr_triton_ops.py +++ b/torchao/kernel/bsr_triton_ops.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # mypy: allow-untyped-decorators # mypy: allow-untyped-defs import os diff --git a/torchao/kernel/intmm.py b/torchao/kernel/intmm.py index bc5df41356..f7fcf46f36 100644 --- a/torchao/kernel/intmm.py +++ b/torchao/kernel/intmm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import os diff --git a/torchao/kernel/intmm_triton.py b/torchao/kernel/intmm_triton.py index bb73a0f5db..1a516a7163 100644 --- a/torchao/kernel/intmm_triton.py +++ b/torchao/kernel/intmm_triton.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import itertools import torch diff --git a/torchao/ops.py b/torchao/ops.py index 2020668cf7..34a97d03f5 100644 --- a/torchao/ops.py +++ b/torchao/ops.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import functools from typing import Optional diff --git a/torchao/optim/adam.py b/torchao/optim/adam.py index 9cad9777bf..cba86897d9 100644 --- a/torchao/optim/adam.py +++ b/torchao/optim/adam.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Optional import torch diff --git a/torchao/optim/cpu_offload.py b/torchao/optim/cpu_offload.py index 61e4077d1d..cca55749db 100644 --- a/torchao/optim/cpu_offload.py +++ b/torchao/optim/cpu_offload.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Type import torch diff --git a/torchao/optim/quant_utils.py b/torchao/optim/quant_utils.py index 628c8a742e..a4035fde1c 100644 --- a/torchao/optim/quant_utils.py +++ b/torchao/optim/quant_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch import Tensor diff --git a/torchao/optim/subclass_4bit.py b/torchao/optim/subclass_4bit.py index 4c05cced87..55d9bf356f 100644 --- a/torchao/optim/subclass_4bit.py +++ b/torchao/optim/subclass_4bit.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math import torch diff --git a/torchao/optim/subclass_8bit.py b/torchao/optim/subclass_8bit.py index 659a43f42d..66d31432b8 100644 --- a/torchao/optim/subclass_8bit.py +++ b/torchao/optim/subclass_8bit.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math import torch diff --git a/torchao/optim/subclass_fp8.py b/torchao/optim/subclass_fp8.py index b5c8af6c83..1ae670dd6d 100644 --- a/torchao/optim/subclass_fp8.py +++ b/torchao/optim/subclass_fp8.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math import torch diff --git a/torchao/prototype/autoround/autoround_llm.py b/torchao/prototype/autoround/autoround_llm.py index f20bb038bb..822ee6554b 100644 --- a/torchao/prototype/autoround/autoround_llm.py +++ b/torchao/prototype/autoround/autoround_llm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse from typing import Optional diff --git a/torchao/prototype/autoround/core.py b/torchao/prototype/autoround/core.py index e14b817c13..68cf341684 100644 --- a/torchao/prototype/autoround/core.py +++ b/torchao/prototype/autoround/core.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import dataclasses import logging from typing import Any, Callable, Dict, Optional, Tuple diff --git a/torchao/prototype/autoround/eval_autoround.py b/torchao/prototype/autoround/eval_autoround.py index 0e5308ca3d..16c1736843 100644 --- a/torchao/prototype/autoround/eval_autoround.py +++ b/torchao/prototype/autoround/eval_autoround.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import logging import os diff --git a/torchao/prototype/autoround/multi_tensor.py b/torchao/prototype/autoround/multi_tensor.py index 441ae2e83b..47d4add9e5 100644 --- a/torchao/prototype/autoround/multi_tensor.py +++ b/torchao/prototype/autoround/multi_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import dataclasses from typing import List diff --git a/torchao/prototype/autoround/run_example.sh b/torchao/prototype/autoround/run_example.sh index 9ae8956ebf..d0be80e8fd 100644 --- a/torchao/prototype/autoround/run_example.sh +++ b/torchao/prototype/autoround/run_example.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # Run examples python autoround_llm.py -m meta-llama/Llama-2-7b-chat-hf python autoround_llm.py -m meta-llama/Llama-2-7b-chat-hf --quant_lm_head @@ -12,6 +17,6 @@ python eval_autoround.py -m meta-llama/Meta-Llama-3.1-8B-Instruct --model_device # wo_int4 python eval_autoround.py -m meta-llama/Llama-2-7b-chat-hf --woq_int4 --tasks wikitext lambada_openai hellaswag winogrande piqa mmlu python eval_autoround.py -m meta-llama/Meta-Llama-3-8B-Instruct --woq_int4 --tasks wikitext lambada_openai hellaswag winogrande piqa mmlu -python eval_autoround.py -m meta-llama/Meta-Llama-3.1-8B-Instruct --woq_int4 --tasks wikitext lambada_openai hellaswag winogrande piqa mmlu +python eval_autoround.py -m meta-llama/Meta-Llama-3.1-8B-Instruct --woq_int4 --tasks wikitext lambada_openai hellaswag winogrande piqa mmlu # uintx -python eval_autoround.py -m /models/Meta-Llama-3.1-8B-Instruct/ --uintx --bits 2 --tasks wikitext lambada_openai hellaswag winogrande piqa mmlu \ No newline at end of file +python eval_autoround.py -m /models/Meta-Llama-3.1-8B-Instruct/ --uintx --bits 2 --tasks wikitext lambada_openai hellaswag winogrande piqa mmlu diff --git a/torchao/prototype/autoround/utils.py b/torchao/prototype/autoround/utils.py index 9269164c8d..4bc1a31e14 100644 --- a/torchao/prototype/autoround/utils.py +++ b/torchao/prototype/autoround/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # ==------------------------------------------------------------------------------------------== # Utils for the auto-round # ==------------------------------------------------------------------------------------------== diff --git a/torchao/prototype/awq/api.py b/torchao/prototype/awq/api.py index 61f865edc1..cdc069bc2a 100644 --- a/torchao/prototype/awq/api.py +++ b/torchao/prototype/awq/api.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import types from dataclasses import dataclass diff --git a/torchao/prototype/awq/core.py b/torchao/prototype/awq/core.py index 6882f3ade4..651188b4cd 100644 --- a/torchao/prototype/awq/core.py +++ b/torchao/prototype/awq/core.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Optional import torch diff --git a/torchao/prototype/awq/example.py b/torchao/prototype/awq/example.py index a2cc6082da..ba1ba6834c 100644 --- a/torchao/prototype/awq/example.py +++ b/torchao/prototype/awq/example.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import time diff --git a/torchao/prototype/common/profiling_tools.py b/torchao/prototype/common/profiling_tools.py index 607895d4e4..b5fb5fcaa8 100644 --- a/torchao/prototype/common/profiling_tools.py +++ b/torchao/prototype/common/profiling_tools.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import os import types from datetime import datetime diff --git a/torchao/prototype/common/triton/matmul.py b/torchao/prototype/common/triton/matmul.py index 5b86bce968..5c5ec7d0c0 100644 --- a/torchao/prototype/common/triton/matmul.py +++ b/torchao/prototype/common/triton/matmul.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from triton import Config, autotune, cdiv, heuristics, jit from triton import language as tl diff --git a/torchao/prototype/common/triton/matmul_perf_model.py b/torchao/prototype/common/triton/matmul_perf_model.py index 7bbb5e63a3..12af01244b 100644 --- a/torchao/prototype/common/triton/matmul_perf_model.py +++ b/torchao/prototype/common/triton/matmul_perf_model.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # Source: https://github.com/triton-lang/kernels/blob/main/kernels/matmul_perf_model.py # This file is taken from the upstream triton-lang/kernels repo. diff --git a/torchao/prototype/float8nocompile/benchmark/benchmark.py b/torchao/prototype/float8nocompile/benchmark/benchmark.py index 85b97d908a..f1c0c4b93a 100644 --- a/torchao/prototype/float8nocompile/benchmark/benchmark.py +++ b/torchao/prototype/float8nocompile/benchmark/benchmark.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # this benchmarking script is a modified version of the original script from: https://github.com/drisspg/transformer_nuggets/blob/main/transformer_nuggets/utils/benchmark.py import itertools diff --git a/torchao/prototype/float8nocompile/examples/example.py b/torchao/prototype/float8nocompile/examples/example.py index 7da145c4d1..97d42eee90 100644 --- a/torchao/prototype/float8nocompile/examples/example.py +++ b/torchao/prototype/float8nocompile/examples/example.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import torch.nn as nn diff --git a/torchao/prototype/float8nocompile/float8nocompile_linear_test.py b/torchao/prototype/float8nocompile/float8nocompile_linear_test.py index 7b06fe0ce1..f62569cbb4 100644 --- a/torchao/prototype/float8nocompile/float8nocompile_linear_test.py +++ b/torchao/prototype/float8nocompile/float8nocompile_linear_test.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch diff --git a/torchao/prototype/float8nocompile/kernels/fp8_dynamic_tensorwise_test.py b/torchao/prototype/float8nocompile/kernels/fp8_dynamic_tensorwise_test.py index 55a3fecd79..2348877d5c 100644 --- a/torchao/prototype/float8nocompile/kernels/fp8_dynamic_tensorwise_test.py +++ b/torchao/prototype/float8nocompile/kernels/fp8_dynamic_tensorwise_test.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch diff --git a/torchao/prototype/float8nocompile/test/fsdp_test.py b/torchao/prototype/float8nocompile/test/fsdp_test.py index 44c0b13b71..4e73fb9b97 100644 --- a/torchao/prototype/float8nocompile/test/fsdp_test.py +++ b/torchao/prototype/float8nocompile/test/fsdp_test.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. ###################################################################### # # To run these unit tests, use the following command: diff --git a/torchao/prototype/float8nocompile/test/train_test.py b/torchao/prototype/float8nocompile/test/train_test.py index 871a49219e..3f2ee47cd7 100644 --- a/torchao/prototype/float8nocompile/test/train_test.py +++ b/torchao/prototype/float8nocompile/test/train_test.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import pytest import torch import torch.nn as nn diff --git a/torchao/prototype/galore/kernels/adam_downproj_fused.py b/torchao/prototype/galore/kernels/adam_downproj_fused.py index 2c2875b815..2367b9b427 100644 --- a/torchao/prototype/galore/kernels/adam_downproj_fused.py +++ b/torchao/prototype/galore/kernels/adam_downproj_fused.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging import torch diff --git a/torchao/prototype/galore/kernels/adam_step.py b/torchao/prototype/galore/kernels/adam_step.py index 0fc058453a..fcb554bd1d 100644 --- a/torchao/prototype/galore/kernels/adam_step.py +++ b/torchao/prototype/galore/kernels/adam_step.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import triton import triton.language as tl diff --git a/torchao/prototype/galore/kernels/custom_autotune.py b/torchao/prototype/galore/kernels/custom_autotune.py index 2a8de5d8c6..8ecfabf849 100644 --- a/torchao/prototype/galore/kernels/custom_autotune.py +++ b/torchao/prototype/galore/kernels/custom_autotune.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from __future__ import annotations import builtins diff --git a/torchao/prototype/galore/kernels/matmul.py b/torchao/prototype/galore/kernels/matmul.py index 5cff909bdf..47e76fc91c 100644 --- a/torchao/prototype/galore/kernels/matmul.py +++ b/torchao/prototype/galore/kernels/matmul.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import triton import triton.language as tl diff --git a/torchao/prototype/galore/kernels/quant.py b/torchao/prototype/galore/kernels/quant.py index 2b3ff27cf8..7c8a58e864 100644 --- a/torchao/prototype/galore/kernels/quant.py +++ b/torchao/prototype/galore/kernels/quant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import triton import triton.language as tl diff --git a/torchao/prototype/galore/optim/galore_torch.py b/torchao/prototype/galore/optim/galore_torch.py index b2269a1a7b..876c40292d 100644 --- a/torchao/prototype/galore/optim/galore_torch.py +++ b/torchao/prototype/galore/optim/galore_torch.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """Reference implementations See https://github.com/jiaweizzhao/GaLore/tree/master/galore_torch """ diff --git a/torchao/prototype/galore/utils.py b/torchao/prototype/galore/utils.py index 3c13952544..6e9db05d30 100644 --- a/torchao/prototype/galore/utils.py +++ b/torchao/prototype/galore/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch diff --git a/torchao/prototype/hqq/example.py b/torchao/prototype/hqq/example.py index d622f482db..46fae4bfe9 100644 --- a/torchao/prototype/hqq/example.py +++ b/torchao/prototype/hqq/example.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torchao.dtypes import PlainLayout, TensorCoreTiledLayout diff --git a/torchao/prototype/hqq/hqq_tinygemm_linear.py b/torchao/prototype/hqq/hqq_tinygemm_linear.py index 24c0efbf82..2e11210601 100644 --- a/torchao/prototype/hqq/hqq_tinygemm_linear.py +++ b/torchao/prototype/hqq/hqq_tinygemm_linear.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # mobicham's tinygemm hqq eval script import torch diff --git a/torchao/prototype/hqq/kernels.py b/torchao/prototype/hqq/kernels.py index 103814bb9d..d32fab3f2c 100644 --- a/torchao/prototype/hqq/kernels.py +++ b/torchao/prototype/hqq/kernels.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import triton import triton.language as tl from triton import Config diff --git a/torchao/prototype/hqq/mixed_mm.py b/torchao/prototype/hqq/mixed_mm.py index a5cb3a6dd3..e50b5c74cb 100644 --- a/torchao/prototype/hqq/mixed_mm.py +++ b/torchao/prototype/hqq/mixed_mm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import triton.language as tl from triton import cdiv diff --git a/torchao/prototype/low_bit_optim/adam.py b/torchao/prototype/low_bit_optim/adam.py index 9cad9777bf..cba86897d9 100644 --- a/torchao/prototype/low_bit_optim/adam.py +++ b/torchao/prototype/low_bit_optim/adam.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Optional import torch diff --git a/torchao/prototype/low_bit_optim/cpu_offload.py b/torchao/prototype/low_bit_optim/cpu_offload.py index 61e4077d1d..cca55749db 100644 --- a/torchao/prototype/low_bit_optim/cpu_offload.py +++ b/torchao/prototype/low_bit_optim/cpu_offload.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Type import torch diff --git a/torchao/prototype/low_bit_optim/quant_utils.py b/torchao/prototype/low_bit_optim/quant_utils.py index 628c8a742e..a4035fde1c 100644 --- a/torchao/prototype/low_bit_optim/quant_utils.py +++ b/torchao/prototype/low_bit_optim/quant_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch import Tensor diff --git a/torchao/prototype/low_bit_optim/subclass_4bit.py b/torchao/prototype/low_bit_optim/subclass_4bit.py index 4c05cced87..55d9bf356f 100644 --- a/torchao/prototype/low_bit_optim/subclass_4bit.py +++ b/torchao/prototype/low_bit_optim/subclass_4bit.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math import torch diff --git a/torchao/prototype/low_bit_optim/subclass_8bit.py b/torchao/prototype/low_bit_optim/subclass_8bit.py index 659a43f42d..66d31432b8 100644 --- a/torchao/prototype/low_bit_optim/subclass_8bit.py +++ b/torchao/prototype/low_bit_optim/subclass_8bit.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math import torch diff --git a/torchao/prototype/low_bit_optim/subclass_fp8.py b/torchao/prototype/low_bit_optim/subclass_fp8.py index b5c8af6c83..1ae670dd6d 100644 --- a/torchao/prototype/low_bit_optim/subclass_fp8.py +++ b/torchao/prototype/low_bit_optim/subclass_fp8.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math import torch diff --git a/torchao/prototype/mx_formats/constants.py b/torchao/prototype/mx_formats/constants.py index 402bf24a09..63567f1143 100644 --- a/torchao/prototype/mx_formats/constants.py +++ b/torchao/prototype/mx_formats/constants.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch # This is conceptually an enum of non-core dtypes diff --git a/torchao/prototype/parq/optim/binarelax.py b/torchao/prototype/parq/optim/binarelax.py index 0dcc8abdd7..0ce88d8ccb 100644 --- a/torchao/prototype/parq/optim/binarelax.py +++ b/torchao/prototype/parq/optim/binarelax.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Optional import torch diff --git a/torchao/prototype/parq/optim/parq.py b/torchao/prototype/parq/optim/parq.py index 742e1564d4..b756efd3ec 100644 --- a/torchao/prototype/parq/optim/parq.py +++ b/torchao/prototype/parq/optim/parq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import math from functools import partial from typing import Optional diff --git a/torchao/prototype/parq/optim/proxmap.py b/torchao/prototype/parq/optim/proxmap.py index 3757fdec10..0bfbf57498 100644 --- a/torchao/prototype/parq/optim/proxmap.py +++ b/torchao/prototype/parq/optim/proxmap.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from abc import ABC, abstractmethod from typing import Optional diff --git a/torchao/prototype/parq/optim/quantopt.py b/torchao/prototype/parq/optim/quantopt.py index 69c0dc37cf..016aea28bc 100644 --- a/torchao/prototype/parq/optim/quantopt.py +++ b/torchao/prototype/parq/optim/quantopt.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from collections.abc import Callable from functools import partial from typing import Any, Optional diff --git a/torchao/prototype/parq/quant/lsbq.py b/torchao/prototype/parq/quant/lsbq.py index 12e61bab31..e821b8f460 100644 --- a/torchao/prototype/parq/quant/lsbq.py +++ b/torchao/prototype/parq/quant/lsbq.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import itertools from collections.abc import Iterable from typing import Optional diff --git a/torchao/prototype/parq/quant/quantizer.py b/torchao/prototype/parq/quant/quantizer.py index 70e1057f12..22dd2a1bb7 100644 --- a/torchao/prototype/parq/quant/quantizer.py +++ b/torchao/prototype/parq/quant/quantizer.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from abc import ABC, abstractmethod from typing import Optional diff --git a/torchao/prototype/parq/quant/uniform.py b/torchao/prototype/parq/quant/uniform.py index a94d55a27b..de9e465bc0 100644 --- a/torchao/prototype/parq/quant/uniform.py +++ b/torchao/prototype/parq/quant/uniform.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Optional import torch diff --git a/torchao/prototype/parq/utils.py b/torchao/prototype/parq/utils.py index 109dda4ecd..d18257574f 100644 --- a/torchao/prototype/parq/utils.py +++ b/torchao/prototype/parq/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch import Tensor diff --git a/torchao/prototype/quantization/autoquant_v2.py b/torchao/prototype/quantization/autoquant_v2.py index 0780eb3a84..297b1a1b60 100644 --- a/torchao/prototype/quantization/autoquant_v2.py +++ b/torchao/prototype/quantization/autoquant_v2.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import csv import logging diff --git a/torchao/prototype/quantization/codebook/codebook_ops.py b/torchao/prototype/quantization/codebook/codebook_ops.py index 4c0b371c69..a7db8774ea 100644 --- a/torchao/prototype/quantization/codebook/codebook_ops.py +++ b/torchao/prototype/quantization/codebook/codebook_ops.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import List, Optional, Tuple import torch diff --git a/torchao/prototype/quantization/codebook/codebook_quantized_tensor.py b/torchao/prototype/quantization/codebook/codebook_quantized_tensor.py index 4566f94e8e..e16a339e82 100644 --- a/torchao/prototype/quantization/codebook/codebook_quantized_tensor.py +++ b/torchao/prototype/quantization/codebook/codebook_quantized_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Optional, Tuple diff --git a/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_modelsize.py b/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_modelsize.py index df7f670b41..68561408bd 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_modelsize.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_modelsize.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import random import torch diff --git a/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_throughput.py b/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_throughput.py index 12fc77bd9a..b2277ef4e5 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_throughput.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/BO_acc_throughput.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import random import time from pathlib import Path diff --git a/torchao/prototype/quantization/mixed_precision/scripts/fit.py b/torchao/prototype/quantization/mixed_precision/scripts/fit.py index 0765b93247..d8e6be4550 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/fit.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/fit.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import random import numpy as np diff --git a/torchao/prototype/quantization/mixed_precision/scripts/hessian_grad.py b/torchao/prototype/quantization/mixed_precision/scripts/hessian_grad.py index 750947eafa..1e7b403e3d 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/hessian_grad.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/hessian_grad.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import random import numpy as np diff --git a/torchao/prototype/quantization/mixed_precision/scripts/hessian_vhp.py b/torchao/prototype/quantization/mixed_precision/scripts/hessian_vhp.py index cb4f202cf2..faf46b01eb 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/hessian_vhp.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/hessian_vhp.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import random import numpy as np diff --git a/torchao/prototype/quantization/mixed_precision/scripts/mp_quant_eval.py b/torchao/prototype/quantization/mixed_precision/scripts/mp_quant_eval.py index 8d2f4f0b8b..e10b10ffb2 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/mp_quant_eval.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/mp_quant_eval.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from lm_eval.evaluator import evaluate diff --git a/torchao/prototype/quantization/mixed_precision/scripts/naive_intNwo.py b/torchao/prototype/quantization/mixed_precision/scripts/naive_intNwo.py index 87417df36f..016b6c9eef 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/naive_intNwo.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/naive_intNwo.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass import torch diff --git a/torchao/prototype/quantization/mixed_precision/scripts/utils.py b/torchao/prototype/quantization/mixed_precision/scripts/utils.py index 67ca8c0231..5a47664200 100644 --- a/torchao/prototype/quantization/mixed_precision/scripts/utils.py +++ b/torchao/prototype/quantization/mixed_precision/scripts/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import csv import json diff --git a/torchao/prototype/quantization/subgraph_utils/extract_subgraphs.py b/torchao/prototype/quantization/subgraph_utils/extract_subgraphs.py index 4f22ea84c2..d27f2a2431 100644 --- a/torchao/prototype/quantization/subgraph_utils/extract_subgraphs.py +++ b/torchao/prototype/quantization/subgraph_utils/extract_subgraphs.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import csv import os import traceback diff --git a/torchao/prototype/quantized_training/bitnet.py b/torchao/prototype/quantized_training/bitnet.py index 5d1a0a539f..129c63414c 100644 --- a/torchao/prototype/quantized_training/bitnet.py +++ b/torchao/prototype/quantized_training/bitnet.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # this file implements BitNet b1.58 https://arxiv.org/abs/2402.17764 # a reference implementation is available at # https://github.com/microsoft/unilm/blob/master/bitnet/The-Era-of-1-bit-LLMs__Training_Tips_Code_FAQ.pdf diff --git a/torchao/prototype/quantized_training/int8.py b/torchao/prototype/quantized_training/int8.py index fe6415de11..6b438ca787 100644 --- a/torchao/prototype/quantized_training/int8.py +++ b/torchao/prototype/quantized_training/int8.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Any, Optional, Tuple import torch diff --git a/torchao/prototype/quantized_training/int8_mixed_precision.py b/torchao/prototype/quantized_training/int8_mixed_precision.py index 9be21af120..44cd72e682 100644 --- a/torchao/prototype/quantized_training/int8_mixed_precision.py +++ b/torchao/prototype/quantized_training/int8_mixed_precision.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass from typing import Any, Optional, Tuple, Union diff --git a/torchao/prototype/quantized_training/int8_mm.py b/torchao/prototype/quantized_training/int8_mm.py index faaa6e463e..56846f98a7 100644 --- a/torchao/prototype/quantized_training/int8_mm.py +++ b/torchao/prototype/quantized_training/int8_mm.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. # TODO: might merge this with torchao/kernel/intmm_triton.py import torch diff --git a/torchao/prototype/smoothquant/api.py b/torchao/prototype/smoothquant/api.py index 63115fee2c..9397b340b3 100644 --- a/torchao/prototype/smoothquant/api.py +++ b/torchao/prototype/smoothquant/api.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import types from dataclasses import dataclass from typing import Dict, Optional diff --git a/torchao/prototype/smoothquant/core.py b/torchao/prototype/smoothquant/core.py index 1d7d18aa07..3e6c6ea5d5 100644 --- a/torchao/prototype/smoothquant/core.py +++ b/torchao/prototype/smoothquant/core.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Optional import torch diff --git a/torchao/prototype/smoothquant/example.py b/torchao/prototype/smoothquant/example.py index 788201d3fe..de1e4ed93e 100644 --- a/torchao/prototype/smoothquant/example.py +++ b/torchao/prototype/smoothquant/example.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import argparse import os import time diff --git a/torchao/prototype/sparsity/pruner/FPGM_pruner.py b/torchao/prototype/sparsity/pruner/FPGM_pruner.py index d8c3d20052..ae46a8df11 100644 --- a/torchao/prototype/sparsity/pruner/FPGM_pruner.py +++ b/torchao/prototype/sparsity/pruner/FPGM_pruner.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Callable, Optional, Union import torch diff --git a/torchao/prototype/sparsity/pruner/base_structured_sparsifier.py b/torchao/prototype/sparsity/pruner/base_structured_sparsifier.py index 407052731f..5bbd07b936 100644 --- a/torchao/prototype/sparsity/pruner/base_structured_sparsifier.py +++ b/torchao/prototype/sparsity/pruner/base_structured_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from itertools import chain from operator import getitem from typing import Callable, Dict, Optional, Set, Tuple, Type, Union diff --git a/torchao/prototype/sparsity/pruner/lstm_saliency_pruner.py b/torchao/prototype/sparsity/pruner/lstm_saliency_pruner.py index 3d47116e96..c61a00b8e1 100644 --- a/torchao/prototype/sparsity/pruner/lstm_saliency_pruner.py +++ b/torchao/prototype/sparsity/pruner/lstm_saliency_pruner.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import cast import torch diff --git a/torchao/prototype/sparsity/pruner/match_utils.py b/torchao/prototype/sparsity/pruner/match_utils.py index d7200c128e..353ee02a2f 100644 --- a/torchao/prototype/sparsity/pruner/match_utils.py +++ b/torchao/prototype/sparsity/pruner/match_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ Contains utility functions to check if a pattern is in the graph and return the matching nodes """ diff --git a/torchao/prototype/sparsity/pruner/parametrization.py b/torchao/prototype/sparsity/pruner/parametrization.py index c3ac3dda35..47d485009c 100644 --- a/torchao/prototype/sparsity/pruner/parametrization.py +++ b/torchao/prototype/sparsity/pruner/parametrization.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch import nn from torch.nn.utils.parametrize import is_parametrized diff --git a/torchao/prototype/sparsity/pruner/prune_functions.py b/torchao/prototype/sparsity/pruner/prune_functions.py index bcf736cd63..3c3600bc24 100644 --- a/torchao/prototype/sparsity/pruner/prune_functions.py +++ b/torchao/prototype/sparsity/pruner/prune_functions.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ Collection of conversion functions for linear / conv2d structured pruning Also contains utilities for bias propagation diff --git a/torchao/prototype/sparsity/pruner/saliency_pruner.py b/torchao/prototype/sparsity/pruner/saliency_pruner.py index a29399c0b6..0c0af152fa 100644 --- a/torchao/prototype/sparsity/pruner/saliency_pruner.py +++ b/torchao/prototype/sparsity/pruner/saliency_pruner.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from .base_structured_sparsifier import BaseStructuredSparsifier diff --git a/torchao/prototype/sparsity/scheduler/base_scheduler.py b/torchao/prototype/sparsity/scheduler/base_scheduler.py index dc5713340b..0c500482ee 100644 --- a/torchao/prototype/sparsity/scheduler/base_scheduler.py +++ b/torchao/prototype/sparsity/scheduler/base_scheduler.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import warnings import weakref from functools import wraps diff --git a/torchao/prototype/sparsity/scheduler/cubic_scheduler.py b/torchao/prototype/sparsity/scheduler/cubic_scheduler.py index 805e5c3a1c..ea67db09a9 100644 --- a/torchao/prototype/sparsity/scheduler/cubic_scheduler.py +++ b/torchao/prototype/sparsity/scheduler/cubic_scheduler.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import warnings from .base_scheduler import BaseScheduler diff --git a/torchao/prototype/sparsity/scheduler/lambda_scheduler.py b/torchao/prototype/sparsity/scheduler/lambda_scheduler.py index 01d0aee017..d5bed639a4 100644 --- a/torchao/prototype/sparsity/scheduler/lambda_scheduler.py +++ b/torchao/prototype/sparsity/scheduler/lambda_scheduler.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import warnings from .base_scheduler import BaseScheduler diff --git a/torchao/prototype/sparsity/sparsifier/base_sparsifier.py b/torchao/prototype/sparsity/sparsifier/base_sparsifier.py index 2246ff48f9..2c93ceb5d8 100644 --- a/torchao/prototype/sparsity/sparsifier/base_sparsifier.py +++ b/torchao/prototype/sparsity/sparsifier/base_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import abc import copy from collections import defaultdict diff --git a/torchao/prototype/sparsity/sparsifier/nearly_diagonal_sparsifier.py b/torchao/prototype/sparsity/sparsifier/nearly_diagonal_sparsifier.py index 7b341f09d9..a1f824c373 100644 --- a/torchao/prototype/sparsity/sparsifier/nearly_diagonal_sparsifier.py +++ b/torchao/prototype/sparsity/sparsifier/nearly_diagonal_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from . import base_sparsifier diff --git a/torchao/prototype/sparsity/sparsifier/utils.py b/torchao/prototype/sparsity/sparsifier/utils.py index be01955101..20d85a7116 100644 --- a/torchao/prototype/sparsity/sparsifier/utils.py +++ b/torchao/prototype/sparsity/sparsifier/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from itertools import chain from typing import Any, Dict, Optional, Type diff --git a/torchao/prototype/sparsity/sparsifier/weight_norm_sparsifier.py b/torchao/prototype/sparsity/sparsifier/weight_norm_sparsifier.py index 398ed4d1a9..d86e6c63cf 100644 --- a/torchao/prototype/sparsity/sparsifier/weight_norm_sparsifier.py +++ b/torchao/prototype/sparsity/sparsifier/weight_norm_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import operator from functools import reduce from typing import Callable, Optional, Tuple, Union diff --git a/torchao/prototype/sparsity/superblock/benchmark.sh b/torchao/prototype/sparsity/superblock/benchmark.sh index 3fc2a9869b..ac52ee8e02 100644 --- a/torchao/prototype/sparsity/superblock/benchmark.sh +++ b/torchao/prototype/sparsity/superblock/benchmark.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. MODEL=vit_h_14 BATCH_SIZE=256 diff --git a/torchao/prototype/sparsity/superblock/evaluate.sh b/torchao/prototype/sparsity/superblock/evaluate.sh index 68be5175fd..8696c9da42 100644 --- a/torchao/prototype/sparsity/superblock/evaluate.sh +++ b/torchao/prototype/sparsity/superblock/evaluate.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. MODEL=vit_b_16 BATCH_SIZE=256 diff --git a/torchao/prototype/spinquant/_hadamard_matrices.py b/torchao/prototype/spinquant/_hadamard_matrices.py index 8602a100df..91e29cd64b 100644 --- a/torchao/prototype/spinquant/_hadamard_matrices.py +++ b/torchao/prototype/spinquant/_hadamard_matrices.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch diff --git a/torchao/prototype/spinquant/spinquant.py b/torchao/prototype/spinquant/spinquant.py index 60ad1a8b41..8efee62456 100644 --- a/torchao/prototype/spinquant/spinquant.py +++ b/torchao/prototype/spinquant/spinquant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ SpinQuant implementation (https://arxiv.org/abs/2405.16406) diff --git a/torchao/quantization/GPTQ_MT.py b/torchao/quantization/GPTQ_MT.py index f7178ba669..4d0a7e9e40 100644 --- a/torchao/quantization/GPTQ_MT.py +++ b/torchao/quantization/GPTQ_MT.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import torch diff --git a/torchao/quantization/__init__.py b/torchao/quantization/__init__.py index c986084af4..67a70c5a35 100644 --- a/torchao/quantization/__init__.py +++ b/torchao/quantization/__init__.py @@ -1,10 +1,3 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. - -# This source code is licensed under the license found in the -# LICENSE file in the root directory of this source tree. - - from torchao.kernel import ( int_scaled_matmul, safe_int_mm, diff --git a/torchao/quantization/autoquant.py b/torchao/quantization/autoquant.py index d49e84e066..f018d5dffe 100644 --- a/torchao/quantization/autoquant.py +++ b/torchao/quantization/autoquant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import torch.nn.functional as F from torch.utils._python_dispatch import return_and_correct_aliasing diff --git a/torchao/quantization/linear_activation_quantized_tensor.py b/torchao/quantization/linear_activation_quantized_tensor.py index 0c8127b7c7..1c0c867ade 100644 --- a/torchao/quantization/linear_activation_quantized_tensor.py +++ b/torchao/quantization/linear_activation_quantized_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Any, Callable, Dict, Optional import torch diff --git a/torchao/quantization/linear_activation_scale.py b/torchao/quantization/linear_activation_scale.py index f1fb187338..6c433844a6 100644 --- a/torchao/quantization/linear_activation_scale.py +++ b/torchao/quantization/linear_activation_scale.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch.utils._python_dispatch import return_and_correct_aliasing diff --git a/torchao/quantization/linear_activation_weight_observed_tensor.py b/torchao/quantization/linear_activation_weight_observed_tensor.py index a40fec6509..029b89e54b 100644 --- a/torchao/quantization/linear_activation_weight_observed_tensor.py +++ b/torchao/quantization/linear_activation_weight_observed_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Callable, Dict, Optional import torch diff --git a/torchao/quantization/marlin_qqq/utils.py b/torchao/quantization/marlin_qqq/utils.py index e0bcc0d853..c1fe817dba 100644 --- a/torchao/quantization/marlin_qqq/utils.py +++ b/torchao/quantization/marlin_qqq/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass, field from typing import List, Tuple diff --git a/torchao/quantization/observer.py b/torchao/quantization/observer.py index cbbe1b581d..ee001eb731 100644 --- a/torchao/quantization/observer.py +++ b/torchao/quantization/observer.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import logging from abc import ABCMeta, abstractmethod from functools import partial diff --git a/torchao/quantization/qat/affine_fake_quantized_tensor.py b/torchao/quantization/qat/affine_fake_quantized_tensor.py index f60c858b73..6829441f51 100644 --- a/torchao/quantization/qat/affine_fake_quantized_tensor.py +++ b/torchao/quantization/qat/affine_fake_quantized_tensor.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Callable, Optional, Tuple import torch diff --git a/torchao/quantization/transform_module.py b/torchao/quantization/transform_module.py index 96fc808863..b6fac49ae9 100644 --- a/torchao/quantization/transform_module.py +++ b/torchao/quantization/transform_module.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import functools from typing import Callable, Dict diff --git a/torchao/quantization/unified.py b/torchao/quantization/unified.py index 4a419cd5e3..948d5f2fe8 100644 --- a/torchao/quantization/unified.py +++ b/torchao/quantization/unified.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from abc import ABC, abstractmethod from typing import Any diff --git a/torchao/quantization/weight_tensor_linear_activation_quantization.py b/torchao/quantization/weight_tensor_linear_activation_quantization.py index 0ed90ffaa1..6612213bc1 100644 --- a/torchao/quantization/weight_tensor_linear_activation_quantization.py +++ b/torchao/quantization/weight_tensor_linear_activation_quantization.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Any, Callable, Dict, Optional import torch diff --git a/torchao/sparsity/blocksparse.py b/torchao/sparsity/blocksparse.py index f0da181339..6a33736130 100644 --- a/torchao/sparsity/blocksparse.py +++ b/torchao/sparsity/blocksparse.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import List, Optional, Tuple import torch diff --git a/torchao/sparsity/marlin/utils.py b/torchao/sparsity/marlin/utils.py index 45837773dd..34dfef5dee 100644 --- a/torchao/sparsity/marlin/utils.py +++ b/torchao/sparsity/marlin/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from dataclasses import dataclass, field from typing import List, Tuple diff --git a/torchao/sparsity/prototype/pruner/FPGM_pruner.py b/torchao/sparsity/prototype/pruner/FPGM_pruner.py index 3e091bfafb..e11dedf9ab 100644 --- a/torchao/sparsity/prototype/pruner/FPGM_pruner.py +++ b/torchao/sparsity/prototype/pruner/FPGM_pruner.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.pruner.FPGM_pruner import FPGMPruner __all__ = ["FPGMPruner"] diff --git a/torchao/sparsity/prototype/pruner/base_structured_sparsifier.py b/torchao/sparsity/prototype/pruner/base_structured_sparsifier.py index 10898e0509..15471a4df8 100644 --- a/torchao/sparsity/prototype/pruner/base_structured_sparsifier.py +++ b/torchao/sparsity/prototype/pruner/base_structured_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.pruner.base_structured_sparsifier import ( BaseStructuredSparsifier, ) diff --git a/torchao/sparsity/prototype/pruner/lstm_saliency_pruner.py b/torchao/sparsity/prototype/pruner/lstm_saliency_pruner.py index bc5663303c..c22ca6bb59 100644 --- a/torchao/sparsity/prototype/pruner/lstm_saliency_pruner.py +++ b/torchao/sparsity/prototype/pruner/lstm_saliency_pruner.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.pruner.lstm_saliency_pruner import LSTMSaliencyPruner __all__ = ["LSTMSaliencyPruner"] diff --git a/torchao/sparsity/prototype/pruner/parametrization.py b/torchao/sparsity/prototype/pruner/parametrization.py index f8c6e6e418..03fab85f43 100644 --- a/torchao/sparsity/prototype/pruner/parametrization.py +++ b/torchao/sparsity/prototype/pruner/parametrization.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.pruner.parametrization import ( BiasHook, FakeStructuredSparsity, diff --git a/torchao/sparsity/prototype/pruner/saliency_pruner.py b/torchao/sparsity/prototype/pruner/saliency_pruner.py index 4556569447..421cac2a6f 100644 --- a/torchao/sparsity/prototype/pruner/saliency_pruner.py +++ b/torchao/sparsity/prototype/pruner/saliency_pruner.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.pruner.saliency_pruner import SaliencyPruner __all__ = ["SaliencyPruner"] diff --git a/torchao/sparsity/prototype/scheduler/base_scheduler.py b/torchao/sparsity/prototype/scheduler/base_scheduler.py index 31169a28ef..30a29c4775 100644 --- a/torchao/sparsity/prototype/scheduler/base_scheduler.py +++ b/torchao/sparsity/prototype/scheduler/base_scheduler.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.scheduler.base_scheduler import BaseScheduler __all__ = ["BaseScheduler"] diff --git a/torchao/sparsity/prototype/scheduler/cubic_scheduler.py b/torchao/sparsity/prototype/scheduler/cubic_scheduler.py index 82847ffef7..6ea7e95c36 100644 --- a/torchao/sparsity/prototype/scheduler/cubic_scheduler.py +++ b/torchao/sparsity/prototype/scheduler/cubic_scheduler.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.scheduler.cubic_scheduler import CubicSL __all__ = ["CubicSL"] diff --git a/torchao/sparsity/prototype/scheduler/lambda_scheduler.py b/torchao/sparsity/prototype/scheduler/lambda_scheduler.py index 47fce2a0b3..97d0abf174 100644 --- a/torchao/sparsity/prototype/scheduler/lambda_scheduler.py +++ b/torchao/sparsity/prototype/scheduler/lambda_scheduler.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.scheduler.lambda_scheduler import LambdaSL __all__ = ["LambdaSL"] diff --git a/torchao/sparsity/prototype/sparsifier/base_sparsifier.py b/torchao/sparsity/prototype/sparsifier/base_sparsifier.py index 490c1872c7..3c9f0947d8 100644 --- a/torchao/sparsity/prototype/sparsifier/base_sparsifier.py +++ b/torchao/sparsity/prototype/sparsifier/base_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.sparsifier.base_sparsifier import BaseSparsifier __all__ = ["BaseSparsifier"] diff --git a/torchao/sparsity/prototype/sparsifier/nearly_diagonal_sparsifier.py b/torchao/sparsity/prototype/sparsifier/nearly_diagonal_sparsifier.py index d0ec384367..e6caa9087d 100644 --- a/torchao/sparsity/prototype/sparsifier/nearly_diagonal_sparsifier.py +++ b/torchao/sparsity/prototype/sparsifier/nearly_diagonal_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.sparsifier.nearly_diagonal_sparsifier import ( NearlyDiagonalSparsifier, ) diff --git a/torchao/sparsity/prototype/sparsifier/utils.py b/torchao/sparsity/prototype/sparsifier/utils.py index a30fe5628b..8cb822513e 100644 --- a/torchao/sparsity/prototype/sparsifier/utils.py +++ b/torchao/sparsity/prototype/sparsifier/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.sparsifier.utils import FakeSparsity __all__ = ["FakeSparsity"] diff --git a/torchao/sparsity/prototype/sparsifier/weight_norm_sparsifier.py b/torchao/sparsity/prototype/sparsifier/weight_norm_sparsifier.py index 0a33ac5295..93d2799316 100644 --- a/torchao/sparsity/prototype/sparsifier/weight_norm_sparsifier.py +++ b/torchao/sparsity/prototype/sparsifier/weight_norm_sparsifier.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.sparsifier.weight_norm_sparsifier import ( WeightNormSparsifier, ) diff --git a/torchao/sparsity/prototype/superblock/blocksparse.py b/torchao/sparsity/prototype/superblock/blocksparse.py index 54510e393a..845be888fc 100644 --- a/torchao/sparsity/prototype/superblock/blocksparse.py +++ b/torchao/sparsity/prototype/superblock/blocksparse.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.superblock.blocksparse import BlockSparseTensor __all__ = ["BlockSparseTensor"] diff --git a/torchao/sparsity/prototype/superblock/supermask.py b/torchao/sparsity/prototype/superblock/supermask.py index 97d0b36c79..1066271013 100644 --- a/torchao/sparsity/prototype/superblock/supermask.py +++ b/torchao/sparsity/prototype/superblock/supermask.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.sparsity.supermask import ( SupermaskLinear, ) diff --git a/torchao/sparsity/prototype/superblock/utils.py b/torchao/sparsity/prototype/superblock/utils.py index e60e244c80..e0ef628ebc 100644 --- a/torchao/sparsity/prototype/superblock/utils.py +++ b/torchao/sparsity/prototype/superblock/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.prototype.sparsity.superblock.utils import ( ClassificationPresetEval, ClassificationPresetTrain, diff --git a/torchao/sparsity/sparse_api.py b/torchao/sparsity/sparse_api.py index 4b5cf0d8d4..b263b5e098 100644 --- a/torchao/sparsity/sparse_api.py +++ b/torchao/sparsity/sparse_api.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import types from dataclasses import dataclass from typing import Callable, Optional diff --git a/torchao/sparsity/training/autograd.py b/torchao/sparsity/training/autograd.py index fa61fa3b2c..fafbd7c3c3 100644 --- a/torchao/sparsity/training/autograd.py +++ b/torchao/sparsity/training/autograd.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from enum import Enum import torch diff --git a/torchao/sparsity/training/pointwise_ops.py b/torchao/sparsity/training/pointwise_ops.py index 0c50cff43b..ec483fb094 100644 --- a/torchao/sparsity/training/pointwise_ops.py +++ b/torchao/sparsity/training/pointwise_ops.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from functools import partial import torch diff --git a/torchao/sparsity/utils.py b/torchao/sparsity/utils.py index 467672ed72..db25b93210 100644 --- a/torchao/sparsity/utils.py +++ b/torchao/sparsity/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch.ao.quantization.observer import UniformQuantizationObserverBase diff --git a/torchao/sparsity/wanda.py b/torchao/sparsity/wanda.py index 50cf7835ce..7ad12a2d55 100644 --- a/torchao/sparsity/wanda.py +++ b/torchao/sparsity/wanda.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import warnings from typing import Dict, List, Optional, Tuple diff --git a/torchao/testing/float8/fsdp2_utils.py b/torchao/testing/float8/fsdp2_utils.py index debcffa231..9eef296040 100644 --- a/torchao/testing/float8/fsdp2_utils.py +++ b/torchao/testing/float8/fsdp2_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import List import torch diff --git a/torchao/testing/float8/test_utils.py b/torchao/testing/float8/test_utils.py index 2da34f53ed..4a30931c9e 100644 --- a/torchao/testing/float8/test_utils.py +++ b/torchao/testing/float8/test_utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from torchao.float8.config import ( CastConfig, Float8LinearConfig, diff --git a/torchao/testing/utils.py b/torchao/testing/utils.py index 02d151cdb4..d778f5b950 100644 --- a/torchao/testing/utils.py +++ b/torchao/testing/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy import functools import unittest diff --git a/torchao/utils.py b/torchao/utils.py index acb4502747..a0628d7049 100644 --- a/torchao/utils.py +++ b/torchao/utils.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import functools import itertools import re diff --git a/tutorials/add_an_op.py b/tutorials/add_an_op.py index bb89aa05f9..4f1cfcf6c7 100644 --- a/tutorials/add_an_op.py +++ b/tutorials/add_an_op.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import torchao diff --git a/tutorials/calibration_flow/awq_like.py b/tutorials/calibration_flow/awq_like.py index c047b8531e..19ce9e872e 100644 --- a/tutorials/calibration_flow/awq_like.py +++ b/tutorials/calibration_flow/awq_like.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ Demo for awq like flow that applies equalization scale to input activation * insert_observers_: insert observer for activation and weight diff --git a/tutorials/calibration_flow/gptq_like.py b/tutorials/calibration_flow/gptq_like.py index e4f28faf6f..7d9552e665 100644 --- a/tutorials/calibration_flow/gptq_like.py +++ b/tutorials/calibration_flow/gptq_like.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ Traditional calibration flow has the following flow (see static_quant.py for code examples): diff --git a/tutorials/calibration_flow/static_quant.py b/tutorials/calibration_flow/static_quant.py index 1ebce411d3..59f50444e8 100644 --- a/tutorials/calibration_flow/static_quant.py +++ b/tutorials/calibration_flow/static_quant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ Demo for static quantization flow """ diff --git a/tutorials/developer_api_guide/export_to_executorch.py b/tutorials/developer_api_guide/export_to_executorch.py index 9d4b54e508..233c5dd1bc 100644 --- a/tutorials/developer_api_guide/export_to_executorch.py +++ b/tutorials/developer_api_guide/export_to_executorch.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ This tutorial shows how to preserve higher level operators in the model in order to be used in executorch diff --git a/tutorials/developer_api_guide/my_dtype_tensor_subclass.py b/tutorials/developer_api_guide/my_dtype_tensor_subclass.py index 40c602cdef..7b431c0242 100644 --- a/tutorials/developer_api_guide/my_dtype_tensor_subclass.py +++ b/tutorials/developer_api_guide/my_dtype_tensor_subclass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ Following is a example for a simple dtype implemented with tensor subclass it shows diff --git a/tutorials/developer_api_guide/my_trainable_tensor_subclass.py b/tutorials/developer_api_guide/my_trainable_tensor_subclass.py index 1e0136d18b..d6d3b0fad4 100644 --- a/tutorials/developer_api_guide/my_trainable_tensor_subclass.py +++ b/tutorials/developer_api_guide/my_trainable_tensor_subclass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. """ This is an example for a tensor subclass representing a simple dtype that can be used in training. diff --git a/tutorials/developer_api_guide/print_op_and_shapes.py b/tutorials/developer_api_guide/print_op_and_shapes.py index d099875c82..9501aefe8e 100644 --- a/tutorials/developer_api_guide/print_op_and_shapes.py +++ b/tutorials/developer_api_guide/print_op_and_shapes.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch PRINT_ARGS = False diff --git a/tutorials/developer_api_guide/tensor_parallel.py b/tutorials/developer_api_guide/tensor_parallel.py index ba41000989..45e763e685 100644 --- a/tutorials/developer_api_guide/tensor_parallel.py +++ b/tutorials/developer_api_guide/tensor_parallel.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import os from typing import Sequence diff --git a/tutorials/examples/logging_subclass.py b/tutorials/examples/logging_subclass.py index ded50c56d6..d2b6dca2de 100644 --- a/tutorials/examples/logging_subclass.py +++ b/tutorials/examples/logging_subclass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch import torch.utils._pytree as pytree diff --git a/tutorials/examples/quantized_module_swap.py b/tutorials/examples/quantized_module_swap.py index 07281a5bca..462d4be8b6 100644 --- a/tutorials/examples/quantized_module_swap.py +++ b/tutorials/examples/quantized_module_swap.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. from typing import Tuple import torch diff --git a/tutorials/examples/quantized_subclass.py b/tutorials/examples/quantized_subclass.py index e256068294..24ca8691ca 100644 --- a/tutorials/examples/quantized_subclass.py +++ b/tutorials/examples/quantized_subclass.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import copy from typing import Any, List, Tuple diff --git a/tutorials/quantize_vit/bfloat16_code.py b/tutorials/quantize_vit/bfloat16_code.py index b01dc86cce..913be25cfa 100644 --- a/tutorials/quantize_vit/bfloat16_code.py +++ b/tutorials/quantize_vit/bfloat16_code.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch._inductor.async_compile import AsyncCompile from torch._inductor.select_algorithm import extern_kernels diff --git a/tutorials/quantize_vit/quant_code.py b/tutorials/quantize_vit/quant_code.py index df1c0ea402..20404b7009 100644 --- a/tutorials/quantize_vit/quant_code.py +++ b/tutorials/quantize_vit/quant_code.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torch._inductor.async_compile import AsyncCompile from torch._inductor.select_algorithm import extern_kernels diff --git a/tutorials/quantize_vit/run.sh b/tutorials/quantize_vit/run.sh index 759ad8e025..aa39586783 100755 --- a/tutorials/quantize_vit/run.sh +++ b/tutorials/quantize_vit/run.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash # Run bfloat16 version diff --git a/tutorials/quantize_vit/run_vit_b.py b/tutorials/quantize_vit/run_vit_b.py index 08578c66ea..b149c84e51 100644 --- a/tutorials/quantize_vit/run_vit_b.py +++ b/tutorials/quantize_vit/run_vit_b.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torchvision import models diff --git a/tutorials/quantize_vit/run_vit_b_quant.py b/tutorials/quantize_vit/run_vit_b_quant.py index 2779dd3cb2..faaa9b1ae9 100644 --- a/tutorials/quantize_vit/run_vit_b_quant.py +++ b/tutorials/quantize_vit/run_vit_b_quant.py @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. import torch from torchvision import models diff --git a/tutorials/run_all.sh b/tutorials/run_all.sh index ffa014c2ac..33fb84daa7 100644 --- a/tutorials/run_all.sh +++ b/tutorials/run_all.sh @@ -1,3 +1,8 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD 3-Clause license found in the +# LICENSE file in the root directory of this source tree. #!/bin/bash FAILED=0 for dir in $(find . -type d); do