transformers
1f8daee0 - tests: reduce processor test memory usage by using tiny Hub checkpoints (#47213)

Commit
3 days ago
tests: reduce processor test memory usage by using tiny Hub checkpoints (#47213) * tests/kimi_k25: add tiny_model_id to speed up processor tests Use hf-internal-testing/tiny-processor-kimi_k25 (75KB tokenizer vs 19MB full) so most tests load the tiny processor instead of the full one. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests/llama4: add tiny_model_id, remove _setup_tokenizer hook Use hf-internal-testing/tiny-processor-llama4 (500 vocab vs 200k) so tests load the tiny processor instead of the full one. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests/deepseek_ocr2,got_ocr2: add tiny_model_id, remove _setup_tokenizer - deepseek_ocr2: tiny-processor-deepseek_ocr2 (500 vocab vs 102k) - got_ocr2: tiny-processor-got_ocr2 (500 vocab vs 32k); add _setup_image_processor() to preserve default 384x384 size; update test_ocr_queries expected input_ids shapes for tiny tokenizer Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix * Add analyze_mem.py and memory_tracker_plugin from debug_mem Brings memory profiling tooling into fix_slow_processor branch: - analyze_mem.py: runs processor tests and aggregates memory usage - memory_tracker_plugin.py: pytest plugin for per-test memory tracking - conftest.py: integrate memory tracker plugin Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix processor test failures for florence2, granite4_vision, pp_chart2table - florence2: skip 6 tests that check max_length/padding; processor always produces ~585 tokens (256 image tokens + task prompt) and does not forward tokenizer padding kwargs - granite4_vision: add _setup_image_processor with LlavaNextImageProcessor (returns required image_sizes key); add num_additional_image_tokens=1 to prepare_processor_dict to match tiny repo config - pp_chart2table: skip test_model_input_names (image processor declares original_image_size in model_input_names but does not return it); fix test_ocr_queries token count assertion 325→324 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix granite4_vision test_image_token_filling expected token count num_additional_image_tokens=1 adds 1 to base features: 405 - 1 (CLS) = 404. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix Florence2 processor tests: use image_seq_length=2 instead of skipping Add _setup_image_processor hook that loads image processor from tiny repo but sets image_seq_length=2, keeping output sequences short enough for the standard max_length/padding tests to pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests/pp_chart2table: fix test_model_input_names instead of skipping Add _setup_image_processor returning PPChart2TableImageProcessor() (default, model_input_names=['pixel_values']) so the Hub config's extra 'original_image_size' entry doesn't cause the assertion to fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests/kimi_k25: use tiny_video_320x240.mp4 instead of 4K source video The previous video (raushan-testing-hf/tiny_video.mp4) was 3840x2160 (4K), causing ~150 MB of memory just to decode frames before resizing to 28x28. Switch to hf-internal-testing/test-videos/tiny_video_320x240.mp4 (320x240, same 11 frames) which is 144x cheaper to decode. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests: reduce memory in deepseek_ocr2 and audioflamingo3 processor tests - deepseek_ocr2: use (769,577) image instead of (3264,2448) — same 2×3 tiling grid (ar≈0.75 matches 2×3 canvas best), same 1121 token count, 18× smaller tensor - audioflamingo3: use tiny processor + small public audio fixture instead of full nvidia/audio-flamingo-3-hf model + nvidia/AudioSkills wav in test_apply_transcription_request_single Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests: eliminate full-model downloads in audioflamingo3 processor tests Replace self.checkpoint (nvidia/audio-flamingo-3-hf) with tiny_model_id in test_can_load_various_tokenizers, test_save_load_pretrained_default, test_tokenizer_integration, and test_chat_template. For tokenizer_integration, drop hardcoded golden tokens and just assert slow==fast parity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests: fix kimi_k25 slow setup and stale video assertions - Remove model_id (RaushanTurganbay/kimi2.7-processor): no test calls get_processor(use_tiny_ckpt=False), so the full-model download in setUpClass was purely wasted time - Replace hardcoded pixel_values_videos length assertions (written for 4K video) with video_grid_thw-based checks; also verify num_frames vs fps give different token counts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests: reduce memory in sam3, qwen3_asr, vibevoice_asr processor tests - sam3: add _setup_image_processor reducing default size from 1008×1008 to 64×64 (mask_size 288×288 → 16×16); default sizes allocate ~100 MB of tensors - qwen3_asr: replace self.checkpoint (Qwen/Qwen3-ASR-0.6B-hf) with tiny_model_id in test_can_load_various_tokenizers, test_save_load_pretrained_default, and get_processor() in test_chat_template, test_apply_transcription_request_with_language, test_decode_formats; use small public audio fixture instead of bezzam dataset - vibevoice_asr: same pattern — tiny_model_id for load tests, get_processor() for transcription/decode tests, replace bezzam wav with small public audio fixture Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * tests: eliminate full-model downloads in musicflamingo processor tests Replace self.checkpoint (nvidia/music-flamingo-2601-hf) with tiny_model_id in test_can_load_various_tokenizers, test_save_load_pretrained_default; use get_processor() in test_chat_template and test_transcription_helpers_not_supported; simplify test_tokenizer_integration to slow==fast parity check with tiny tokenizer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(glmasr): use tiny_model_id in test_can_load_various_tokenizers and test_save_load_pretrained_default Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(vibevoice_asr): mock batch_decode in test_decode_output_formats to avoid tiny tokenizer vocab mismatch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(vibevoice_asr): add comment explaining mock in test_decode_output_formats Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(vibevoice_asr): use real decoded string in test_decode_output_formats mock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(vibevoice_asr): clarify mock comment in test_decode_output_formats Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(vibevoice_asr): mock tokenizer.decode to avoid tiny-tokenizer JSON parse failure test_decode_output_formats hardcoded Qwen token IDs that the tiny tokenizer decodes to garbage, breaking json.loads(). Mock tokenizer.decode with the real decoded string from the full processor (microsoft/VibeVoice-ASR-HF) prior to PR #47213, which is what this test was always validating. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: trigger processor tests via test_processing_common.py touch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: restrict test fetcher to processor tests only for this PR Temporarily limit JOB_TO_TEST_FILE to tests_processors so CI only runs processor tests, avoiding unrelated modeling/tokenization jobs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * format * format * fix(ovis2): add _setup_image_processor and image_token to prepare_processor_dict - max_patches=1 ensures each image produces exactly 1 tile so len(pixel_values)==batch_size as _test_apply_chat_template expects - image_token='<IMG_ATOM>' in prepare_processor_dict prevents mismatch in test_processor_from_pretrained_vs_from_components when the tokenizer lacks an image_token attribute (defaults to '<image>' without the kwarg) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * revert(qwen3_asr): restore original test until checkpoints are updated Eric will update the Qwen3 ASR checkpoints; the tiny-processor-qwen3_asr switch will be re-applied once the new checkpoint is available. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * revert: remove analyze_mem, memory_tracker_plugin, conftest changes These memory profiling tools are not part of the processor test speed-up scope for PR #47213. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * revert: restore tests_fetcher.py and test_processing_common.py to main Both were temporary CI-triggering changes not meant for the PR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: add @slow test_tokenizer_full_integration for audioflamingo3 and musicflamingo Preserves the original golden-token assertions (EXPECTED_OUTPUT) against the full Hub checkpoints as a slow test, while the fast test_tokenizer_integration uses the tiny repo for a quick slow/fast parity check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fixup: use self.checkpoint in test_tokenizer_full_integration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * processor tests: add source comments, remove unused checkpoints, document setup hooks - Add `# Tiny processor created with make_tiny_processor.py from "<repo>"` comment on every `tiny_model_id` class attribute (14 files) - Remove unused `checkpoint = ...` class attributes from glmasr and vibevoice_asr (neither file ever references `self.checkpoint`) - Add explanatory comments on all `_setup_image_processor` / `_setup_video_processor` hooks that lacked them, explaining why each custom setup is needed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Author
Parents
Loading