File tree Expand file tree Collapse file tree
src/evaluator/LlamaContext Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1407,12 +1407,13 @@ export class LlamaContextSequence {
14071407 if ( deletionSuccessful )
14081408 return ;
14091409
1410- const restoreCheckpointIndex = this . _contextTokens . length - 1 ;
1411- const existingCheckpoint = this . _checkpoints . getLastCheckpoint ( restoreCheckpointIndex ) ;
1410+ let restoreCheckpointIndex = this . _contextTokens . length - 1 ;
1411+ const existingCheckpoint = this . _checkpoints . getLastCheckpoint ( restoreCheckpointIndex , this . contextSize ) ;
14121412 if ( existingCheckpoint != null &&
14131413 restoreCheckpointIndex >= existingCheckpoint . minPos &&
1414- restoreCheckpointIndex <= existingCheckpoint . maxPos
1414+ existingCheckpoint . maxPos <= this . contextSize
14151415 ) {
1416+ restoreCheckpointIndex = Math . min ( restoreCheckpointIndex , existingCheckpoint . maxPos ) ;
14161417 const restoredSuccessfully = await this . _context . _ctx . restoreCheckpoint ( existingCheckpoint , restoreCheckpointIndex ) ;
14171418 if ( restoredSuccessfully ) {
14181419 const tokensToEvaluate = this . _contextTokens . slice ( restoreCheckpointIndex + 1 ) ;
Original file line number Diff line number Diff line change @@ -41,13 +41,13 @@ export class LlamaContextSequenceCheckpoints {
4141 return false ;
4242 }
4343
44- public getLastCheckpoint ( restoreIndex : number ) {
44+ public getLastCheckpoint ( restoreIndex : number , contextSize : number ) {
4545 if ( restoreIndex <= 0 )
4646 return null ;
4747
4848 for ( let i = this . _checkpoints . length - 1 ; i >= 0 ; i -- ) {
4949 const [ , checkpoint ] = this . _checkpoints [ i ] ! ;
50- if ( restoreIndex < = checkpoint . maxPos && restoreIndex >= checkpoint . minPos )
50+ if ( restoreIndex > = checkpoint . minPos && checkpoint . maxPos <= contextSize )
5151 return checkpoint ;
5252 else if ( restoreIndex < checkpoint . minPos )
5353 return null ;
Original file line number Diff line number Diff line change @@ -6,9 +6,7 @@ export default defineConfig({
66 ...configDefaults . exclude ,
77 "./llama"
88 ] ,
9- pool : ( process . platform === "darwin" && process . arch === "arm64" )
10- ? "threads"
11- : "forks" ,
9+ pool : "forks" ,
1210 maxWorkers : 1 ,
1311 maxConcurrency : 1 ,
1412 snapshotSerializers : [
You can’t perform that action at this time.
0 commit comments