repo_id
stringlengths
15
89
file_path
stringlengths
27
180
content
stringlengths
1
2.23M
__index_level_0__
int64
0
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/server/requirements_common.txt
backoff==2.2.1 ; python_version >= "3.9" and python_version < "3.13" certifi==2023.11.17 ; python_version >= "3.9" and python_version < "3.13" charset-normalizer==3.3.2 ; python_version >= "3.9" and python_version < "3.13" click==8.1.7 ; python_version >= "3.9" and python_version < "3.13" colorama==0.4.6 ; python_versi...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/server/poetry.lock
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "accelerate" version = "0.20.3" description = "Accelerate" optional = true python-versions = ">=3.7.0" files = [ {file = "accelerate-0.20.3-py3-none-any.whl", hash = "sha256:147183e7a2215f7bd45a7af3b986a96...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/server/Makefile-flash-att-v2
flash_att_v2_commit_cuda := 02ac572f3ffc4f402e4183aaa6824b45859d3ed3 flash_att_v2_commit_rocm := 8736558c287ff2ef28b24878e42828c595ac3e69 flash-attention-v2-cuda: # Clone flash attention pip install -U packaging ninja --no-cache-dir git clone https://github.com/HazyResearch/flash-attention.git flash-attention-v2...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/exllama_kernels/setup.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension setup( name="exllama_kernels", ext_modules=[ CUDAExtension( name="exllama_kernels", sources=[ "exllama_kernels/exllama_ext.cpp", "exllama_kernels/cuda...
0
hf_public_repos/text-generation-inference/server/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_compat.cuh
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _cuda_compat_cuh #define _cuda_compat_cuh // atomicAdd for half types, to support CC < 7.x __device__ __forceinline__ void atomicAdd_half(half* address, half val) { unsigned int * address_as_ui = (unsigned int *) ((char *)address - (...
0
hf_public_repos/text-generation-inference/server/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cuh
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _cuda_buffers_cuh #define _cuda_buffers_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> const int CUDA_MAX_DEVICES = 16; // #ifndef _cuda_buffers_cu // extern __constant__ half2 q4_table[16][256...
0
hf_public_repos/text-generation-inference/server/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/util.cuh
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _util_cuh #define _util_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #define cudaUnspecified cudaErrorApiFailureBase // React to failure on return code != cudaSuccess #define _cuda_check(fn)...
0
hf_public_repos/text-generation-inference/server/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/exllama_ext.cpp
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #include <torch/extension.h> #include <c10/cuda/CUDAGuard.h> #include <ATen/cuda/CUDAContext.h> #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #include "util.cuh" #include "tuning.h" #include "cuda_buffers.cu...
0
hf_public_repos/text-generation-inference/server/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cu
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #define _cuda_buffers_cu #include "cuda_buffers.cuh" CudaBuffers* g_buffers[CUDA_MAX_DEVICES] = {NULL}; // __constant__ half2 q4_table[16][256]; // half2 q4_table_host[16][256]; // bool q4_table_init = false; CudaBuffers::CudaBuffers ( int _...
0
hf_public_repos/text-generation-inference/server/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/matrix.cuh
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _matrix_cuh #define _matrix_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> class MatrixView_half { public: const half* data; const int height; const int width; __device__ __forceinline__ MatrixView_half(const half*...
0
hf_public_repos/text-generation-inference/server/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/tuning.h
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _tuning_h #define _tuning_h struct ExLlamaTuning { int matmul_recons_thd; bool matmul_fused_remap; bool matmul_no_half2; }; #endif
0
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matrix.cuh
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _q4_matrix_cuh #define _q4_matrix_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> class Q4Matrix { public: int device; int height; int width; int groups; int groupsize; uint32_t* cuda_qw...
0
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/column_remap.cuh
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _column_remap_cuh #define _column_remap_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> void column_remap_cuda ( const half* x, half* x_new, const int x_height, const int x_width, const uint32_...
0
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cu
#include "q4_matmul.cuh" #include "column_remap.cuh" #include "../util.cuh" #include "../matrix.cuh" #include "../cuda_compat.cuh" #include "../cuda_buffers.cuh" const int THREADS_X = 32; // Block size and thread count along columns in w and out const int THREADS_Y = 1; // Block size and thread count alon...
0
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matrix.cu
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #include "q4_matrix.cuh" #include <vector> #include "../util.cuh" #include "../matrix.cuh" using namespace std; const int UNSHUF_BLOCKSIZE_X = 64; const int RECONS_THREADS_X = 64; // Block size and thread count along columns in out, each t...
0
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cuh
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _q4_matmul_cuh #define _q4_matmul_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #include <ATen/cuda/CUDAContext.h> #include "q4_matrix.cuh" #include "../tuning.h" void q4_matmul_cuda ( ExL...
0
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels
hf_public_repos/text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/column_remap.cu
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #include "column_remap.cuh" #include "../util.cuh" const int SHUF_BLOCKSIZE_X = 256; const int SHUF_BLOCKSIZE_Y = 16; __global__ void column_remap_kernel ( const half* __restrict__ x, half* __restrict__ x_new, const int x_width, ...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/custom_kernels/setup.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension import torch extra_compile_args = ["-std=c++17"] if not torch.version.hip: extra_compile_args.append("-arch=compute_80") setup( name="custom_kernels", ext_modules=[ CUDAExtension( name="cus...
0
hf_public_repos/text-generation-inference/server/custom_kernels
hf_public_repos/text-generation-inference/server/custom_kernels/custom_kernels/fused_attention_cuda.cu
#include <ATen/Dispatch.h> #include <THC/THCAtomics.cuh> #include <ATen/ATen.h> #include <torch/torch.h> #include <vector> #include <optional> /** * Friendly reminder of how multithreading works in CUDA: https://developer.nvidia.com/blog/even-easier-introduction-cuda * Check example at https://github.com/thomasw21/Li...
0
hf_public_repos/text-generation-inference/server/custom_kernels
hf_public_repos/text-generation-inference/server/custom_kernels/custom_kernels/fused_bloom_attention_cuda.cu
#include <ATen/Dispatch.h> #include <THC/THCAtomics.cuh> #include <ATen/ATen.h> #include <torch/torch.h> #include <vector> #include <optional> /** * Friendly reminder of how multithreading works in CUDA: https://developer.nvidia.com/blog/even-easier-introduction-cuda * Check example at https://github.com/thomasw21/Li...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/tests/conftest.py
import pytest from text_generation_server.pb import generate_pb2 @pytest.fixture def default_pb_parameters(): return generate_pb2.NextTokenChooserParameters( temperature=1.0, repetition_penalty=1.0, top_k=0, top_p=1.0, typical_p=1.0, do_sample=False, ) @pytes...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_hub.py
import pytest from text_generation_server.utils.hub import ( weight_hub_files, download_weights, weight_files, EntryNotFoundError, LocalEntryNotFoundError, RevisionNotFoundError, ) def test_weight_hub_files(): filenames = weight_hub_files("bigscience/bloom-560m") assert filenames == [...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_convert.py
from text_generation_server.utils.hub import ( download_weights, weight_hub_files, weight_files, ) from text_generation_server.utils.convert import convert_files def test_convert_files(): model_id = "bigscience/bloom-560m" pt_filenames = weight_hub_files(model_id, extension=".bin") local_pt_f...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_watermark.py
# test_watermark_logits_processor.py import os import numpy as np import torch from text_generation_server.utils.watermark import WatermarkLogitsProcessor GAMMA = os.getenv("WATERMARK_GAMMA", 0.5) DELTA = os.getenv("WATERMARK_DELTA", 2.0) def test_seed_rng(): input_ids = [101, 2036, 3731, 102, 2003, 103] p...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_tokens.py
import torch from text_generation_server.utils.tokens import ( StopSequenceCriteria, StoppingCriteria, FinishReason, batch_top_tokens, ) def test_stop_sequence_criteria(): criteria = StopSequenceCriteria("/test;") assert not criteria("/") assert not criteria("/test") assert criteria("...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/models/test_model.py
import pytest import torch from transformers import AutoTokenizer from text_generation_server.models import Model def get_test_model(): class TestModel(Model): def batch_type(self): raise NotImplementedError def generate_token(self, batch): raise NotImplementedError ...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/models/test_seq2seq_lm.py
import pytest import torch from copy import copy from transformers import AutoTokenizer from text_generation_server.pb import generate_pb2 from text_generation_server.models.seq2seq_lm import Seq2SeqLM, Seq2SeqLMBatch @pytest.fixture(scope="session") def mt0_small_tokenizer(): tokenizer = AutoTokenizer.from_pr...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/models/test_santacoder.py
import pytest from text_generation_server.pb import generate_pb2 from text_generation_server.models.causal_lm import CausalLMBatch from text_generation_server.models.santacoder import SantaCoder @pytest.fixture(scope="session") def default_santacoder(): return SantaCoder("bigcode/santacoder") @pytest.fixture d...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/models/test_bloom.py
import pytest import torch from copy import copy from transformers import AutoTokenizer from text_generation_server.pb import generate_pb2 from text_generation_server.models.causal_lm import CausalLMBatch from text_generation_server.utils import weight_hub_files, download_weights from text_generation_server.models.bl...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/models/test_causal_lm.py
import pytest import torch from copy import copy from transformers import AutoTokenizer from text_generation_server.pb import generate_pb2 from text_generation_server.models.causal_lm import CausalLM, CausalLMBatch @pytest.fixture(scope="session") def default_causal_lm(): return CausalLM("gpt2") @pytest.fixtu...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/text_generation_server/tracing.py
import grpc from opentelemetry import trace from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter from opentelemetry.instrumentation.grpc._aio_server import ( OpenTelemetryAioServerInterceptor, ) from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.sdk.resources im...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/text_generation_server/server.py
import asyncio import os import torch from grpc import aio from loguru import logger from grpc_reflection.v1alpha import reflection from pathlib import Path from typing import List, Optional from text_generation_server.cache import Cache from text_generation_server.interceptor import ExceptionInterceptor from text_g...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/text_generation_server/cache.py
import torch from typing import Dict, Optional, TypeVar from text_generation_server.models.types import Batch B = TypeVar("B", bound=Batch) class Cache: def __init__(self): self.cache: Dict[int, B] = {} def pop(self, batch_id: int) -> Optional[B]: return self.cache.pop(batch_id, None) ...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/text_generation_server/cli.py
import os import sys import typer from pathlib import Path from loguru import logger from typing import Optional from enum import Enum from huggingface_hub import hf_hub_download app = typer.Typer() class Quantization(str, Enum): bitsandbytes = "bitsandbytes" bitsandbytes_nf4 = "bitsandbytes-nf4" bitsa...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/text_generation_server/interceptor.py
import torch import grpc from google.rpc import status_pb2, code_pb2 from grpc_status import rpc_status from grpc_interceptor.server import AsyncServerInterceptor from loguru import logger from typing import Callable, Any class ExceptionInterceptor(AsyncServerInterceptor): async def intercept( self, ...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/flash_attn.py
import os import torch from loguru import logger from text_generation_server.utils.import_utils import IS_CUDA_SYSTEM, IS_ROCM_SYSTEM if os.getenv("USE_FLASH_ATTENTION", "").lower() == "false": raise ImportError("`USE_FLASH_ATTENTION` is false.") if not torch.cuda.is_available(): raise ImportError("CUDA is ...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/logits_process.py
import math import torch from functools import lru_cache from typing import Optional, List, Dict, Union from transformers import ( LogitsWarper, LogitsProcessor, TemperatureLogitsWarper, TopKLogitsWarper, TopPLogitsWarper, TypicalLogitsWarper, ) mempool = torch.cuda.graph_pool_handle() if tor...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/watermark.py
# coding=utf-8 # Copyright 2023 Authors of "A Watermark for Large Language Models" # available at https://arxiv.org/abs/2301.10226 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/peft.py
import os import json from loguru import logger import torch from transformers import AutoTokenizer from peft import AutoPeftModelForCausalLM, AutoPeftModelForSeq2SeqLM def download_and_unload_peft(model_id, revision, trust_remote_code): torch_dtype = torch.float16 logger.info("Peft model detected.") lo...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/convert.py
import datetime import torch import os from loguru import logger from pathlib import Path from safetensors.torch import save_file, load_file, _find_shared_tensors, _is_complete from typing import List, Dict from collections import defaultdict def _remove_duplicate_names( state_dict: Dict[str, torch.Tensor], ...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/__init__.py
from text_generation_server.utils.convert import convert_file, convert_files from text_generation_server.utils.dist import initialize_torch_distributed from text_generation_server.utils.weights import Weights from text_generation_server.utils.peft import download_and_unload_peft from text_generation_server.utils.hub im...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/tokens.py
import re from typing import Callable, List, Optional, Tuple import torch from text_generation_server.pb import generate_pb2 from text_generation_server.pb.generate_pb2 import FinishReason from text_generation_server.utils.logits_process import ( HeterogeneousProcessorWrapper, HeterogeneousRepetitionPenaltyLog...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/hub.py
import time import os from datetime import timedelta from loguru import logger from pathlib import Path from typing import Optional, List from huggingface_hub import HfApi, hf_hub_download from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE from huggingface_hub.utils import ( LocalEntryNotFoundError, ...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/paged_attention.py
import torch # vllm imports from vllm import cache_ops from vllm import attention_ops _PARTITION_SIZE = 512 def reshape_and_cache(key: torch.Tensor, value: torch.Tensor, key_cache: torch.Tensor, value_cache: torch.Tensor, slots: torch.Tensor): cache_ops.reshape_and_cache( key, valu...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/layers.py
import os import torch import torch.distributed from torch import nn from torch.nn import functional as F from typing import List from loguru import logger from functools import lru_cache HAS_BITS_AND_BYTES = True try: import bitsandbytes as bnb from bitsandbytes.nn import Int8Params, Params4bit except Import...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/import_utils.py
import torch IS_ROCM_SYSTEM = torch.version.hip is not None IS_CUDA_SYSTEM = torch.version.cuda is not None
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/weights.py
import os from pathlib import Path from typing import List, Dict, Optional, Tuple from safetensors import safe_open, SafetensorError import torch from loguru import logger from huggingface_hub import hf_hub_download import json class Weights: def __init__( self, filenames: List[Path], devi...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/utils/dist.py
import os import torch from datetime import timedelta from loguru import logger # Tensor Parallelism settings RANK = int(os.getenv("RANK", "0")) WORLD_SIZE = int(os.getenv("WORLD_SIZE", "1")) # CUDA memory fraction MEMORY_FRACTION = float(os.getenv("CUDA_MEMORY_FRACTION", "1.0")) class FakeBarrier: def wait(se...
0
hf_public_repos/text-generation-inference/server/text_generation_server/utils/awq
hf_public_repos/text-generation-inference/server/text_generation_server/utils/awq/quantize/qmodule.py
# Copied logic from https://github.com/mit-han-lab/llm-awq/blob/f084f40bd996f3cf3a0633c1ad7d9d476c318aaa/awq/quantize/qmodule.py import math import torch import torch.nn as nn import awq_inference_engine # with CUDA kernels # class ScaledActivation(nn.Module): # def __init__(self, module, scales): # sup...
0
hf_public_repos/text-generation-inference/server/text_generation_server/utils
hf_public_repos/text-generation-inference/server/text_generation_server/utils/gptq/quant_linear.py
import math import numpy as np import torch import torch.nn as nn from torch.cuda.amp import custom_bwd, custom_fwd try: import triton import triton.language as tl from . import custom_autotune # code based https://github.com/fpgaminer/GPTQ-triton @custom_autotune.autotune( configs=[ ...
0
hf_public_repos/text-generation-inference/server/text_generation_server/utils
hf_public_repos/text-generation-inference/server/text_generation_server/utils/gptq/exllamav2.py
# Adapted from turboderp exllama: https://github.com/turboderp/exllamav2 from logging import getLogger import torch import torch.nn as nn import math logger = getLogger(__name__) try: from exllamav2_kernels import make_q_matrix, gemm_half_q_half except ImportError: logger.error('exllamav2_kernels not instal...
0
hf_public_repos/text-generation-inference/server/text_generation_server/utils
hf_public_repos/text-generation-inference/server/text_generation_server/utils/gptq/quantize.py
import time import torch.nn as nn import math import json import os import torch import transformers from texttable import Texttable from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer from huggingface_hub import HfApi from accelerate import init_empty_weights from text_generation_server.utils imp...
0
hf_public_repos/text-generation-inference/server/text_generation_server/utils
hf_public_repos/text-generation-inference/server/text_generation_server/utils/gptq/custom_autotune.py
# https://github.com/fpgaminer/GPTQ-triton """ Mostly the same as the autotuner in Triton, but with a few changes like using 40 runs instead of 100. """ import builtins import math import time from typing import Dict import triton class Autotuner(triton.KernelInterface): def __init__( self, fn, ...
0
hf_public_repos/text-generation-inference/server/text_generation_server/utils
hf_public_repos/text-generation-inference/server/text_generation_server/utils/gptq/exllama.py
import torch from exllama_kernels import make_q4, q4_matmul, prepare_buffers, set_tuning_params # Dummy tensor to pass instead of g_idx since there is no way to pass "None" to a C++ extension none_tensor = torch.empty((1, 1), device="meta") def ext_make_q4(qweight, qzeros, scales, g_idx, device): """Construct Q4...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/causal_lm.py
from text_generation_server.utils.tokens import batch_top_tokens import torch import inspect from dataclasses import dataclass from opentelemetry import trace from transformers import AutoTokenizer, AutoModelForCausalLM, PreTrainedTokenizerBase from typing import Optional, Tuple, List, Type, Dict from text_generation...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/flash_llama.py
import torch import torch.distributed from opentelemetry import trace from transformers import AutoConfig, AutoTokenizer from transformers.models.llama import LlamaTokenizer from typing import Optional from text_generation_server.models import FlashCausalLM from text_generation_server.models.custom_modeling.flash_lla...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/t5.py
import torch import torch.distributed from typing import List, Optional, Tuple from transformers import ( AutoTokenizer, AutoConfig, ) from text_generation_server.models import Seq2SeqLM from text_generation_server.models.custom_modeling.t5_modeling import ( T5ForConditionalGeneration, ) from text_genera...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/cache_manager.py
import math import torch from typing import Optional, List, Tuple BLOCK_SIZE: int = 16 # Will be set in warmup CACHE_MANAGER: Optional["CacheManager"] = None class CacheManager: def __init__( self, num_blocks: int, num_layers: int, num_heads: int, head_size: int, ...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/galactica.py
import re import torch import torch.distributed from typing import List, Optional, Type from transformers import ( AutoTokenizer, AutoConfig, PreTrainedTokenizerBase, ) from text_generation_server.models import CausalLM from text_generation_server.models.causal_lm import CausalLMBatch from text_generation...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/__init__.py
import os import torch from loguru import logger from transformers.configuration_utils import PretrainedConfig from transformers.models.auto import modeling_auto from typing import Optional from text_generation_server.models.model import Model from text_generation_server.models.causal_lm import CausalLM from text_gen...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/idefics_causal_lm.py
import torch import inspect import re from io import BytesIO import base64 from PIL import Image import re from dataclasses import dataclass from opentelemetry import trace from transformers import ( AutoProcessor, AutoTokenizer, AutoModelForCausalLM, PreTrainedTokenizerBase, ProcessorMixin, ) from...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/types.py
from functools import total_ordering import torch from abc import ABC, abstractmethod from dataclasses import dataclass from typing import List, Optional from transformers import PreTrainedTokenizerBase from text_generation_server.pb import generate_pb2 from text_generation_server.pb.generate_pb2 import FinishReason...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/opt.py
import torch import torch.distributed from typing import Optional from transformers import ( AutoTokenizer, AutoConfig, ) from text_generation_server.models.custom_modeling.opt_modeling import OPTForCausalLM from text_generation_server.models import CausalLM from text_generation_server.utils import ( init...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/model.py
import inspect import torch from abc import ABC, abstractmethod from typing import List, Tuple, Optional, TypeVar, Type from transformers import PreTrainedTokenizerBase, PretrainedConfig from text_generation_server.models.types import Batch, Generation from text_generation_server.pb.generate_pb2 import InfoResponse ...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/flash_neox.py
import torch import torch.distributed from opentelemetry import trace from transformers import AutoTokenizer, AutoConfig from typing import Optional from text_generation_server.models import FlashCausalLM from text_generation_server.models.custom_modeling.flash_neox_modeling import ( FlashGPTNeoXForCausalLM, ) fr...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/flash_causal_lm.py
import math import itertools from text_generation_server.utils.tokens import batch_top_tokens import torch import torch.distributed import numpy as np from dataclasses import dataclass from opentelemetry import trace from transformers import PreTrainedTokenizerBase from typing import Optional, Tuple, List, Type, Unio...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/rw.py
import torch from transformers import AutoTokenizer, AutoModelForCausalLM from typing import List, Optional, Tuple from text_generation_server.models import CausalLM class RW(CausalLM): def __init__( self, model_id: str, revision: Optional[str] = None, quantize: Optional[str] = N...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/flash_mistral.py
import math import torch import torch.distributed import numpy as np from dataclasses import dataclass from opentelemetry import trace from transformers import PreTrainedTokenizerBase from transformers.models.llama import LlamaTokenizerFast from typing import Optional, Tuple, Type from text_generation_server.pb impo...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/mpt.py
import torch import torch.distributed from pathlib import Path from typing import Optional, Type from opentelemetry import trace from transformers import AutoTokenizer, PretrainedConfig, PreTrainedTokenizerBase from huggingface_hub import hf_hub_download import json from text_generation_server.models import CausalLM ...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/idefics.py
import torch import torch.distributed from typing import List, Optional, Tuple from transformers import ( AutoTokenizer, AutoConfig, AutoProcessor, ) from text_generation_server.models.custom_modeling.idefics_config import IdeficsConfig from text_generation_server.models.custom_modeling.idefics_processin...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/flash_santacoder.py
import torch import torch.distributed from opentelemetry import trace from transformers import AutoTokenizer, AutoConfig from typing import Optional, List import json import os from huggingface_hub import hf_hub_download from text_generation_server.models import FlashCausalLM from text_generation_server.models.custom...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/gpt_neox.py
import torch import torch.distributed from typing import Optional from transformers import ( AutoTokenizer, AutoConfig, ) from text_generation_server.models import CausalLM from text_generation_server.models.custom_modeling.neox_modeling import ( GPTNeoxForCausalLM, ) from text_generation_server.utils imp...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/santacoder.py
import torch import torch.distributed from typing import Optional, List from transformers import AutoTokenizer, AutoModelForCausalLM from text_generation_server.models import CausalLM FIM_PREFIX = "<fim-prefix>" FIM_MIDDLE = "<fim-middle>" FIM_SUFFIX = "<fim-suffix>" FIM_PAD = "<fim-pad>" EOD = "<|endoftext|>" cla...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/seq2seq_lm.py
from text_generation_server.utils.tokens import batch_top_tokens import torch from dataclasses import dataclass from opentelemetry import trace from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, PreTrainedTokenizerBase from typing import Optional, Tuple, List, Type, Dict from text_generation_server.models...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/bloom.py
import torch import torch.distributed from typing import Optional, Type from transformers import ( AutoTokenizer, AutoConfig, PreTrainedTokenizerBase, ) from text_generation_server.models.custom_modeling.bloom_modeling import ( BloomForCausalLM, ) from text_generation_server.models import CausalLM fr...
0
hf_public_repos/text-generation-inference/server/text_generation_server
hf_public_repos/text-generation-inference/server/text_generation_server/models/flash_rw.py
import torch import torch.distributed from opentelemetry import trace from transformers import AutoTokenizer from typing import Optional from text_generation_server.models import FlashCausalLM from text_generation_server.models.custom_modeling.flash_rw_modeling import ( RWConfig, FlashRWForCausalLM, ) from te...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/flash_rw_modeling.py
import torch import torch.distributed from torch import nn from transformers.modeling_utils import PreTrainedModel from transformers.configuration_utils import PretrainedConfig from typing import Optional, List, Tuple from text_generation_server.utils import paged_attention, flash_attn from text_generation_server.uti...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/t5_modeling.py
# coding=utf-8 # Copyright 2018 Mesh TensorFlow authors, T5 Authors and HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/flash_neox_modeling.py
# coding=utf-8 # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to G...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_perceiver.py
# This code was adapted from https://github.com/lucidrains/flamingo-pytorch licensed under the MIT License. # # MIT License # # Copyright (c) 2020 The Google AI Language Team Authors, The HuggingFace Inc. team and github/lonePatient # # Permission is hereby granted, free of charge, to any person obtaining a copy # of ...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_vision.py
# coding=utf-8 # Copyright 2021 The OpenAI Team Authors and The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/L...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_config.py
# coding=utf-8 # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to G...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/flash_santacoder_modeling.py
import torch import torch.distributed from torch import nn from transformers.activations import ACT2FN from typing import Optional, List, Tuple from text_generation_server.utils import paged_attention, flash_attn from text_generation_server.utils.flash_attn import attention from text_generation_server.utils.layers im...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/mpt_modeling.py
"""A simple, flexible implementation of a GPT model. Inspired by https://github.com/karpathy/minGPT/blob/master/mingpt/model.py """ import math import os import warnings from typing import List, Optional, Tuple, Union import torch import torch.nn as nn import torch.nn.functional as F from transformers import PreTraine...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/bloom_modeling.py
# coding=utf-8 # Copyright 2022 HuggingFace Inc. team and BigScience workshop. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_image_processing.py
# coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/opt_modeling.py
# coding=utf-8 # Copyright 2022 The Fairseq Authors and The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/flash_mistral_modeling.py
# coding=utf-8 # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to G...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/neox_modeling.py
# coding=utf-8 # Copyright 2022 EleutherAI The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 #...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_processing.py
# coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_modeling.py
# coding=utf-8 # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to G...
0
hf_public_repos/text-generation-inference/server/text_generation_server/models
hf_public_repos/text-generation-inference/server/text_generation_server/models/custom_modeling/flash_llama_modeling.py
# coding=utf-8 # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to G...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/exllamav2_kernels/setup.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension setup( name="exllamav2_kernels", ext_modules=[ CUDAExtension( name="exllamav2_kernels", sources=[ "exllamav2_kernels/ext.cpp", "exllamav2_kernels/cuda...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/config.h
#ifndef _config_h #define _config_h #define MAX_Q_GEMM_ROWS 50 #define QMODE_2BIT 1 #define QMODE_3BIT 1 #define QMODE_4BIT 1 #define QMODE_5BIT 1 #define QMODE_6BIT 0 #define QMODE_8BIT 0 #endif
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/ext.cpp
#include <torch/extension.h> #include <c10/cuda/CUDAGuard.h> #include <ATen/cuda/CUDAContext.h> #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #include "config.h" #include "cuda/q_matrix.cuh" #include "cuda/q_gemm.cuh" #include "cpp/util.h" // Some decluttering macros #define...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/compat.cuh
#ifndef _compat_cuh #define _compat_cuh // atomicAdd for half types, to support CC < 7.x __device__ __forceinline__ void atomicAdd_half(half* address, half val) { unsigned int * address_as_ui = (unsigned int *) ((char *)address - ((size_t)address & 2)); unsigned int old = *address_as_ui; unsigned int assu...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm.cuh
#ifndef _q_gemm_cuh #define _q_gemm_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #include <ATen/cuda/CUDAContext.h> #include "q_matrix.cuh" void gemm_half_q_half_cuda ( cublasHandle_t cublas_handle, const half* a, QMatrix* b, half* c, int size_m, i...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/util.cuh
#define DIVIDE(x, size) (((x) + (size) - 1) / (size)) #define DBGS(__x) printf("%s\n", __x) #define DBGI(__x) printf("%s: %i\n", #__x, __x) #define DBGI2(__x, __y) printf("%s, %s: %i, %i\n", #__x, #__y, __x, __y) #define DBGI3(__x, __y, __z) printf("%s, %s, %s: %i, %i, %i\n", #__x, #__y, #__z, __x, __y, __z) #define ...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_matrix.cuh
#ifndef _q_matrix_cuh #define _q_matrix_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #define MAX_SUPERGROUPS 16 class QMatrix { public: int device; bool is_gptq; int height; int width; int groups; int groupsize; int rows_8; int rows_6; ...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel.cuh
#include "compat.cuh" #include <cuda_runtime.h> #include <cuda_fp16.h> __forceinline__ __device__ half2 dot22_8(half2(&dq)[4], const half* a_ptr, const half2 g_result, const half qs_h) { half2 result = {}; const half2* a2_ptr = (const half2*)a_ptr; #pragma unroll for (int i = 0; i < 4; i++) result = _...
0