Skip to content

Commit 0209e00

Browse files
committed
refactor: colocate sampled mtp state
1 parent 8272f4e commit 0209e00

1 file changed

Lines changed: 51 additions & 51 deletions

File tree

examples/batch-processing/server.py

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,46 +1214,6 @@ class MTPDraftProvider(DraftProvider):
12141214
batched_draft = True
12151215
sampled_batch_draft = True
12161216

1217-
@dataclass(frozen=True)
1218-
class SampledContextRow:
1219-
seq_id: int
1220-
draft_pos: int
1221-
token: int
1222-
source_row: Optional[int]
1223-
1224-
@dataclass(frozen=True)
1225-
class SampledPendingRow:
1226-
update_index: int
1227-
seq_id: int
1228-
draft_pos: int
1229-
token: int
1230-
source_row: int
1231-
1232-
@dataclass(frozen=True)
1233-
class SampledOutput:
1234-
update_index: int
1235-
seq_id: int
1236-
output_index: int
1237-
keep_len: int
1238-
ready_pos: int
1239-
1240-
@dataclass(frozen=True)
1241-
class SampledBatchUpdate:
1242-
seq_id: int
1243-
start_pos: int
1244-
tokens: List[int]
1245-
row_indices: List[int]
1246-
target_count: int
1247-
sample_index: int
1248-
pending_token: Optional[int]
1249-
max_tokens: Optional[int]
1250-
1251-
@dataclass
1252-
class SampledBatchPlan:
1253-
context_rows: List["MTPDraftProvider.SampledContextRow"]
1254-
pending_rows: List["MTPDraftProvider.SampledPendingRow"]
1255-
sample_pending_index_by_update: Dict[int, int]
1256-
12571217
@dataclass
12581218
class DraftManyState:
12591219
result_index: int
@@ -1266,17 +1226,6 @@ class DraftManyState:
12661226
embedding: np.ndarray
12671227
cache_key: Tuple[Tuple[int, ...], int]
12681228

1269-
@dataclass
1270-
class SampledDraftState:
1271-
update_index: int
1272-
seq_id: int
1273-
keep_len: int
1274-
pos: int
1275-
token: int
1276-
drafted: List[int]
1277-
n_predict: int
1278-
embedding: np.ndarray
1279-
12801229
def __init__(
12811230
self,
12821231
*,
@@ -1983,6 +1932,57 @@ def draft_many(
19831932
)
19841933
return results
19851934

1935+
@dataclass(frozen=True)
1936+
class SampledContextRow:
1937+
seq_id: int
1938+
draft_pos: int
1939+
token: int
1940+
source_row: Optional[int]
1941+
1942+
@dataclass(frozen=True)
1943+
class SampledPendingRow:
1944+
update_index: int
1945+
seq_id: int
1946+
draft_pos: int
1947+
token: int
1948+
source_row: int
1949+
1950+
@dataclass(frozen=True)
1951+
class SampledOutput:
1952+
update_index: int
1953+
seq_id: int
1954+
output_index: int
1955+
keep_len: int
1956+
ready_pos: int
1957+
1958+
@dataclass(frozen=True)
1959+
class SampledBatchUpdate:
1960+
seq_id: int
1961+
start_pos: int
1962+
tokens: List[int]
1963+
row_indices: List[int]
1964+
target_count: int
1965+
sample_index: int
1966+
pending_token: Optional[int]
1967+
max_tokens: Optional[int]
1968+
1969+
@dataclass
1970+
class SampledBatchPlan:
1971+
context_rows: List["MTPDraftProvider.SampledContextRow"]
1972+
pending_rows: List["MTPDraftProvider.SampledPendingRow"]
1973+
sample_pending_index_by_update: Dict[int, int]
1974+
1975+
@dataclass
1976+
class SampledDraftState:
1977+
update_index: int
1978+
seq_id: int
1979+
keep_len: int
1980+
pos: int
1981+
token: int
1982+
drafted: List[int]
1983+
n_predict: int
1984+
embedding: np.ndarray
1985+
19861986
def _target_row_count(
19871987
self,
19881988
updates: Sequence["MTPDraftProvider.SampledBatchUpdate"],

0 commit comments

Comments
 (0)