Skip to content

Add copyright header and pre-commit validator #1900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)$
5 changes: 5 additions & 0 deletions benchmarks/bench_galore_fused_kernels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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

Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_aq.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_fp6.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_gpu_sparsity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_hqq.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_low_bit_adam.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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:
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_marlin_qqq.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_rowwise_scaled_linear_cutlass.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/benchmark_rowwise_scaled_linear_sparse_cutlass.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
15 changes: 10 additions & 5 deletions benchmarks/benchmark_uintx.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/float8/bench_padding.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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

Expand Down
5 changes: 5 additions & 0 deletions benchmarks/float8/training/float8_training_benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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,
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/float8/training/parse_torchtitan_logs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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,
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/fused_benchmark_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/intmm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/print_config_shapes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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()
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/quantized_training/benchmark_int8mm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/quantized_training/pretrain_llama2.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
#
Expand Down
5 changes: 5 additions & 0 deletions docs/source/tutorials_source/template_tutorial.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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 -*-

"""
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/amg_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/annotate_with_rle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/cli_on_modal.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/compare_rle_lists.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/compile_export_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/generate_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
9 changes: 7 additions & 2 deletions examples/sam2_amg_server/modal_experiments.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/reproduce_experiments.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_amg_server/server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_vos_example/compile_export_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions examples/sam2_vos_example/video_profile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# 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
Expand Down
Loading
Loading