@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 6e9f21e8a2
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 7, 07:45 UTC

[Chore] Remove debug code in model implementation (#35883)

Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>

Isotr0py committed Mar 4, 2026 at 11:50 UTC 6e9f21e8a2ba1e53ee4f1cff4844e11ce600f7fa
2 files changed -178
vllm/model_executor/models/funaudiochat.py
-80
@@ -13,7 +13,6 @@ positions via `inputs_embeds`, while `position_ids` (RoPE) remains standard 1D.
13
14 from __future__ import annotations
15
16 -import os
16 from collections.abc import Iterable, Mapping, Sequence
17 from functools import cached_property
18 from typing import Any
@@ -924,53 +923,6 @@ class FunAudioChatForConditionalGeneration(nn.Module, SupportsMultiModal, Suppor
923 f"sequence of Tensors (got {type(speech_attention_mask)})"
924 )
925
927 - debug = os.getenv("VLLM_FUN_AUDIOCHAT_DEBUG", "") == "1"
928 - if debug:
929 - print(
930 - f"[FunAudioChat] embed_multimodal speech_ids={tuple(speech_ids.shape)} "
931 - f"speech_attention_mask={tuple(speech_attention_mask.shape)}",
932 - flush=True,
933 - )
934 - attn_impl = getattr(
935 - self.continuous_audio_tower.config, "_attn_implementation", None
936 - )
937 - print(
938 - f"[FunAudioChat] audio_attn_impl={attn_impl}",
939 - flush=True,
940 - )
941 - if hasattr(self.continuous_audio_tower, "conv1"):
942 - conv1_w = self.continuous_audio_tower.conv1.weight
943 - print(
944 - f"[FunAudioChat] conv1_w_norm={float(conv1_w.norm().item()):.6g}",
945 - flush=True,
946 - )
947 - try:
948 - attn0 = self.continuous_audio_tower.layers[0].self_attn
949 - q_norm = float(attn0.q_proj.weight.norm().item())
950 - k_norm = float(attn0.k_proj.weight.norm().item())
951 - v_norm = float(attn0.v_proj.weight.norm().item())
952 - o_norm = float(attn0.out_proj.weight.norm().item())
953 - print(
954 - f"[FunAudioChat] attn0_q_norm={q_norm:.6g} "
955 - f"k_norm={k_norm:.6g} "
956 - f"v_norm={v_norm:.6g} "
957 - f"o_norm={o_norm:.6g}",
958 - flush=True,
959 - )
960 - except Exception:
961 - pass
962 - if isinstance(input_features, torch.Tensor):
963 - print(
964 - f"[FunAudioChat] input_features={tuple(input_features.shape)}",
965 - flush=True,
966 - )
967 - if isinstance(feature_attention_mask, torch.Tensor):
968 - print(
969 - "[FunAudioChat] feature_attention_mask="
970 - f"{tuple(feature_attention_mask.shape)}",
971 - flush=True,
972 - )
973 -
926 group_size = int(self.audio_tower.group_size)
927 speech_maxlen = int(speech_ids.shape[-1])
928
@@ -1019,38 +971,6 @@ class FunAudioChatForConditionalGeneration(nn.Module, SupportsMultiModal, Suppor
971 embeds = tuple(
972 audio_features[i, : int(length)] for i, length in enumerate(lengths)
973 )
1022 - if debug:
1023 - embed_lens = [int(t.shape[0]) for t in embeds]
1024 - print(f"[FunAudioChat] embed_multimodal out_lens={embed_lens}", flush=True)
1025 - if embeds:
1026 - t0 = embeds[0]
1027 - print(
1028 - f"[FunAudioChat] embed0 dtype={t0.dtype} device={t0.device} "
1029 - f"nan={bool(torch.isnan(t0).any())} "
1030 - f"norm={float(t0.norm().item()):.6g}",
1031 - flush=True,
1032 - )
1033 - dump_path = os.getenv("VLLM_FUN_AUDIOCHAT_DUMP_PATH", "")
1034 - if (
1035 - dump_path
1036 - and speech_ids.shape[0] == 1
1037 - and len(embeds) == 1
1038 - and embed_lens[0] > 10
1039 - ):
1040 - if not os.path.exists(dump_path):
1041 - np.save(dump_path, embeds[0].detach().float().cpu().numpy())
1042 - print(f"[FunAudioChat] dumped embeds to {dump_path}", flush=True)
1043 - cont_path = dump_path.replace(".npy", "_cont.npy")
1044 - if continuous_audio_features is not None and not os.path.exists(
1045 - cont_path
1046 - ):
1047 - np.save(
1048 - cont_path,
1049 - continuous_audio_features.detach().float().cpu().numpy(),
1050 - )
1051 - print(
1052 - f"[FunAudioChat] dumped continuous to {cont_path}", flush=True
1053 - )
974 return embeds
975
976 def forward(
vllm/model_executor/models/nano_nemotron_vl.py
-98
@@ -2225,104 +2225,6 @@ class NemotronH_Nano_VL_V2(
2225 assert len(sound_weights) > 0
2226 self.sound_encoder.load_weights(sound_weights)
2227
2228 - def print_architecture(self, detailed: bool = True, save_to_file: str = None):
2229 - """
2230 - Print model architecture with parameter names, shapes, and sizes.
2231 -
2232 - Args:
2233 - detailed: If True, show detailed parameter breakdown
2234 - save_to_file: If provided, save output to this file path
2235 - """
2236 - import sys
2237 - from io import StringIO
2238 -
2239 - # Capture output if saving to file
2240 - original_stdout = sys.stdout
2241 - if save_to_file:
2242 - sys.stdout = StringIO()
2243 -
2244 - try:
2245 - print("=" * 100)
2246 - print("NemotronH_Nano_VL_V2 Model Architecture")
2247 - print("=" * 100)
2248 -
2249 - total_params = 0
2250 - param_groups = {
2251 - "language_model": [],
2252 - "vision_model": [],
2253 - "mlp1": [],
2254 - "other": [],
2255 - }
2256 -
2257 - for name, param in self.named_parameters():
2258 - param_size = param.numel()
2259 - total_params += param_size
2260 -
2261 - # Group parameters by main component
2262 - if name.startswith("language_model"):
2263 - param_groups["language_model"].append(
2264 - (name, param.shape, param_size, param.dtype)
2265 - )
2266 - elif name.startswith("vision_model"):
2267 - param_groups["vision_model"].append(
2268 - (name, param.shape, param_size, param.dtype)
2269 - )
2270 - elif name.startswith("mlp1"):
2271 - param_groups["mlp1"].append(
2272 - (name, param.shape, param_size, param.dtype)
2273 - )
2274 - else:
2275 - param_groups["other"].append(
2276 - (name, param.shape, param_size, param.dtype)
2277 - )
2278 -
2279 - if detailed:
2280 - print(
2281 - f"{name:<70} | Shape: {str(param.shape):<25} | "
2282 - f"Size: {param_size:>12,} | Dtype: {param.dtype}"
2283 - )
2284 -
2285 - print("=" * 100)
2286 - print("Summary by Component:")
2287 - print("-" * 60)
2288 -
2289 - for component, params in param_groups.items():
2290 - if params: # Only show components that have parameters
2291 - component_total = sum(size for _, _, size, _ in params)
2292 - percentage = (
2293 - (component_total / total_params) * 100
2294 - if total_params > 0
2295 - else 0
2296 - )
2297 - print(
2298 - f"{component:<20} | Parameters: {len(params):>4} | "
2299 - f"Total Size: {component_total:>15,} | "
2300 - f"{percentage:>6.2f}%"
2301 - )
2302 -
2303 - print("-" * 60)
2304 - print(f"{'Total Parameters':<20} | {total_params:>15,}")
2305 -
2306 - # Estimate memory usage (assuming bfloat16 = 2 bytes per parameter)
2307 - memory_mb = total_params * 2 / (1024**2)
2308 - memory_gb = memory_mb / 1024
2309 - print(f"{'Est. Memory (MB)':<20} | {memory_mb:>15.2f}")
2310 - print(f"{'Est. Memory (GB)':<20} | {memory_gb:>15.2f}")
2311 - print("=" * 100)
2312 -
2313 - # Save to file if requested
2314 - if save_to_file:
2315 - output = sys.stdout.getvalue()
2316 - sys.stdout = original_stdout
2317 - with open(save_to_file, "w") as f:
2318 - f.write(output)
2319 - print(f"Architecture saved to: {save_to_file}")
2320 - print(output) # Also print to console
2321 -
2322 - finally:
2323 - if save_to_file and sys.stdout != original_stdout:
2324 - sys.stdout = original_stdout
2325 -
2228 def get_vit_model_from_radio_config(self, hf_config):
2229 hf_config_vision = hf_config.vision_config
2230 model_name = hf_config_vision.args.get("model")