Update llama.py
This commit is contained in:
parent
9a54a6f05e
commit
e094914b0e
1 changed files with 13 additions and 5 deletions
|
|
@ -206,21 +206,29 @@ def LlamaAttention_fast_forward_inference(
|
|||
return A, (Kn, Vn)
|
||||
pass
|
||||
|
||||
|
||||
@torch.compile(options = {
|
||||
"epilogue_fusion" : True,
|
||||
"max_autotune" : True,
|
||||
"fallback_random" : False,
|
||||
"shape_padding" : True,
|
||||
"triton.cudagraphs" : False,
|
||||
"trace.enabled" : True,
|
||||
"trace.graph_diagram" : True,
|
||||
}, dynamic = True,)
|
||||
def fast_mlp_inference(self, X):
|
||||
# gate = self.gate_proj(X)
|
||||
# up = self.up_proj(X)
|
||||
bsz, _, hd = X.shape
|
||||
mlp_size = self.config.intermediate_size
|
||||
temp = torch.empty((2, 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])
|
||||
gate = fast_linear_forward(self.gate_proj, X)#, out = temp[0])
|
||||
up = fast_linear_forward(self. up_proj, X)#, out = temp[1])
|
||||
gate = torch.nn.functional.silu(gate, inplace = True)
|
||||
gate *= up
|
||||
|
||||
# X = self.down_proj(gate)
|
||||
down = fast_linear_forward(self.down_proj, gate, out = up[:,:,:hd])
|
||||
down = fast_linear_forward(self.down_proj, gate)#, out = up[:,:,:hd])
|
||||
return down
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue