File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
src/evaluator/LlamaContext Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export class LlamaContext {
7474 flashAttention = _model . defaultContextFlashAttention ,
7575 threads,
7676 batching : {
77- dispatchSchedule : batchingDispatchSchedule = "nextTick " ,
77+ dispatchSchedule : batchingDispatchSchedule = "nextCycle " ,
7878 itemPrioritizationStrategy : batchingItemsPrioritizationStrategy = "maximumParallelism"
7979 } = { } ,
8080 performanceTracking = false ,
@@ -675,10 +675,19 @@ export class LlamaContext {
675675
676676 if ( this . _queuedDecodeSequenceIds . size === this . _totalSequences )
677677 dispatch ( ) ;
678- if ( dispatchSchedule === "nextTick" )
679- setTimeout ( dispatch , 0 ) ;
680- else
678+ if ( dispatchSchedule === "nextCycle" ) {
679+ if ( typeof setImmediate === "function" )
680+ setImmediate ( dispatch ) ;
681+ else
682+ setTimeout ( dispatch , 0 ) ;
683+ } else if ( typeof dispatchSchedule === "function" )
681684 dispatchSchedule ( dispatch ) ;
685+ else {
686+ if ( typeof setImmediate === "function" )
687+ setImmediate ( dispatch ) ;
688+ else
689+ setTimeout ( dispatch , 0 ) ;
690+ }
682691 }
683692
684693 /** @internal */
Original file line number Diff line number Diff line change @@ -215,12 +215,12 @@ export type LlamaContextSequenceRepeatPenalty = {
215215export type BatchingOptions = {
216216 /**
217217 * The strategy used to dispatch items to be processed when there are items pending to be processed.
218- * - **`"nextTick "`** - dispatch the items on the next event loop tick .
218+ * - **`"nextCycle "`** - dispatch the items on the next event loop cycle .
219219 * You can provide a custom function to define a custom dispatch schedule.
220220 *
221- * Defaults to `"nextTick "`.
221+ * Defaults to `"nextCycle "`.
222222 */
223- dispatchSchedule ?: "nextTick " | CustomBatchingDispatchSchedule ,
223+ dispatchSchedule ?: "nextCycle " | CustomBatchingDispatchSchedule ,
224224
225225 /**
226226 * The strategy used to prioritize pending items to be processed.
You can’t perform that action at this time.
0 commit comments