Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 5 additions & 7 deletions examples/apps/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import colorama
from transformers import AutoTokenizer, PreTrainedTokenizer

from tensorrt_llm._tensorrt_engine import LLM
from tensorrt_llm.llmapi import BuildConfig, KvCacheConfig, SamplingParams
from tensorrt_llm import LLM
from tensorrt_llm.llmapi import KvCacheConfig, SamplingParams


class LlmConsole(code.InteractiveConsole):
Expand Down Expand Up @@ -72,18 +72,16 @@ def main(model: str, tokenizer: str, tp_size: int):
free_gpu_memory_fraction=0.8)
kv_cache_config.enable_block_reuse = True

build_config = BuildConfig(max_batch_size=1,
max_input_len=6000,
max_num_tokens=10240)

sampling_params = SamplingParams(max_tokens=100,
temperature=0.5,
top_p=0.95,
n=1)

llm = LLM(model,
tokenizer,
build_config=build_config,
max_batch_size=1,
max_input_len=6000,
max_num_tokens=10240,
kv_cache_config=kv_cache_config,
tensor_parallel_size=tp_size)

Expand Down
9 changes: 4 additions & 5 deletions examples/apps/fastapi_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse, Response, StreamingResponse

from tensorrt_llm._tensorrt_engine import LLM
from tensorrt_llm import LLM
from tensorrt_llm.executor import CppExecutorError, RequestError
from tensorrt_llm.llmapi import BuildConfig, KvCacheConfig, SamplingParams
from tensorrt_llm.llmapi import KvCacheConfig, SamplingParams

TIMEOUT_KEEP_ALIVE = 5 # seconds.

Expand Down Expand Up @@ -120,16 +120,15 @@ def entrypoint(model_dir: str,
port = port or 8000
logging.info(f"Starting server at {host}:{port}")

build_config = BuildConfig(max_batch_size=10, max_beam_width=max_beam_width)

kv_cache_config = KvCacheConfig(
free_gpu_memory_fraction=kv_cache_free_gpu_memory_fraction)

llm = LLM(model_dir,
tokenizer,
tensor_parallel_size=tp_size,
pipeline_parallel_size=pp_size,
build_config=build_config,
max_batch_size=10,
max_beam_width=max_beam_width,
kv_cache_config=kv_cache_config)

server = LlmServer(llm=llm)
Expand Down
Loading
Loading