This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bitblas | |
from bitblas.cache import global_operator_cache, get_database_path | |
from bitblas import auto_detect_nvidia_target | |
BITBLAS_TARGET = auto_detect_nvidia_target() | |
BITBLAS_DATABASE_PATH = get_database_path() | |
import torch | |
import torch.nn.functional as F | |
import torch.nn as nn | |
# adapated from https://github.com/microsoft/BitBLAS/blob/main/integration/BitNet/utils_quant.py | |
class BitLinear158(nn.Module): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import triton | |
import triton.language as tl | |
def unpack_weights(packed: torch.Tensor, bits: int = 2) -> torch.Tensor: | |
values_per_item = 8 // bits | |
packed_shape = packed.shape | |
if len(packed_shape) == 1: |