vllm.model_executor.models.phi4mm_audio
AudioEmbedding
¶
Bases: Module
Image embedding.
Source code in vllm/model_executor/models/phi4mm_audio.py
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 |
|
freeze_audio_processor
instance-attribute
¶
linear_downsample_rate
instance-attribute
¶
__init__
¶
Source code in vllm/model_executor/models/phi4mm_audio.py
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 |
|
forward
¶
forward(
audio_features: FloatTensor,
audio_attention_mask: Tensor = None,
audio_projection_mode: str = "speech",
) -> FloatTensor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio_features
|
FloatTensor
|
audio features (T, D) |
required |
Returns:
Name | Type | Description |
---|---|---|
audio_embeds |
FloatTensor
|
audio embeddings (num_audio_tokens, hidden_dim) |
Source code in vllm/model_executor/models/phi4mm_audio.py
get_audio_features
¶
get_audio_features(
input_embeds: FloatTensor,
audio_attention_mask: Tensor = None,
audio_projection_mode: str = "speech",
) -> FloatTensor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_embeds
|
FloatTensor
|
audio features (B, T, D) B: num audios in a sequence |
required |
Source code in vllm/model_executor/models/phi4mm_audio.py
set_audio_embed_sizes
¶
ConformerEncoder
¶
Bases: TransformerEncoderBase
ConformerEncoder module. see original paper for more details: https://arxiv.org/abs/2005.08100
Please set causal = True in streaming model Args: input_size: int input feature dimension. chunk_size: int, list(int) Number of frames for each chunk This variable can take 2 forms: int: Used for inference, or single chunk size training list(int) : Used only for variable chunk size training Some examples for the 2 cases: chunk_size = 12 chunk_size = [6, 8, 12, 24] left_chunk: int, list(int) Number of chunks used for masking in streaming mode. This variable can take 2 forms: int: Used for inference, or single chunk size training list(int) : Used only for variable chunk size training. When chunk_size is a list, left_chunk must be a list with same length. Some examples for the 2 cases: left_chunk = 6 left_chunk = [12, 9, 6, 3] left_chunk: int number of chunks used for masking in streaming mode. num_lang: int This parameter is used to store the number of languages in the lang_dict, only used for multiseed/multilingual models. default None. attention_dim: int, optional attention dimension. default 256. attention_heads: int, optional the number of heads. default 4 linear_units: the number of units of position-wise feed forward. default 2048 num_block: number of Transformer layer. default 6 dropout_rate: float, optional dropout rate. default 0.1 input_layer: str, optional input layer type before Conformer, one of ["linear", "conv2d", "custom", "vgg2l", "embed"], default "conv2d" causal: bool, optional if set to True, convolution have no access to future frames. default False. batch_norm: bool, optional if set to True, apply batchnorm before activation in ConvModule layer of the conformer. default False cnn_out: int, optional the number of CNN channels before Conformer. default -1. cnn_layer_norm: bool, optional layer norm between Conformer and the first CNN. default False. ext_pw_out_channel: int, optional the number of channel for CNN before depthwise_seperable_CNN. If 0 then use linear. default 0. ext_pw_kernel_size: int, optional kernel size of N before depthwise_seperable_CNN. only work for ext_pw_out_channel > 0. default 1 depthwise_seperable_out_channel: int, optional the number of channel for depthwise_seperable_CNN. default 256. depthwise_multiplier: int, optional the number of multiplier for depthwise_seperable_CNN. default 1. chunk_se: int, optional 0 for offline SE. 1 for streaming SE, where mean is computed by accumulated history until current chunk_se. 2 for streaming SE, where mean is computed by only the current chunk. default 0. kernel_size: int, optional the number of kernels for depthwise_seperable_CNN. default 3. activation: str, optional FeedForward block activation. one of ["relu", "swish", "sigmoid"] default "relu". conv_activation: str, optional activation function used in ConvModule part of the conformer, default "relu". conv_glu_type: str, optional activation used use glu in depthwise_seperable_CNN, default "sigmoid" bias_in_glu: bool, optional if set to True, use additive bias in the weight module before GLU. default True linear_glu_in_convm: bool, optional if set to True, use GLULinear module, otherwise, used GLUPointWiseConv module. default to False. attention_glu_type: str only work for glu_in_attention !=0 default "swish". export: bool, optional if set to True, it remove the padding from convolutional layers and allow the onnx conversion for inference. default False. activation_checkpointing: str, optional a dictionarry of {"module","interval","offload"}, where "module": str accept ["transformer", "attention"] to select which module should do activation checkpointing. "interval": int, default 1, interval of applying activation checkpointing, interval = 1 means that we apply checkpointing on every layer (if activation), otherwise, we apply it every x interval. "offload": bool, default False, if set to True, we offload activation to cpu and reload it during backward, otherwise, we recalculate activation in backward. default "". extra_layer_output_idx: int the layer index to be exposed. relative_attention_bias_args: dict, optional use more efficient scalar bias-based relative multihead attention (Q*K^T + B) implemented in cmb.basics.embedding. [T5/ALiBi]RelativeAttentionLogitBias usage: relative_attention_bias_args={"type": t5/alibi} additional method-specific arguments can be provided (see transformer_base.py) time_reduction: int optional time reduction factor default 4 use_pt_scaled_dot_product_attention: whether to use pytorch scaled dot product attention in training. Default: False nemo_conv_settings: dict, optional A dictionary of settings for NeMo Subsampling. default: None usage: nemo_conv_settings= { "subsampling": dw_striding/striding/dw_striding_conv1d/striding_conv1d, "conv_channels": int, "subsampling_conv_chunking_factor": int, "is_causal": True/False } conv2d_extra_padding: str, optional Add extra padding in conv2d subsampling layers. Choices are (feat, feat_time, none, True) Default: none replication_pad_for_subsample_embedding: For batched-streaming decoding, use "replication" padding for the cache at start of utterance. Default: False attention_group_size: int, optional the number of groups to use for attention, default 1 (Multi-Head Attention), 1 = typical Multi-Head Attention, 1 < attention_group_size < attention_heads = Grouped-Query Attention attention_group_size = attention_heads = Multi-Query Attention
Source code in vllm/model_executor/models/phi4mm_audio.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 |
|
encoders
instance-attribute
¶
encoders = MultiSequential(
*[
ConformerEncoderLayer(
d_model=attention_dim,
ext_pw_out_channel=ext_pw_out_channel,
depthwise_seperable_out_channel=depthwise_seperable_out_channel,
depthwise_multiplier=depthwise_multiplier,
n_head=attention_heads,
d_ffn=linear_units,
ext_pw_kernel_size=ext_pw_kernel_size,
kernel_size=kernel_size,
dropout_rate=dropout_rate,
causal=causal,
batch_norm=batch_norm,
activation=activation,
chunk_se=chunk_se,
chunk_size=chunk_size,
conv_activation=conv_activation,
conv_glu_type=conv_glu_type,
bias_in_glu=bias_in_glu,
linear_glu_in_convm=linear_glu_in_convm,
attention_glu_type=attention_glu_type,
activation_checkpointing=activation_checkpointing,
export=export,
use_pt_scaled_dot_product_attention=use_pt_scaled_dot_product_attention,
attn_group_sizes=attention_group_size,
)
for _ in range(num_blocks)
]
)
extra_multi_layer_output_idxs
instance-attribute
¶
replication_pad_for_subsample_embedding
instance-attribute
¶
replication_pad_for_subsample_embedding: bool = (
replication_pad_for_subsample_embedding
)
__init__
¶
__init__(
input_size,
chunk_size,
left_chunk,
num_lang=None,
attention_dim=256,
attention_heads=4,
linear_units=2048,
num_blocks=6,
dropout_rate=0.1,
input_layer="nemo_conv",
causal=True,
batch_norm=False,
cnn_out=-1,
cnn_layer_norm=False,
ext_pw_out_channel=0,
ext_pw_kernel_size=1,
depthwise_seperable_out_channel=256,
depthwise_multiplier=1,
chunk_se=0,
kernel_size=3,
activation="relu",
conv_activation="relu",
conv_glu_type="sigmoid",
bias_in_glu=True,
linear_glu_in_convm=False,
attention_glu_type="swish",
export=False,
extra_layer_output_idx=-1,
extra_multi_layer_output_idxs=[],
activation_checkpointing="",
relative_attention_bias_args=None,
time_reduction=4,
use_pt_scaled_dot_product_attention=False,
nemo_conv_settings=None,
conv2d_extra_padding: Literal[
"feat", "feat_time", "none", True
] = "none",
replication_pad_for_subsample_embedding=False,
attention_group_size=1,
encoder_embedding_config=None,
)
Source code in vllm/model_executor/models/phi4mm_audio.py
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
|
calculate_hs_mask
¶
Source code in vllm/model_executor/models/phi4mm_audio.py
forward
¶
Conformer Forward function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xs_pad
|
torch.Tensor input tensor |
required | |
masks
|
torch.Tensor post-embedding input lengths |
required |
Source code in vllm/model_executor/models/phi4mm_audio.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 |
|
ConformerEncoderLayer
¶
Bases: Module
ConformerEncoder Layer module. for more details see conformer paper: https://arxiv.org/abs/2005.08100 This module implement the Conformer block layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d_model
|
int attention dim. |
512
|
|
ext_pw_out_channel
|
int if > 0, ext_pw_out_channel is a dim channel size for the last pointwise conv after swish activation. |
0
|
|
depthwise_seperable_out_channel
|
int if set different to 0, the number of depthwise_seperable_out_channel will be used as a channel_out of the second conv1d layer. otherwise, it equal to 0, the second conv1d layer is skipped. |
256
|
|
depthwise_multiplier
|
int number of input_dim channels duplication. this value will be used to compute the hidden channels of the Conv1D. |
1
|
|
n_head
|
int the number of heads for multihead attention module. |
4
|
|
d_ffn
|
int output size of the feed_forward blocks. |
2048
|
|
ext_pw_kernel_size
|
int kernel size of the conv pointwise of the conformer. |
1
|
|
kernel_size
|
int kernel size. |
3
|
|
dropout_rate
|
float dropout rate. |
0.1
|
|
causal
|
bool, optional if set to True, convolution have no access to future frames. default False. |
False
|
|
batch_norm
|
bool, optional if set to True, apply batchnorm before activation in ConvModule layer of the conformer. default False |
False
|
|
activation
|
str, optional activation function name, one of ["relu", "swish", "sigmoid"], sigmoid activation is only used with "glu_in_fnn=True", default "relu". |
'relu'
|
|
chunk_se
|
int, optional 0 for offline SE. 1 for streaming SE, where mean is computed by accumulated history until current chunk_se. 2 for streaming SE, where mean is computed by only the current chunk. default 0. |
0
|
|
chunk_size
|
int, optional chunk_size for cnn. default 18 |
18
|
|
conv_activation
|
str, optional activation function used in ConvModule part of the conformer, default "relu". |
'relu'
|
|
conv_glu_type
|
str, optional activation function used for the glu inside the ConvModule part of the conformer. default: "sigmoid". |
'sigmoid'
|
|
bias_in_glu
|
bool, optional if set to True, use additive bias in the weight module before GLU. |
True
|
|
linear_glu_in_convm
|
bool, optional if set to True, use GLULinear module, otherwise, used GLUPointWiseConv module. default to False. |
False
|
|
attention_inner_dim
|
int, optional if equal to -1, attention dim for linears k/q/v is equal to d_model. otherwise attention_inner_dim is used. default -1. |
-1
|
|
attention_glu_type
|
str, optional activation function for glu used in the multihead attention, default "swish". |
'swish'
|
|
activation_checkpointing
|
str, optional a dictionarry of {"module","interval","offload"}, where "module": str accept ["transformer", "attention"] to select which module should do activation checkpointing. "interval": int, default 1, interval of applying activation checkpointing, interval = 1 means that we apply checkpointing on every layer (if activation), otherwise, we apply it every x interval. "offload": bool, default False, if set to True, we offload activation to cpu and reload it during backward, otherwise, we recalculate activation in backward. default "". |
''
|
|
export
|
bool, optional if set to True, it remove the padding from convolutional layers and allow the onnx conversion for inference. default False. |
False
|
|
use_pt_scaled_dot_product_attention
|
bool, optional if set to True, use pytorch's scaled dot product attention implementation in training. |
False
|
|
attn_group_sizes
|
int
|
int, optional the number of groups to use for attention, default 1 (Multi-Head Attention), 1 = typical Multi-Head Attention, 1 < attn_group_sizes < attention_heads = Grouped-Query Attention attn_group_sizes = attention_heads = Multi-Query Attention |
1
|
Source code in vllm/model_executor/models/phi4mm_audio.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
conv
instance-attribute
¶
conv = ConvModule(
d_model,
ext_pw_out_channel,
depthwise_seperable_out_channel,
ext_pw_kernel_size,
kernel_size,
depthwise_multiplier,
dropout_rate,
causal,
batch_norm,
chunk_se,
chunk_size,
conv_activation,
conv_glu_type,
bias_in_glu,
linear_glu_in_convm,
export=export,
)
feed_forward_in
instance-attribute
¶
feed_forward_in = FeedForward(
d_model=d_model,
d_inner=d_ffn,
dropout_rate=dropout_rate,
activation=activation,
bias_in_glu=bias_in_glu,
)
feed_forward_out
instance-attribute
¶
feed_forward_out = FeedForward(
d_model=d_model,
d_inner=d_ffn,
dropout_rate=dropout_rate,
activation=activation,
bias_in_glu=bias_in_glu,
)
self_attn
instance-attribute
¶
self_attn = MultiHeadedAttention(
n_head,
d_model,
dropout_rate,
attention_inner_dim,
attention_glu_type,
bias_in_glu,
use_pt_scaled_dot_product_attention=use_pt_scaled_dot_product_attention,
group_size=attn_group_sizes,
)
__init__
¶
__init__(
d_model=512,
ext_pw_out_channel=0,
depthwise_seperable_out_channel=256,
depthwise_multiplier=1,
n_head=4,
d_ffn=2048,
ext_pw_kernel_size=1,
kernel_size=3,
dropout_rate=0.1,
causal=False,
batch_norm=False,
activation="relu",
chunk_se=0,
chunk_size=18,
conv_activation="relu",
conv_glu_type="sigmoid",
bias_in_glu=True,
linear_glu_in_convm=False,
attention_inner_dim=-1,
attention_glu_type="swish",
activation_checkpointing="",
export=False,
use_pt_scaled_dot_product_attention=False,
attn_group_sizes: int = 1,
)
Source code in vllm/model_executor/models/phi4mm_audio.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
forward
¶
ConformerEncoder forward.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
torch.Tensor input feature of shape (batch, max_time_in, size) |
required | |
pos_k
|
torch.Tensor positional key embedding. |
required | |
mask
|
torch.Tensor mask for x (batch, max_time_in) |
required | |
relative_attention_bias
|
Optional[Tensor]
|
Optional[torch.Tensor] bias added to attention logits w.r.t. relative positions (1, n_head, time1, time2) |
None
|
Source code in vllm/model_executor/models/phi4mm_audio.py
TransformerEncoderBase
¶
The Base class for Transformer based encoders
Please set causal = True in streaming model Args: input_size: int input feature dimension. chunk_size: int, list(int) Number of frames for each chunk This variable can take 2 forms: int: Used for inference, or single chunk size training list(int) : Used only for variable chunk size training Some examples for the 2 cases: chunk_size = 12 chunk_size = [6, 8, 12, 24] left_chunk: int, list(int) Number of chunks used for masking in streaming mode. This variable can take 2 forms: int: Used for inference, or single chunk size training list(int) : Used only for variable chunk size training. When chunk_size is a list, left_chunk must be a list with same length. Some examples for the 2 cases: left_chunk = 6 left_chunk = [12, 9, 6, 3] attention_dim: int, optional attention dimension. default 256. attention_heads: int, optional the number of heads. default 4 input_layer: str, optional input layer type before Conformer, one of ["linear", "conv2d", "custom", "vgg2l", "embed"], default "conv2d" cnn_out: int, optional the number of CNN channels before Conformer. default -1. cnn_layer_norm: bool, optional layer norm between Conformer and the first CNN. default False. time_reduction: int, optional time reduction factor default 4 dropout_rate: float, optional dropout rate. default 0.1 padding_idx: int, optional padding index for input_layer=embed default -1 relative_attention_bias_args: dict, optional use more efficient scalar bias-based relative multihead attention (Q*K^T + B) implemented in cmb.basics.embedding. [T5/ALiBi]RelativeAttentionLogitBias usage: relative_attention_bias_args={"type": t5/alibi} additional method-specific arguments can be provided (see transformer_base.py) positional_dropout_rate: float, optional dropout rate after positional encoding. default 0.0 nemo_conv_settings: dict, optional A dictionary of settings for NeMo Subsampling. default None conv2d_extra_padding: str, optional Add extra padding in conv2d subsampling layers. Choices are (feat, feat_time, none, True). if True or feat_time, the extra padding is added into non full supraframe utts in batch. Default: none attention_group_size: int, optional the number of groups to use for attention, default 1 (Multi-Head Attention), 1 = typical Multi-Head Attention, 1 < attention_group_size < attention_heads = Grouped-Query Attention attention_group_size = attention_heads = Multi-Query Attention
Source code in vllm/model_executor/models/phi4mm_audio.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
|
encoder_embedding
instance-attribute
¶
encoder_embedding = MeanVarianceNormLayer(
encoder_embedding_config["input_size"]
)
pos_emb
instance-attribute
¶
pos_emb = AbsolutePositionalEncoding(
attention_dim, positional_dropout_rate
)
relative_attention_bias_layer
instance-attribute
¶
relative_attention_bias_layer = (
T5RelativeAttentionLogitBias(
num_heads // attention_group_size,
max_distance=get("t5_bias_max_distance", 1000),
symmetric=get("t5_bias_symmetric", False),
)
)
relative_attention_bias_type
instance-attribute
¶
__init__
¶
__init__(
input_size,
chunk_size,
left_chunk,
attention_dim=256,
attention_heads=4,
input_layer="nemo_conv",
cnn_out=-1,
cnn_layer_norm=False,
time_reduction=4,
dropout_rate=0.0,
padding_idx=-1,
relative_attention_bias_args=None,
positional_dropout_rate=0.0,
nemo_conv_settings=None,
conv2d_extra_padding: Literal[
"feat", "feat_time", "none", True
] = "none",
attention_group_size=1,
encoder_embedding_config=None,
)
Source code in vllm/model_executor/models/phi4mm_audio.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
_chunk_size_selection
¶
If chunk size is a list, we will randomly select a chunk size.
Source code in vllm/model_executor/models/phi4mm_audio.py
_forward_embeddings_core
¶
Source code in vllm/model_executor/models/phi4mm_audio.py
_get_embed_class
¶
Source code in vllm/model_executor/models/phi4mm_audio.py
_position_embedding
¶
Source code in vllm/model_executor/models/phi4mm_audio.py
_streaming_mask
¶
Source code in vllm/model_executor/models/phi4mm_audio.py
compute_lens_change
¶
feature_lens: int return updated feature lens.
This used to return a different lambda function for each case that computed the right thing. That does not work within Torchscript. If you really need this to be faster, create nn.Module()-s for all the cases and return one of them. Torchscript does support that.
Source code in vllm/model_executor/models/phi4mm_audio.py
forward
abstractmethod
¶
forward_embeddings
¶
Forwarding the inputs through the top embedding layers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xs_pad
|
torch.Tensor input tensor |
required | |
masks
|
torch.Tensor input mask |
required | |
chunk_size_nc
|
(optional, default is None) chunk size for non-causal layers |
None
|
|
left_chunk_nc
|
(optional, default is None) # of left chunks for non-causal layers |
None
|
Source code in vllm/model_executor/models/phi4mm_audio.py
get_offset
¶
Returns offset used when retaining inputs for decoding.
This is essentially, how many additional frames have to be added to the front-end CNN input to ensure it can produce a single output. So if the "padding" parameter is 0, typically offset will be > 0.
Source code in vllm/model_executor/models/phi4mm_audio.py
WindowQformer
¶
Bases: Module
Window-level Qformer
Source code in vllm/model_executor/models/phi4mm_audio.py
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
|
after_norm
instance-attribute
¶
after_norm = (
LayerNorm(attention_dim, eps=1e-12)
if normalize_before
else None
)
decoders
instance-attribute
¶
decoders = ModuleList(
[
TransformerDecoderLayer(
d_model=attention_dim,
nhead=attention_heads,
dim_feedforward=linear_units,
dropout=dropout_rate,
activation="relu",
batch_first=True,
norm_first=normalize_before,
)
for _ in range(num_blocks)
]
)
__init__
¶
__init__(
window_size: int = 8,
num_queries: int = 1,
num_blocks: int = 2,
attention_dim: int = 512,
attention_heads: int = 8,
linear_units: int = 2048,
dropout_rate: float = 0.0,
normalize_before: bool = True,
)
Source code in vllm/model_executor/models/phi4mm_audio.py
forward
¶
forward decoder