diff --git a/tests/integration/defs/accuracy/references/mmmu.yaml b/tests/integration/defs/accuracy/references/mmmu.yaml index 365e75f2351c..509272628d86 100644 --- a/tests/integration/defs/accuracy/references/mmmu.yaml +++ b/tests/integration/defs/accuracy/references/mmmu.yaml @@ -42,10 +42,6 @@ Qwen/Qwen2.5-VL-7B-Instruct: accuracy: 40.67 nvidia/Nano-v2-VLM: - accuracy: 43.78 -Efficient-Large-Model/NVILA-8B: - - accuracy: 47.77 -Efficient-Large-Model/VILA1.5-3b: - - accuracy: 32.33 # MMMU for Nemotron-Nano-* models require reasoning on. # While enabling reasoning for current test harness is not supported, the metric here is for model # regression testing, not an indicator of official benchmark results. diff --git a/tests/integration/defs/accuracy/test_llm_api_pytorch_multimodal.py b/tests/integration/defs/accuracy/test_llm_api_pytorch_multimodal.py index 5f869f590ef4..8890f95a995e 100644 --- a/tests/integration/defs/accuracy/test_llm_api_pytorch_multimodal.py +++ b/tests/integration/defs/accuracy/test_llm_api_pytorch_multimodal.py @@ -143,63 +143,6 @@ def test_auto_dtype(self, enable_chunked_prefill, max_num_tokens): task.evaluate(llm, sampling_params=self.sampling_params) -@skip_pre_hopper -class TestNVILA_8B(LlmapiAccuracyTestHarness): - MODEL_NAME = "Efficient-Large-Model/NVILA-8B" - MODEL_PATH = f"{llm_models_root()}/vila/NVILA-8B" - MAX_NUM_TOKENS = 16384 - - # NOTE: MMMU adds <|endoftext|> to the stop token. - sampling_params = SamplingParams( - max_tokens=MMMU.MAX_OUTPUT_LEN, - truncate_prompt_tokens=MMMU.MAX_INPUT_LEN, - stop="<|endoftext|>", - ) - - kv_cache_config = KvCacheConfig( - free_gpu_memory_fraction=0.6, - # NOTE: VILA models do not support block reuse. - enable_block_reuse=False, - ) - - def test_auto_dtype(self): - with LLM( - self.MODEL_PATH, - max_num_tokens=self.MAX_NUM_TOKENS, - kv_cache_config=self.kv_cache_config, - ) as llm: - task = MMMU(self.MODEL_NAME) - task.evaluate(llm, sampling_params=self.sampling_params) - - -class TestVILA1_5_3B(LlmapiAccuracyTestHarness): - MODEL_NAME = "Efficient-Large-Model/VILA1.5-3b" - MODEL_PATH = f"{llm_models_root()}/vila/VILA1.5-3b" - MAX_NUM_TOKENS = 16384 - - # NOTE: MMMU adds <|endoftext|> to the stop token. - sampling_params = SamplingParams( - max_tokens=MMMU.MAX_OUTPUT_LEN, - truncate_prompt_tokens=MMMU.MAX_INPUT_LEN, - stop="<|endoftext|>", - ) - - kv_cache_config = KvCacheConfig( - free_gpu_memory_fraction=0.6, - # NOTE: VILA models do not support block reuse. - enable_block_reuse=False, - ) - - def test_auto_dtype(self): - with LLM( - self.MODEL_PATH, - max_num_tokens=self.MAX_NUM_TOKENS, - kv_cache_config=self.kv_cache_config, - ) as llm: - task = MMMU(self.MODEL_NAME) - task.evaluate(llm, sampling_params=self.sampling_params) - - @skip_pre_hopper class TestNemotron_Nano_12B_V2_VL(LlmapiAccuracyTestHarness): MODEL_NAME = "nvidia/NVIDIA-Nemotron-Nano-12B-v2-VL-BF16" diff --git a/tests/integration/defs/conftest.py b/tests/integration/defs/conftest.py index 2155e7d65548..7dfd00ee261f 100644 --- a/tests/integration/defs/conftest.py +++ b/tests/integration/defs/conftest.py @@ -560,8 +560,6 @@ def multimodal_model_root(request, llm_venv): assert models_root, "Did you set LLM_MODELS_ROOT?" tllm_model_name = request.param - if "VILA" in tllm_model_name: - models_root = os.path.join(llm_models_root(), "vila") if "cogvlm-chat" in tllm_model_name: models_root = os.path.join(llm_models_root(), "cogvlm-chat") if "video-neva" in tllm_model_name: diff --git a/tests/integration/test_lists/qa/llm_function_core.txt b/tests/integration/test_lists/qa/llm_function_core.txt index a3c05c0f24d5..46497f84b6cb 100644 --- a/tests/integration/test_lists/qa/llm_function_core.txt +++ b/tests/integration/test_lists/qa/llm_function_core.txt @@ -794,7 +794,6 @@ accuracy/test_llm_api_pytorch_multimodal.py::TestGemma3_27BInstruct::test_fp8_pr accuracy/test_llm_api_pytorch_multimodal.py::TestKimiK25::test_nvfp4[dep8] accuracy/test_llm_api_pytorch_multimodal.py::TestMistralLarge3_675B::test_nvfp4_4gpus[latency_moe_trtllm] accuracy/test_llm_api_pytorch_multimodal.py::TestMistralSmall24B::test_auto_dtype[forced_chunked_prefill] -accuracy/test_llm_api_pytorch_multimodal.py::TestNVILA_8B::test_auto_dtype accuracy/test_llm_api_pytorch_multimodal.py::TestNanoV3Omni::test_auto_dtype[bf16] accuracy/test_llm_api_pytorch_multimodal.py::TestNanoV3Omni::test_auto_dtype[fp8] accuracy/test_llm_api_pytorch_multimodal.py::TestNanoV3Omni::test_auto_dtype[fp8_mmmu_encoder_cuda_graph] @@ -811,7 +810,6 @@ accuracy/test_llm_api_pytorch_multimodal.py::TestStep3_7::test_fp8_block_scales[ accuracy/test_llm_api_pytorch_multimodal.py::TestStep3_7::test_fp8_block_scales[mtp_nextn=3] TIMEOUT (120) accuracy/test_llm_api_pytorch_multimodal.py::TestStep3_7::test_nvfp4[mtp_nextn=0] TIMEOUT (120) accuracy/test_llm_api_pytorch_multimodal.py::TestStep3_7::test_nvfp4[mtp_nextn=3] TIMEOUT (120) -accuracy/test_llm_api_pytorch_multimodal.py::TestVILA1_5_3B::test_auto_dtype accuracy/test_llm_api_pytorch_ray.py::TestLlama3_1_8BInstruct::test_pp2_ray unittest/disaggregated/test_cache_transceiver_single_process.py::test_cache_transceiver_v1_masked_dsa_indexer_across_asymmetric_pp disaggregated/test_ad_disagg.py::test_async_eagle3_full_model_handoff diff --git a/tests/integration/test_lists/qa/llm_function_rtx6k.txt b/tests/integration/test_lists/qa/llm_function_rtx6k.txt index 0ad2b58d7e21..26ac472678db 100644 --- a/tests/integration/test_lists/qa/llm_function_rtx6k.txt +++ b/tests/integration/test_lists/qa/llm_function_rtx6k.txt @@ -177,4 +177,3 @@ accuracy/test_llm_api_pytorch.py::TestQwen3_5_4B::test_bf16 accuracy/test_llm_api_pytorch.py::TestQwen3_5_4B::test_dflash accuracy/test_llm_api_pytorch.py::TestQwen3_5_4B::test_fp8 accuracy/test_llm_api_pytorch.py::TestQwen3_8B::test_dflash -accuracy/test_llm_api_pytorch_multimodal.py::TestNVILA_8B::test_auto_dtype diff --git a/tests/integration/test_lists/test-db/l0_l40s.yml b/tests/integration/test_lists/test-db/l0_l40s.yml index 8a2e75eeee59..4deb7d3893c3 100644 --- a/tests/integration/test_lists/test-db/l0_l40s.yml +++ b/tests/integration/test_lists/test-db/l0_l40s.yml @@ -16,7 +16,6 @@ l0_l40s: # ------------- PyTorch tests --------------- # Multimodal modeling tests - unittest/_torch/modeling -k "modeling_siglip" - - unittest/_torch/modeling -k "modeling_vila" - unittest/_torch/modeling -k "modeling_nemotron_nano_v2_vl" - unittest/_torch/modeling/test_modeling_qwen2_5vl.py::TestQwen2_5_VL::test_all - unittest/_torch/modeling/test_modeling_qwen3vl_moe.py::TestQwen3VLMoe::test_all diff --git a/tests/integration/test_lists/waives.txt b/tests/integration/test_lists/waives.txt index 06842f2cb211..e691e40998e6 100644 --- a/tests/integration/test_lists/waives.txt +++ b/tests/integration/test_lists/waives.txt @@ -200,8 +200,6 @@ full:GB300/accuracy/test_llm_api_pytorch.py::TestQwen3_5_35B_A3B::test_fp8_moe_d full:GB300/accuracy/test_llm_api_pytorch_multimodal.py::TestExaone4_5_33B::test_auto_dtype[forced_chunked_prefill] SKIP (https://nvbugs/6597570) full:GB300/accuracy/test_llm_api_pytorch_multimodal.py::TestExaone4_5_33B::test_auto_dtype[full_budget] SKIP (https://nvbugs/6597570) full:GB300/accuracy/test_llm_api_pytorch_multimodal.py::TestGemma3_27BInstruct::test_fp8_prequantized SKIP (https://nvbugs/6479708) -full:GB300/accuracy/test_llm_api_pytorch_multimodal.py::TestNVILA_8B::test_auto_dtype SKIP (https://nvbugs/6597570) -full:GB300/accuracy/test_llm_api_pytorch_multimodal.py::TestVILA1_5_3B::test_auto_dtype SKIP (https://nvbugs/6597570) full:GB300/disaggregated/test_disaggregated.py::test_disaggregated_deepseek_v3_lite_fp8_attention_dp_overlap[DeepSeek-V3-Lite-fp8] SKIP (https://nvbugs/6581064) full:GB300/perf/test_perf_sanity.py::test_e2e[disagg_upload-gen_only-gb300_kimi-k25-thinking-fp4_8k1k_con4_ctx1_dep4_gen1_tep8_eplb0_mtp3_ccb-NIXL] SKIP (https://nvbugs/6572464) full:H100/accuracy/test_disaggregated_serving.py::TestDeepSeekV3Lite::test_auto_dtype[mtp_nextn=2-overlap_scheduler=False] SKIP (https://nvbugs/6313072) diff --git a/tests/unittest/_torch/attention/model_attn_config.py b/tests/unittest/_torch/attention/model_attn_config.py index b6f32e2fbbe3..1c82d2e2b774 100644 --- a/tests/unittest/_torch/attention/model_attn_config.py +++ b/tests/unittest/_torch/attention/model_attn_config.py @@ -248,13 +248,6 @@ class ModelAttnConfig: num_kv_heads=32, head_dim=128, ), - ModelAttnConfig( - "vila1_5_3b_mha", - "VILA1.5-3B LLM", - num_heads=20, - num_kv_heads=20, - head_dim=128, - ), ModelAttnConfig( "llama2_13b_qwen1_5_14b_mha", "Llama-2-13B, Qwen1.5-14B", diff --git a/tests/unittest/_torch/modeling/test_modeling_vila.py b/tests/unittest/_torch/modeling/test_modeling_vila.py deleted file mode 100644 index f846fcbe5bbb..000000000000 --- a/tests/unittest/_torch/modeling/test_modeling_vila.py +++ /dev/null @@ -1,737 +0,0 @@ -import unittest -from copy import deepcopy -from types import SimpleNamespace -from typing import Any - -import pytest -import torch -from parameterized import parameterized -from utils.llm_data import llm_models_root - -import tensorrt_llm -from tensorrt_llm._torch.attention_backend.utils import get_attention_backend -from tensorrt_llm._torch.metadata import KVCacheParams -from tensorrt_llm._torch.model_config import ModelConfig -from tensorrt_llm._torch.models.modeling_vila import ( - VilaConfig, VilaModel, _validate_vila_mm_alignment, fuse_input_embeds) -from tensorrt_llm._torch.pyexecutor.resource_manager import KVCacheManager -from tensorrt_llm.bindings.executor import KvCacheConfig -from tensorrt_llm.mapping import Mapping - -VILA_1_5_3B_CONFIG = { - "_name_or_path": f"{llm_models_root()}/vila/VILA1.5-3b", - "architectures": ["LlavaLlamaModel"], - "drop_path_rate": 0.0, - "hidden_size": 2560, - "image_aspect_ratio": "resize", - "interpolate_mode": "linear", - "llm_cfg": { - "_name_or_path": "./llm", - "add_cross_attention": False, - "architectures": ["LlamaForCausalLM"], - "attention_bias": False, - "attention_dropout": 0.0, - "bad_words_ids": None, - "begin_suppress_tokens": None, - "bos_token_id": 1, - "chunk_size_feed_forward": 0, - "cross_attention_hidden_size": None, - "decoder_start_token_id": None, - "diversity_penalty": 0.0, - "do_sample": False, - "early_stopping": False, - "encoder_no_repeat_ngram_size": 0, - "eos_token_id": 2, - "exponential_decay_length_penalty": None, - "finetuning_task": None, - "forced_bos_token_id": None, - "forced_eos_token_id": None, - "hidden_act": "silu", - "hidden_size": 2560, - "id2label": { - "0": "LABEL_0", - "1": "LABEL_1" - }, - "initializer_range": 0.02, - "intermediate_size": 6912, - "is_decoder": False, - "is_encoder_decoder": False, - "label2id": { - "LABEL_0": 0, - "LABEL_1": 1 - }, - "length_penalty": 1.0, - "max_length": 20, - "max_position_embeddings": 4096, - "min_length": 0, - "model_max_length": 4096, - "model_type": "llama", - "no_repeat_ngram_size": 0, - "num_attention_heads": 20, - "num_beam_groups": 1, - "num_beams": 1, - "num_hidden_layers": 32, - "num_key_value_heads": 20, - "num_return_sequences": 1, - "output_attentions": False, - "output_hidden_states": False, - "output_scores": False, - "pad_token_id": 0, - "prefix": None, - "pretraining_tp": 1, - "problem_type": None, - "pruned_heads": {}, - "remove_invalid_values": False, - "repetition_penalty": 1.0, - "return_dict": True, - "return_dict_in_generate": False, - "rms_norm_eps": 1e-5, - "rope_scaling": None, - "rope_theta": 10000.0, - "sep_token_id": None, - "suppress_tokens": None, - "task_specific_params": None, - "temperature": 1.0, - "tf_legacy_loss": False, - "tie_encoder_decoder": False, - "tie_word_embeddings": False, - "tokenizer_class": None, - "tokenizer_model_max_length": 4096, - "tokenizer_padding_side": "right", - "top_k": 50, - "top_p": 1.0, - "torch_dtype": "bfloat16", - "torchscript": False, - "typical_p": 1.0, - "use_bfloat16": False, - "use_cache": True, - "vocab_size": 32000 - }, - "mm_hidden_size": 1152, - "mm_projector_cfg": { - "_name_or_path": "./mm_projector", - "add_cross_attention": False, - "architectures": ["MultimodalProjector"], - "bad_words_ids": None, - "begin_suppress_tokens": None, - "bos_token_id": None, - "chunk_size_feed_forward": 0, - "cross_attention_hidden_size": None, - "decoder_start_token_id": None, - "diversity_penalty": 0.0, - "do_sample": False, - "early_stopping": False, - "encoder_no_repeat_ngram_size": 0, - "eos_token_id": None, - "exponential_decay_length_penalty": None, - "finetuning_task": None, - "forced_bos_token_id": None, - "forced_eos_token_id": None, - "id2label": { - "0": "LABEL_0", - "1": "LABEL_1" - }, - "is_decoder": False, - "is_encoder_decoder": False, - "label2id": { - "LABEL_0": 0, - "LABEL_1": 1 - }, - "length_penalty": 1.0, - "max_length": 20, - "min_length": 0, - "mm_projector_type": "mlp_downsample", - "model_type": "v2l_projector", - "no_repeat_ngram_size": 0, - "num_beam_groups": 1, - "num_beams": 1, - "num_return_sequences": 1, - "output_attentions": False, - "output_hidden_states": False, - "output_scores": False, - "pad_token_id": None, - "prefix": None, - "problem_type": None, - "pruned_heads": {}, - "remove_invalid_values": False, - "repetition_penalty": 1.0, - "return_dict": True, - "return_dict_in_generate": False, - "sep_token_id": None, - "suppress_tokens": None, - "task_specific_params": None, - "temperature": 1.0, - "tf_legacy_loss": False, - "tie_encoder_decoder": False, - "tie_word_embeddings": True, - "tokenizer_class": None, - "top_k": 50, - "top_p": 1.0, - "torch_dtype": "bfloat16", - "torchscript": False, - "typical_p": 1.0, - "use_bfloat16": False - }, - "mm_projector_lr": None, - "mm_use_im_patch_token": False, - "mm_use_im_start_end": False, - "mm_vision_select_feature": "cls_patch", - "mm_vision_select_layer": -2, - "model_dtype": "torch.bfloat16", - "model_type": "llava_llama", - "num_video_frames": 8, - "resume_path": "./vlm", - "s2": False, - "s2_max_split_size": 336, - "s2_scales": "336,672,1008", - "transformers_version": "4.36.2", - "tune_language_model": True, - "tune_mm_projector": True, - "tune_vision_tower": True, - "vision_resolution": -1, - "vision_tower_cfg": { - "_name_or_path": "./vision_tower", - "add_cross_attention": False, - "architectures": ["SiglipVisionModel"], - "attention_dropout": 0.0, - "bad_words_ids": None, - "begin_suppress_tokens": None, - "bos_token_id": None, - "chunk_size_feed_forward": 0, - "cross_attention_hidden_size": None, - "decoder_start_token_id": None, - "diversity_penalty": 0.0, - "do_sample": False, - "early_stopping": False, - "encoder_no_repeat_ngram_size": 0, - "eos_token_id": None, - "exponential_decay_length_penalty": None, - "finetuning_task": None, - "forced_bos_token_id": None, - "forced_eos_token_id": None, - "hidden_act": "gelu_pytorch_tanh", - "hidden_size": 1152, - "id2label": { - "0": "LABEL_0", - "1": "LABEL_1" - }, - "image_size": 384, - "intermediate_size": 4304, - "is_decoder": False, - "is_encoder_decoder": False, - "label2id": { - "LABEL_0": 0, - "LABEL_1": 1 - }, - "layer_norm_eps": 1e-06, - "length_penalty": 1.0, - "max_length": 20, - "min_length": 0, - "model_type": "siglip_vision_model", - "no_repeat_ngram_size": 0, - "num_attention_heads": 16, - "num_beam_groups": 1, - "num_beams": 1, - "num_channels": 3, - "num_hidden_layers": 27, - "num_return_sequences": 1, - "output_attentions": False, - "output_hidden_states": False, - "output_scores": False, - "pad_token_id": None, - "patch_size": 14, - "prefix": None, - "problem_type": None, - "pruned_heads": {}, - "remove_invalid_values": False, - "repetition_penalty": 1.0, - "return_dict": True, - "return_dict_in_generate": False, - "sep_token_id": None, - "suppress_tokens": None, - "task_specific_params": None, - "temperature": 1.0, - "tf_legacy_loss": False, - "tie_encoder_decoder": False, - "tie_word_embeddings": True, - "tokenizer_class": None, - "top_k": 50, - "top_p": 1.0, - "torch_dtype": "bfloat16", - "torchscript": False, - "typical_p": 1.0, - "use_bfloat16": False - } -} - -NVILA_8B_CONFIG = { - "_attn_implementation_autoset": True, - "_name_or_path": f"{llm_models_root()}/vila/NVILA-8B", - "architectures": ["LlavaLlamaModel"], - "chat_template": None, - "drop_path_rate": 0.0, - "dynamic_s2": True, - "fps": 0.0, - "hidden_size": 3584, - "image_aspect_ratio": "dynamic_s2", - "interpolate_mode": "linear", - "llm_cfg": { - "_attn_implementation_autoset": False, - "_name_or_path": - "runs/train/qwen25-8B-dynamic_s2-stage3-20241126000711/model/llm", - "add_cross_attention": False, - "architectures": ["Qwen2ForCausalLM"], - "attention_dropout": 0.0, - "bad_words_ids": None, - "begin_suppress_tokens": None, - "bos_token_id": 151643, - "chunk_size_feed_forward": 0, - "cross_attention_hidden_size": None, - "decoder_start_token_id": None, - "diversity_penalty": 0.0, - "do_sample": False, - "early_stopping": False, - "encoder_no_repeat_ngram_size": 0, - "eos_token_id": 151645, - "exponential_decay_length_penalty": None, - "finetuning_task": None, - "forced_bos_token_id": None, - "forced_eos_token_id": None, - "hidden_act": "silu", - "hidden_size": 3584, - "id2label": { - "0": "LABEL_0", - "1": "LABEL_1" - }, - "initializer_range": 0.02, - "intermediate_size": 18944, - "is_decoder": False, - "is_encoder_decoder": False, - "label2id": { - "LABEL_0": 0, - "LABEL_1": 1 - }, - "length_penalty": 1.0, - "max_length": 20, - "max_position_embeddings": 32768, - "max_window_layers": 28, - "min_length": 0, - "model_max_length": 8192, - "model_type": "qwen2", - "no_repeat_ngram_size": 0, - "num_attention_heads": 28, - "num_beam_groups": 1, - "num_beams": 1, - "num_hidden_layers": 28, - "num_key_value_heads": 4, - "num_return_sequences": 1, - "output_attentions": False, - "output_hidden_states": False, - "output_scores": False, - "pad_token_id": None, - "prefix": None, - "problem_type": None, - "pruned_heads": {}, - "remove_invalid_values": False, - "repetition_penalty": 1.0, - "return_dict": True, - "return_dict_in_generate": False, - "rms_norm_eps": 1e-06, - "rope_scaling": None, - "rope_theta": 1000000.0, - "sep_token_id": None, - "sliding_window": None, - "suppress_tokens": None, - "task_specific_params": None, - "temperature": 1.0, - "tf_legacy_loss": False, - "tie_encoder_decoder": False, - "tie_word_embeddings": False, - "tokenizer_class": None, - "tokenizer_model_max_length": 8192, - "tokenizer_padding_side": "right", - "top_k": 50, - "top_p": 1.0, - "torch_dtype": "bfloat16", - "torchscript": False, - "typical_p": 1.0, - "use_bfloat16": False, - "use_cache": True, - "use_sliding_window": False, - "vocab_size": 151648 - }, - "mm_hidden_size": 3456, - "mm_projector_cfg": { - "_attn_implementation_autoset": False, - "_name_or_path": - "runs/train/qwen25-8B-dynamic_s2-stage3-20241126000711/model/mm_projector", - "add_cross_attention": False, - "architectures": ["MultimodalProjector"], - "bad_words_ids": None, - "begin_suppress_tokens": None, - "bos_token_id": None, - "chunk_size_feed_forward": 0, - "cross_attention_hidden_size": None, - "decoder_start_token_id": None, - "diversity_penalty": 0.0, - "do_sample": False, - "early_stopping": False, - "encoder_no_repeat_ngram_size": 0, - "eos_token_id": None, - "exponential_decay_length_penalty": None, - "finetuning_task": None, - "forced_bos_token_id": None, - "forced_eos_token_id": None, - "id2label": { - "0": "LABEL_0", - "1": "LABEL_1" - }, - "is_decoder": False, - "is_encoder_decoder": False, - "label2id": { - "LABEL_0": 0, - "LABEL_1": 1 - }, - "length_penalty": 1.0, - "max_length": 20, - "min_length": 0, - "mm_projector_type": "mlp_downsample", - "model_type": "v2l_projector", - "no_repeat_ngram_size": 0, - "num_beam_groups": 1, - "num_beams": 1, - "num_return_sequences": 1, - "output_attentions": False, - "output_hidden_states": False, - "output_scores": False, - "pad_token_id": None, - "prefix": None, - "problem_type": None, - "pruned_heads": {}, - "remove_invalid_values": False, - "repetition_penalty": 1.0, - "return_dict": True, - "return_dict_in_generate": False, - "sep_token_id": None, - "suppress_tokens": None, - "task_specific_params": None, - "temperature": 1.0, - "tf_legacy_loss": False, - "tie_encoder_decoder": False, - "tie_word_embeddings": True, - "tokenizer_class": None, - "top_k": 50, - "top_p": 1.0, - "torch_dtype": "bfloat16", - "torchscript": False, - "typical_p": 1.0, - "use_bfloat16": False - }, - "mm_projector_lr": None, - "mm_use_im_patch_token": True, - "mm_use_im_start_end": False, - "mm_vision_select_feature": "cls_patch", - "mm_vision_select_layer": -2, - "model_dtype": "torch.bfloat16", - "model_type": "llava_llama", - "num_time_tokens": 0, - "num_video_frames": 8, - "resume_path": - "runs/train/qwen25-8B-dynamic_s2-stage3-20241126000711/model", - "s2": False, - "s2_max_split_size": 448, - "s2_resize_output_to_scale_idx": -1, - "s2_scales": "448,896,1344", - "soft_ce_std": 1.0, - "time_token_format": "", - "time_token_ids": [], - "transformers_version": "4.46.0", - "tune_language_model": True, - "tune_mm_projector": True, - "tune_vision_tower": True, - "vision_resolution": -1, - "vision_tower_cfg": { - "_attn_implementation_autoset": False, - "_name_or_path": - "runs/train/qwen25-8B-dynamic_s2-stage3-20241126000711/model/vision_tower", - "add_cross_attention": False, - "architectures": ["SiglipVisionModel"], - "attention_dropout": 0.0, - "bad_words_ids": None, - "begin_suppress_tokens": None, - "bos_token_id": None, - "chunk_size_feed_forward": 0, - "cross_attention_hidden_size": None, - "decoder_start_token_id": None, - "diversity_penalty": 0.0, - "do_sample": False, - "early_stopping": False, - "encoder_no_repeat_ngram_size": 0, - "eos_token_id": None, - "exponential_decay_length_penalty": None, - "finetuning_task": None, - "forced_bos_token_id": None, - "forced_eos_token_id": None, - "hidden_act": "gelu_pytorch_tanh", - "hidden_size": 1152, - "id2label": { - "0": "LABEL_0", - "1": "LABEL_1" - }, - "image_size": 448, - "intermediate_size": 4304, - "is_decoder": False, - "is_encoder_decoder": False, - "label2id": { - "LABEL_0": 0, - "LABEL_1": 1 - }, - "layer_norm_eps": 1e-06, - "length_penalty": 1.0, - "max_length": 20, - "min_length": 0, - "model_type": "siglip_vision_model", - "no_repeat_ngram_size": 0, - "num_attention_heads": 16, - "num_beam_groups": 1, - "num_beams": 1, - "num_channels": 3, - "num_hidden_layers": 27, - "num_image_tokens": 256, - "num_return_sequences": 1, - "output_attentions": False, - "output_hidden_states": False, - "output_scores": False, - "pad_token_id": None, - "patch_size": 14, - "prefix": None, - "problem_type": None, - "projection_dim": 2048, - "projector_hidden_act": "gelu_fast", - "pruned_heads": {}, - "remove_invalid_values": False, - "repetition_penalty": 1.0, - "return_dict": True, - "return_dict_in_generate": False, - "sep_token_id": None, - "suppress_tokens": None, - "task_specific_params": None, - "temperature": 1.0, - "tf_legacy_loss": False, - "tie_encoder_decoder": False, - "tie_word_embeddings": True, - "tokenizer_class": None, - "top_k": 50, - "top_p": 1.0, - "torch_dtype": "bfloat16", - "torchscript": False, - "typical_p": 1.0, - "use_bfloat16": False, - "vision_use_head": False, - } -} - - -def reduce_vila_config(mem_for_full_model: int, config_dict: dict[str, Any]): - _, total_mem = torch.cuda.mem_get_info() - # scale model down if gpu memory is low - if total_mem < mem_for_full_model: - model_fraction = total_mem / mem_for_full_model - num_layers = int(config_dict['llm_cfg']["num_hidden_layers"] * - model_fraction) - num_layers = min(num_layers, 32) - config_dict['llm_cfg']["num_hidden_layers"] = num_layers - - -class TestVila(unittest.TestCase): - - @parameterized.expand([(VILA_1_5_3B_CONFIG, 3), (NVILA_8B_CONFIG, 8)]) - def test_vila_sanity(self, config_dict, param_cnt): - model, input_ids, position_ids, past_seen_tokens, attn_metadata, kv_cache_manager = \ - self._prepare_sanity_test(config_dict, param_cnt) - - with torch.inference_mode(): - attn_metadata.prepare() - logits = model.forward(input_ids=input_ids, - position_ids=position_ids, - attn_metadata=attn_metadata) - - self.assertEqual(len(past_seen_tokens), logits.shape[0]) - - with torch.inference_mode(): - attn_metadata.prepare() - logits = model.forward(input_ids=input_ids, - position_ids=position_ids, - attn_metadata=attn_metadata, - return_context_logits=True) - self.assertEqual(input_ids.shape, logits.shape[:-1]) - - kv_cache_manager.shutdown() - - def test_vila_fuse_input_embeds(self): - config_dict = deepcopy(VILA_1_5_3B_CONFIG) - model, _, _, _, _, _ = self._prepare_sanity_test(config_dict, 3) - - device = torch.device('cuda') - dtype = model.model_dtype - - input_ids = torch.tensor([ - 1, 319, 13563, 1546, 263, 12758, 5199, 322, 385, 23116, 21082, - 20255, 29889, 12968, 29901, 29871, 32000, 32001, 32002, 32003, - 32004, 32005, 32006, 32007, 32008, 32009, 32010, 32011, 32012, - 32013, 32014, 32015, 32016, 32017, 32018, 32019, 32020, 32021, - 32022, 32023, 32024, 32025, 32026, 32027, 32028, 32029, 32030, - 32031, 32032, 32033, 32034, 32035, 32036, 32037, 32038, 32039, - 32040, 32041, 32042, 32043, 32044, 32045, 32046, 32047, 32048, - 32049, 32050, 32051, 32052, 32053, 32054, 32055, 32056, 32057, - 32058, 32059, 32060, 32061, 32062, 32063, 32064, 32065, 32066, - 32067, 32068, 32069, 32070, 32071, 32072, 32073, 32074, 32075, - 32076, 32077, 32078, 32079, 32080, 32081, 32082, 32083, 32084, - 32085, 32086, 32087, 32088, 32089, 32090, 32091, 32092, 32093, - 32094, 32095, 32096, 32097, 32098, 32099, 32100, 32101, 32102, - 32103, 32104, 32105, 32106, 32107, 32108, 32109, 32110, 32111, - 32112, 32113, 32114, 32115, 32116, 32117, 32118, 32119, 32120, - 32121, 32122, 32123, 32124, 32125, 32126, 32127, 32128, 32129, - 32130, 32131, 32132, 32133, 32134, 32135, 32136, 32137, 32138, - 32139, 32140, 32141, 32142, 32143, 32144, 32145, 32146, 32147, - 32148, 32149, 32150, 32151, 32152, 32153, 32154, 32155, 32156, - 32157, 32158, 32159, 32160, 32161, 32162, 32163, 32164, 32165, - 32166, 32167, 32168, 32169, 32170, 32171, 32172, 32173, 32174, - 32175, 32176, 32177, 32178, 32179, 32180, 32181, 32182, 32183, - 32184, 32185, 32186, 32187, 32188, 32189, 32190, 32191, 32192, - 32193, 32194, 32195, 29871, 320, 29876, 20355, 915, 278, 1203, 322, - 278, 14826, 4195, 297, 278, 1967, 29889, 2277, 29937, 7900, 22137, - 29901, 450 - ], - device=device, - dtype=torch.int) - images = [torch.rand(196, 2560, dtype=dtype, device=device)] - input_ids, input_embeds = fuse_input_embeds( - model.llm.model.embed_tokens, input_ids, images) - self.assertIsNone(input_ids) - self.assertEqual(list(input_embeds.shape), [233, 2560]) - - def _prepare_sanity_test(self, config_dict, param_cnt): - config_dict = deepcopy(config_dict) - # (param_cnt)B * sizeof(float16) plus some extra for activations - mem_for_full_model = (2 + 1) * param_cnt * 2**(30) - reduce_vila_config(mem_for_full_model, config_dict) - if config_dict['llm_cfg']["num_hidden_layers"] <= 0: - self.skipTest("Insufficient memory for a single Llava layer") - vila_config = VilaConfig.from_dict(config_dict) - device = torch.device('cuda') - - model_config = ModelConfig(pretrained_config=vila_config, - quant_config=None) - model = VilaModel(model_config).to(device) - - dtype = model.model_dtype - - input_ids = torch.tensor([100, 200, 300, 100, 200, 100, 400, 500], - dtype=torch.int, - device=device) - - context_sequence_lengths = [3, 2, 1] - sequence_lengths = context_sequence_lengths + [1, 1] - past_seen_tokens = [0, 0, 0, 62, 75] - batch_size = len(sequence_lengths) - request_ids = list(range(batch_size)) - token_nums = (torch.tensor(past_seen_tokens) + - torch.tensor(sequence_lengths)).tolist() - prompt_lens = token_nums[:3] + past_seen_tokens[3:] - - num_blocks = 100 - tokens_per_block = 128 - head_dim = model.config.hidden_size // model.config.num_attention_heads - num_layers = model.config.num_hidden_layers - num_kv_heads = model.config.num_key_value_heads - max_seq_len = num_blocks * tokens_per_block - - if dtype == torch.half: - kv_cache_dtype = tensorrt_llm.bindings.DataType.HALF - elif dtype == torch.bfloat16: - kv_cache_dtype = tensorrt_llm.bindings.DataType.BF16 - else: - raise ValueError(f"Invalid dtype: {dtype}") - - mapping = Mapping(world_size=1, tp_size=1, rank=0) - kv_cache_config = KvCacheConfig(max_tokens=num_blocks * - tokens_per_block) - kv_cache_manager = KVCacheManager( - kv_cache_config, - tensorrt_llm.bindings.internal.batch_manager.CacheType.SELF, - num_layers=num_layers, - num_kv_heads=num_kv_heads, - head_dim=head_dim, - tokens_per_block=tokens_per_block, - max_seq_len=max_seq_len, - max_batch_size=batch_size, - mapping=mapping, - dtype=kv_cache_dtype, - ) - kv_cache_manager.add_dummy_requests(request_ids, token_nums) - - metadata_cls = get_attention_backend(model_config.attn_backend).Metadata - attn_metadata = metadata_cls( - seq_lens=torch.tensor(sequence_lengths, dtype=torch.int), - num_contexts=len(context_sequence_lengths), - kv_cache_params=KVCacheParams( - use_cache=True, - num_cached_tokens_per_seq=past_seen_tokens, - ), - kv_cache_manager=kv_cache_manager, - request_ids=request_ids, - prompt_lens=prompt_lens, - max_num_requests=batch_size, - max_num_tokens=8192, - ) - - position_ids = [] - for i, tokens in enumerate(past_seen_tokens): - seq_len = context_sequence_lengths[i] if i < len( - context_sequence_lengths) else 1 - position_id = torch.arange(tokens, - tokens + seq_len, - device=input_ids.device) - position_ids.append(position_id) - - position_ids = torch.cat(position_ids).unsqueeze(0) - return model, input_ids, position_ids, past_seen_tokens, attn_metadata, kv_cache_manager - - -def test_validate_vila_mm_alignment_locates_in_vocab_media_tokens(): - """VILA expands media placeholders to the in-vocab media token id, so the - alignment check must locate them via ``mm_token_ids`` (torch.isin). With the - legacy OOV (``>= vocab_size``) predicate it would find zero positions and - raise a spurious count mismatch.""" - vocab_size = 100 - media_token_id = 42 - # text, 3 in-vocab media tokens, text - input_ids = torch.tensor( - [1, media_token_id, media_token_id, media_token_id, 2], dtype=torch.int) - embedding_layer = SimpleNamespace(num_embeddings=vocab_size) - mm_embeds = [torch.zeros(3, 8)] - mm_token_ids = torch.tensor([media_token_id], dtype=torch.int32) - - text_token_indices, mm_token_indices = _validate_vila_mm_alignment( - input_ids=input_ids, - embedding_layer=embedding_layer, - mm_embeds=mm_embeds, - mm_token_ids=mm_token_ids, - ) - - torch.testing.assert_close(mm_token_indices.cpu(), torch.tensor([1, 2, 3])) - torch.testing.assert_close(text_token_indices.cpu(), torch.tensor([0, 4])) - - -def test_validate_vila_mm_alignment_raises_on_count_mismatch(): - """A genuine token/embed count mismatch must still raise.""" - input_ids = torch.tensor([1, 42, 42, 2], dtype=torch.int) - embedding_layer = SimpleNamespace(num_embeddings=100) - with pytest.raises(ValueError, match="Multimodal token count mismatch"): - _validate_vila_mm_alignment( - input_ids=input_ids, - embedding_layer=embedding_layer, - mm_embeds=[torch.zeros(5, 8)], # 5 embeds != 2 media tokens - mm_token_ids=torch.tensor([42], dtype=torch.int32), - )