MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / copy_sequence

Method copy_sequence

examples/server/server.py:2415–2458  ·  view source on GitHub ↗
(
        self,
        source_seq_id: int,
        dest_seq_id: int,
        p0: int,
        p1: int,
    )

Source from the content-addressed store, hash-verified

2413 self.ready[seq_id] = False
2414
2415 def copy_sequence(
2416 self,
2417 source_seq_id: int,
2418 dest_seq_id: int,
2419 p0: int,
2420 p1: int,
2421 ) -> None:
2422 if (
2423 source_seq_id < 0
2424 or source_seq_id >= self.n_seq_max
2425 or dest_seq_id < 0
2426 or dest_seq_id >= self.n_seq_max
2427 ):
2428 return
2429 if not self.is_mem_shared:
2430 llama_cpp.llama_memory_seq_cp(
2431 self.mem,
2432 source_seq_id,
2433 dest_seq_id,
2434 p0,
2435 p1,
2436 )
2437 source_ready_pos = self.ready_pos[source_seq_id]
2438 copied_full_ready_state = p1 < 0 or p1 == source_ready_pos
2439 if self.ready[source_seq_id] and copied_full_ready_state:
2440 self.pending_h[dest_seq_id] = self.pending_h[source_seq_id]
2441 self.verify_h[dest_seq_id] = self.verify_h[source_seq_id].copy()
2442 self.verify_h_pos[dest_seq_id] = list(self.verify_h_pos[source_seq_id])
2443 self.verify_h_rows[dest_seq_id] = self.verify_h_rows[source_seq_id]
2444 self.ready[dest_seq_id] = True
2445 self.ready_pos[dest_seq_id] = source_ready_pos
2446 self.context_pos[dest_seq_id] = min(
2447 self.context_pos[source_seq_id],
2448 source_ready_pos,
2449 )
2450 return
2451
2452 self.pending_h[dest_seq_id].fill(0.0)
2453 self.verify_h[dest_seq_id] = np.empty((0, self.n_embd), dtype=np.float32)
2454 self.verify_h_pos[dest_seq_id] = []
2455 self.verify_h_rows[dest_seq_id] = 0
2456 self.ready[dest_seq_id] = False
2457 self.ready_pos[dest_seq_id] = 0
2458 self.context_pos[dest_seq_id] = 0
2459
2460
2461class CompletionRequestCancelledError(RuntimeError):

Callers

nothing calls this directly

Calls 1

copyMethod · 0.45

Tested by

no test coverage detected