执行器#
disaggServerUtil.h#
-
namespace tensorrt_llm#
-
namespace executor#
-
namespace disagg_executor#
-
class DisaggExecutorOrchestrator#
公有函数
- DisaggExecutorOrchestrator(
- std::vector<std::filesystem::path> const &ctxEnginePaths,
- std::vector<std::filesystem::path> const &genEnginePaths,
- std::vector<executor::ExecutorConfig> const &ctxExecutorConfigs,
- std::vector<executor::ExecutorConfig> const &genExecutorConfigs,
- bool hasContextAwaitThreads,
- bool hasGenAwaitThreads,
构造一个 DisaggExecutorOrchestrator 对象。
- 参数:
ctxEnginePaths – 指向上下文引擎文件的文件路径向量。
genEnginePaths – 指向生成引擎文件的文件路径向量。
ctxExecutorConfigs – 上下文执行器的 ExecutorConfig 向量。
genExecutorConfigs – 生成执行器的 ExecutorConfig 向量。
hasContextAwaitThreads – 是否存在接收每个生成执行器响应的线程。
hasGenAwaitThreads – 是否存在接收每个生成执行器响应的线程。
- std::vector<IdType> enqueueContext(
- std::vector<texec::Request> const &requests,
- std::optional<int> selectContextId = std::nullopt,
- bool batch = false,
将仅上下文请求入队到上下文执行器。
- 参数:
requests – 仅上下文请求的向量。
selectContextId – 要使用的上下文执行器的索引。如果为
std::nullopt
,则使用 inflight 请求数量最少的执行器。batch – 如果为 true,则在同一上下文执行器中请求入队。如果为 false,则尝试对每个请求使用不同的执行器。
- 返回:
全局请求 ID 的向量,与
requests
中请求的顺序相对应,返回的 ID 可能与每个执行器中的请求 ID 不同。
- void enqueueGeneration(
- std::vector<texec::Request> const &requests,
- std::vector<IdType> const &globalRequestIds,
- std::optional<int> selectGenIdx = std::nullopt,
- bool batch = false,
将仅生成请求入队到生成执行器。
- 参数:
requests – 仅生成请求的向量。
globalRequestIds – 全局请求 ID 的向量,与请求的顺序相对应,并且必须是 enqueueContext 函数返回的 ID。
selectGenIdx – 要使用的生成执行器的索引。如果为
std::nullopt
,则使用 inflight 请求数量最少的执行器。batch – 如果为 true,则在同一生成执行器中请求入队。如果为 false,则尝试对每个请求使用不同的执行器。
- std::vector<ResponseWithId> awaitContextResponses(
- std::optional<std::chrono::milliseconds> const &timeout,
- std::optional<int> contextIdx = std::nullopt,
等待上下文响应。
- 参数:
timeout – 等待新响应的最长时间
contextIdx – 要使用的上下文执行器的索引。如果为
std::nullopt
,则返回所有上下文执行器中已准备好的响应;如果hasContextAwaitThreads
为 true,则此参数必须为 std::nullopt。
- 返回:
带有相应全局请求 ID 的响应向量
- std::vector<ResponseWithId> awaitGenerationResponses(
- std::optional<std::chrono::milliseconds> const &timeout,
- std::optional<int> genIdx = std::nullopt,
等待生成响应。
- 参数:
timeout – 等待新响应的最长时间。
genIdx – 要使用的生成执行器的索引。如果为
std::nullopt
,则返回所有生成执行器中已准备好的响应;如果hasGenAwaitThreads
为 true,则此参数必须为 std::nullopt。
- 返回:
带有相应全局请求 ID 的响应向量。
-
bool canEnqueue() const#
指示当前进程是否允许 enqueueRequests。
- std::vector<std::unique_ptr<texec::Executor>> const &getContextExecutors(
获取上下文执行器。
- std::vector<std::unique_ptr<texec::Executor>> const &getGenExecutors(
获取生成执行器。
-
~DisaggExecutorOrchestrator()#
私有成员
-
std::unique_ptr<Impl> mImpl#
-
struct ResponseWithId#
公有函数
- inline ResponseWithId(
- tensorrt_llm::executor::Response &&response,
- IdType gid,
- inline ResponseWithId(
- tensorrt_llm::executor::Response const &response,
- IdType gid,
-
inline ResponseWithId(ResponseWithId &&other) noexcept#
-
ResponseWithId(ResponseWithId const &other) = default#
-
inline ResponseWithId &operator=(ResponseWithId &&other) noexcept#
-
inline ResponseWithId &operator=(ResponseWithId const &other)#
-
~ResponseWithId() = default#
-
class DisaggExecutorOrchestrator#
-
namespace disagg_executor#
-
namespace executor#
executor.h#
-
namespace tensorrt_llm
-
-
namespace executor
类型定义
-
using RetentionPriority = SizeType32#
-
using KVCacheEventData = std::variant<KVCacheCreatedData, KVCacheStoredData, KVCacheRemovedData,KVCacheUpdatedData>#
函数
-
char const *version() noexcept#
TRT-LLM 的版本。
-
class AdditionalModelOutput#
- #include <executor.h>
应收集的额外输出。
默认情况下,从每个生成阶段收集形状为 [beamWidth, x] 的输出。如果 gatherContext 为 true,则还从上下文阶段收集形状为 [promptLen, x] 的输出。
公有函数
- explicit AdditionalModelOutput(
- std::string name,
- bool gatherContext = false,
-
struct AdditionalOutput#
公有函数
-
AdditionalOutput(AdditionalOutput const &other) = default#
-
AdditionalOutput(AdditionalOutput &&other) noexcept = default#
-
AdditionalOutput &operator=(AdditionalOutput const &other) = default#
- AdditionalOutput &operator=(
- AdditionalOutput &&other,
-
~AdditionalOutput() = default#
-
AdditionalOutput(AdditionalOutput const &other) = default#
-
class ContextPhaseParams#
公共类型
-
using RequestIdType = std::uint64_t#
公有函数
- ContextPhaseParams(
- VecTokens firstGenTokens,
- RequestIdType reqId,
- std::optional<VecTokens> draftTokens,
- ContextPhaseParams(
- VecTokens firstGenTokens,
- RequestIdType reqId,
- void *state,
- std::optional<VecTokens> draftTokens,
- ContextPhaseParams(
- VecTokens firstGenTokens,
- RequestIdType reqId,
- std::vector<char> const &serializedState,
- std::optional<VecTokens> draftTokens,
-
ContextPhaseParams(ContextPhaseParams const&)#
-
ContextPhaseParams(ContextPhaseParams&&) noexcept#
-
ContextPhaseParams &operator=(ContextPhaseParams const&)#
-
ContextPhaseParams &operator=(ContextPhaseParams&&) noexcept#
-
~ContextPhaseParams()#
-
bool operator==(ContextPhaseParams const&) const noexcept#
-
RequestIdType getReqId() const noexcept#
-
void const *getState() const noexcept#
-
void *getState() noexcept#
-
void *releaseState() noexcept#
-
std::vector<char> getSerializedState() const noexcept#
私有成员
-
RequestIdType mReqId = {0}#
此请求对应于上下文阶段的请求 ID。
私有静态函数
-
static void deleter(void const *data)#
友元
- 友元类 Serialization
-
using RequestIdType = std::uint64_t#
-
class DebugConfig#
- #include <executor.h>
用于调试输出的配置类。
公有函数
- explicit DebugConfig(
- bool debugInputTensors = false,
- bool debugOutputTensors = false,
- StringVec debugTensorNames = {},
- SizeType32 debugTensorsMaxIterations = 0,
-
bool operator==(DebugConfig const &other) const#
-
bool getDebugInputTensors() const#
-
bool getDebugOutputTensors() const#
-
SizeType32 getDebugTensorsMaxIterations() const#
-
void setDebugInputTensors(bool debugInputTensors)#
-
void setDebugOutputTensors(bool debugOutputTensors)#
- void setDebugTensorsMaxIterations(
- SizeType32 debugTensorsMaxIterations,
私有类型
-
using StringVec = std::vector<std::string>#
私有成员
-
bool mDebugInputTensors#
如果为 true,则调试所有输入张量。
-
bool mDebugOutputTensors#
如果为 true,则调试所有输出张量。
-
SizeType32 mDebugTensorsMaxIterations#
如果 > 0,则最多提供过去 debugTensorsMaxIterations 次迭代的调试张量,否则将它们转储到文件中。
友元
- 友元类 Serialization
-
class DecodingConfig#
- #include <executor.h>
解码的配置类。
公有函数
- explicit DecodingConfig(
- std::optional<DecodingMode> decodingMode = std::nullopt,
- std::optional<LookaheadDecodingConfig> lookaheadDecodingConfig = std::nullopt,
- std::optional<MedusaChoices> medusaChoices = std::nullopt,
- std::optional<EagleConfig> eagleConfig = std::nullopt,
-
bool operator==(DecodingConfig const &other) const#
-
void setDecodingMode(DecodingMode const&)#
设置解码模式。某些模式需要使用其自身的设置器。
-
std::optional<DecodingMode> getDecodingMode() const#
- void setLookaheadDecodingConfig(
- LookaheadDecodingConfig const &lookaheadDecodingConfig,
设置前瞻解码模式和配置。
-
void enableSeamlessLookaheadDecoding()#
- std::optional<LookaheadDecodingConfig> getLookaheadDecodingConfig(
-
SizeType32 getLookaheadDecodingMaxNumRequest() const#
-
void setMedusaChoices(MedusaChoices const&)#
设置 Medusa 模式和配置。
-
std::optional<MedusaChoices> getMedusaChoices() const#
-
void setEagleConfig(EagleConfig const&)#
设置 Eagle 模式和配置。
-
std::optional<EagleConfig> getEagleConfig() const#
私有成员
-
std::optional<DecodingMode> mDecodingMode#
-
std::optional<LookaheadDecodingConfig> mLookaheadDecodingConfig#
-
std::optional<MedusaChoices> mMedusaChoices#
-
std::optional<EagleConfig> mEagleConfig#
私有静态属性
-
static constexpr SizeType32 mLookaheadDecodingMaxNumRequest = 8#
友元
- 友元类 Serialization
-
class DynamicBatchConfig#
- #include <executor.h>
用于动态调整批次大小和最大令牌数的配置类。在运行时记录输入和输出长度的统计信息。基于这些统计信息,动态调整批次大小和最大令牌数以更好地服务请求。
公有函数
- explicit DynamicBatchConfig(
- bool enableBatchSizeTuning = false,
- bool enableMaxNumTokensTuning = false,
- SizeType32 dynamicBatchMovingAverageWindow = kDefaultDynamicBatchMovingAverageWindow,
- std::vector<std::pair<SizeType32, SizeType32>> batchSizeTable = kDefaultBatchSizeTable,
-
SizeType32 getDynamicBatchMovingAverageWindow() const#
-
bool getEnableBatchSizeTuning() const#
-
bool getEnableMaxNumTokensTuning() const#
- std::vector<std::pair<SizeType32, SizeType32>> getBatchSizeTable(
公共静态属性
-
static SizeType32 const kDefaultDynamicBatchMovingAverageWindow = 128#
输入和输出长度移动平均的默认窗口大小,用于计算动态批处理大小和最大令牌数。
-
static std::vector<std::pair<SizeType32, SizeType32>> const kDefaultBatchSizeTable#
批处理大小表的默认值。
私有成员
-
bool mEnableBatchSizeTuning#
控制是否应动态调整批处理大小。
-
bool mEnableMaxNumTokensTuning#
控制是否应动态调整最大令牌数。
-
SizeType32 mDynamicBatchMovingAverageWindow#
输入和输出长度移动平均的窗口大小,用于计算动态批处理大小和最大令牌数。
-
std::vector<std::pair<SizeType32, SizeType32>> mBatchSizeTable#
包含 (batchSizeLimit, batchSize) 对的向量。当最大容量批处理大小小于。
友元
- 友元类 Serialization
-
struct EagleConfig#
公有函数
- explicit EagleConfig(
- std::optional<EagleChoices> eagleChoices = std::nullopt,
- bool greedySampling = true,
- std::optional<float> posteriorThreshold = std::nullopt,
- bool useDynamicTree = false,
- std::optional<SizeType32> dynamicTreeMaxTopK = std::nullopt,
-
bool operator==(EagleConfig const &other) const#
-
std::optional<EagleChoices> getEagleChoices() const#
-
std::optional<float> getPosteriorThreshold() const#
-
bool isGreedySampling() const#
-
bool useDynamicTree() const#
-
std::optional<SizeType32> getDynamicTreeMaxTopK() const#
私有函数
- std::optional<float> const &checkPosteriorValue(
- std::optional<float> const &value,
私有成员
-
std::optional<EagleChoices> mEagleChoices#
构成 EAGLE-1 的树的选择。
-
bool mGreedySampling#
使用贪婪或典型接受的标志。
-
std::optional<float> mPosteriorThreshold#
典型接受的最小令牌概率。对应于 https://arxiv.org/pdf/2401.10774 中的 epsilon。默认值为 0.09f。
-
bool mUseDynamicTree#
使用 Eagle-2 的标志。
-
std::optional<SizeType32> mDynamicTreeMaxTopK#
Eagle-2 中每个节点扩展的草稿令牌数量。
友元
- 友元类 Serialization
-
class Executor#
- #include <executor.h>
执行器负责接收新请求和发送响应,并运行推理。
公有函数
- Executor(
- std::filesystem::path const &modelPath,
- ModelType modelType,
- ExecutorConfig const &executorConfig,
- 参数:
modelPath – 定义要运行模型的文件夹路径
modelType – 模型类型
executorConfig – 执行器的配置
- Executor(
- std::filesystem::path const &encoderModelPath,
- std::filesystem::path const &decoderModelPath,
- ModelType modelType,
- ExecutorConfig const &executorConfig,
- Executor(
- BufferView const &engineBuffer,
- std::string const &jsonConfigStr,
- ModelType modelType,
- ExecutorConfig const &executorConfig,
- std::optional<std::map<std::string, Tensor>> const &managedWeights = std::nullopt,
- Executor(
- BufferView const &encoderEngineBuffer,
- std::string const &encoderJsonConfigStr,
- BufferView const &decoderEngineBuffer,
- std::string const &decoderJsonConfigStr,
- ModelType modelType,
- ExecutorConfig const &executorConfig,
- std::shared_ptr<Model> model,
- ExecutorConfig const &executorConfig,
- std::shared_ptr<Model> encoderModel,
- std::shared_ptr<Model> decoderModel,
- ExecutorConfig const &executorConfig,
-
~Executor()#
-
IdType enqueueRequest(Request const &request)#
将新请求排队。
- 参数:
request – 包含输入令牌和请求参数的 LLM 请求
- 返回:
标识请求的唯一 ID
- std::vector<Response> awaitResponses(
- std::optional<std::chrono::milliseconds> const &timeout = std::nullopt,
等待就绪的响应。
This overload awaits for any ready responses. In particular, if several requests have been enqueued, this method will provide any ready responses without order guarantees.
- 参数:
timeout – 等待新响应的最长时间
- 返回:
一个响应向量
- std::vector<Response> awaitResponses(
- IdType const &requestId,
- std::optional<std::chrono::milliseconds> const &timeout = std::nullopt,
等待就绪的响应。
- 参数:
id – 请求 ID
timeout – 等待新响应的最长时间
- 返回:
一个响应向量
- std::vector<std::vector<Response>> awaitResponses(
- std::vector<IdType> const &requestIds,
- std::optional<std::chrono::milliseconds> const &timeout = std::nullopt,
等待多个就绪的响应。
A multiple ID request behaves as if awaitResponses(IdType, timeout) were invoked on all IDs. The returned vector contains a vector of responses per ID in the same order specified by the requestIds. The same behaviour as awaitResponses(IdType, timeout) applies: * Responses may be empty. * If all responses have already been given for one of the requestIds, then this method will hang unless a timeout is specified.
- 参数:
requestIds – 请求的 ID 列表
timeout – 等待新响应的最长时间
- 返回:
一个响应向量的向量
- SizeType32 getNumResponsesReady(
- std::optional<IdType> const &requestId = std::nullopt,
获取就绪响应的数量。
- 参数:
requestId – 可选的请求 ID
- 返回:
就绪响应的数量
-
void shutdown()#
发出信号通知服务器关闭。
此调用是阻塞的。仅当所有请求都已终止或达到超时时才会返回。
-
std::deque<IterationStats> getLatestIterationStats()#
返回自上次调用 getLatestIterationStats 以来计算的每次迭代的统计信息。最多包含 iterStatsMaxIterations 次迭代的统计信息。
- 返回:
迭代统计信息
-
std::deque<RequestStatsPerIteration> getLatestRequestStats()#
返回自上次调用 getLatestRequestStats 以来计算的每次迭代的请求统计信息。最多包含 requestStatsMaxIterations 次迭代的统计信息。
- 返回:
按迭代分组的 Request 统计信息
-
std::deque<DebugTensorsPerIteration> getLatestDebugTensors()#
返回自上次调用 getLatestDebugTensors 以来计算的每次迭代的调试张量。最多包含 debugTensorsMaxIterations 次迭代的调试张量。
- 返回:
按迭代分组的 Request 调试张量
-
bool canEnqueueRequests() const#
指示当前进程是否允许 enqueueRequests。
-
bool isParticipant() const#
指示当前进程是否参与此执行器实例。
- std::optional<std::shared_ptr<KVCacheEventManager>> getKVCacheEventManager(
私有成员
-
std::unique_ptr<Impl> mImpl#
-
class ExecutorConfig#
- #include <executor.h>
模型执行器的配置类。
公有函数
- explicit ExecutorConfig(
- SizeType32 maxBeamWidth = 1,
- SchedulerConfig schedulerConfig = SchedulerConfig(),
- KvCacheConfig kvCacheConfig = KvCacheConfig(),
- bool enableChunkedContext = true,
- bool normalizeLogProbs = true,
- SizeType32 iterStatsMaxIterations = kDefaultIterStatsMaxIterations,
- SizeType32 requestStatsMaxIterations = kDefaultRequestStatsMaxIterations,
- BatchingType batchingType = BatchingType::kINFLIGHT,
- std::optional<SizeType32> maxBatchSize = std::nullopt,
- std::optional<SizeType32> maxNumTokens = std::nullopt,
- std::optional<ParallelConfig> parallelConfig = std::nullopt,
- std::optional<PeftCacheConfig> const &peftCacheConfig = std::nullopt,
- std::optional<LogitsPostProcessorConfig> logitsPostProcessorConfig = std::nullopt,
- std::optional<DecodingConfig> decodingConfig = std::nullopt,
- bool useGpuDirectStorage = false,
- float gpuWeightsPercent = 1,
- std::optional<SizeType32> maxQueueSize = std::nullopt,
- ExtendedRuntimePerfKnobConfig const &extendedRuntimePerfKnobConfig = ExtendedRuntimePerfKnobConfig(),
- std::optional<DebugConfig> debugConfig = std::nullopt,
- SizeType32 recvPollPeriodMs = 0,
- uint64_t maxSeqIdleMicroseconds = kDefaultMaxSeqIdleMicroseconds,
- std::optional<SpeculativeDecodingConfig> specDecConfig = std::nullopt,
- std::optional<GuidedDecodingConfig> guidedDecodingConfig = std::nullopt,
- std::optional<std::vector<AdditionalModelOutput>> additionalModelOutputs = std::nullopt,
- bool gatherGenerationLogits = false,
- bool useVariableBeamWidthSearch = false,
- bool promptTableOffloading = false,
-
SizeType32 getMaxBeamWidth() const#
-
SchedulerConfig getSchedulerConfig() const#
-
KvCacheConfig getKvCacheConfig() const#
-
SchedulerConfig &getSchedulerConfigRef()#
-
KvCacheConfig &getKvCacheConfigRef()#
-
bool getEnableChunkedContext() const#
-
bool 获取对数概率归一化() const#
-
SizeType32 获取迭代统计最大迭代次数() const#
-
SizeType32 获取请求统计最大迭代次数() const#
-
BatchingType 获取批处理类型() const#
-
std::optional<SizeType32> 获取最大批处理大小() const#
-
std::optional<SizeType32> 获取最大令牌数() const#
-
std::optional<ParallelConfig> 获取并行配置() const#
-
std::optional<PeftCacheConfig> 获取 Peft 缓存配置() const#
- std::optional<LogitsPostProcessorConfig> 获取 Logits 后处理器配置(
-
std::optional<DecodingConfig> 获取解码配置() const#
-
bool 获取是否使用 GPU 直接存储() const#
-
float 获取 GPU 权重百分比() const#
-
std::optional<SizeType32> 获取最大队列大小() const#
- ExtendedRuntimePerfKnobConfig 获取扩展运行时性能旋钮配置(
-
std::optional<DebugConfig> 获取调试配置() const#
-
SizeType32 获取接收轮询周期(毫秒)() const#
-
uint64_t 获取最大序列空闲时间(微秒)() const#
-
std::optional<SpeculativeDecodingConfig> 获取推测解码配置() const#
-
std::optional<GuidedDecodingConfig> 获取引导解码配置() const#
- std::vector<AdditionalModelOutput>> 获取附加模型输出(
-
bool 获取收集生成 Logits() const#
-
bool 获取是否使用变长束搜索() const#
-
bool 获取 Prompt Table 卸载() const#
-
void 设置最大束宽度(SizeType32 maxBeamWidth)#
-
void 设置最大批处理大小(SizeType32 maxBatchSize)#
-
void 设置最大令牌数(SizeType32 maxNumTokens)#
-
void 设置调度器配置(SchedulerConfig const &schedulerConfig)#
-
void 设置 Kv 缓存配置(KvCacheConfig const &kvCacheConfig)#
-
void 设置是否启用分块上下文(bool enableChunkedContext)#
-
void 设置对数概率归一化(bool normalizeLogProbs)#
-
void 设置迭代统计最大迭代次数(SizeType32 iterStatsMaxIterations)#
- void 设置请求统计最大迭代次数(
- SizeType32 requestStatsMaxIterations,
-
void 设置批处理类型(BatchingType batchingType)#
-
void 设置并行配置(ParallelConfig const ¶llelConfig)#
-
void 设置 Peft 缓存配置(PeftCacheConfig const &peftCacheConfig)#
- void 设置 Logits 后处理器配置(
- LogitsPostProcessorConfig const &logitsPostProcessorConfig,
-
void 设置解码配置(DecodingConfig const &decodingConfig)#
-
void 设置是否使用 GPU 直接存储(bool const &useGpuDirectStorage)#
-
void 设置 GPU 权重百分比(float const &gpuWeightsPercent)#
-
void setMaxQueueSize(std::optional<SizeType32> const &maxQueueSize)#
- void setExtendedRuntimePerfKnobConfig(
- ExtendedRuntimePerfKnobConfig const &extendedRuntimePerfKnobConfig,
-
void setDebugConfig(DebugConfig const &debugConfig)#
-
void setRecvPollPeriodMs(SizeType32 const &recvPollPeriodMs)#
-
void setMaxSeqIdleMicroseconds(uint64_t maxSeqIdleMicroseconds)#
-
void setSpecDecConfig(SpeculativeDecodingConfig const &specDecConfig)#
- void setGuidedDecodingConfig(
- GuidedDecodingConfig const &guidedDecodingConfig,
- void setAdditionalModelOutputs(
- std::vector<AdditionalModelOutput> const &additionalModelOutputs,
-
void setGatherGenerationLogits(bool gatherGenerationLogits)#
-
void setUseVariableBeamWidthSearch(bool useVariableBeamWidthSearch)#
-
void setPromptTableOffloading(bool promptTableOffloading)#
公共静态属性
-
static constexpr uint64_t kDefaultMaxSeqIdleMicroseconds = 180000000#
-
static constexpr SizeType32 kDefaultIterStatsMaxIterations = 1000#
-
static constexpr SizeType32 kDefaultRequestStatsMaxIterations = 0#
私有成员
-
SizeType32 mMaxBeamWidth#
将发送到执行器的请求的 beam width 值。
-
SchedulerConfig mSchedulerConfig#
调度器配置。
-
KvCacheConfig mKvCacheConfig#
KV 缓存配置。
-
bool mEnableChunkedContext#
KV 缓存配置。
-
bool mNormalizeLogProbs#
控制是否应规范化对数概率。
-
SizeType32 mIterStatsMaxIterations#
控制保留统计信息的最大迭代次数。
-
SizeType32 mRequestStatsMaxIterations#
控制保留每个请求统计信息的最大迭代次数。
-
BatchingType mBatchingType#
要使用的批处理策略类型。请参阅 BatchingType。
-
std::optional<SizeType32> mMaxBatchSize#
请求的最大批处理大小。
-
std::optional<SizeType32> mMaxNumTokens#
每批次的最大 token 数量。
-
std::optional<ParallelConfig> mParallelConfig#
并行执行配置。
-
std::optional<PeftCacheConfig> mPeftCacheConfig#
-
std::optional<LogitsPostProcessorConfig> mLogitsPostProcessorConfig#
Logits 后处理器配置。
-
std::optional<DecodingConfig> mDecodingConfig#
解码配置。
-
bool mUseGpuDirectStorage#
启用/禁用使用 GPU Direct Storage (GDS) 加载引擎。
-
float mGpuWeightsPercent#
用于权重流的 GPU 权重百分比。
-
std::optional<SizeType32> mMaxQueueSize#
在拒绝新请求之前队列中允许的最大请求数。
-
ExtendedRuntimePerfKnobConfig mExtendedRuntimePerfKnobConfig#
可在运行时设置的性能旋钮配置。
-
std::optional<DebugConfig> mDebugConfig#
调试配置。
-
SizeType32 mRecvPollPeriodMs#
在编排器模式下轮询新通信之间的时间间隔(以毫秒为单位)。使用 0 表示忙循环。
-
uint64_t mMaxSeqIdleMicroseconds#
计划请求在终止前可以保持空闲的最大时间(以微秒为单位)。默认值为 3 分钟。
-
std::optional<SpeculativeDecodingConfig> mSpeculativeDecodingConfig#
推测解码配置。
-
std::optional<GuidedDecodingConfig> mGuidedDecodingConfig#
指导式解码配置。
-
std::optional<std::vector<AdditionalModelOutput>> mAdditionalModelOutputs#
要从模型中收集的附加输出。
-
bool mGatherGenerationLogits = {false}#
控制是否应收集生成的 logits,以便可以请求 returnGenerationLogits。
-
bool mUseVariableBeamWidthSearch = {false}#
控制是否启用可变 Beam Width 搜索。
-
bool mPromptTableOffloading = {false}#
控制是否启用提示表卸载。
友元
- 友元类 Serialization
-
class ExtendedRuntimePerfKnobConfig#
- #include <executor.h>
用于运行时性能旋钮的配置类。
公有函数
- explicit ExtendedRuntimePerfKnobConfig(
- bool multiBlockMode = true,
- bool enableContextFMHAFP32Acc = false,
- bool cudaGraphMode = false,
- SizeType32 cudaGraphCacheSize = 0,
- inline bool operator==(
- ExtendedRuntimePerfKnobConfig const &other,
-
bool getMultiBlockMode() const#
-
bool getEnableContextFMHAFP32Acc() const#
-
bool getCudaGraphMode() const#
-
SizeType32 getCudaGraphCacheSize() const#
-
void setMultiBlockMode(bool multiBlockMode)#
-
void setEnableContextFMHAFP32Acc(bool enableContextFMHAFP32Acc)#
-
void setCudaGraphMode(bool cudaGraphMode)#
-
void setCudaGraphCacheSize(SizeType32 cacheSize)#
私有成员
-
bool mMultiBlockMode#
控制是否启用多块模式。
-
bool mEnableContextFMHAFP32Acc#
是否启用 FMHA 运行器 FP32 累加。
-
bool mCudaGraphMode#
控制是否启用 CUDA Graph。
-
SizeType32 mCudaGraphCacheSize#
在运行时缓存的 CUDA Graph 数量。缓存越大,性能越好,但消耗的 GPU 内存也越多。
友元
- 友元类 Serialization
-
class ExternalDraftTokensConfig#
- #include <executor.h>
使用外部草稿令牌进行推测性解码的配置。允许包含草稿令牌、草稿 logits 并指定接受阈值。
公有函数
- explicit ExternalDraftTokensConfig(
- VecTokens tokens,
- std::optional<Tensor> logits = std::nullopt,
- std::optional<FloatType> const &acceptanceThreshold = std::nullopt,
- std::optional<bool> const &fastLogits = std::nullopt,
-
std::optional<bool> getFastLogits() const#
私有成员
-
std::optional<bool> mFastLogits#
为草稿 logits 使用直接传输。
友元
- 友元类 Serialization
-
class GuidedDecodingConfig#
- #include <executor.h>
执行器的引导解码配置。
公有函数
- explicit GuidedDecodingConfig(
- GuidedDecodingBackend backend,
- std::optional<std::vector<std::string>> encodedVocab = std::nullopt,
- std::optional<std::string> tokenizerStr = std::nullopt,
- std::optional<std::vector<TokenIdType>> stopTokenIds = std::nullopt,
-
bool operator==(GuidedDecodingConfig const &other) const#
-
void setBackend(GuidedDecodingBackend const &backend)#
-
GuidedDecodingBackend getBackend() const#
-
void setEncodedVocab(std::vector<std::string> const &encodedVocab)#
-
std::optional<std::vector<std::string>> getEncodedVocab() const#
-
void setTokenizerStr(std::string const &tokenizerStr)#
-
std::optional<std::string> getTokenizerStr() const#
-
void setStopTokenIds(std::vector<TokenIdType> const &stopTokenIds)#
-
std::optional<std::vector<TokenIdType>> getStopTokenIds() const#
-
void validate() const#
私有成员
-
GuidedDecodingBackend mBackend#
引导解码后端。当前支持 XGrammar。
-
std::optional<std::vector<std::string>> mEncodedVocab#
编码词汇表。对于 huggingface 分词器,可以通过以下方式提取:
encoded_vocab = tokenizer.get_vocab() encoded_vocab = [token for token, _ in sorted(encoded_vocab.items(), key=lambda x: x[1])]
-
std::optional<std::string> mTokenizerStr#
分词器字符串。对于 huggingface fast 分词器,可以通过以下方式提取:
tokenizer_str = tokenizer.backend_tokenizer.to_str()
-
std::optional<std::vector<TokenIdType>> mStopTokenIds#
停止令牌 ID。如果未提供,则可以自动检测。
友元
- 友元类 Serialization
-
class GuidedDecodingParams#
- #include <executor.h>
请求的引导解码参数。
公共类型
公有函数
- explicit GuidedDecodingParams(
- GuideType guideType,
- std::optional<std::string> guide = std::nullopt,
-
bool operator==(GuidedDecodingParams const &other) const#
-
std::optional<std::string> getGuide() const#
私有成员
-
std::optional<std::string> mGuide#
详细的指导字符串。根据 mGuideType,它可以是 JSON schema、正则表达式或 EBNF 语法。
友元
- 友元类 Serialization
-
class JsonSerialization#
- #include <executor.h>
包含用于将统计数据序列化为 JSON 字符串的工具函数类。
公共静态函数
-
static std::string toJsonStr(IterationStats const &iterationStats)#
将 iterationStats 结构转换为 JSON 序列化字符串的工具函数。
- static std::string toJsonStr(
- RequestStatsPerIteration const &requestStatsPerIter,
将 requestStatsPerIteration 结构转换为 JSON 序列化字符串的工具函数。
-
static std::string toJsonStr(RequestStats const &requestStats)#
将 requestStats 结构转换为 JSON 序列化字符串的工具函数。
-
static std::string toJsonStr(IterationStats const &iterationStats)#
-
class KvCacheConfig#
- #include <executor.h>
KV cache 的配置类。
公有函数
- explicit KvCacheConfig(
- bool enableBlockReuse = true,
- std::optional<SizeType32> const &maxTokens = std::nullopt,
- std::optional<std::vector<SizeType32>> const &maxAttentionWindowVec = std::nullopt,
- std::optional<SizeType32> const &sinkTokenLength = std::nullopt,
- std::optional<FloatType> const &freeGpuMemoryFraction = std::nullopt,
- std::optional<size_t> const &hostCacheSize = std::nullopt,
- bool onboardBlocks = true,
- std::optional<FloatType> const &crossKvCacheFraction = std::nullopt,
- std::optional<RetentionPriority> secondaryOffloadMinPriority = std::nullopt,
- size_t eventBufferMaxSize = 0,
- std::optional<tensorrt_llm::runtime::RuntimeDefaults> const &runtimeDefaults = std::nullopt,
- bool enablePartialReuse = true,
- bool copyOnPartialReuse = true,
-
bool getEnableBlockReuse() const#
-
bool getEnablePartialReuse() const#
-
bool getCopyOnPartialReuse() const#
-
std::optional<SizeType32> getMaxTokens() const#
- std::optional<std::vector<SizeType32>> getMaxAttentionWindowVec(
-
std::optional<SizeType32> getSinkTokenLength() const#
-
std::optional<size_t> getHostCacheSize() const#
-
bool getOnboardBlocks() const#
- std::optional<RetentionPriority> getSecondaryOffloadMinPriority(
-
size_t getEventBufferMaxSize() const#
-
void setEnableBlockReuse(bool enableBlockReuse)#
-
void setEnablePartialReuse(bool enablePartialReuse)#
-
void setCopyOnPartialReuse(bool copyOnPartialReuse)#
-
void setMaxTokens(SizeType32 maxTokens)#
- void setMaxAttentionWindowVec(
- std::vector<SizeType32> maxAttentionWindowVec,
-
void setSinkTokenLength(SizeType32 sinkTokenLength)#
-
void setHostCacheSize(size_t hostCacheSize)#
-
void setOnboardBlocks(bool onboardBlocks)#
- void setSecondaryOffloadMinPriority(
- std::optional<RetentionPriority> secondaryOffloadMinPriority,
-
void setEventBufferMaxSize(size_t eventBufferMaxSize)#
- void fillEmptyFieldsFromRuntimeDefaults(
- tensorrt_llm::runtime::RuntimeDefaults runtimeDefaults,
私有成员
-
bool mEnableBlockReuse#
控制 KV 缓存块是否可以用于不同的请求。
-
std::optional<SizeType32> mMaxTokens#
KV 缓存中应存储的最大令牌数。如果同时指定了 mMaxTokens 和 mFreeGpuMemoryFraction,将分配对应于两者最小值的那部分内存。
-
std::optional<std::vector<SizeType32>> mMaxAttentionWindowVec#
每个序列的注意力窗口大小。每个序列中只有最后的 mMaxAttentionWindow 个令牌将存储在 KV 缓存中。不同的层可以有不同的最大注意力窗口大小。如果 mMaxAttentionWindowVec 中的元素数量少于层数,mMaxAttentionWindowVec 将被重复多次以达到层数。
-
std::optional<SizeType32> mSinkTokenLength#
沉没令牌数(始终保留在注意力窗口中的令牌)
-
std::optional<FloatType> mFreeGpuMemoryFraction#
应用于 KV 缓存的 GPU 显存占比。默认为 90%。如果同时指定了 mMaxTokens 和 mFreeGpuMemoryFraction,将分配对应于两者最小值的那部分内存。
-
std::optional<FloatType> mCrossKvCacheFraction#
KV 缓存内存中应为交叉注意力保留的比例。如果设置为 p,自注意力将使用 KV 缓存内存的 1-p,而交叉注意力将使用 p。默认为 50%。仅在使用编码器-解码器模型时设置。
-
std::optional<size_t> mHostCacheSize#
辅助内存池的大小(字节)。默认为 0。拥有辅助内存池可以增加 KV 缓存块的重用潜力。
-
bool mOnboardBlocks#
控制卸载的块在重用之前是否应重新载入主内存。
-
std::optional<RetentionPriority> mSecondaryOffloadMinPriority#
只有优先级 > mSecondaryOfflineMinPriority 的块可以被卸载到辅助内存。
-
size_t mEventBufferMaxSize#
KV 缓存事件缓冲区最大大小。
-
bool mEnablePartialReuse#
部分匹配的块是否可以被重用。
-
bool mCopyOnPartialReuse#
正在使用的部分匹配块是否可以在复制后被重用。
友元
- 友元类 Serialization
-
struct KVCacheCreatedData#
公有成员
-
std::vector<SizeType32> numBlocksPerCacheLevel#
每个缓存级别的块数量。
-
std::vector<SizeType32> numBlocksPerCacheLevel#
-
struct KVCacheEvent#
公有函数
-
KVCacheEvent(IdType eventId, KVCacheEventData data)#
-
KVCacheEvent(IdType eventId, KVCacheEventData data)#
-
template<typename T>
struct KVCacheEventDiff#
-
class KVCacheEventManager#
- #include <executor.h>
暴露 KV 缓存管理器的一部分功能。
公有函数
- std::shared_ptr<tensorrt_llm::batch_manager::kv_cache_manager::BaseKVCacheManager> kvCacheManager,
- std::deque<KVCacheEvent> getLatestEvents(
- std::optional<std::chrono::milliseconds> timeout = std::nullopt,
获取最新的 KV 缓存事件。
- 参数:
timeout – 等待新事件的最长时间。如果为 nullopt,则仅在新事件可用或执行器实例已关闭时返回。
私有成员
-
std::shared_ptr<tensorrt_llm::batch_manager::kv_cache_manager::BaseKVCacheManager> kvCacheManager#
-
struct KVCacheRemovedData#
-
class KvCacheRetentionConfig#
- #include <executor.h>
请求在 KV 缓存中的保留配置。
公有函数
-
inline explicit KvCacheRetentionConfig()#
- explicit KvCacheRetentionConfig(
- std::vector<TokenRangeRetentionConfig> const &tokenRangeRetentionPriorities,
- RetentionPriority decodeRetentionPriority = kDefaultRetentionPriority,
- std::optional<std::chrono::milliseconds> decodeDurationMs = std::nullopt,
- std::vector<TokenRangeRetentionConfig> getTokenRangeRetentionConfigs(
-
RetentionPriority getDecodeRetentionPriority() const#
- std::optional<std::chrono::milliseconds> getDecodeDurationMs(
- std::vector<RetentionPriorityAndDuration> getPerBlockRetentionPriorityDuration(
- SizeType32 blockSize,
- SizeType32 seqLen,
将令牌范围数据转换为每个 KV 块的条目。返回一个向量元组,分别对应于每个块的优先级和持续时间。
-
inline bool operator==(KvCacheRetentionConfig const &other) const#
公共静态属性
-
static constexpr RetentionPriority kMinRetentionPriority = 0#
-
static constexpr RetentionPriority kMaxRetentionPriority = 100#
-
static constexpr RetentionPriority kDefaultRetentionPriority = 35#
私有成员
-
std::vector<TokenRangeRetentionConfig> mTokenRangeRetentionConfigs#
需要更新的令牌范围和优先级。范围必须不重叠。例如,[(0, 64), (100, 128), (70, 80)] 是有效的,而 [(0, 64), (60, 128)] 是无效的。
-
RetentionPriority mDecodeRetentionPriority#
分配给解码阶段分配的块的优先级。
-
std::optional<std::chrono::milliseconds> mDecodeDurationMs#
解码块应保持在其指定优先级级别的持续时间(毫秒)。
-
struct TokenRangeRetentionConfig#
- #include <executor.h>
用于设置令牌范围内块优先级的一个条目。先前的范围总是优先于后续的范围。例如,块大小为 16 时,范围 [0, 17] 将应用于前两个块。
公有函数
- explicit TokenRangeRetentionConfig(
- SizeType32 tokenStart,
- std::optional<SizeType32> tokenEnd = std::nullopt,
- RetentionPriority priority = KvCacheRetentionConfig::kDefaultRetentionPriority,
- std::optional<std::chrono::milliseconds> durationMs = std::nullopt,
-
bool operator==(TokenRangeRetentionConfig const &other) const#
公有成员
-
SizeType32 tokenStart#
此范围的第一个令牌。
-
std::optional<SizeType32> tokenEnd#
此范围的最后一个令牌。范围不包含此结束令牌。可以设置为 std::nullopt 以将范围扩展到序列的末尾。
-
RetentionPriority priority#
此令牌范围的优先级。优先级越高,越不容易被逐出或卸载。
-
std::optional<std::chrono::milliseconds> durationMs#
块应保持在给定优先级级别的持续时间(毫秒)。设置为 std::nullopt 表示没有过期时间,并将块保持在给定优先级级别直到被回收。持续时间过后,块将移回
kDefaultRetentionPriority
级别。
-
inline explicit KvCacheRetentionConfig()#
-
struct KVCacheStoredBlockData#
- #include <executor.h>
存储到树中的单个块的条目。
公有函数
- inline KVCacheStoredBlockData(
- IdType blockHash,
- tensorrt_llm::runtime::VecUniqueTokens tokens,
- std::optional<tensorrt_llm::runtime::LoraTaskIdType> loraId,
- SizeType32 cacheLevel,
- SizeType32 priority,
公有成员
-
tensorrt_llm::runtime::VecUniqueTokens tokens#
块的唯一令牌。
-
std::optional<tensorrt_llm::runtime::LoraTaskIdType> loraId#
块的 Lora 任务 ID。
-
SizeType32 cacheLevel#
块的缓存级别。
-
SizeType32 priority#
块的优先级。
-
struct KVCacheStoredData#
公有成员
-
std::vector<KVCacheStoredBlockData> blocks#
一串块。块
i
的父级是块i-1
。
-
std::vector<KVCacheStoredBlockData> blocks#
-
struct KVCacheUpdatedData#
公有函数
- inline KVCacheUpdatedData &cacheLevelUpdated(
- SizeType32 oldValue,
- SizeType32 newValue,
- inline KVCacheUpdatedData &priorityUpdated(
- SizeType32 oldValue,
- SizeType32 newValue,
公有成员
-
std::optional<KVCacheEventDiff<SizeType32>> cacheLevel = std::nullopt#
cacheLevel 字段的更新值。
-
std::optional<KVCacheEventDiff<SizeType32>> priority = std::nullopt#
priority 字段的更新值。
-
class LogitsPostProcessorConfig#
公有函数
- explicit LogitsPostProcessorConfig(
- std::optional<LogitsPostProcessorMap> processorMap = std::nullopt,
- std::optional<LogitsPostProcessorBatched> processorBatched = std::nullopt,
- bool replicate = true,
-
std::optional<LogitsPostProcessorMap> getProcessorMap() const#
- std::optional<LogitsPostProcessorBatched> getProcessorBatched(
-
bool getReplicate() const#
-
void setProcessorMap(LogitsPostProcessorMap const &processorMap)#
- void setProcessorBatched(
- LogitsPostProcessorBatched const &processorBatched,
-
void setReplicate(bool replicate)#
私有成员
-
std::optional<LogitsPostProcessorMap> mProcessorMap#
从后处理器名称到非批量后处理器的映射
-
std::optional<LogitsPostProcessorBatched> mProcessorBatched#
单个批量后处理器
-
bool mReplicate#
如果设置为 true,Logits 后处理器将在最后一个 PP 秩的所有 TP 秩上运行。
-
struct LookaheadDecodingConfig#
- #include <executor.h>
前瞻性推测解码的配置。允许包含窗口大小、ngram 大小和验证集大小。
公有函数
- LookaheadDecodingConfig(
- SizeType32 windowSize,
- SizeType32 ngramSize,
- SizeType32 verificationSetSize,
-
inline explicit LookaheadDecodingConfig()#
-
bool operator==(LookaheadDecodingConfig const &other) const#
- std::tuple<SizeType32 const, SizeType32 const, SizeType32 const> get(
-
SizeType32 getWindowSize() const#
-
SizeType32 getNgramSize() const#
-
SizeType32 getVerificationSetSize() const#
- std::tuple<SizeType32, SizeType32, SizeType32, SizeType32> calculateSpeculativeResource(
返回 <最大解码标记数, 最大路径长度, 最大草稿标记数, 最大草稿路径长度>
-
bool isLE(LookaheadDecodingConfig const &that) const#
当
this
可以在由that
定义的资源上执行时返回 true
公共静态函数
- static std::tuple<SizeType32, SizeType32, SizeType32, SizeType32> calculateSpeculativeResourceTuple(
- SizeType32 windowSize,
- SizeType32 ngramSize,
- SizeType32 verificationSetSize,
- static bool isLegal(
- SizeType32 windowSize,
- SizeType32 ngramSize,
- SizeType32 verificationSetSize,
参数组合有效时返回 true。
公共静态属性
-
static constexpr SizeType32 kDefaultLookaheadDecodingWindow = 4#
-
static constexpr SizeType32 kDefaultLookaheadDecodingNgram = 3#
-
static constexpr SizeType32 kDefaultLookaheadDecodingVerificationSet = 4#
友元
- 友元类 Serialization
-
class LoraConfig#
- #include <executor.h>
LoRA 的配置。
公有函数
私有成员
友元
- 友元类 Serialization
-
class MropeConfig#
- #include <executor.h>
mrope 的配置。
公有函数
- explicit MropeConfig(
- Tensor mropeRoratySinCos,
- SizeType32 mropePositionDeltas,
-
SizeType32 getMRopePositionDeltas() const#
私有成员
-
Tensor mMRopeRotaryCosSin#
mrope 旋转正弦和余弦缓存。预期形状:[maxPositionEmbeddings*rotaryEmbeddingDim],数据类型必须是 float32。
-
SizeType32 mMRopePositionDeltas#
mrope 位置增量。
友元
- 友元类 Serialization
-
class OrchestratorConfig#
公有函数
- bool isOrchestrator = true,
- std::string workerExecutablePath = "",
- std::shared_ptr<mpi::MpiComm> orchLeaderComm = nullptr,
- bool spawnProcesses = true,
-
bool getIsOrchestrator() const#
-
std::string getWorkerExecutablePath() const#
-
bool getSpawnProcesses() const#
-
void setIsOrchestrator(bool isOrchestrator)#
-
void setWorkerExecutablePath(std::string const &workerExecutablePath)#
-
void setSpawnProcesses(bool spawnProcesses)#
-
class OutputConfig#
- #include <executor.h>
控制 Result 输出的配置。
公有函数
- explicit OutputConfig(
- bool returnLogProbs = false,
- bool returnContextLogits = false,
- bool returnGenerationLogits = false,
- bool excludeInputFromOutput = false,
- bool returnEncoderOutput = false,
- bool returnPerfMetrics = false,
- std::optional<std::vector<AdditionalModelOutput>> additionalModelOutputs = std::nullopt,
公有成员
-
std::optional<std::vector<AdditionalModelOutput>> additionalModelOutputs#
要从模型中收集的附加输出。
-
class ParallelConfig#
- #include <executor.h>
并行执行参数的配置类。目前仅支持 commType = CommunicationType::kMPI。
公有函数
- explicit ParallelConfig(
- CommunicationType commType = CommunicationType::kMPI,
- CommunicationMode commMode = CommunicationMode::kLEADER,
- std::optional<std::vector<SizeType32>> deviceIds = std::nullopt,
- std::optional<std::vector<SizeType32>> participantIds = std::nullopt,
- std::optional<OrchestratorConfig> const &orchestratorConfig = std::nullopt,
- std::optional<SizeType32> numNodes = std::nullopt,
构造函数。
- 参数:
commType – 通信类型。参见 CommunicationType。
commMode – 通信模式。参见 CommunicationMode。
deviceIds – 模型执行中涉及的 GPU 的 ID。
participantIds – 模型执行中涉及的参与者 ID(如果 commType == kMPI,则为 MPI 进程等级)。第一个参与者被视为领导者。
orchestratorConfig – 协调器配置。参见 OrchestratorConfig。
numNodes – 用于执行的节点数量。默认为 1。
-
CommunicationType getCommunicationType() const#
-
CommunicationMode getCommunicationMode() const#
-
std::optional<std::vector<SizeType32>> getDeviceIds() const#
-
std::optional<std::vector<SizeType32>> getParticipantIds() const#
-
std::optional<OrchestratorConfig> getOrchestratorConfig() const#
-
std::optional<SizeType32> getNumNodes() const#
-
void setCommunicationType(CommunicationType type)#
-
void setCommunicationMode(CommunicationMode mode)#
-
void setDeviceIds(std::vector<SizeType32> const &deviceIds)#
- void setParticipantIds(
- std::vector<SizeType32> const &participantIds,
- void setOrchestratorConfig(
- OrchestratorConfig const &orchestratorConfig,
-
void setNumNodes(SizeType32 numNodes)#
私有成员
-
CommunicationType mCommType#
使用的通信协议类型。默认为 MPI。
-
CommunicationMode mCommMode#
通信模式。参见 CommunicationMode。
-
std::optional<std::vector<SizeType32>> mDeviceIds#
用于执行此模型的 GPU 设备 ID。
-
std::optional<std::vector<SizeType32>> mParticipantIds#
用于执行此模型的参与者 ID(例如 MPI rank)。
-
std::optional<OrchestratorConfig> mOrchestratorConfig#
可选的协调器配置。
-
std::optional<SizeType32> mNumNodes#
用于执行的节点数量。默认值为 1。
友元
- 友元类 Serialization
-
class PeftCacheConfig#
- #include <executor.h>
PeftCacheManager 的配置
公有函数
- explicit PeftCacheConfig(
- SizeType32 numHostModuleLayer = 0,
- SizeType32 numDeviceModuleLayer = 0,
- SizeType32 optimalAdapterSize = kDefaultOptimalAdapterSize,
- SizeType32 maxAdapterSize = kDefaultMaxAdapterSize,
- SizeType32 numPutWorkers = 1,
- SizeType32 numEnsureWorkers = 1,
- SizeType32 numCopyStreams = 1,
- SizeType32 maxPagesPerBlockHost = kDefaultMaxPagesPerBlockHost,
- SizeType32 maxPagesPerBlockDevice = kDefaultMaxPagesPerBlockDevice,
- std::optional<float> const &deviceCachePercent = std::nullopt,
- std::optional<size_t> const &hostCacheSize = std::nullopt,
- std::optional<std::string> const &loraPrefetchDir = std::nullopt,
-
bool operator==(PeftCacheConfig const &other) const#
-
SizeType32 getNumHostModuleLayer() const#
-
SizeType32 getNumDeviceModuleLayer() const#
-
SizeType32 getOptimalAdapterSize() const#
-
SizeType32 getMaxAdapterSize() const#
-
SizeType32 getNumPutWorkers() const#
-
SizeType32 getNumEnsureWorkers() const#
-
SizeType32 getNumCopyStreams() const#
-
SizeType32 getMaxPagesPerBlockHost() const#
-
SizeType32 getMaxPagesPerBlockDevice() const#
-
std::optional<float> getDeviceCachePercent() const#
-
std::optional<size_t> getHostCacheSize() const#
-
std::optional<std::string> getLoraPrefetchDir() const#
公共静态属性
-
static constexpr SizeType32 kDefaultOptimalAdapterSize = 8#
-
static constexpr SizeType32 kDefaultMaxAdapterSize = 64#
-
static constexpr SizeType32 kDefaultMaxPagesPerBlockHost = 24#
-
static constexpr SizeType32 kDefaultMaxPagesPerBlockDevice = 8#
私有成员
-
SizeType32 mNumHostModuleLayer#
-
SizeType32 mNumDeviceModuleLayer#
-
SizeType32 mOptimalAdapterSize#
-
SizeType32 mMaxAdapterSize#
-
SizeType32 mNumPutWorkers#
-
SizeType32 mNumEnsureWorkers#
-
SizeType32 mNumCopyStreams#
-
SizeType32 mMaxPagesPerBlockHost#
-
SizeType32 mMaxPagesPerBlockDevice#
-
std::optional<size_t> mHostCacheSize#
-
std::optional<std::string> mLoraPrefetchDir#
友元
- 友元类 Serialization
-
class PromptTuningConfig#
- #include <executor.h>
Prompt tuning 的配置。
公有函数
- explicit PromptTuningConfig(
- Tensor embeddingTable,
- std::optional<VecTokenExtraIds> inputTokenExtraIds = std::nullopt,
-
std::optional<VecTokenExtraIds> getInputTokenExtraIds() const#
私有成员
-
std::optional<VecTokenExtraIds> mInputTokenExtraIds#
当启用 p-tuning 时,用于 KV Cache 重用的输入 token 额外 ID。
友元
- 友元类 Serialization
-
class Request#
- #include <executor.h>
一个包含请求信息的类。
公有函数
- Request(
- VecTokens inputTokenIds,
- SizeType32 maxTokens,
- bool streaming = false,
- SamplingConfig const &samplingConfig = SamplingConfig(),
- OutputConfig const &outputConfig = OutputConfig(),
- std::optional<SizeType32> const &endId = std::nullopt,
- std::optional<SizeType32> const &padId = std::nullopt,
- std::optional<std::vector<SizeType32>> positionIds = std::nullopt,
- std::optional<std::list<VecTokens>> badWords = std::nullopt,
- std::optional<std::list<VecTokens>> stopWords = std::nullopt,
- std::optional<Tensor> embeddingBias = std::nullopt,
- std::optional<ExternalDraftTokensConfig> externalDraftTokensConfig = std::nullopt,
- std::optional<PromptTuningConfig> pTuningConfig = std::nullopt,
- std::optional<MropeConfig> mRopeConfig = std::nullopt,
- std::optional<LoraConfig> loraConfig = std::nullopt,
- std::optional<LookaheadDecodingConfig> lookaheadConfig = std::nullopt,
- std::optional<KvCacheRetentionConfig> kvCacheRetentionConfig = std::nullopt,
- std::optional<std::string> logitsPostProcessorName = std::nullopt,
- std::optional<LogitsPostProcessor> logitsPostProcessor = std::nullopt,
- std::optional<VecTokens> encoderInputTokenIds = std::nullopt,
- std::optional<IdType> clientId = std::nullopt,
- bool returnAllGeneratedTokens = false,
- PriorityType priority = kDefaultPriority,
- RequestType type = RequestType::REQUEST_TYPE_CONTEXT_AND_GENERATION,
- std::optional<ContextPhaseParams> contextPhaseParams = std::nullopt,
- std::optional<Tensor> encoderInputFeatures = std::nullopt,
- std::optional<SizeType32> encoderOutputLength = std::nullopt,
- std::optional<Tensor> crossAttentionMask = std::nullopt,
- SizeType32 numReturnSequences = 1,
- std::optional<EagleConfig> eagleConfig = std::nullopt,
- std::optional<Tensor> skipCrossAttnBlocks = std::nullopt,
- std::optional<GuidedDecodingParams> guidedDecodingParams = std::nullopt,
- std::optional<SizeType32> languageAdapterUid = std::nullopt,
- std::optional<MillisecondsType> allottedTimeMs = std::nullopt,
Request 构造函数。
- 参数:
inputTokenIds – 输入 token ID
maxTokens – 要生成的最大 token 数
streaming – 指示是否应流式传输响应。默认值为 false。
samplingConfig – 采样配置
outputConfig – 输出配置
endId – 结束 token ID
padId – 填充 token ID
positionIds – 输入位置 ID
badWords – 不良词汇 token 列表。每个“词”可以由多个 token 组成。
stopWords – 停用词 token 列表。每个“词”可以由多个 token 组成。
embeddingBias – Embedding 偏差张量。预期形状为 [vocab_size]。
externalDraftTokensConfig – 使用外部草稿 token 的推测解码配置
pTuningConfig – Prompt Tuning 配置
mRopeConfig – Mrope 配置
loraConfig – LoRA 配置
lookaheadConfig – Lookahead 推测解码配置
kvCacheRetentionConfig – 用于 KV cache 块驱逐的配置。
logitsPostProcessorName – Logits 后处理器名称。必须与提供给 ExecutorConfig 的 logits 后处理器名称之一对应。
logitsPostProcessor – 按请求动态指定的 logits 后处理器;仅在 replicate=false 或没有张量并行时支持。
encoderInputTokenIds – 编码器-解码器模型或仅编码器模型的编码器输入 token ID
clientId –
returnAllGeneratedTokens – 指示在每个流式传输步骤后是返回完整 beam 还是仅返回新生成的 token。
priority – 设置此请求的执行优先级。
type – 在分离式服务模式下指示请求类型。
contextPhaseParams – 从仅上下文执行器生成的 token ID。
encoderInputFeatures – 多模态模型的编码器输入特征。
encoderOutputLength – 如果编码器输入和输出长度不同(由于卷积下采样等原因),则为编码器输出长度。
crossAttentionMask – 交叉注意力掩码。
numReturnSequences – 返回序列的数量。
eagleConfig – EAGLE 推测解码配置
skipCrossAttnBlocks – 是否跳过交叉注意力 Transformer 块。
guidedDecodingParams – 指导式解码参数。
languageAdapterUid – 语言适配器的任务 Uid。
allottedTimeMs – 分配的时间(毫秒),在此时间之后请求将以 timedOut 结束原因完成。请求总是会稍微超过这个时间,但最多不超过一次正向传播。请求甚至可能在被调度之前就超时。
-
~Request()#
-
SizeType32 getMaxTokens() const#
-
SizeType32 getMaxNewTokens() const#
-
bool getStreaming() const#
-
SamplingConfig getSamplingConfig() const#
-
OutputConfig getOutputConfig() const#
-
std::optional<SizeType32> getEndId() const#
-
std::optional<SizeType32> getPadId() const#
-
std::optional<std::vector<SizeType32>> getPositionIds() const#
- std::optional<ExternalDraftTokensConfig> getExternalDraftTokensConfig(
-
std::optional<PromptTuningConfig> getPromptTuningConfig() const#
-
std::optional<MropeConfig> getMropeConfig() const#
-
std::optional<LoraConfig> getLoraConfig() const#
-
std::optional<LookaheadDecodingConfig> getLookaheadConfig() const#
- std::optional<KvCacheRetentionConfig> getKvCacheRetentionConfig(
-
std::optional<std::string> getLogitsPostProcessorName() const#
-
std::optional<LogitsPostProcessor> getLogitsPostProcessor() const#
-
PriorityType getPriority() const#
-
bool getReturnAllGeneratedTokens() const#
- std::optional<ContextPhaseParams> const &getContextPhaseParams(
-
std::optional<SizeType32> getEncoderOutputLength() const#
-
RequestType getRequestType() const#
-
SizeType32 getNumReturnSequences() const#
-
std::optional<EagleConfig> getEagleConfig() const#
-
std::optional<GuidedDecodingParams> getGuidedDecodingParams() const#
-
std::optional<SizeType32> getLanguageAdapterUid() const#
-
std::optional<MillisecondsType> getAllottedTimeMs() const#
- std::optional<std::vector<std::string>> getAdditionalOutputNames(
-
void setStreaming(bool streaming)#
-
void setSamplingConfig(SamplingConfig const &config)#
-
void setOutputConfig(OutputConfig const &outputConfig)#
-
void setEndId(SizeType32 endId)#
-
void setPadId(SizeType32 padId)#
-
void setPositionIds(std::vector<SizeType32> const &positionIds)#
- void setExternalDraftTokensConfig(
- ExternalDraftTokensConfig const &externalDraftTokensConfig,
-
void setPromptTuningConfig(PromptTuningConfig const &pTuningConfig)#
-
void setMropeConfig(MropeConfig const &mRopeConfig)#
-
void setLoraConfig(LoraConfig const &loraConfig)#
- void setLookaheadConfig(
- LookaheadDecodingConfig const &lookaheadConfig,
- void setKvCacheRetentionConfig(
- KvCacheRetentionConfig const &kvCacheRetentionConfig,
- void setLogitsPostProcessorName(
- std::string const &logitsPostProcessorName,
- void setLogitsPostProcessor(
- std::optional<LogitsPostProcessor> const &logitsPostProcessor,
-
void setPriority(PriorityType priority)#
-
void setReturnAllGeneratedTokens(bool returnAllGeneratedTokens)#
-
void setRequestType(RequestType const &requestType)#
-
void setContextPhaseParams(ContextPhaseParams contextPhaseParams)#
-
void setEncoderOutputLength(SizeType32 encoderOutputLength)#
-
void setNumReturnSequences(SizeType32 numReturnSequences)#
-
void setEagleConfig(std::optional<EagleConfig> const &eagleConfig)#
- void setGuidedDecodingParams(
- GuidedDecodingParams const &guidedDecodingParams,
-
void setLanguageAdapterUid(SizeType32 languageAdapterUid)#
-
void setAllottedTimeMs(MillisecondsType allottedTimeMs)#
公共静态属性
-
static constexpr PriorityType kDefaultPriority = 0.5#
-
static auto constexpr kBatchedPostProcessorName = "batched"#
此 logits 后处理器名称将分派到批处理 logits 后处理器。
-
static auto constexpr kDynamicPostProcessorNamePrefix = "dynamic"#
动态 logits 后处理器名称将是“dynamic” + requestId。
私有成员
-
std::unique_ptr<Impl> mImpl#
友元
- 友元类 Serialization
-
class Response#
- #include <executor.h>
包含错误或结果的类。
公有函数
-
~Response()#
-
bool hasError() const#
指示此响应是否包含错误。
-
std::string const &getErrorMsg() const#
获取此响应的错误消息。如果 hasError 为 false,将抛出异常。
私有成员
-
std::unique_ptr<Impl> mImpl#
友元
- 友元类 Serialization
-
~Response()#
-
struct Result#
- #include <executor.h>
包含生成结果的结构体。
公有成员
-
bool isFinal#
指示这是否是请求的最终结果。
-
BeamTokens outputTokenIds#
每个 beam 的输出 tokens。
-
std::optional<VecLogProbs> cumLogProbs#
累积对数概率。大小为 beamSize。
-
std::optional<std::vector<VecLogProbs>> logProbs#
每个生成的 token 的对数概率。大小为 [beamSize, outputLen]。
-
std::optional<Tensor> generationLogits#
生成 logits。大小为 [beamSize, maxNewTokens, vocabSizePadded](非流式)或 [maxNewTokens, beamSize, vocabSizePadded](流式且 allGeneratedTokens)或 [1, beamSize, vocabSizePadded](流式且非 allGeneratedTokens)。
-
std::optional<SpeculativeDecodingFastLogitsInfo> specDecFastLogitsInfo#
使用快速 logits 时用于直接传输的 logits 信息。
-
std::vector<FinishReason> finishReasons#
模型停止为请求中的每个 beam 生成 token 的原因。大小为 [beamSize]。目前仅在 beamSize 为 1 且使用 BatchingType::kINFLIGHT 时支持。
-
std::optional<ContextPhaseParams> contextPhaseParams#
上下文阶段的参数。
-
SizeType32 decodingIter = {0}#
用于生成结果的解码迭代次数。在自回归解码中,它等于 outputTokenIds 中 beam 的最大长度。在推测解码中,由于每次迭代可以生成多个 token,其次数可能小于 outputTokenIds 中 beam 的最大长度。用于推测解码统计。
-
SizeType32 sequenceIndex = {0}#
此结果的输出序列索引,其中 0 <= sequenceIndex < numReturnSequences。在 beam search (beamWidth > 1) 中,此索引将始终为零,因为所有要返回的 beams 都包含在此结果中。
-
bool isSequenceFinal#
指示这是否是请求中给定序列的最终结果。在 beam search (beamWidth > 1) 中,此值将始终等于 isFinal 的值。
-
std::optional<RequestPerfMetrics> requestPerfMetrics#
如果在 OutputConfig 中设置了 returnPerfMetrics,则提供性能指标。
-
std::vector<AdditionalOutput> additionalOutputs#
附加输出。
-
bool isFinal#
-
struct RetentionPriorityAndDuration#
公有函数
- inline RetentionPriorityAndDuration(
- std::optional<RetentionPriority> const &retentionPriority,
- std::optional<std::chrono::milliseconds> const &durationMs,
公有成员
-
std::optional<RetentionPriority> retentionPriority#
-
std::optional<std::chrono::milliseconds> durationMs#
-
class SamplingConfig#
- #include <executor.h>
采样配置。
公有函数
- explicit SamplingConfig(
- SizeType32 beamWidth = 1,
- std::optional<SizeType32> const &topK = std::nullopt,
- std::optional<FloatType> const &topP = std::nullopt,
- std::optional<FloatType> const &topPMin = std::nullopt,
- std::optional<TokenIdType> const &topPResetIds = std::nullopt,
- std::optional<FloatType> const &topPDecay = std::nullopt,
- std::optional<RandomSeedType> const &seed = std::nullopt,
- std::optional<FloatType> const &temperature = std::nullopt,
- std::optional<SizeType32> const &minTokens = std::nullopt,
- std::optional<FloatType> const &beamSearchDiversityRate = std::nullopt,
- std::optional<FloatType> const &repetitionPenalty = std::nullopt,
- std::optional<FloatType> const &presencePenalty = std::nullopt,
- std::optional<FloatType> const &frequencyPenalty = std::nullopt,
- std::optional<FloatType> const &lengthPenalty = std::nullopt,
- std::optional<SizeType32> const &earlyStopping = std::nullopt,
- std::optional<SizeType32> const &noRepeatNgramSize = std::nullopt,
- std::optional<SizeType32> const &numReturnSequences = std::nullopt,
- std::optional<FloatType> const &minP = std::nullopt,
- std::optional<std::vector<SizeType32>> const &beamWidthArray = std::nullopt,
SamplingConfig 的构造函数。请参阅下面的参数说明。
-
bool operator==(SamplingConfig const &other) const#
-
SizeType32 getBeamWidth() const#
-
SizeType32 getNumReturnBeams() const#
-
std::optional<SizeType32> getTopK() const#
-
std::optional<SizeType32> getTopPResetIds() const#
-
std::optional<RandomSeedType> getSeed() const#
-
std::optional<RandomSeedType> getRandomSeed() const#
-
std::optional<SizeType32> getMinTokens() const#
-
std::optional<SizeType32> getMinLength() const#
-
std::optional<SizeType32> getEarlyStopping() const#
-
std::optional<SizeType32> getNoRepeatNgramSize() const#
-
std::optional<SizeType32> getNumReturnSequences() const#
-
std::optional<std::vector<SizeType32>> getBeamWidthArray() const#
-
void setBeamWidth(SizeType32 beamWidth)#
-
void setTopK(std::optional<SizeType32> const &topK)#
- void setTopPResetIds(
- std::optional<TokenIdType> const &topPResetIds,
-
void setSeed(std::optional<RandomSeedType> const &seed)#
-
void setRandomSeed(std::optional<RandomSeedType> const &randomSeed)#
-
void setMinTokens(std::optional<SizeType32> const &minTokens)#
-
void setMinLength(std::optional<SizeType32> const &minLength)#
- void setEarlyStopping(
- std::optional<SizeType32> const &earlyStopping,
- void setNoRepeatNgramSize(
- std::optional<SizeType32> const &noRepeatNgramSize,
- void setNumReturnSequences(
- std::optional<SizeType32> const &numReturnSequences,
- void setBeamWidthArray(
- std::optional<std::vector<SizeType32>> const &beamWidthArray,
私有函数
-
void updateNumReturnBeams()#
私有成员
-
SizeType32 mBeamWidth#
束搜索宽度。默认为1,禁用束搜索。
-
std::optional<SizeType32> mTopK#
控制采样时的 logits 数量。默认为0(所有 logits)。
-
std::optional<TokenIdType> mTopPResetIds#
控制 top-P 算法中的衰减。指示何时重置衰减。默认为1。
-
std::optional<RandomSeedType> mSeed#
控制采样时随机数生成器使用的随机种子。默认为0。
-
std::optional<SizeType32> mMinTokens#
生成的令牌数量的下限。值 < 1 无效。默认为 1。
-
std::optional<FloatType> mRepetitionPenalty#
用于根据令牌在序列中出现的频率来惩罚令牌。它可以是任意大于 0.f 的值。值 < 1.f 鼓励重复,值 > 1.f 抑制重复。默认为 1.f。
-
std::optional<FloatType> mPresencePenalty#
用于惩罚序列中已存在的令牌(不管出现次数)。它可以是任意值。值 < 0.f 鼓励重复,值 > 0.f 抑制重复。默认为 0.f。
-
std::optional<FloatType> mFrequencyPenalty#
用于惩罚序列中已存在的令牌(取决于出现次数)。它可以是任意值。值 < 0.f 鼓励重复,值 > 0.f 抑制重复。默认为 0.f。
-
std::optional<SizeType32> mEarlyStopping#
控制一旦生成 beamWidth 个句子(以结束令牌结束)时,生成过程是否结束。默认为 1。
-
std::optional<SizeType32> mNoRepeatNgramSize#
控制可接受的重复 N-gram 大小数量。默认为 1 << 30。
-
std::optional<SizeType32> mNumReturnSequences#
返回序列或波束的数量。在波束搜索中,该值应小于或等于 mBeamWidth。在采样中,它指定独立生成的序列总数。
-
SizeType32 mNumReturnBeams#
要返回的波束数量。除非设置了 numReturnSequences,否则它等于 beamWidth。如果 beamWidth > 1 且设置了 numReturnSequences,则 numReturnBeams 等于 numReturnSequences。
-
std::optional<FloatType> mMinP#
控制采样的 min_p 缩放。它会掩盖概率 P_x 小于 min_p * P_max 的 x,其中 P_x 是候选 x 的概率。默认为 0.f。
-
std::optional<std::vector<SizeType32>> mBeamWidthArray#
控制可变波束宽度搜索中每一步的波束宽度。
私有静态函数
-
static SizeType32 checkBeamWidth(SizeType32 beamWidth)#
- static std::optional<TokenIdType> const &checkTopPResetIds(
- std::optional<TokenIdType> const &topPResetIds,
- static std::optional<FloatType> const &checkTopPDecay(
- std::optional<FloatType> const &topPDecay,
- static std::optional<FloatType> const &checkTemperature(
- std::optional<FloatType> const &temperature,
- static std::optional<SizeType32> const &checkMinTokens(
- std::optional<SizeType32> const &minTokens,
- static std::optional<FloatType> const &checkBeamSearchDiversityRate(
- std::optional<FloatType> const &beamSearchDiversityRate,
- static std::optional<FloatType> const &checkRepetitionPenalty(
- std::optional<FloatType> const &repetitionpenalty,
- static std::optional<FloatType> const &checkLengthPenalty(
- std::optional<FloatType> const &lengthPenalty,
- static std::optional<SizeType32> const &checkEarlyStopping(
- std::optional<SizeType32> const &earlyStopping,
- static std::optional<SizeType32> const &checkNoRepeatNgramSize(
- std::optional<SizeType32> const &noRepeatNgramSize,
- static std::optional<SizeType32> const &checkNumReturnSequences(
- std::optional<SizeType32> const &numReturnSequences,
- SizeType32 beamWidth,
- static std::optional<std::vector<SizeType32>> const &checkBeamWidthArray(
- std::optional<std::vector<SizeType32>> const &beamWidthArray,
- std::optional<SizeType32> const beamWidth,
友元
- 友元类 Serialization
-
class SchedulerConfig#
- #include <executor.h>
调度器的配置类。
公有函数
- explicit SchedulerConfig(
- CapacitySchedulerPolicy capacitySchedulerPolicy = CapacitySchedulerPolicy::kGUARANTEED_NO_EVICT,
- std::optional<ContextChunkingPolicy> contextChunkingPolicy = std::nullopt,
- std::optional<DynamicBatchConfig> dynamicBatchConfig = std::nullopt,
-
bool operator==(SchedulerConfig const &other) const#
-
CapacitySchedulerPolicy getCapacitySchedulerPolicy() const#
- std::optional<ContextChunkingPolicy> getContextChunkingPolicy(
-
std::optional<DynamicBatchConfig> getDynamicBatchConfig() const#
私有成员
-
CapacitySchedulerPolicy mCapacitySchedulerPolicy#
容量调度器策略。参见 CapacitySchedulerPolicy。
-
std::optional<ContextChunkingPolicy> mContextChunkingPolicy#
上下文分块策略。参见 ContextChunkingPolicy。
-
std::optional<DynamicBatchConfig> mDynamicBatchConfig#
用于动态调整批次大小的配置。参见 DynamicBatchSizeConfig。
友元
- 友元类 Serialization
-
class SpeculativeDecodingConfig#
- #include <executor.h>
推测解码(草稿模型和目标模型)的配置
公有函数
-
explicit SpeculativeDecodingConfig(bool fastLogits = false)#
-
bool operator==(SpeculativeDecodingConfig const &other) const#
公有成员
-
bool fastLogits#
将 logits 张量直接从草稿模型发送到目标模型。
友元
- 友元类 Serialization
-
explicit SpeculativeDecodingConfig(bool fastLogits = false)#
-
struct SpeculativeDecodingFastLogitsInfo#
- #include <executor.h>
包含 logits 信息的结构体,在使用直接传输时使用。
-
using RetentionPriority = SizeType32#
-
namespace mpi#
-
namespace executor
serialization.h#
-
namespace tensorrt_llm
-
namespace executor
-
class Serialization#
公共静态函数
- static RequestPerfMetrics::TimePoint deserializeTimePoint(
- std::istream &is,
- static void serialize(
- RequestPerfMetrics::TimePoint const &tp,
- std::ostream &os,
-
static size_t serializedSize(RequestPerfMetrics::TimePoint const&)#
- static RequestPerfMetrics deserializeRequestPerfMetrics(
- std::istream &is,
- static void serialize(
- RequestPerfMetrics const &metrics,
- std::ostream &os,
-
static size_t serializedSize(RequestPerfMetrics const &metrics)#
-
static SamplingConfig deserializeSamplingConfig(std::istream &is)#
-
static void serialize(SamplingConfig const &config, std::ostream &os)#
-
static size_t serializedSize(SamplingConfig const &config)#
-
static OutputConfig deserializeOutputConfig(std::istream &is)#
-
static void serialize(OutputConfig const &config, std::ostream &os)#
-
static size_t serializedSize(OutputConfig const &config)#
- static AdditionalModelOutput deserializeAdditionalModelOutput(
- std::istream &is,
- static void serialize(
- AdditionalModelOutput const &additionalModelOutput,
- std::ostream &os,
- static size_t serializedSize(
- AdditionalModelOutput const &additionalModelOutput,
- static ExternalDraftTokensConfig deserializeExternalDraftTokensConfig(
- std::istream &is,
- static void serialize(
- ExternalDraftTokensConfig const &config,
- std::ostream &os,
-
static size_t serializedSize(ExternalDraftTokensConfig const &config)#
- static PromptTuningConfig deserializePromptTuningConfig(
- std::istream &is,
- static void serialize(
- PromptTuningConfig const &config,
- std::ostream &os,
-
static size_t serializedSize(PromptTuningConfig const &config)#
-
static MropeConfig deserializeMropeConfig(std::istream &is)#
-
static void serialize(MropeConfig const &config, std::ostream &os)#
-
static size_t serializedSize(MropeConfig const &config)#
-
static LoraConfig deserializeLoraConfig(std::istream &is)#
-
static void serialize(LoraConfig const &config, std::ostream &os)#
-
static size_t serializedSize(LoraConfig const &config)#
-
static kv_cache::SocketState 反序列化SocketState(std::istream &is)#
- static void 序列化(
- kv_cache::SocketState const &state,
- std::ostream &os,
-
static size_t 序列化大小(kv_cache::SocketState const &state)#
-
static kv_cache::CacheState 反序列化CacheState(std::istream &is)#
- static void 序列化(
- kv_cache::CacheState const &state,
- std::ostream &os,
-
static size_t 序列化大小(kv_cache::CacheState const &state)#
- static DataTransceiverState 反序列化DataTransceiverState(
- std::istream &is,
- static DataTransceiverState 反序列化DataTransceiverState(
- std::vector<char> &buffer,
- static void 序列化(
- DataTransceiverState const &dataTransceiverState,
- std::ostream &os,
- static std::vector<char> 序列化(
- DataTransceiverState const &dataTransceiverState,
- static size_t 序列化大小(
- DataTransceiverState const &dataTransceiverState,
- static ContextPhaseParams 反序列化ContextPhaseParams(
- std::istream &is,
- static void 序列化(
- ContextPhaseParams const &contextPhaseParams,
- std::ostream &os,
- static size_t 序列化大小(
- ContextPhaseParams const &contextPhaseParams,
- static SpeculativeDecodingFastLogitsInfo 反序列化SpecDecFastLogitsInfo(
- std::istream &is,
- static void 序列化(
- SpeculativeDecodingFastLogitsInfo const &info,
- std::ostream &os,
- static size_t 序列化大小(
- SpeculativeDecodingFastLogitsInfo const &info,
-
static AdditionalOutput 反序列化AdditionalOutput(std::istream &is)#
- static void 序列化(
- AdditionalOutput const &additionalOutput,
- std::ostream &os,
- static size_t 序列化大小(
- AdditionalOutput const &additionalOutput,
-
static KvCacheConfig 反序列化KvCacheConfig(std::istream &is)#
- static void 序列化(
- KvCacheConfig const &kvCacheConfig,
- std::ostream &os,
-
static size_t 序列化大小(KvCacheConfig const &kvCacheConfig)#
- static DynamicBatchConfig 反序列化DynamicBatchConfig(
- std::istream &is,
- static void 序列化(
- DynamicBatchConfig const &dynamicBatchConfig,
- std::ostream &os,
- static size_t 序列化大小(
- DynamicBatchConfig const &dynamicBatchConfig,
-
static SchedulerConfig deserializeSchedulerConfig(std::istream &is)#
- static void serialize(
- SchedulerConfig const &schedulerConfig,
- std::ostream &os,
-
static size_t serializedSize(SchedulerConfig const &schedulerConfig)#
- static ExtendedRuntimePerfKnobConfig deserializeExtendedRuntimePerfKnobConfig(
- std::istream &is,
- static void serialize(
- ExtendedRuntimePerfKnobConfig const &extendedRuntimePerfKnobConfig,
- std::ostream &os,
- static size_t serializedSize(
- ExtendedRuntimePerfKnobConfig const &extendedRuntimePerfKnobConfig,
-
static ParallelConfig deserializeParallelConfig(std::istream &is)#
- static void serialize(
- ParallelConfig const ¶llelConfig,
- std::ostream &os,
-
static size_t serializedSize(ParallelConfig const ¶llelConfig)#
-
static PeftCacheConfig deserializePeftCacheConfig(std::istream &is)#
- static void serialize(
- PeftCacheConfig const &peftCacheConfig,
- std::ostream &os,
-
static size_t serializedSize(PeftCacheConfig const &peftCacheConfig)#
- static OrchestratorConfig deserializeOrchestratorConfig(
- std::istream &is,
- static void serialize(
- OrchestratorConfig const &orchestratorConfig,
- std::ostream &os,
- static size_t serializedSize(
- OrchestratorConfig const &orchestratorConfig,
-
static DecodingMode deserializeDecodingMode(std::istream &is)#
- static void serialize(
- DecodingMode const &decodingMode,
- std::ostream &os,
-
static size_t serializedSize(DecodingMode const &decodingMode)#
- static LookaheadDecodingConfig deserializeLookaheadDecodingConfig(
- std::istream &is,
- static void serialize(
- LookaheadDecodingConfig const &lookaheadDecodingConfig,
- std::ostream &os,
- static size_t serializedSize(
- LookaheadDecodingConfig const &lookaheadDecodingConfig,
-
static EagleConfig deserializeEagleConfig(std::istream &is)#
- static void serialize(
- EagleConfig const &eagleConfig,
- std::ostream &os,
-
static size_t serializedSize(EagleConfig const &eagleConfig)#
- static SpeculativeDecodingConfig deserializeSpeculativeDecodingConfig(
- std::istream &is,
- static void serialize(
- SpeculativeDecodingConfig const &specDecConfig,
- std::ostream &os,
- static size_t serializedSize(
- SpeculativeDecodingConfig const &specDecConfig,
- static GuidedDecodingConfig deserializeGuidedDecodingConfig(
- std::istream &is,
- static void serialize(
- GuidedDecodingConfig const &guidedDecodingConfig,
- std::ostream &os,
- static size_t serializedSize(
- GuidedDecodingConfig const &guidedDecodingConfig,
- static GuidedDecodingParams deserializeGuidedDecodingParams(
- std::istream &is,
- static void serialize(
- GuidedDecodingParams const &guidedDecodingParams,
- std::ostream &os,
- static size_t serializedSize(
- GuidedDecodingParams const &guidedDecodingParams,
- static KvCacheRetentionConfig deserializeKvCacheRetentionConfig(
- std::istream &is,
- static void serialize(
- KvCacheRetentionConfig const &kvCacheRetentionConfig,
- std::ostream &os,
- static size_t serializedSize(
- KvCacheRetentionConfig const &kvCacheRetentionConfig,
- static KvCacheRetentionConfig::TokenRangeRetentionConfig deserializeTokenRangeRetentionConfig(
- std::istream &is,
- static void serialize(
- KvCacheRetentionConfig::TokenRangeRetentionConfig const &tokenRangeRetentionConfig,
- std::ostream &os,
- static size_t serializedSize(
- KvCacheRetentionConfig::TokenRangeRetentionConfig const &tokenRangeRetentionConfig,
-
static DecodingConfig deserializeDecodingConfig(std::istream &is)#
- static void serialize(
- DecodingConfig const &decodingConfig,
- std::ostream &os,
-
static size_t serializedSize(DecodingConfig const &decodingConfig)#
-
static DebugConfig deserializeDebugConfig(std::istream &is)#
- static void serialize(
- DebugConfig const &debugConfig,
- std::ostream &os,
-
static size_t serializedSize(DebugConfig const &debugConfig)#
-
static ExecutorConfig deserializeExecutorConfig(std::istream &is)#
- static void serialize(
- ExecutorConfig const &executorConfig,
- std::ostream &os,
-
static size_t serializedSize(ExecutorConfig const &executorConfig)#
-
static KvCacheStats deserializeKvCacheStats(std::istream &is)#
- static void serialize(
- KvCacheStats const &kvCacheStats,
- std::ostream &os,
-
static size_t serializedSize(KvCacheStats const &kvCacheStats)#
- static StaticBatchingStats deserializeStaticBatchingStats(
- std::istream &is,
- static void serialize(
- StaticBatchingStats const &staticBatchingStats,
- std::ostream &os,
- static size_t serializedSize(
- StaticBatchingStats const &staticBatchingStats,
- static InflightBatchingStats deserializeInflightBatchingStats(
- std::istream &is,
- static void serialize(
- InflightBatchingStats const &inflightBatchingStats,
- std::ostream &os,
- static size_t serializedSize(
- InflightBatchingStats const &inflightBatchingStats,
- static IterationStats deserializeIterationStats(
- std::vector<char> &buffer,
-
static IterationStats deserializeIterationStats(std::istream &is)#
- static void serialize(
- IterationStats const &iterStats,
- std::ostream &os,
-
static std::vector<char> serialize(IterationStats const &iterStats)#
-
static size_t serializedSize(IterationStats const &iterStats)#
- static std::vector<char> serialize(
- std::vector<IterationStats> const &iterStatsVec,
- static std::vector<IterationStats> deserializeIterationStatsVec(
- std::vector<char> &buffer,
- static DisServingRequestStats deserializeDisServingRequestStats(
- std::istream &is,
- static void serialize(
- DisServingRequestStats const &stats,
- std::ostream &os,
- static size_t serializedSize(
- DisServingRequestStats const &disServingRequestStats,
-
static RequestStage deserializeRequestStage(std::istream &is)#
- static void serialize(
- RequestStage const &requestStage,
- std::ostream &os,
-
static size_t serializedSize(RequestStage const &requestStage)#
-
static RequestStats deserializeRequestStats(std::istream &is)#
-
static void serialize(RequestStats const &state, std::ostream &os)#
-
static size_t serializedSize(RequestStats const &state)#
- static RequestStatsPerIteration deserializeRequestStatsPerIteration(
- std::istream &is,
- static RequestStatsPerIteration deserializeRequestStatsPerIteration(
- std::vector<char> &buffer,
- static void serialize(
- RequestStatsPerIteration const &state,
- std::ostream &os,
- static std::vector<char> serialize(
- RequestStatsPerIteration const &state,
-
static size_t serializedSize(RequestStatsPerIteration const &state)#
- static std::vector<char> serialize(
- std::vector<RequestStatsPerIteration> const &requestStatsVec,
- static std::vector<RequestStatsPerIteration> deserializeRequestStatsPerIterationVec(
- std::vector<char> &buffer,
-
static std::string deserializeString(std::istream &is)#
-
static bool deserializeBool(std::istream &is)#
-
namespace kv_cache#
-
class Serialization#
-
namespace executor
types.h#
-
namespace tensorrt_llm
-
namespace executor
类型定义
-
using SizeType32 = std::int32_t#
-
using FloatType = float#
-
using TokenIdType = std::int32_t#
-
using VecTokens = std::vector<TokenIdType>#
-
using IdType = std::uint64_t#
-
using IterationType = std::uint64_t#
-
using RandomSeedType = std::uint64_t#
-
using StreamPtr = std::shared_ptr<tensorrt_llm::runtime::CudaStream>#
-
using MillisecondsType = std::chrono::milliseconds#
-
using LogitsPostProcessor = std::function<void(IdType, Tensor&, BeamTokens const&, StreamPtr const&, std::optional<IdType>)>#
-
using LogitsPostProcessorMap = std::unordered_map<std::string, LogitsPostProcessor>#
-
using LogitsPostProcessorBatched = std::function<void(std::vector<IdType> const&, std::vector<Tensor>&, std::vector<std::reference_wrapper<BeamTokens const>> const&, StreamPtr const&, std::vector<std::optional<IdType>> const&)>#
-
using MedusaChoices = std::vector<std::vector<SizeType32>>#
-
using EagleChoices = std::vector<std::vector<SizeType32>>#
-
using PriorityType = float#
-
using BufferView = std::basic_string_view<uint8_t>#
枚举
-
enum class DataType#
值
-
enumerator kBOOL#
-
enumerator kUINT8#
-
enumerator kINT8#
-
enumerator kINT32#
-
enumerator kINT64#
-
enumerator kBF16#
-
enumerator kFP8#
-
enumerator kFP16#
-
enumerator kFP32#
-
enumerator kUNKNOWN#
-
enumerator kBOOL#
-
enum class RequestType#
值
-
enumerator REQUEST_TYPE_CONTEXT_AND_GENERATION#
-
enumerator REQUEST_TYPE_CONTEXT_ONLY#
-
enumerator REQUEST_TYPE_GENERATION_ONLY#
-
enumerator REQUEST_TYPE_CONTEXT_AND_GENERATION#
-
enum class MemoryType#
值
-
enumerator kCPU#
-
enumerator kCPU_PINNED#
-
enumerator kCPU_PINNEDPOOL#
-
enumerator kGPU#
-
enumerator kUVM#
-
enumerator kUNKNOWN#
-
enumerator kCPU#
-
enum class ModelType#
值
-
enumerator kDECODER_ONLY#
-
enumerator kENCODER_ONLY#
-
enumerator kENCODER_DECODER#
-
enumerator kDECODER_ONLY#
-
enum class BatchingType#
批处理类型。
值
-
enumerator kSTATIC#
静态批处理是指传统的批处理方案,其中一批请求同步运行,直到所有请求的完整生成完成。批处理中的所有请求都会填充到批处理中任何成员的最大输入和输出序列长度。
-
enumerator kINFLIGHT#
动态批处理是指一种方案,其中新到达的请求会动态地纳入正在执行的批处理中,并且请求一旦满足结束条件就会立即返回,无需进行任何填充。
-
enumerator kSTATIC#
-
enum class CapacitySchedulerPolicy#
用于在执行器生成循环的每次迭代中选择可用请求子集的策略。
值
-
enumerator kMAX_UTILIZATION#
MAX_UTILIZATION 在动态批处理生成循环的任何迭代中打包尽可能多的请求,只要底层的 TRT 引擎能够支持。虽然这有望最大化 GPU 吞吐量,但可能需要根据峰值 KV 缓存内存可用性暂停并重新启动某些请求。
-
enumerator kGUARANTEED_NO_EVICT#
GUARANTEED_NO_EVICT 更保守地使用 KV 缓存,保证一个请求一旦开始就会运行到完成而不会被逐出。
-
enumerator kSTATIC_BATCH#
kSTATIC_BATCH 不会调度新的请求,直到当前批处理中的所有请求都已完成。与 kGUARANTEED_NO_EVICT 类似,请求将运行到完成而不会被逐出。
-
enumerator kMAX_UTILIZATION#
-
enum class ContextChunkingPolicy#
值
-
enumerator kFIRST_COME_FIRST_SERVED#
顺序分块,优先完成未完成的上下文阶段。
-
enumerator kEQUAL_PROGRESS#
按顺序遍历每个上下文请求,并尝试增加其分块计数,直到超出约束。
-
enumerator kFIRST_COME_FIRST_SERVED#
-
enum class RequestStage#
表示请求状态的枚举类。
值
-
enumerator kENCODER_IN_PROGRESS#
处于编码器阶段的活动请求。
-
enumerator kCONTEXT_IN_PROGRESS#
处于上下文阶段的活动请求。
-
enumerator kGENERATION_IN_PROGRESS#
处于生成阶段的活动请求。
-
enumerator kGENERATION_COMPLETE#
已完成生成的活动请求。
-
enumerator kENCODER_IN_PROGRESS#
-
enum class FinishReason#
模型停止为一个请求生成 token 的原因。
值
-
enumerator kNOT_FINISHED#
请求尚未完成。
-
enumerator kEND_ID#
请求因生成了结束 ID 而完成。
-
enumerator kSTOP_WORDS#
请求因生成了停止词而完成。
-
enumerator kLENGTH#
请求因达到最大 token 数量而完成。
-
enumerator kTIMED_OUT#
请求因超时而完成(通过 mAllotedTime 参数)。
-
enumerator kCANCELLED#
请求通过调用 cancelRequest 被取消。
-
enumerator kNOT_FINISHED#
函数
- std::ostream &operator<<(
- std::ostream &os,
- CapacitySchedulerPolicy policy,
- std::ostream &operator<<(
- std::ostream &os,
- ContextChunkingPolicy policy,
-
struct DebugTensorsPerIteration#
- #include <types.h>
在一次迭代中包含调试张量的结构体。
-
class DecodingMode#
- #include <types.h>
解码器的模式
公共类型
-
using UnderlyingType = uint32_t#
公有函数
-
inline auto constexpr useTemperature(bool useTemp)#
-
inline auto constexpr useOccurrencePenalties(bool usePenalty)#
-
inline auto constexpr usePresencePenalty(bool usePenalty)#
-
inline auto constexpr useRepetitionPenalty(bool usePenalty)#
-
inline auto constexpr useFrequencyPenalty(bool usePenalty)#
-
inline auto constexpr useMinLength(bool useMinLen)#
-
inline auto constexpr useBanTokens(bool banTokens)#
-
inline auto constexpr useBanWords(bool banWords)#
-
inline auto constexpr useNoRepeatNgramSize(bool noRepeatNgramSize)#
-
inline auto constexpr useStopWords(bool stopWords)#
-
inline auto constexpr useMaxLengthStop(bool maxLengthStop)#
-
inline auto constexpr useExplicitEosStop(bool explicitEosStop)#
-
inline auto constexpr useMinP(bool useMinP)#
- inline auto constexpr useVariableBeamWidthSearch(
- bool useVariableBeamWidthSearch,
-
inline bool constexpr isAuto() const#
-
inline bool constexpr isTopK() const#
-
inline bool constexpr isTopP() const#
-
inline bool constexpr isTopKorTopP() const#
-
inline bool constexpr isTopKandTopP() const#
-
inline bool constexpr isBeamSearch() const#
-
inline bool constexpr isMedusa() const#
-
inline bool constexpr isLookahead() const#
-
inline bool constexpr isExplicitDraftTokens() const#
-
inline bool constexpr isExternalDraftTokens() const#
-
inline bool constexpr isEagle() const#
-
inline bool constexpr isUseTemperature() const#
-
inline bool constexpr isUsePresencePenalty() const#
-
inline bool constexpr isUseFrequencyPenalty() const#
-
inline bool constexpr isUseRepetitionPenalty() const#
-
inline bool constexpr isUseMinLength() const#
-
inline bool constexpr isUseOccurrencePenalty() const#
-
inline bool constexpr isUsePenalty() const#
-
inline bool constexpr isUseBanWords() const#
-
inline bool constexpr isUseNoRepeatNgramSize() const#
-
inline bool constexpr isUseBanTokens() const#
-
inline bool constexpr isUseStopWords() const#
-
inline bool constexpr isUseMaxLengthStop() const#
-
inline bool constexpr isUseExplicitEosStop() const#
-
inline bool constexpr isUseStopCriteria() const#
-
inline bool constexpr isUseMinP() const#
-
inline bool constexpr isUseVariableBeamWidthSearch() const#
-
inline bool operator==(DecodingMode const &other) const#
-
inline explicit constexpr DecodingMode(UnderlyingType state)#
-
inline constexpr UnderlyingType getState() const#
-
inline constexpr char const *getName() const#
公共静态函数
-
static inline auto constexpr Auto()#
未指定模式。配置将根据运行时第一个请求的束宽确定,如果 beamWidth == 1 则使用 TopKTopP,否则使用 BeamSearch。
-
static inline auto constexpr TopK()#
-
static inline auto constexpr TopP()#
-
static inline auto constexpr TopKTopP()#
-
static inline auto constexpr BeamSearch()#
-
static inline auto constexpr Medusa()#
-
static inline auto constexpr Lookahead()#
-
static inline auto constexpr ExplicitDraftTokens()#
-
static inline auto constexpr ExternalDraftTokens()#
-
static inline auto constexpr Eagle()#
私有函数
-
inline bool constexpr anyBitSet(UnderlyingType bits) const#
-
inline bool constexpr allBitSet(UnderlyingType bits) const#
- inline UnderlyingType constexpr setBitTo(
- UnderlyingType state,
- bool x,
私有成员
-
UnderlyingType mState = {}#
私有静态属性
-
static SizeType32 constexpr kNumFlags = {12}#
-
static UnderlyingType constexpr kUseRepetitionPenalties = {1u << 0}#
-
static UnderlyingType constexpr kUseFrequencyPenalties = {1u << 1}#
-
static UnderlyingType constexpr kUsePresencePenalties = {1u << 2}#
-
static UnderlyingType constexpr kUseTemperature = {1u << 3}#
-
static UnderlyingType constexpr kUseMinLength = {1u << 4}#
-
static UnderlyingType constexpr kUseBanWords = {1u << 5}#
-
static UnderlyingType constexpr kUseStopWords = {1u << 6}#
-
static UnderlyingType constexpr kUseMaxLengthStop = {1u << 7}#
-
static UnderlyingType constexpr kUseExplicitEosStop = {1u << 8}#
-
static UnderlyingType constexpr kUseNoRepeatNgramSize = {1u << 9}#
-
static UnderlyingType constexpr kUseMinP = {1u << 10}#
-
static UnderlyingType constexpr kUseVariableBeamWidthSearch = {1u << 11}#
-
static UnderlyingType constexpr kUseStandardStopCriteria = {kUseStopWords | kUseMaxLengthStop}#
-
static UnderlyingType constexpr kUseOccurrencePenalties{kUseRepetitionPenalties | kUseFrequencyPenalties | kUsePresencePenalties}#
-
static UnderlyingType constexpr kUsePenalties = {kUseOccurrencePenalties | kUseTemperature | kUseMinLength}#
-
static UnderlyingType constexpr kUseBanTokens = {kUseNoRepeatNgramSize | kUseBanWords}#
-
static UnderlyingType constexpr kAuto = {1u << (kNumFlags + 0)}#
-
static UnderlyingType constexpr kTopK = {1u << (kNumFlags + 1)}#
-
static UnderlyingType constexpr kTopP = {1u << (kNumFlags + 2)}#
-
static UnderlyingType constexpr kBeamSearch = {1u << (kNumFlags + 3)}#
-
static UnderlyingType constexpr kMedusa = {1u << (kNumFlags + 4)}#
-
static UnderlyingType constexpr kLookahead = {1u << (kNumFlags + 5)}#
-
static UnderlyingType constexpr kExplicitDraftTokens = {1u << (kNumFlags + 6)}#
-
static UnderlyingType constexpr kExternalDraftTokens = {1u << (kNumFlags + 7)}#
-
static UnderlyingType constexpr kEagle = {1u << (kNumFlags + 8)}#
-
static UnderlyingType constexpr kTopKTopP = {kTopK | kTopP}#
-
using UnderlyingType = uint32_t#
-
struct DisServingRequestStats#
- #include <types.h>
在分离式服务(disaggregated serving)中保存请求统计信息的结构体。
-
struct InflightBatchingStats#
- #include <types.h>
保存单次迭代的动态批处理(inflight batching)模型统计信息的结构体。
公有成员
-
SizeType32 numScheduledRequests#
已调度的请求数量。
-
SizeType32 numContextRequests#
上下文阶段的请求数量。
-
SizeType32 numGenRequests#
生成阶段的请求数量。
-
SizeType32 numPausedRequests#
已暂停的请求数量。
-
SizeType32 numCtxTokens#
本次迭代中的总上下文 tokens 数量。
-
SizeType32 microBatchId#
微批次(micro batch)的索引。
-
float avgNumDecodedTokensPerIter#
每次迭代中每个请求平均解码的 tokens 数量。
-
SizeType32 numScheduledRequests#
-
struct IterationStats#
- #include <types.h>
保存单次迭代统计信息的结构体。
公有成员
-
std::string timestamp#
本次迭代的结束时间。
-
IterationType iter#
迭代 ID。
-
double iterLatencyMS#
迭代延迟(毫秒)
-
double newActiveRequestsQueueLatencyMS#
本次迭代中变为活动状态的请求在队列中花费的总时间(毫秒)
-
SizeType32 numNewActiveRequests#
新获取的活动请求数量。
-
SizeType32 numActiveRequests#
活动请求数量。
-
SizeType32 numQueuedRequests#
队列中的请求数量。
-
SizeType32 numCompletedRequests#
本次迭代中完成的请求数量。
-
SizeType32 maxNumActiveRequests#
最大活动请求数量。
-
SizeType32 maxBatchSizeStatic#
传递给执行器的静态最大批处理大小。
-
SizeType32 maxBatchSizeTunerRecommended#
由动态调优器根据输入统计信息生成的批处理大小。
-
SizeType32 maxBatchSizeRuntime#
@brief maxBatchSizeStatic 和 maxBatchSizeRuntimeUpperbound 中的最小值
-
SizeType32 maxNumTokensStatic#
@brief 传递给执行器的静态最大 token 数量
-
SizeType32 maxNumTokensTunerRecommended#
@brief 由动态调优器根据输入统计信息生成的最大 token 数量
-
SizeType32 maxNumTokensRuntime#
@brief 运行时最大 token 数量
-
size_t gpuMemUsage#
GPU 内存使用量(字节)。
-
size_t cpuMemUsage#
CPU 内存使用量(字节)。
-
size_t pinnedMemUsage#
锁定内存使用量(字节)。
-
std::optional<KvCacheStats> kvCacheStats#
KV 缓存特有的统计信息。
-
std::optional<KvCacheStats> crossKvCacheStats#
交叉 KV 缓存特有的统计信息。
-
std::optional<StaticBatchingStats> staticBatchingStats#
静态批处理特有的统计信息。
-
std::optional<InflightBatchingStats> inflightBatchingStats#
运行时批处理特有的统计信息。
-
std::string timestamp#
-
struct KvCacheStats#
- #include <types.h>
包含 KV 缓存管理器统计信息的结构体。
公有成员
-
SizeType32 maxNumBlocks#
最大块数。
-
SizeType32 freeNumBlocks#
空闲块数。
-
SizeType32 usedNumBlocks#
已用块数。
-
SizeType32 tokensPerBlock#
每块 token 数。
-
SizeType32 allocTotalBlocks#
已分配的总块数。
-
SizeType32 allocNewBlocks#
新分配的块数。
-
SizeType32 reusedBlocks#
重用块数。
-
SizeType32 missedBlocks#
未重用块数。
-
float cacheHitRate#
测量 KV 缓存的重用率。cacheHitRate = reusedBlocks / (reusedBlocks + missedBlocks)。
-
SizeType32 maxNumBlocks#
-
struct RequestPerfMetrics#
- #include <types.h>
包含请求统计信息的结构体。
公共类型
-
using TimePoint = std::chrono::time_point<std::chrono::steady_clock>#
公有成员
-
TimingMetrics timingMetrics#
-
KvCacheMetrics kvCacheMetrics#
-
SpeculativeDecodingMetrics speculativeDecoding#
-
std::optional<IterationType> firstIter#
请求被处理的第一个迭代。
-
std::optional<IterationType> lastIter#
生成 token 的最后一个迭代。
-
std::optional<IterationType> iter#
当前迭代。
-
struct KvCacheMetrics#
公有成员
-
SizeType32 numTotalAllocatedBlocks = {0}#
已分配的总块数。
-
SizeType32 numNewAllocatedBlocks = {0}#
新分配的块数。
-
SizeType32 numReusedBlocks = {0}#
重用块数。
-
SizeType32 numMissedBlocks = {0}#
未重用块数。
-
SizeType32 numTotalAllocatedBlocks = {0}#
-
struct SpeculativeDecodingMetrics#
公有成员
-
SizeType32 totalAcceptedDraftTokens = {0}#
已接受的草稿 token 总数。
-
SizeType32 totalDraftTokens = {0}#
请求中使用的草稿 token 总数。
-
SizeType32 totalAcceptedDraftTokens = {0}#
-
using TimePoint = std::chrono::time_point<std::chrono::steady_clock>#
-
struct RequestStats#
- #include <types.h>
包含单个请求统计信息的结构体。
公有成员
-
RequestStage stage#
请求当前所处的阶段。
-
SizeType32 contextPrefillPosition#
如果使用分块上下文,则表示当前的上下文预填充位置。
-
SizeType32 numGeneratedTokens#
迄今为止生成的 token 数量。
-
float avgNumDecodedTokensPerIter#
每个迭代中解码 token 的平均数量。对于预测解码,该值 >= 1。
-
bool scheduled#
请求是否已调度到当前迭代。
-
bool paused#
请求是否在当前迭代中因资源不足(例如 KV 缓存块耗尽)而被暂停。
-
std::optional<DisServingRequestStats> disServingStats#
分解式服务特有的统计信息。
-
SizeType32 allocTotalBlocksPerRequest#
每个请求已分配的总块数。
-
SizeType32 allocNewBlocksPerRequest#
每个请求新分配的块数。
-
SizeType32 reusedBlocksPerRequest#
每个请求重用块的数量。
-
SizeType32 missedBlocksPerRequest#
每个请求丢失块的数量。
-
RequestStage stage#
-
struct RequestStatsPerIteration#
- #include <types.h>
一个结构体,包含一个迭代中所有请求的统计信息。
-
struct StaticBatchingStats#
- #include <types.h>
一个结构体,包含单个迭代中静态批处理模型的统计信息。
公有成员
-
SizeType32 numScheduledRequests#
已调度的请求数量。
-
SizeType32 numContextRequests#
上下文阶段的请求数量。
-
SizeType32 numCtxTokens#
本次迭代中的总上下文 tokens 数量。
-
SizeType32 numGenTokens#
此迭代中总共要生成的 token 数量。
-
SizeType32 emptyGenSlots#
未使用的生成 token 槽的总数。
-
SizeType32 numScheduledRequests#
-
template<typename T, bool = false>
struct TypeTraits# - #include <types.h>
用于将 C++ 数据类型转换为
TrtLmmDataType
。
-
template<>
struct TypeTraits<bool>#
-
template<>
struct TypeTraits<float>#
-
template<>
struct TypeTraits<half>#
-
template<>
struct TypeTraits<std::int32_t>#
-
template<>
struct TypeTraits<std::int64_t>#
-
template<>
struct TypeTraits<std::int8_t>#
-
template<>
struct TypeTraits<std::uint8_t>#
-
using SizeType32 = std::int32_t#
-
namespace runtime#
-
namespace executor
cacheCommunicator.h#
-
namespace tensorrt_llm
-
namespace batch_manager
-
namespace executor
-
namespace kv_cache
-
class Connection#
公有函数
-
virtual ~Connection() = default#
- virtual void send(
- DataContext const &ctx,
- void const *data,
- size_t size,
- virtual void recv(
- DataContext const &ctx,
- DataContext const &ctx,
- size_t size,
-
size_t size
-
virtual ~Connection() = default#
-
) const = 0#
公有函数
-
inline virtual bool isThreadSafe() const noexcept#
- class ConnectionManager#
- DataContext const &ctx,
- DataContext const &ctx,
- size_t size,
- virtual ~ConnectionManager() = default#
- virtual Connection const *recvConnect(,
-
DataContext const &ctx
-
inline virtual bool isThreadSafe() const noexcept#
-
void *data
-
私有成员
-
virtual std::vector<Connection const*> getConnections(
-
virtual std::vector<Connection const*> getConnections(
-
class Connection#
-
namespace kv_cache
-
namespace batch_manager
CommState const &state
-
namespace tensorrt_llm
-
namespace executor
-
) const = 0#
-
class Tensor#
公共类型
-
using CudaStreamPtr = std::shared_ptr<runtime::CudaStream>#
公有函数
-
Tensor copyToCpu(Tensor::CudaStreamPtr stream = nullptr) const#
-
Tensor copyToPinned(Tensor::CudaStreamPtr stream = nullptr) const#
-
Tensor copyToPooledPinned(Tensor::CudaStreamPtr stream = nullptr) const#
-
Tensor copyToManaged(Tensor::CudaStreamPtr stream = nullptr) const#
-
Tensor copyToGpu(Tensor::CudaStreamPtr stream) const#
-
Tensor() noexcept = default#
-
~Tensor() = default#
-
void *getData()#
返回底层数组的指针。
-
void const *getData() const#
返回底层数组的指针。
-
MemoryType getMemoryType() const#
返回缓冲的内存类型。
-
std::size_t getSize() const#
返回张量中的元素数量。
-
std::size_t getSizeInBytes() const#
返回张量的大小(字节)。
-
void setZero(CudaStreamPtr stream = nullptr)#
将整个内存区域清零。
- 参数:
stream – 如果内存类型是 GPU,则必须是有效的 CUDA 流。
-
void setFrom(Tensor const &other, CudaStreamPtr stream = nullptr)#
从另一个张量复制数据和形状。
- 参数:
other – 要从中复制的张量。
stream – 如果内存类型是 GPU,则必须是有效的 CUDA 流。
-
inline explicit operator bool() const#
公共静态函数
-
static Tensor cpu(DataType dataType, Shape shape = {})#
使用给定的形状和数据类型分配一个 CPU 张量。
- 参数:
shape – 张量的形状。
dataType – 张量的数据类型。
-
static Tensor pinned(DataType dataType, Shape shape = {})#
使用给定的形状和数据类型在锁定内存中分配一个 CPU 张量。
- 参数:
shape – 张量的形状。
dataType – 张量的数据类型。
-
static Tensor pooledPinned(DataType dataType, Shape shape = {})#
使用给定的形状和数据类型在池化锁定内存中分配一个 CPU 张量。
- 参数:
shape – 张量的形状。
dataType – 张量的数据类型。
-
static Tensor managed(DataType dataType, Shape shape = {})#
使用给定的形状和数据类型在托管内存 (UVM) 中分配一个张量。
- 参数:
shape – 张量的形状。
dataType – 张量的数据类型。
- static Tensor gpu(
- DataType dataType,
- CudaStreamPtr stream,
- Shape shape = {},
在特定的 CUDA 流上使用给定的形状和数据类型分配一个 GPU 张量。
- 参数:
shape – 张量的形状。
stream – 指定在哪个 CUDA 流上为 GPU 内存分配张量。
dataType – 张量的数据类型。
-
template<typename T>
static inline Tensor gpu( - CudaStreamPtr stream,
- Shape shape = {},
-
static Tensor of(DataType dataType, void *data, Shape shape)#
将数据指针包装成张量,但不获取所有权。
- 参数:
shape – 张量的形状。
dataType – 张量的数据类型。
stream – 指定在哪个 CUDA 流上为 GPU 内存分配张量。
-
using CudaStreamPtr = std::shared_ptr<runtime::CudaStream>#
-
) const = 0#
-
namespace runtime
-
namespace executor
version.h#
-
namespace tensorrt_llm
-
namespace executor
变量
-
static auto constexpr kTensorRtLlmVersion = "0.20.0rc0"#
-
static auto constexpr kTensorRtLlmVersion = "0.20.0rc0"#
-
namespace executor
dataTransceiverState.h#
-
namespace tensorrt_llm
-
namespace executor
-
class DataTransceiverState#
公有函数
-
DataTransceiverState() = default#
- inline DataTransceiverState(
- kv_cache::CacheState cacheState,
- kv_cache::CommState commState,
-
inline void setCacheState(kv_cache::CacheState state)#
- inline std::optional<kv_cache::CacheState> const &getCacheState(
- inline bool operator==(
- DataTransceiverState const &other,
-
inline std::string toString() const#
私有成员
-
std::optional<kv_cache::CacheState> mCacheState#
友元
- 友元类 Serialization
-
DataTransceiverState() = default#
-
namespace kv_cache
-
class CacheState#
-
公有函数
- inline CacheState(
- ModelConfig modelConfig,
- runtime::WorldConfig const &worldConfig,
- nvinfer1::DataType dataType,
- AttentionType attentionType = AttentionType::kDEFAULT,
- int kvFactor = 2,
- inline CacheState(
- std::vector<SizeType32> nbKvHeadPerLayer,
- SizeType32 sizePerHead,
- SizeType32 tokensPerBlock,
- SizeType32 tensorParallelism,
- SizeType32 pipelineParallelism,
- nvinfer1::DataType dataType,
- AttentionType attentionType = AttentionType::kDEFAULT,
- int kvFactor = 2,
- bool enableAttentionDP = false,
- int DPrank = 0,
- int DPsize = 0,
- inline CacheState(
- SizeType32 nbAttentionLayers,
- SizeType32 nbKvHeads,
- SizeType32 sizePerHead,
- SizeType32 tokensPerBlock,
- SizeType32 tensorParallelism,
- SizeType32 pipelineParallelism,
- nvinfer1::DataType dataType,
- AttentionType attentionType = AttentionType::kDEFAULT,
- int kvFactor = 2,
- bool enableAttentionDP = false,
- int DPrank = 0,
- int DPsize = 0,
- inline bool operator==(
- kv_cache::CacheState const &other,
-
inline ModelConfig const &getModelConfig() const#
-
inline ParallelConfig const &获取并行配置() const#
-
inline AttentionConfig const &获取注意力配置() const#
-
inline std::string 转换为字符串() const#
友元
- 友元 类 tensorrt_llm::executor::Serialization
-
结构体 AttentionConfig#
公有函数
-
inline 注意力配置(AttentionType attention类型, int kv因子)#
-
inline 注意力配置(AttentionType attention类型, int kv因子)#
-
结构体 ModelConfig#
公有函数
-
inline bool operator==(ModelConfig const &其他) const noexcept#
-
inline bool operator==(ModelConfig const &其他) const noexcept#
-
结构体 ParallelConfig#
公有函数
-
inline bool operator==(ParallelConfig const &其他) const noexcept#
公有成员
-
SizeType32 m张量并行度#
-
SizeType32 m流水线并行度#
-
bool m启用注意力数据并行#
-
SizeType32 m数据并行等级#
-
SizeType32 m数据并行大小#
-
inline bool operator==(ParallelConfig const &其他) const noexcept#
-
类 CommState#
公有函数
-
通信状态() = default#
- inline explicit 通信状态(
- std::vector<SizeType32> 等级,
- int 自身索引 = -1,
- inline explicit 通信状态(
- std::vector<SocketState> socket状态,
- int 自身索引 = -1,
-
inline 通信状态(std::uint16_t 端口, std::string ip)#
-
inline bool 是Mpi状态() const noexcept#
-
inline bool 是Socket状态() const noexcept#
-
inline std::vector<SocketState> const &获取Socket状态() const#
-
inline int 获取自身索引() const noexcept#
-
inline std::string 转换为字符串() const#
友元
- 友元 类 tensorrt_llm::executor::Serialization
-
通信状态() = default#
-
结构体 MpiState#
-
公有成员
-
std::vector<SizeType32> m等级#
-
std::vector<SizeType32> m等级#
-
结构体 SocketState#
公有函数
-
inline bool operator==(SocketState const &other) const noexcept#
-
inline std::string toString() const#
-
inline bool operator==(SocketState const &other) const noexcept#
-
class CacheState#
-
class DataTransceiverState#
-
namespace executor