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/router | hf_public_repos/text-generation-inference/router/src/server.rs | /// HTTP Server logic
use crate::health::Health;
use crate::infer::{InferError, InferResponse, InferStreamResponse};
use crate::validation::ValidationError;
use crate::HubTokenizerConfig;
use crate::{
BestOfSequence, ChatCompletion, ChatCompletionChunk, ChatRequest, CompatGenerateRequest,
Details, ErrorResponse... | 0 |
hf_public_repos/text-generation-inference/router | hf_public_repos/text-generation-inference/router/src/infer.rs | /// Batching and inference logic
use crate::validation::{Validation, ValidationError};
use crate::HubTokenizerConfig;
use crate::{ChatRequest, GenerateRequest, GenerateStreamResponse, PrefillToken};
use crate::{Entry, Queue, Token};
use futures::future::try_join_all;
use minijinja::{Environment, ErrorKind, Template};
u... | 0 |
hf_public_repos/text-generation-inference | hf_public_repos/text-generation-inference/server/Makefile-vllm | vllm-cuda:
# Clone vllm
pip install -U ninja packaging --no-cache-dir
git clone https://github.com/vllm-project/vllm.git vllm
build-vllm-cuda: vllm-cuda
cd vllm && git fetch && git checkout f8a1e39fae05ca610be8d5a78be9d40f5274e5fc
cd vllm && python setup.py build
install-vllm-cuda: build-vllm-cuda
pip uninst... | 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 | hf_public_repos/text-generation-inference/server/Makefile-awq | awq_commit := f084f40bd996f3cf3a0633c1ad7d9d476c318aaa
awq:
rm -rf llm-awq
git clone https://github.com/mit-han-lab/llm-awq
build-awq: awq
cd llm-awq/ && git fetch && git checkout $(awq_commit)
cd llm-awq/awq/kernels && python setup.py build
install-awq: build-awq
pip uninstall awq_inference_engine -y || true
... | 0 |
hf_public_repos/text-generation-inference | hf_public_repos/text-generation-inference/server/requirements_rocm.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/README.md | # Text Generation Inference Python gRPC Server
A Python gRPC server for Text Generation Inference
## Install
```shell
make install
```
## Run
```shell
make run-dev
``` | 0 |
hf_public_repos/text-generation-inference | hf_public_repos/text-generation-inference/server/pyproject.toml | [tool.poetry]
name = "text-generation-server"
version = "1.3.4"
description = "Text Generation Inference Python gRPC Server"
authors = ["Olivier Dehaene <olivier@huggingface.co>"]
[tool.poetry.scripts]
text-generation-server = 'text_generation_server.cli:app'
[tool.poetry.dependencies]
python = ">=3.9,<3.13"
protobuf... | 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.25.0"
description = "Accelerate"
optional = true
python-versions = ">=3.8.0"
files = [
{file = "accelerate-0.25.0-py3-none-any.whl", hash = "sha256:c7bb817eb974bba0ff3ea1ba0f24d55... | 0 |
hf_public_repos/text-generation-inference | hf_public_repos/text-generation-inference/server/Makefile-eetq | eetq_commit := 323827dd471458a84e9c840f614e4592b157a4b1
eetq:
# Clone eetq
pip install packaging
git clone https://github.com/NetEase-FuXi/EETQ.git eetq
build-eetq: eetq
cd eetq && git fetch && git checkout $(eetq_commit)
cd eetq && python setup.py build
install-eetq: build-eetq
cd eetq && python setup.py i... | 0 |
hf_public_repos/text-generation-inference | hf_public_repos/text-generation-inference/server/Makefile-flash-att | flash_att_commit := 3a9bfd076f98746c73362328958dbc68d145fbec
flash-attention:
# Clone flash attention
pip install -U packaging ninja --no-cache-dir
git clone https://github.com/HazyResearch/flash-attention.git
build-flash-attention: flash-attention
cd flash-attention && git fetch && git checkout $(flash_att_c... | 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/requirements_cuda.txt | backoff==2.2.1 ; python_version >= "3.9" and python_version < "3.13"
bitsandbytes==0.41.3.post2 ; 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 ; p... | 0 |
hf_public_repos/text-generation-inference | hf_public_repos/text-generation-inference/server/Makefile | include Makefile-flash-att
include Makefile-flash-att-v2
include Makefile-vllm
include Makefile-awq
include Makefile-eetq
unit-tests:
pytest -s -vv -m "not private" tests
gen-server:
# Compile protos
pip install grpcio-tools==1.51.1 mypy-protobuf==3.4.0 'types-protobuf>=3.20.4' --no-cache-dir
mkdir text_generatio... | 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
import time
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... | 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 | 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/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/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/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/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/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 | 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_mixtral.py | import torch
from typing import Optional
from text_generation_server.models.flash_mistral import BaseFlashMistral
from text_generation_server.models.custom_modeling.flash_mixtral_modeling import (
MixtralConfig,
FlashMixtralForCausalLM,
)
class FlashMixtral(BaseFlashMistral):
def __init__(
self,... | 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.utils.speculate import get_speculate
... | 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/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, List
from text_generation_server.p... | 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 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.utils.speculate import get_speculate, set_speculate
from text_generation_server.models.model import Model
from... | 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 | import torch
import time
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_server.models import Model
from text_generation_server.utils.tokens... | 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 time
import itertools
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, Dict
from text_generation_server.models import Model
fro... | 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/seq2seq_lm.py | import torch
import time
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.utils.tokens import batch_top_tokens
from text_generation_s... | 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/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/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/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/idefics_causal_lm.py | import torch
import time
from dataclasses import dataclass
from opentelemetry import trace
from transformers import (
AutoProcessor,
AutoTokenizer,
PreTrainedTokenizerBase,
ProcessorMixin,
)
from typing import Optional, Tuple, List, Type, Dict
from text_generation_server.models import Model
from text_... | 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/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/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/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/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/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/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/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/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/flash_mixtral_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/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.layers import (
TensorParallelRowLinear,
TensorParallelColumnLi... | 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/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/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/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/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/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/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_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 | 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, value, key_c... | 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/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 | 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/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/__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/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/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 file_download, hf_api, HfApi, hf_hub_download
from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE
from huggingface_hub.utils import (
LocalE... | 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
from text_generation_server.utils.log import log_once
class Weights:
def __init__(
... | 0 |
hf_public_repos/text-generation-inference/server/text_generation_server | hf_public_repos/text-generation-inference/server/text_generation_server/utils/medusa.py | import torch
from dataclasses import dataclass
from text_generation_server.utils.layers import TensorParallelHead, FastLinear
@dataclass
class Output:
logits: torch.FloatTensor = None
speculative_logits: torch.FloatTensor = None
class ResBlock(torch.nn.Module):
def __init__(self, config, prefix, weights... | 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/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/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/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("Trying to load a Peft model. ... | 0 |
hf_public_repos/text-generation-inference/server/text_generation_server | hf_public_repos/text-generation-inference/server/text_generation_server/utils/log.py | from functools import lru_cache
@lru_cache(10)
def log_once(log, msg: str):
log(msg)
| 0 |
hf_public_repos/text-generation-inference/server/text_generation_server | hf_public_repos/text-generation-inference/server/text_generation_server/utils/speculate.py | SPECULATE = None
def get_speculate() -> int:
global SPECULATE
return SPECULATE
def set_speculate(speculate: int):
global SPECULATE
SPECULATE = speculate
| 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/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/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/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/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 | 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/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/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 | 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/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/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/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/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_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/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/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 | 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/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/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_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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.