vllm.model_executor.models.granite_speech
Inference-only IBM Granite speech model.
GraniteSpeechAudioInputs
¶
Bases: TypedDict
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechCTCEncoder
¶
Bases: Module
CTC Encoder comprising conformer blocks and additional linear layers.
Source code in vllm/model_executor/models/granite_speech.py
attention_dists
instance-attribute
¶
attention_dists = (
clamp(relpos_dist, -context_size, context_size)
+ max_pos_emb
)
layers
instance-attribute
¶
layers = ModuleList(
[
GraniteSpeechConformerBlock(
config, prefix=f"{prefix}.layers.{idx}"
)
for idx in range(num_layers)
]
)
out
instance-attribute
¶
out = ColumnParallelLinear(
input_size=hidden_dim,
output_size=output_dim,
bias=True,
quant_config=quant_config,
prefix=f"{prefix}.out",
)
out_mid
instance-attribute
¶
out_mid = RowParallelLinear(
input_size=output_dim,
output_size=hidden_dim,
bias=True,
quant_config=quant_config,
prefix=f"{prefix}.out_mid",
)
__init__
¶
__init__(
config: PretrainedConfig,
prefix: str,
quant_config: Optional[QuantizationConfig] = None,
)
Source code in vllm/model_executor/models/granite_speech.py
forward
¶
forward(hidden_states: Tensor)
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechConformerAttention
¶
Bases: Module
Attention for conformer blocks using Shaw's relative positional embeddings. See the following paper for more details.
Source code in vllm/model_executor/models/granite_speech.py
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 |
|
__init__
¶
__init__(config: PretrainedConfig, prefix: str = '')
Source code in vllm/model_executor/models/granite_speech.py
forward
¶
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechConformerBlock
¶
Bases: Module
Conformer block, consisting largely of linear layers, attention, and convolutional layers.
Source code in vllm/model_executor/models/granite_speech.py
conv
instance-attribute
¶
conv = GraniteSpeechConformerConvModule(
config, prefix=f"{prefix}.conv"
)
__init__
¶
__init__(config: PretrainedConfig, prefix: str = '')
Source code in vllm/model_executor/models/granite_speech.py
forward
¶
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechConformerConvModule
¶
Bases: Module
Conformer conv module consisting of several 1D/depthwise 1D convolutional layers.
Source code in vllm/model_executor/models/granite_speech.py
depth_conv
instance-attribute
¶
depth_conv = GraniteSpeechConformerDepthWiseConv1d(
inner_dim,
inner_dim,
kernel_size=conv_kernel_size,
prefix=f"{prefix}.depth_conv",
)
__init__
¶
__init__(config: PretrainedConfig, prefix: str = '')
Source code in vllm/model_executor/models/granite_speech.py
forward
¶
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechConformerDepthWiseConv1d
¶
Bases: Module
Wrapper for padded 1D pointwise convolution.
Source code in vllm/model_executor/models/granite_speech.py
conv
instance-attribute
¶
conv = Conv1d(
chan_in,
chan_out,
kernel_size,
groups=chan_in,
bias=False,
)
__init__
¶
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechConformerFeedForward
¶
Bases: Module
Feedforward module for conformer encoder blocks.
Source code in vllm/model_executor/models/granite_speech.py
down_proj
instance-attribute
¶
down_proj = RowParallelLinear(
input_size=hidden_dim * feedforward_mult,
output_size=hidden_dim,
quant_config=quant_config,
prefix=f"{prefix}.down_proj",
)
up_proj
instance-attribute
¶
up_proj = ColumnParallelLinear(
input_size=hidden_dim,
output_size=hidden_dim * feedforward_mult,
quant_config=quant_config,
prefix=f"{prefix}.up_proj",
)
__init__
¶
__init__(
config: PretrainedConfig,
quant_config: Optional[QuantizationConfig] = None,
prefix: str = "",
)
Source code in vllm/model_executor/models/granite_speech.py
forward
¶
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechDummyInputsBuilder
¶
Bases: BaseDummyInputsBuilder[GraniteSpeechMultiModalProcessingInfo]
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechEncoderProjector
¶
Bases: Module
Source code in vllm/model_executor/models/granite_speech.py
qformer
instance-attribute
¶
qformer = Blip2QFormerModel(
projector_config,
quant_config=quant_config,
cache_config=cache_config,
prefix=f"{prefix}.qformer",
)
__init__
¶
__init__(
config: PretrainedConfig,
cache_config: CacheConfig,
quant_config: Optional[QuantizationConfig] = None,
prefix: str = "",
)
Source code in vllm/model_executor/models/granite_speech.py
forward
¶
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechForConditionalGeneration
¶
Bases: Module
, SupportsMultiModal
, SupportsPP
, SupportsLoRA
Source code in vllm/model_executor/models/granite_speech.py
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 580 581 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 |
|
encoder
instance-attribute
¶
encoder = GraniteSpeechCTCEncoder(
config=encoder_config,
quant_config=quant_config,
prefix=f"{prefix}.encoder",
)
language_model
instance-attribute
¶
language_model = init_vllm_registered_model(
vllm_config=vllm_config,
hf_config=text_config,
prefix=maybe_prefix(prefix, "language_model"),
)
make_empty_intermediate_tensors
instance-attribute
¶
packed_modules_mapping
class-attribute
instance-attribute
¶
packed_modules_mapping = {
"qkv_proj": ["q_proj", "k_proj", "v_proj"],
"gate_up_proj": ["gate_proj", "up_proj"],
}
projector
instance-attribute
¶
projector = GraniteSpeechEncoderProjector(
config=config,
quant_config=quant_config,
cache_config=cache_config,
prefix=f"{prefix}.projector",
)
__init__
¶
__init__(*, vllm_config: VllmConfig, prefix: str)
Source code in vllm/model_executor/models/granite_speech.py
_build_input_features_mask
¶
Calculate the input features mask, which will generally be used to mask the padded features for all entries in the batch except for those with the most audio features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio_embed_sizes
|
Tensor
|
torch.Tensor Tensor of num features in each seq in the batch. |
required |
Returns: torch.Tensor: Mask of shape (bsz, num_features) to be applied to the audio features prior to splitting the audio embeddings.
Source code in vllm/model_executor/models/granite_speech.py
_pad_and_stack_input_features
¶
Given a list of input features of varying length, pad them to the same length and stack them into a torch.Tensor.
NOTE: Usually, padding is done in the input processor/feature extractor and zero padded prior to the computation of the Mel features; the resulting values are only constant within a batch and generally nonzero (i.e., slightly negative nums); we should validate that this is okay since we don't use a feature attention mask, but the more important thing is that we apply the input_features_mask with variable len batches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_features
|
list[Tensor]
|
list[torch.Tensor] Input features to be coerced into a tensor. |
required |
Returns: torch.Tensor: Tensor of shape [bsz, num_features, 160], where num_features is the max number of features of any entry in the batch.
Source code in vllm/model_executor/models/granite_speech.py
_parse_and_validate_audio_input
¶
_parse_and_validate_audio_input(
**kwargs: object,
) -> Optional[GraniteSpeechAudioInputs]
Source code in vllm/model_executor/models/granite_speech.py
_process_audio_input
¶
_process_audio_input(
audio_input: GraniteSpeechAudioInputs,
) -> tuple[Tensor]
Compute the audio features to be merged into the LLM embeddings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio_input
|
GraniteSpeechAudioInputs
|
GraniteSpeechAudioInputs Audio inputs object containing Mel features, an input features mask, and the (flattened) number of audio tokens per instance. |
required |
Returns: tuple[torch.Tensor]: List of length bsz.
Source code in vllm/model_executor/models/granite_speech.py
compute_logits
¶
compute_logits(
hidden_states: Tensor,
sampling_metadata: SamplingMetadata,
) -> Optional[Tensor]
forward
¶
forward(
input_ids: Tensor,
positions: Tensor,
intermediate_tensors: Optional[
IntermediateTensors
] = None,
inputs_embeds: Optional[Tensor] = None,
**kwargs: object,
) -> Union[Tensor, IntermediateTensors]
Source code in vllm/model_executor/models/granite_speech.py
get_input_embeddings
¶
get_input_embeddings(
input_ids: Tensor,
multimodal_embeddings: Optional[
MultiModalEmbeddings
] = None,
) -> Tensor
Compute the merged LLM / audio embeddings.
Source code in vllm/model_executor/models/granite_speech.py
get_mm_mapping
¶
get_mm_mapping() -> MultiModelKeys
Get the module prefix in multimodal models.
Source code in vllm/model_executor/models/granite_speech.py
get_multimodal_embeddings
¶
get_multimodal_embeddings(
**kwargs: object,
) -> MultiModalEmbeddings
Compute the audio embeddings if audio inputs are present.
Source code in vllm/model_executor/models/granite_speech.py
get_placeholder_str
classmethod
¶
load_weights
¶
GraniteSpeechMultiModalProcessingInfo
¶
Bases: BaseProcessingInfo
Source code in vllm/model_executor/models/granite_speech.py
GraniteSpeechMultiModalProcessor
¶
Bases: BaseMultiModalProcessor[GraniteSpeechMultiModalProcessingInfo]
Source code in vllm/model_executor/models/granite_speech.py
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 |
|
_call_hf_processor
¶
_call_hf_processor(
prompt: str,
mm_data: Mapping[str, object],
mm_kwargs: Mapping[str, object],
tok_kwargs: Mapping[str, object],
) -> BatchFeature
Source code in vllm/model_executor/models/granite_speech.py
_get_data_parser
¶
_get_data_parser() -> MultiModalDataParser
Source code in vllm/model_executor/models/granite_speech.py
_get_mm_fields_config
¶
_get_mm_fields_config(
hf_inputs: BatchFeature,
hf_processor_mm_kwargs: Mapping[str, object],
) -> Mapping[str, MultiModalFieldConfig]
Source code in vllm/model_executor/models/granite_speech.py
_get_prompt_updates
¶
_get_prompt_updates(
mm_items: MultiModalDataItems,
hf_processor_mm_kwargs: Mapping[str, object],
out_mm_kwargs: MultiModalKwargs,
) -> list[PromptUpdate]