Skip to content

Commit 549b7a7

Browse files
vcruz305ashhart
authored andcommitted
feat: Flash Next CUDA can keep its KV cache in int8
--kv-dtype int8 stores each attention layer's keys and values as 8-bit codes with one fp16 scale per 32 values, the same arithmetic as ExLlamaV3's -cq 8 (H32 rotation, midpoint grid). The default stays bf16. The MLX path and the other CUDA families refuse anything else. Indexer keys and pooled block keys stay bf16. The query rides the rotation, so a group is read as stored.
1 parent 7dba55b commit 549b7a7

9 files changed

Lines changed: 318 additions & 47 deletions

File tree

‎src/tensorfold/cli.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def build_parser() -> argparse.ArgumentParser:
9393
help="with --tp 2: this machine's rank; rank 0 serves HTTP, rank 1 follows it")
9494
cuda.add_argument("--master", default="", help="with --tp 2: rank 0's address on the link between the machines")
9595
cuda.add_argument("--master-port", type=int, default=29551, help="with --tp 2: rank 0's rendezvous port")
96+
cuda.add_argument("--kv-dtype", choices=("bf16", "int8"), default="bf16",
97+
help="KV cache: bf16 (the default), or int8 = keys and values quantized to 8 bits with "
98+
"one fp16 scale per 32 values (1.88x smaller; changes the output, families vary)")
9699
serve.set_defaults(func=cmd_serve)
97100

98101
pull = commands.add_parser("pull", help="download models (or draft models) from Hugging Face")
@@ -321,6 +324,13 @@ def _serve_cuda(args: argparse.Namespace, family: Any, model_dir: Path, context:
321324
drafter = "" if args.no_drafts else _drafter(family, args.drafter)
322325
options: dict[str, Any] = {"drafter": drafter, "tp": int(args.tp), "rank": int(args.rank), "master": args.master,
323326
"master_port": int(args.master_port), "no_drafts": bool(args.no_drafts)}
327+
kv_dtype = getattr(args, "kv_dtype", "bf16")
328+
if kv_dtype != "bf16":
329+
supported = getattr(family.package, "CUDA_KV_DTYPES", ("bf16",))
330+
if kv_dtype not in supported:
331+
raise ValueError(f"{family.title} on CUDA serves a {' or '.join(supported)} KV cache, "
332+
f"not --kv-dtype {kv_dtype}")
333+
options["kv_dtype"] = kv_dtype
324334
if args.mtp_drafts is not None:
325335
options["mtp_drafts"] = int(args.mtp_drafts)
326336
if args.ple_on_ssd:
@@ -391,6 +401,9 @@ def cmd_serve(args: argparse.Namespace) -> int:
391401
if args.ple_on_ssd and not hasattr(family.package, "ple_bytes"):
392402
raise ValueError(f"--ple-on-ssd: {family.title} has no n-gram (PLE) tables to read from SSD")
393403
backend = _backend(args.backend, family)
404+
if getattr(args, "kv_dtype", "bf16") != "bf16" and backend != "cuda":
405+
raise ValueError(f"--kv-dtype {args.kv_dtype} is a CUDA engine option: the MLX path caches keys and "
406+
"values as bf16")
394407
families.require_readable(family, families.read_config(config_dir), backend)
395408
_note_untested(family, args.model)
396409
required_files = getattr(family.package, "REQUIRED_FILES", {}).get(args.model, ())

‎src/tensorfold/families/qwen4_exp/__init__.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,18 @@ def kernel_version(model: Any) -> str:
115115

116116
# the CUDA engine's kernels read MLX affine weights of this (bits, group size)
117117
CUDA_QUANTIZATION = (4, 32)
118+
# the KV cache dtypes the CUDA engine can allocate (``--kv-dtype``): int8 is the quantized cache
119+
CUDA_KV_DTYPES = ("bf16", "int8")
118120

119121
def cuda_engine(model_dir: str | Path, *, drafter: str = "", tp: int = 1, rank: int = 0, master: str = "",
120122
master_port: int = 29551, no_drafts: bool = False, mtp_drafts: int | None = None,
121-
context: int | None = None, ple_on_ssd: bool = False, **options: Any):
122-
"""The CUDA engine: MTP chains verified exactly on one GPU or two (``tp=2``; start rank 1 first)."""
123+
context: int | None = None, ple_on_ssd: bool = False, kv_dtype: str = "bf16",
124+
**options: Any):
125+
"""The CUDA engine: MTP chains verified exactly on one GPU or two (``tp=2``; start rank 1 first).
126+
127+
``kv_dtype``: "bf16" (the default) or "int8", the attention caches quantized to 8 bits with one fp16 scale
128+
per 32 values (1.88x smaller; see docs/recipes/qwen3.8-flash-next.md and docs/recipes/cuda.md).
129+
"""
123130

124131
from tensorfold.cuda.exl3.format import is_exl3
125132

@@ -130,7 +137,9 @@ def cuda_engine(model_dir: str | Path, *, drafter: str = "", tp: int = 1, rank:
130137
raise ValueError(f"{TITLE} drafts with its own MTP head on CUDA: a separate draft model does not apply")
131138
from .cuda import DEPTH
132139
from .cuda.engine import FlashNextEngine
140+
from .cuda.kvcache import check as check_kv
133141

142+
check_kv(kv_dtype) # refuse an unknown cache before any weight is read
134143
depth = 0 if no_drafts else DEPTH if mtp_drafts is None else int(mtp_drafts)
135144
if depth and not has_mtp(Path(model_dir)):
136145
raise ValueError(f"this checkpoint has no MTP head, which {TITLE}'s CUDA engine drafts with ({MODELS[0]} "
@@ -139,4 +148,4 @@ def cuda_engine(model_dir: str | Path, *, drafter: str = "", tp: int = 1, rank:
139148
return FlashNextEngine(Path(model_dir), depth=depth, max_len=context,
140149
context_explicit=options.get("context_explicit"), tp=int(tp), rank=int(rank),
141150
master=master, port=int(master_port), streams=max(1, int(options.get("parallel") or 1)),
142-
ple_on_ssd=ple_on_ssd)
151+
ple_on_ssd=ple_on_ssd, kv_dtype=kv_dtype)

‎src/tensorfold/families/qwen4_exp/cuda/attention.py‎

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import triton
77
import triton.language as tl
88

9+
from .kvcache import dequant_group, h32
10+
911
CHUNK = 512
1012
TILE = 64
1113

@@ -25,9 +27,9 @@ def _tile(q, k, v, m, l, o, valid, scale: tl.constexpr):
2527

2628

2729
@triton.jit
28-
def _chunks(Q, KC, VC, POS0, PO, PM, PL, IDS, NKR, SPR,
30+
def _chunks(Q, KC, VC, KSC, VSC, POS0, PO, PM, PL, IDS, NKR, SPR,
2931
H: tl.constexpr, HK: tl.constexpr, D: tl.constexpr, G: tl.constexpr, CH: tl.constexpr,
30-
NCH: tl.constexpr, SCALE: tl.constexpr, IDW: tl.constexpr, QSA: tl.constexpr):
32+
NCH: tl.constexpr, SCALE: tl.constexpr, IDW: tl.constexpr, QSA: tl.constexpr, KVQ: tl.constexpr):
3133
r = tl.program_id(0)
3234
hk = tl.program_id(1)
3335
c = tl.program_id(2)
@@ -51,8 +53,21 @@ def _chunks(Q, KC, VC, POS0, PO, PM, PL, IDS, NKR, SPR,
5153
if QSA:
5254
if sparse:
5355
ki = tl.load(IDS + r * IDW + ki, mask=valid, other=0)
54-
kk = tl.load(KC + (ki[:, None].to(tl.int64) * HK + hk) * D + d[None, :], mask=valid[:, None], other=0.0)
55-
vv = tl.load(VC + (ki[:, None].to(tl.int64) * HK + hk) * D + d[None, :], mask=valid[:, None], other=0.0)
56+
off = (ki[:, None].to(tl.int64) * HK + hk) * D + d[None, :]
57+
if KVQ:
58+
# int8 codes + one fp16 scale per 32 values: dequantize the tile before the dot (the keys are
59+
# stored rotated; the query is rotated by the write path, so no rotation is undone here)
60+
gs = tl.arange(0, D // 32)
61+
sgc = (ki[:, None].to(tl.int64) * HK + hk) * (D // 32) + gs[None, :]
62+
kc = tl.load(KC + off, mask=valid[:, None], other=0)
63+
sc = tl.load(KSC + sgc, mask=valid[:, None], other=0.0)
64+
kk = dequant_group(tl.reshape(kc, (64, D)), sc, M=64, W=D)
65+
vc = tl.load(VC + off, mask=valid[:, None], other=0)
66+
sv = tl.load(VSC + sgc, mask=valid[:, None], other=0.0)
67+
vv = dequant_group(tl.reshape(vc, (64, D)), sv, M=64, W=D)
68+
else:
69+
kk = tl.load(KC + off, mask=valid[:, None], other=0.0)
70+
vv = tl.load(VC + off, mask=valid[:, None], other=0.0)
5671
m, l, o = _tile(q, kk, vv, m, l, o, valid, SCALE)
5772
base = (r * NCH + c) * H + hk * G + gg
5873
tl.store(PO + base[:, None] * D + d[None, :], o, mask=gg[:, None] < G)
@@ -62,7 +77,7 @@ def _chunks(Q, KC, VC, POS0, PO, PM, PL, IDS, NKR, SPR,
6277

6378
@triton.jit
6479
def _merge(PO, PM, PL, POS0, OUT, NKR, SPR, H: tl.constexpr, HK: tl.constexpr, D: tl.constexpr, G: tl.constexpr,
65-
CH: tl.constexpr, NCH: tl.constexpr, QSA: tl.constexpr):
80+
CH: tl.constexpr, NCH: tl.constexpr, QSA: tl.constexpr, KVQ: tl.constexpr):
6681
r = tl.program_id(0)
6782
hk = tl.program_id(1)
6883
n = tl.load(POS0) + r + 1
@@ -87,6 +102,10 @@ def _merge(PO, PM, PL, POS0, OUT, NKR, SPR, H: tl.constexpr, HK: tl.constexpr, D
87102
l = l * a + cl * b
88103
m = next_m
89104
result = o / l[:, None]
105+
if KVQ:
106+
# the values are stored rotated: o = p . (H v) = H (p . v), so one rotation a row puts the merged
107+
# output back, whatever windows and chunks it came from
108+
result = tl.reshape(h32(tl.reshape(result, (16 * D // 32, 32)), M=16 * D // 32), (16, D))
90109
tl.store(OUT + (r * H + head[:, None]) * D + d[None, :], result.to(tl.bfloat16), mask=gg[:, None] < G)
91110

92111

@@ -112,9 +131,18 @@ def __init__(self, rows: int, heads: int, head_dim: int, capacity: int, device,
112131

113132
def attention(q: torch.Tensor, kc: torch.Tensor, vc: torch.Tensor, pos0: torch.Tensor, scratch: AttnScratch,
114133
rows: int, scale: float, out: torch.Tensor | None = None, *,
115-
context: int | None = None) -> torch.Tensor:
116-
"""q [R, H, D] against caches holding [0, P0 + R) -> [R, H, D] bf16; sparse rows read ``scratch.ids``."""
117-
134+
context: int | None = None, ks: torch.Tensor | None = None, vs: torch.Tensor | None = None,
135+
kvq: bool = False) -> torch.Tensor:
136+
"""q [R, H, D] against caches holding [0, P0 + R) -> [R, H, D] bf16; sparse rows read ``scratch.ids``.
137+
138+
With ``kvq`` the caches hold int8 codes and one fp16 scale per 32 values (``ks``/``vs``), and both ``q``
139+
and the returned output are in the caches' H32 rotation: ``q`` was rotated by ``glue.attn_prep``, and the
140+
output is rotated back in ``_merge``, so the caller sees the same arithmetic either way."""
141+
142+
if kvq and (ks is None or vs is None):
143+
raise ValueError("an int8 KV cache needs its scale tensors")
144+
if ks is None:
145+
ks = vs = kc
118146
_, h, d = q.shape
119147
hk = kc.shape[1]
120148
g = h // hk
@@ -124,11 +152,11 @@ def attention(q: torch.Tensor, kc: torch.Tensor, vc: torch.Tensor, pos0: torch.T
124152
keys = min(keys, (scratch.budget // scratch.ratio + 1) * scratch.ratio - 1)
125153
chunks = min(nch, triton.cdiv(keys, CHUNK))
126154
out = scratch.out if out is None else out
127-
_chunks[(rows, hk, chunks)](q, kc, vc, pos0, scratch.po, scratch.pm, scratch.pl, scratch.ids, scratch.nk,
155+
_chunks[(rows, hk, chunks)](q, kc, vc, ks, vs, pos0, scratch.po, scratch.pm, scratch.pl, scratch.ids, scratch.nk,
128156
scratch.sparse, H=h, HK=hk, D=d, G=g, CH=CHUNK, NCH=nch, SCALE=scale,
129-
IDW=scratch.idw, QSA=scratch.qsa, num_warps=4, num_stages=1)
157+
IDW=scratch.idw, QSA=scratch.qsa, KVQ=kvq, num_warps=4, num_stages=1)
130158
_merge[(rows, hk)](scratch.po, scratch.pm, scratch.pl, pos0, out, scratch.nk, scratch.sparse, H=h,
131-
HK=hk, D=d, G=g, CH=CHUNK, NCH=nch, QSA=scratch.qsa, num_warps=4)
159+
HK=hk, D=d, G=g, CH=CHUNK, NCH=nch, QSA=scratch.qsa, KVQ=kvq, num_warps=4)
132160
return out
133161

134162

‎src/tensorfold/families/qwen4_exp/cuda/decode.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ class Engine:
112112
"""Weights, one sequence's state, buffers for decode windows (main model and MTP head) and for prompt chunks."""
113113

114114
def __init__(self, w: Weights, *, capacity: int = 4096, max_rows: int = 8, prefill_rows: int = PREFILL_ROWS,
115-
graphs: bool = False) -> None:
115+
graphs: bool = False, kv_dtype: str = "bf16") -> None:
116116
self.w = w
117117
self.capacity = capacity
118118
self.rows, self.prefill_rows = max_rows, prefill_rows
119+
self.kv_dtype = kv_dtype
119120
self.buf = Buffers(w, max_rows, capacity)
120121
self.mbuf = Buffers(w, max_rows, capacity) if w.mtp is not None else None
121122
self.pbuf = Buffers(w, prefill_rows, capacity, prefill=True)
122-
self.st = State(w, capacity, max_rows)
123+
self.st = State(w, capacity, max_rows, kv_dtype)
123124
self.graphs = None
124125
if graphs:
125126
from .graphs import Graphs
@@ -135,7 +136,7 @@ def twin(self) -> "Engine":
135136
other = object.__new__(Engine)
136137
other.w, other.capacity, other.rows, other.prefill_rows = self.w, self.capacity, self.rows, self.prefill_rows
137138
other.buf, other.mbuf, other.pbuf, other.graphs = self.buf, None, self.pbuf, None
138-
other.st = State(self.w, self.capacity, self.rows)
139+
other.st = State(self.w, self.capacity, self.rows, self.st.kv_dtype)
139140
return other
140141

141142
def forward(self, tokens: Sequence[int]) -> torch.Tensor:

‎src/tensorfold/families/qwen4_exp/cuda/engine.py‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class FlashNextEngine:
2020
def __init__(self, model_dir: Path, *, depth: int = DEPTH, confidence: float = CONFIDENCE,
2121
draft_vocab: str | int | None = "default", max_len: int | None = None,
2222
context_explicit: bool | None = None, tp: int = 1, rank: int = 0, master: str = "", port: int = 29551,
23-
prefetch: bool = True, graphs: bool = True, streams: int = 1, ple_on_ssd: bool = False) -> None:
23+
prefetch: bool = True, graphs: bool = True, streams: int = 1, ple_on_ssd: bool = False,
24+
kv_dtype: str = "bf16") -> None:
2425
import torch
2526

2627
from .exl3_pack import admission, extra_files, is_exl3
@@ -33,6 +34,7 @@ def __init__(self, model_dir: Path, *, depth: int = DEPTH, confidence: float = C
3334
raise ValueError("--ple-on-ssd reads the MLX checkpoint's n-gram tables; an EXL3 pack maps its own table "
3435
"from its file, so drop --ple-on-ssd")
3536
from .decode import Engine
37+
from .kvcache import check as check_kv
3638
from .weights import draft_token_ids, load
3739
from tensorfold.cuda.capacity import admit, gather_ints
3840
from tensorfold.cuda.geometry import gdn_geometry, indexed_stream_geometry, indexed_weights
@@ -46,6 +48,7 @@ def __init__(self, model_dir: Path, *, depth: int = DEPTH, confidence: float = C
4648
raise ValueError(f"MTP drafts a round: 0 to {MAX_DEPTH}, not {depth}")
4749
torch.cuda.set_device(0)
4850
self.tp, self.rank, self.depth, self.confidence = tp, rank, int(depth), float(confidence)
51+
self.kv_dtype = check_kv(kv_dtype)
4952
self.comm = None
5053
ids = draft_token_ids(draft_vocab) if self.depth > 0 else None
5154
if tp == 2:
@@ -88,7 +91,8 @@ def __init__(self, model_dir: Path, *, depth: int = DEPTH, confidence: float = C
8891
confidence=self.confidence, keep=KEEP)
8992
self.scheduler = Scheduler(self.multi, max_streams=streams)
9093
else:
91-
self.e = Engine(w, capacity=self.max_len, max_rows=max(8, self.depth + 1), graphs=graphs)
94+
self.e = Engine(w, capacity=self.max_len, max_rows=max(8, self.depth + 1), graphs=graphs,
95+
kv_dtype=self.kv_dtype)
9296
started = time.perf_counter()
9397
locked = False
9498
if prefetch and not ple_on_ssd: # the n-gram tables' pages, read now rather than by requests
@@ -113,21 +117,23 @@ def __init__(self, model_dir: Path, *, depth: int = DEPTH, confidence: float = C
113117
f"{self.context_window}-token prompt/reply window; {self.max_len}-token cache")
114118
how = ("read from SSD at each lookup" if ple_on_ssd else
115119
f"{'locked in memory' if locked else 'read'} in {read_s:.1f}s")
116-
print(f"[tensorfold] Flash Next on CUDA: {rule}; {where}; n-gram tables {how}; {captured} "
120+
kv = "" if self.kv_dtype == "bf16" else f"; int8 KV cache (fp16 scale per 32 values)"
121+
print(f"[tensorfold] Flash Next on CUDA: {rule}; {where}{kv}; n-gram tables {how}; {captured} "
117122
"decode graphs captured", flush=True)
118123

119124
def _same_settings(self, torch, ids) -> None:
120-
"""Both ranks must decode with the same rule, context and draft vocabulary, or they would fall out of step: refuse to start otherwise."""
125+
"""Both ranks must decode with the same rule, context, draft vocabulary and KV cache, or they would fall out of step: refuse to start otherwise."""
121126

122127
total = int(ids.sum()) if ids is not None else -1
123128
mine = torch.tensor([self.depth, round(self.confidence * 1e6), self.max_len,
124-
len(ids) if ids is not None else -1, total], dtype=torch.int64, device="cuda")
129+
len(ids) if ids is not None else -1, total, int(self.kv_dtype == "int8")],
130+
dtype=torch.int64, device="cuda")
125131
both = torch.empty((2 * mine.numel(),), dtype=torch.int64, device="cuda")
126132
self.comm.all_gather(mine, both)
127133
both = both.view(2, -1).cpu()
128134
if not torch.equal(both[0], both[1]):
129135
raise RuntimeError(f"the two ranks were started with different settings (drafts, confidence, context, "
130-
f"draft vocabulary): rank 0 {both[0].tolist()}, rank 1 {both[1].tolist()}")
136+
f"draft vocabulary, KV cache): rank 0 {both[0].tolist()}, rank 1 {both[1].tolist()}")
131137

132138
def _key(self, n: int) -> str:
133139
return f"tensorfold/flashnext/request/{n}"

‎src/tensorfold/families/qwen4_exp/cuda/forward.py‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ def _caches(layer: LayerW, st: State, mtp: bool) -> tuple:
150150
"""The layer's caches and committed length (on the device and on the host)."""
151151

152152
if mtp:
153-
return st.mtp_kc, st.mtp_vc, st.mtp_ikc, st.mtp_pooled, st.mtp_pos, st.mtp_len
153+
return st.mtp_kc, st.mtp_ikc, st.mtp_pooled, st.mtp_pos, st.mtp_len
154154
ai = st.att_index[layer.index]
155-
return st.kc[ai], st.vc[ai], st.ikc[ai], st.pooled[ai], st.pos_dev, st.pos
155+
return st.kc[ai], st.ikc[ai], st.pooled[ai], st.pos_dev, st.pos
156156

157157

158158
def attn_block(layer: LayerW, w: Weights, segs: Sequence[Seg], b: Buffers, R: int, mtp: bool,
@@ -164,11 +164,12 @@ def attn_block(layer: LayerW, w: Weights, segs: Sequence[Seg], b: Buffers, R: in
164164
_mm(b.mixed[:R], a.proj, b.xs_mixed[:R], b.pa[:R], b)
165165
scale = c.head_dim ** -0.5
166166
for st, a0, a1 in segs:
167-
kc, vc, ikc, pooled, pos, host_pos = _caches(layer, st, mtp)
167+
cache, ikc, pooled, pos, host_pos = _caches(layer, st, mtp)
168168
keys = context if context is not None else host_pos + a1 - a0
169-
glue.attn_prep(b.pa[a0:a1], pos, a.q_scale, a.k_scale, a.iq_scale, w.inv_freq, b.q[a0:], kc, vc, b.iq[a0:],
170-
ikc, c.eps, q_heads=c.heads, kv_heads=c.kv_heads, head_dim=c.head_dim,
171-
index_heads=c.index_heads, index_dim=c.index_dim)
169+
glue.attn_prep(b.pa[a0:a1], pos, a.q_scale, a.k_scale, a.iq_scale, w.inv_freq, b.q[a0:], cache.k, cache.v,
170+
b.iq[a0:], ikc, c.eps, q_heads=c.heads, kv_heads=c.kv_heads, head_dim=c.head_dim,
171+
index_heads=c.index_heads, index_dim=c.index_dim, ks=cache.ks, vs=cache.vs,
172+
kvq=cache.quantized)
172173
if b.prefill:
173174
if b.attn.qsa:
174175
attn_mod.qsa_pool(ikc, pooled, pos, a.ik_scale, w.inv_freq, c.eps, b.attn, a1 - a0)
@@ -178,13 +179,15 @@ def attn_block(layer: LayerW, w: Weights, segs: Sequence[Seg], b: Buffers, R: in
178179
ends = host_pos + r0 - a0 + n
179180
if b.attn.qsa:
180181
attn_mod.qsa_rows(b.iq[r0:r0 + n], pooled, b.pos_blk, b.attn, n, context=ends)
181-
attn_mod.attention(b.q[r0:r0 + n], kc, vc, b.pos_blk, b.attn, n, scale, out=b.attn_o[r0:r0 + n],
182-
context=ends)
182+
attn_mod.attention(b.q[r0:r0 + n], cache.k, cache.v, b.pos_blk, b.attn, n, scale,
183+
out=b.attn_o[r0:r0 + n], context=ends, ks=cache.ks, vs=cache.vs,
184+
kvq=cache.quantized)
183185
continue
184186
if b.attn.qsa:
185187
attn_mod.qsa_select(b.iq[a0:a1], ikc, pooled, pos, a.ik_scale, w.inv_freq, c.eps, b.attn, a1 - a0,
186188
context=keys)
187-
o = attn_mod.attention(b.q[a0:a1], kc, vc, pos, b.attn, a1 - a0, scale, context=keys)
189+
o = attn_mod.attention(b.q[a0:a1], cache.k, cache.v, pos, b.attn, a1 - a0, scale, context=keys,
190+
ks=cache.ks, vs=cache.vs, kvq=cache.quantized)
188191
if len(segs) > 1: # the scratch output is the next stream's too
189192
b.attn_o[a0:a1].copy_(o[:a1 - a0])
190193
o = b.attn_o if b.prefill or len(segs) > 1 else o

0 commit comments

Comments
 (0)