MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / __init__

Method __init__

inference/models/falcon.py:79–126  ·  view source on GitHub ↗
(self, args)

Source from the content-addressed store, hash-verified

77
78class FalconAttentionFused(nn.Module):
79 def __init__(self, args):
80 super().__init__()
81 self.args = args
82 self.n_local_heads = args.n_head
83 self.head_dim = args.hidden_size // args.n_head
84
85 self.query_key_value = nn.Linear(
86 args.hidden_size,
87 args.n_head * self.head_dim + 2 * self.head_dim,
88 bias=False,
89 )
90
91 self.dense = nn.Linear(
92 args.n_head * self.head_dim,
93 args.hidden_size,
94 bias=False,
95 )
96
97 # following fastertransformer definition
98
99 self.cache_v = (
100 torch.zeros(
101 (
102 max_batch_size,
103 1,
104 max_seq_len,
105 self.head_dim,
106 )
107 )
108 .cuda()
109 .half()
110 ) # added to half
111 # 8: pack 8 fp16 in FT, if fp32 then use 4
112 self.cache_k = (
113 torch.zeros(
114 (
115 max_batch_size,
116 1,
117 self.head_dim // 8,
118 max_seq_len,
119 8,
120 )
121 )
122 .cuda()
123 .half()
124 ) # added to half
125
126 self.rotary_emb = RotaryEmbedding(self.head_dim)
127
128 def forward(
129 self,

Callers

nothing calls this directly

Calls 2

RotaryEmbeddingClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected