MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / __init__

Method __init__

tensorrt_llm/models/bloom/model.py:27–69  ·  view source on GitHub ↗
(self, config: PretrainedConfig, layer_idx: int)

Source from the content-addressed store, hash-verified

25class BloomDecoderLayer(Module):
26
27 def __init__(self, config: PretrainedConfig, layer_idx: int):
28 super().__init__()
29 self.layer_idx = layer_idx
30 self.config = config
31
32 hidden_size = config.hidden_size
33 dtype = config.dtype
34 tp_group = config.mapping.tp_group
35 tp_size = config.mapping.tp_size
36 tp_rank = config.mapping.tp_rank
37 self.input_layernorm = LayerNorm(normalized_shape=hidden_size,
38 dtype=dtype)
39
40 layers_range = config.mapping.pp_layers(config.num_hidden_layers)
41 local_layer_idx = layer_idx - layers_range[0]
42 self.attention = Attention(
43 local_layer_idx=local_layer_idx,
44 hidden_size=hidden_size,
45 num_attention_heads=config.num_attention_heads,
46 num_kv_heads=config.num_key_value_heads,
47 num_layers=config.num_hidden_layers,
48 dtype=dtype,
49 attention_mask_type=AttentionMaskType.causal,
50 position_embedding_type=PositionEmbeddingType.alibi,
51 bias=True,
52 tp_group=tp_group,
53 tp_size=tp_size,
54 tp_rank=tp_rank,
55 reorder=True,
56 quant_mode=config.quant_mode)
57
58 mlp_hidden_size = hidden_size * 4 if config.intermediate_size is None else config.intermediate_size
59
60 self.mlp = MLP(hidden_size=hidden_size,
61 ffn_hidden_size=mlp_hidden_size,
62 hidden_act='gelu',
63 dtype=dtype,
64 bias=True,
65 tp_group=tp_group,
66 tp_size=tp_size,
67 quant_mode=config.quant_mode)
68 self.post_layernorm = LayerNorm(normalized_shape=hidden_size,
69 dtype=dtype)
70
71 def forward(self,
72 hidden_states: Tensor,

Callers

nothing calls this directly

Calls 5

pp_layersMethod · 0.80
LayerNormClass · 0.50
AttentionClass · 0.50
MLPClass · 0.50
__init__Method · 0.45

Tested by

no test coverage detected