inference
This commit is contained in:
parent
38b59825b1
commit
8920cafbe7
2 changed files with 5 additions and 5 deletions
|
|
@ -119,7 +119,7 @@ def fast_gemv(X, W, quant_state, out = None):
|
|||
# For fast X @ W where seq_len == 1
|
||||
# From https://github.com/TimDettmers/bitsandbytes/blob/main/bitsandbytes/functional.py#L1469
|
||||
bsz, q_len, hd = X.shape
|
||||
assert(q_len == 1)
|
||||
# assert(q_len == 1)
|
||||
|
||||
if type(quant_state) is not list:
|
||||
# https://github.com/TimDettmers/bitsandbytes/pull/763/files
|
||||
|
|
@ -138,7 +138,7 @@ def fast_gemv(X, W, quant_state, out = None):
|
|||
offset, state2 = compressed_stats
|
||||
absmax2, code2, blocksize2, _, _, _, _ = state2
|
||||
pass
|
||||
assert(dtype == X.dtype)
|
||||
# assert(dtype == X.dtype)
|
||||
bout = shape[0]
|
||||
|
||||
if out is None:
|
||||
|
|
@ -152,7 +152,7 @@ def fast_gemv(X, W, quant_state, out = None):
|
|||
k = shape[1]
|
||||
lda = shape[0]
|
||||
ldc = shape[0]
|
||||
ldb = (X.shape[-1]+1)//2
|
||||
ldb = (hd+1)//2
|
||||
m = ctypes.c_int32(m)
|
||||
n = ctypes.c_int32(n)
|
||||
k = ctypes.c_int32(k)
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ def fast_mlp_inference(self, X):
|
|||
# up = self.up_proj(X)
|
||||
bsz, _, hd = X.shape
|
||||
mlp_size = self.config.intermediate_size
|
||||
temp = torch.empty((3, bsz, 1, mlp_size), dtype = X.dtype, device = "cuda")
|
||||
temp = torch.empty((2, bsz, 1, mlp_size), dtype = X.dtype, device = "cuda")
|
||||
|
||||
gate = fast_linear_forward(self.gate_proj, X, out = temp[0])
|
||||
up = fast_linear_forward(self. up_proj, X, out = temp[1])
|
||||
|
|
@ -294,7 +294,7 @@ def fast_mlp_inference(self, X):
|
|||
gate *= up
|
||||
|
||||
# X = self.down_proj(gate)
|
||||
down = fast_linear_forward(self.down_proj, gate, out = temp[2])
|
||||
down = fast_linear_forward(self.down_proj, gate)
|
||||
return down
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue