Skip to content

< Back


BatchedExecutor

Namespace: LLama.Batched

A batched executor that can infer multiple separate "conversations" simultaneously.

1
public sealed class BatchedExecutor : System.IDisposable

Inheritance ObjectBatchedExecutor
Implements IDisposable
Attributes NullableContextAttribute, NullableAttribute

Properties

Context

The LLamaContext this executor is using

1
public LLamaContext Context { get; }

Property Value

LLamaContext

Model

The LLamaWeights this executor is using

1
public LLamaWeights Model { get; }

Property Value

LLamaWeights

BatchedTokenCount

Get the number of tokens in the batch, waiting for BatchedExecutor.Infer(CancellationToken) to be called

1
public int BatchedTokenCount { get; }

Property Value

Int32

BatchQueueCount

Number of batches in the queue, waiting for BatchedExecutor.Infer(CancellationToken) to be called

1
public int BatchQueueCount { get; }

Property Value

Int32

IsDisposed

Check if this executor has been disposed.

1
public bool IsDisposed { get; private set; }

Property Value

Boolean

Constructors

BatchedExecutor(LLamaWeights, IContextParams)

Create a new batched executor

1
public BatchedExecutor(LLamaWeights model, IContextParams contextParams)

Parameters

model LLamaWeights
The model to use

contextParams IContextParams
Parameters to create a new context

Methods

Create()

Start a new Conversation

1
public Conversation Create()

Returns

Conversation

Load(String)

Load a conversation that was previously saved to a file. Once loaded the conversation will need to be prompted.

1
public Conversation Load(string filepath)

Parameters

filepath String

Returns

Conversation

Exceptions

ObjectDisposedException

Load(State)

Load a conversation that was previously saved into memory. Once loaded the conversation will need to be prompted.

1
public Conversation Load(State state)

Parameters

state State

Returns

Conversation

Exceptions

ObjectDisposedException

Infer(CancellationToken)

Run inference for all conversations in the batch which have pending tokens.

If the result is NoKvSlot then there is not enough memory for inference, try disposing some conversation threads and running inference again.

1
public Task<DecodeResult> Infer(CancellationToken cancellation)

Parameters

cancellation CancellationToken

Returns

Task<DecodeResult>

Dispose()

1
public void Dispose()

< Back