vllm.model_executor.models.nemotron_parse ¶
BartDecoderLayer ¶
Bases: Module
Source code in vllm/model_executor/models/nemotron_parse.py
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 | |
encoder_attn instance-attribute ¶
encoder_attn = WhisperCrossAttention(
embed_dim,
decoder_attention_heads,
cache_config=cache_config,
quant_config=quant_config,
prefix=f"{prefix}.encoder_attn",
)
fc1 instance-attribute ¶
fc1 = ColumnParallelLinear(
ffn_hidden_size,
ffn_intermediate_size,
bias=ffn_has_bias,
quant_config=quant_config,
prefix=f"{prefix}.fc1",
)
fc2 instance-attribute ¶
fc2 = RowParallelLinear(
ffn_intermediate_size,
ffn_hidden_size,
bias=ffn_has_bias,
quant_config=quant_config,
prefix=f"{prefix}.fc2",
)
self_attn instance-attribute ¶
self_attn = WhisperAttention(
embed_dim=embed_dim,
num_heads=decoder_attention_heads,
attn_type=DECODER,
cache_config=cache_config,
quant_config=quant_config,
prefix=f"{prefix}.self_attn",
)
self_attn_layer_norm instance-attribute ¶
self_attn_layer_norm = LayerNorm(embed_dim)
afeldman-nm: personally I would call this "cross-attention", however I left the name as "encoder_attn" to maintain consistency with the name of the pretrained weights.
__init__ ¶
__init__(
config: BartConfig,
cache_config: CacheConfig | None = None,
quant_config: QuantizationConfig | None = None,
prefix: str = "",
)
Source code in vllm/model_executor/models/nemotron_parse.py
forward ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decoder_hidden_states | Tensor | torch.Tensor of decoder input embeddings. | required |
encoder_hidden_states | Tensor | None | torch.Tensor of encoder input embeddings. | None |
Returns: Decoder layer output torch.Tensor
Source code in vllm/model_executor/models/nemotron_parse.py
BartParallelLMHead ¶
Bases: ParallelLMHead
This module overrides ParallelLMHead's forward by dividing by embeddings scale, yielding effectively the inverse of BartScaledWordEmbedding
Source code in vllm/model_executor/models/nemotron_parse.py
__init__ ¶
BartScaledWordEmbedding ¶
Bases: VocabParallelEmbedding
This module overrides VocabParallelEmbedding's forward by multiplying with embeddings scale.
Source code in vllm/model_executor/models/nemotron_parse.py
__init__ ¶
MBartDecoderLayer ¶
Bases: BartDecoderLayer
Source code in vllm/model_executor/models/nemotron_parse.py
forward ¶
Source code in vllm/model_executor/models/nemotron_parse.py
MBartDecoderNoPos ¶
Bases: Module
Transformer decoder consisting of config.decoder_layers layers. Each layer is a [BartDecoderLayer] Args: config: BartConfig embed_tokens (nn.Embedding): output embedding
Source code in vllm/model_executor/models/nemotron_parse.py
245 246 247 248 249 250 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 | |
embed_tokens instance-attribute ¶
embed_tokens = BartScaledWordEmbedding(
vocab_size, d_model, embed_scale=embed_scale
)
layers instance-attribute ¶
layers = ModuleList(
[
(
MBartDecoderLayer(
config,
cache_config,
quant_config,
prefix=f"{prefix}.layers.{layer_idx}",
)
)
for layer_idx in (range(decoder_layers))
]
)
__init__ ¶
__init__(
config: BartConfig,
cache_config: CacheConfig | None = None,
quant_config: QuantizationConfig | None = None,
lora_config: LoRAConfig | None = None,
embed_tokens: Embedding | None = None,
prefix: str = "",
)
Source code in vllm/model_executor/models/nemotron_parse.py
forward ¶
forward(
decoder_input_ids: Tensor,
*,
encoder_hidden_states: Tensor | None,
inputs_embeds: Tensor | None = None,
**kwargs,
) -> Tensor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decoder_input_ids | Tensor | Indices of decoder input sequence tokens in the vocabulary. Padding will be ignored by default should you provide it. | required |
encoder_hidden_states | Tensor | None | Tensor of encoder output embeddings | required |
Returns: Decoder output torch.Tensor
Source code in vllm/model_executor/models/nemotron_parse.py
load_weights ¶
Source code in vllm/model_executor/models/nemotron_parse.py
NemotronParseDummyInputsBuilder ¶
Bases: BaseDummyInputsBuilder[NemotronParseProcessingInfo]
Source code in vllm/model_executor/models/nemotron_parse.py
get_dummy_mm_data ¶
get_dummy_mm_data(
seq_len: int,
mm_counts: Mapping[str, int],
mm_options: Mapping[str, BaseDummyOptions]
| None = None,
) -> MultiModalDataDict
Source code in vllm/model_executor/models/nemotron_parse.py
NemotronParseForConditionalGeneration ¶
Bases: Module, SupportsMultiModal
Source code in vllm/model_executor/models/nemotron_parse.py
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 | |
decoder instance-attribute ¶
decoder = MBartDecoderNoPos(
decoder,
cache_config=cache_config,
quant_config=quant_config,
prefix=f"{prefix}.decoder",
)
encoder instance-attribute ¶
encoder = RadioWithNeck(
config=config,
quant_config=quant_config,
prefix=f"{prefix}.encoder",
)
lm_head instance-attribute ¶
lm_head = ParallelLMHead(
vocab_size, d_model, quant_config=quant_config
)
__init__ ¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm/model_executor/models/nemotron_parse.py
_parse_and_validate_image_input ¶
_parse_and_validate_image_input(
**kwargs: object,
) -> NemotronParsePixelInputs | None
Source code in vllm/model_executor/models/nemotron_parse.py
_process_image_input ¶
_process_image_input(
image_input: NemotronParsePixelInputs,
) -> Tensor
Source code in vllm/model_executor/models/nemotron_parse.py
compute_logits ¶
embed_multimodal ¶
embed_multimodal(
**kwargs: object,
) -> MultiModalEmbeddings | None
Source code in vllm/model_executor/models/nemotron_parse.py
forward ¶
forward(
input_ids: Tensor,
positions: Tensor,
encoder_outputs: list[Tensor] | None = None,
**kwargs,
) -> Tensor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_ids | Tensor | torch.Tensor of decoder input token ids. | required |
positions | Tensor | torch.Tensor of decoder position indices. | required |
encoder_outputs | list[Tensor] | None | List of encoder output tensors (vision embeddings). During profiling, this may be None or empty. | None |
Returns: Output torch.Tensor
Source code in vllm/model_executor/models/nemotron_parse.py
get_placeholder_str classmethod ¶
load_weights ¶
Source code in vllm/model_executor/models/nemotron_parse.py
NemotronParseImageProcessor ¶
NemotronParse Image Processor
Source code in vllm/model_executor/models/nemotron_parse.py
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 | |
__call__ ¶
__init__ ¶
__init__(
final_size: tuple = DEFAULT_FINAL_IMAGE_SIZE, **kwargs
)
Source code in vllm/model_executor/models/nemotron_parse.py
_create_transforms ¶
Create transform objects.
Source code in vllm/model_executor/models/nemotron_parse.py
_pad_to_size ¶
Pad image to target size with white padding (matches A.PadIfNeeded behavior).
Source code in vllm/model_executor/models/nemotron_parse.py
_resize_with_aspect_ratio ¶
Resize image maintaining aspect ratio (exact replica of original LongestMaxSizeHW).
Source code in vllm/model_executor/models/nemotron_parse.py
preprocess ¶
Preprocess an image or batch of images for the NemotronParse model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images | Image | list[Image] | Input image(s) | required |
Source code in vllm/model_executor/models/nemotron_parse.py
NemotronParseMultiModalProcessor ¶
Bases: EncDecMultiModalProcessor[NemotronParseProcessingInfo]
Source code in vllm/model_executor/models/nemotron_parse.py
_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/nemotron_parse.py
_get_mm_fields_config ¶
_get_prompt_updates ¶
_get_prompt_updates(
mm_items: MultiModalDataItems,
hf_processor_mm_kwargs: Mapping[str, object],
out_mm_kwargs: MultiModalKwargsItems,
) -> Sequence[PromptUpdate]
Source code in vllm/model_executor/models/nemotron_parse.py
create_encoder_prompt ¶
NemotronParsePixelInputs ¶
Bases: TensorSchema
Dimensions
- b: Batch size
- c: Number of channels (3)
- h: Height
- w: Width
Source code in vllm/model_executor/models/nemotron_parse.py
NemotronParseProcessingInfo ¶
Bases: BaseProcessingInfo
Source code in vllm/model_executor/models/nemotron_parse.py
get_hf_config ¶
get_hf_processor ¶
get_hf_processor(**kwargs) -> NemotronParseProcessor
get_mm_max_tokens_per_item ¶
NemotronParseProcessor ¶
NemotronParse Processor
Source code in vllm/model_executor/models/nemotron_parse.py
image_processor instance-attribute ¶
image_processor = NemotronParseImageProcessor(
final_size=image_size
)
__call__ ¶
__call__(
text: str | None = None,
images: Image | list[Image] | None = None,
return_tensors: str | TensorType | None = None,
**kwargs,
) -> BatchFeature
Source code in vllm/model_executor/models/nemotron_parse.py
__init__ ¶
Source code in vllm/model_executor/models/nemotron_parse.py
_make_batch_input ¶
RadioWithNeck ¶
Bases: Module
Vision encoder using RADIO model with custom neck.
Source code in vllm/model_executor/models/nemotron_parse.py
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 | |
conv2 instance-attribute ¶
conv2 = Conv2d(
last_hidden_state,
last_hidden_state,
kernel_size=(1, 4),
stride=(1, 4),
padding=0,
bias=False,
)
layer_norm1 instance-attribute ¶
layer_norm1 = LayerNorm(
last_hidden_state, eps=1e-06, elementwise_affine=True
)
layer_norm2 instance-attribute ¶
layer_norm2 = LayerNorm(
last_hidden_state, eps=1e-06, elementwise_affine=True
)
layer_norm3 instance-attribute ¶
layer_norm3 = LayerNorm(
last_hidden_state, eps=1e-06, elementwise_affine=True
)
model_encoder instance-attribute ¶
sum_proj instance-attribute ¶
sum_proj = ColumnParallelLinear(
3840,
last_hidden_state,
quant_config=quant_config,
prefix=f"{prefix}.sum_proj",
)
__init__ ¶
__init__(
config: PretrainedConfig,
quant_config: QuantizationConfig | None = None,
prefix: str = "",
)
Source code in vllm/model_executor/models/nemotron_parse.py
forward ¶
Source code in vllm/model_executor/models/nemotron_parse.py
get_vit_model_from_radio_config ¶
get_vit_model_from_radio_config(
hf_config: PretrainedConfig,
quant_config: QuantizationConfig | None = None,
) -> RadioModel