From 4c51ceb11bbc2177a3639dfae2592cd34b83a7ef Mon Sep 17 00:00:00 2001 From: dmai-afk Date: Wed, 12 Aug 2026 18:02:10 +0700 Subject: [PATCH] [Bugfix][Multimodal] Invalidate retained PyNvVideoCodec decoder after failure (#51139) Signed-off-by: Dat Mai --- .../multimodal/assets/unsupported_8k_h264.mp4 | Bin 0 -> 98767 bytes tests/multimodal/test_video.py | 123 ++++++++++++++++++ vllm/multimodal/video.py | 12 +- 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/multimodal/assets/unsupported_8k_h264.mp4 diff --git a/tests/multimodal/assets/unsupported_8k_h264.mp4 b/tests/multimodal/assets/unsupported_8k_h264.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c81f83823e1bfc11b1d67c7b562a3eed0486336f GIT binary patch literal 98767 zcmeIwJ!~9B6u|L08xRO2EEJ>&nJ^InQN-unwS6*HRx+_7T!54UQXtT2Zg>Xdyrm8Wb9!pf_*!e8gC3Y0!UsxASJ+n~(dgl~Q`> zj;gFF3#I0i@8uhrNfH*-YN(WYbXZ%fI=4P7QsboNjYl3nKED3*wcoz{_0IO^A6@=I z-+BJ`KMtebs$SAbSz8_U)^xoRMUft?to4F5BZ=*<6fD1f{o1QbtNN82TT+?YL=szN zb(Gto(@_wtEJZ=ICX*xQs*UC4gM)+aBuj0Xn{l_Scb5Gr-H|JDsVOU$mE&eZCuU%h zIMB5n#-UE_ATN{MIM|RsZN?@)YOEjW!p3Q4bhAH@D9}}NB<1q#*J&Jf11XV*F0w4u_5Pi`=M|1&vheyexOkNJjnHJmMx^PHoj(9o5K2wAJ}YXZ`1bXFz&r9 z6OFS~ysEQGROQ_X`l`I4y*N;}Rp;H%zW?6Fi!Z6i=DwxuY@T`6u@4TubqMq52{zrAFF8 None: + self.decoder = None + self.source_path = None + def _construct(self, file_path: str, nvc, device_index: int) -> None: - self.decoder = nvc.SimpleDecoder( + self.invalidate() + decoder = nvc.SimpleDecoder( file_path, output_color_type=nvc.OutputColorType.RGB, use_device_memory=True, @@ -271,6 +276,7 @@ class PyNvVideoCodecDecoderSlot: cuda_stream=self.stream.cuda_stream, decoder_cache_size=PYNVVIDEOCODEC_DECODER_CACHE_SIZE, ) + self.decoder = decoder self.source_path = file_path def get_decoder(self, file_path: str, nvc, device_index: int): @@ -747,9 +753,13 @@ class PyNvVideoCodecVideoBackendMixin: cls._decoder_slot_cond.notify() raise + borrow_succeeded = False try: yield slot + borrow_succeeded = True finally: + if not borrow_succeeded: + slot.invalidate() with cls._decoder_slot_cond: cls._decoder_slots.append(slot) cls._decoder_slot_cond.notify()