Repository navigation
Conversation
|
I see the PR went to |
|
Hi @zucchini-nlp, it’s ready for review when you have a chance. Thanks! |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Thanks a lot for working on the model. I think we can use modular in more cases and thus reduce LOC to review and maintain. I left comments below
|
Hi @zucchini-nlp, thanks for your review~ I’ve addressed your review comments point by point and this should be ready for your review again. The main changes are:
If there’s anything else that needs changes, please ping me anytime🤗. |
|
Thanks, reviewing today-tomorrow |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Thanks for iterating, looks much cleaner. I left a few questions and suggestions below, but approving so it can be reviewed by a core maintainer next
After addressing the comments and fixing the CI, you can ping Cyrilvallez for final review
| # Initialize weights and apply final processing | ||
| self.post_init() | ||
|
|
||
| # modified from transformers.models.qwen2_5_vl.modeling_qwen2_5_vl.Qwen2_5_VLModel.forward |
There was a problem hiding this comment.
we can copy. The diff is only in position ids and tbh I don't think it is needed, as long as the generation prepares the position ids for us
There was a problem hiding this comment.
You are correct. Our primary motivation is to reuse the existing functions from Qwen2.5-VL, such as get_rope_index and prepare_inputs_for_generation. The key modification in the forward function is the insertion of the line position_ids = position_ids[0] if len(position_ids.shape) == 3 else position_ids before the data is passed to the Qwen3 model. However, as the current modular tool does not support this specific operation, I had to directly copy the relevant code and implement the modification. Do you have any better solution?
| "MllamaVisionModel", # Building part of bigger (tested) model. # TODO: add tests | ||
| "Llama4TextModel", # Building part of bigger (tested) model. # TODO: add tests | ||
| "Llama4VisionModel", # Building part of bigger (tested) model. # TODO: add tests | ||
| "LlavaOnevision1_5Model", # Building part of bigger (tested) model. Tested implicitly through LlavaOnevision1_5ForConditionalGeneration. |
There was a problem hiding this comment.
this can be added in all_models_classes in the test file
There was a problem hiding this comment.
Thanks. But I did not find all_models_classes in the test file.
| "BltLocalDecoder", # Building part of bigger (tested) model. Tested implicitly through BLTForCausalLM. | ||
| "BltGlobalTransformer", # Building part of bigger (tested) model. Tested implicitly through BLTForCausalLM. | ||
| "Ovis2VisionModel", | ||
| "LlavaOnevision1_5VisionPretrainedModel", |
There was a problem hiding this comment.
let's expose it, usually PretrainedModel are not private. You need to add it in docs and in __all__
There was a problem hiding this comment.
LlavaOnevision1_5PreTrainedModel has been exposed in __all__, but LlavaOnevision1_5VisionPretrainedModel is only the vision part of LlavaOnevision1_5 and not an independent model. We might consider keeping it internal. For example, Qwen2_5_VisionTransformerPretrainedModel in Qwen2.5-VL is also not exposed, isn't that right?
|
Hi, @zucchini-nlp @Cyrilvallez. The comments have been addressed, I think... and this should be ready for final review. If there’s anything else that needs changes, please ping me anytime🤗. |
|
Dear @Cyrilvallez , apologies for the gentle nudge. Whenever convenient, could you please perform the final review? All feedback has been addressed and CI is passing. Thank you very much for your time and guidance. |
|
@Rocketknight1 @ArthurZucker @zucchini-nlp Sorry for the gentle nudge. Whenever convenient, could you please take a look for a final review/approval? All feedback has been addressed and CI is green. If there’s anything else you’d like me to adjust, I’m happy to update right away. Thank you very much for your time and guidance! |
|
run-slow: llava_onevision1_5 |
|
This comment contains models: ["models/llava_onevision1_5"] |
|
Hey @anxiangsir! Deeply deeply sorry for the delay on this! We are really focused on the upcoming v5 currently, which explain my late answer on this. Next iterations will be much quicker now that things are calming down. |
Cyrilvallez
left a comment
There was a problem hiding this comment.
Sorry again for the delay! here are a few things to still consider!
| # default: Load the model on the available device(s) | ||
| model = LlavaOnevision1_5ForConditionalGeneration.from_pretrained( | ||
| model_path, torch_dtype="auto", device_map="auto", trust_remote_code=True | ||
| ) | ||
|
|
||
| # default processer | ||
| processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True) |
There was a problem hiding this comment.
No trust_remote_code in the examples! We use native hf format!
| if isinstance(text_config, dict): | ||
| text_config["model_type"] = text_config.get("model_type", "qwen3") | ||
| self.sub_configs["text_config"] = CONFIG_MAPPING[text_config["model_type"]] | ||
| elif text_config is None: | ||
| self.sub_configs["text_config"] = CONFIG_MAPPING["qwen3"] |
There was a problem hiding this comment.
We never set sub_configs like this! I think this can simply be removed as not useful
|
|
||
| class LlavaOnevision1_5VisionMlp(VisionMlp): | ||
| pass |
There was a problem hiding this comment.
Let's use another base class, or redefine the init: we want the modules to be fully configured by the config, not different kwargs coming from the config
| torch.nn.init.normal_(module.class_embedding, mean=0.0, std=std_cls) | ||
| torch.nn.init.normal_(module.class_pos_emb, mean=0.0, std=std_cls) |
There was a problem hiding this comment.
Should use transformer inits: from ... import initialization as init and use this instead of torch.nn
|
|
||
| class LlavaOnevision1_5VisionPretrainedModel(Qwen2_5_VisionTransformerPretrainedModel): |
There was a problem hiding this comment.
Let's rename, PreTrained is always kept for the actual PreTrainedModel base class
| class LlavaOnevision1_5VisionPretrainedModel(Qwen2_5_VisionTransformerPretrainedModel): | |
| class LlavaOnevision1_5VisionModel(Qwen2_5_VisionTransformerPretrainedModel): |
| def __init__(self, config: LlavaOnevision1_5Config): | ||
| PreTrainedModel.__init__(self, config) | ||
| self.visual = LlavaOnevision1_5VisionPretrainedModel._from_config(config.vision_config) | ||
| self.language_model = AutoModel.from_config(config.text_config) | ||
| self.rope_deltas = None | ||
| # Initialize weights and apply final processing | ||
| self.post_init() | ||
|
|
||
| @auto_docstring | ||
| def forward( | ||
| self, | ||
| input_ids: Optional[torch.LongTensor] = None, | ||
| attention_mask: Optional[torch.Tensor] = None, | ||
| position_ids: Optional[torch.LongTensor] = None, | ||
| past_key_values: Optional[Cache] = None, | ||
| inputs_embeds: Optional[torch.FloatTensor] = None, | ||
| use_cache: Optional[bool] = None, | ||
| output_attentions: Optional[bool] = None, | ||
| output_hidden_states: Optional[bool] = None, | ||
| return_dict: Optional[bool] = None, | ||
| pixel_values: Optional[torch.Tensor] = None, | ||
| pixel_values_videos: Optional[torch.FloatTensor] = None, | ||
| image_grid_thw: Optional[torch.LongTensor] = None, | ||
| video_grid_thw: Optional[torch.LongTensor] = None, | ||
| rope_deltas: Optional[torch.LongTensor] = None, | ||
| cache_position: Optional[torch.LongTensor] = None, | ||
| second_per_grid_ts: Optional[torch.Tensor] = None, | ||
| **kwargs: Unpack[TransformersKwargs], | ||
| ) -> Union[tuple, LlavaOnevision1_5ModelOutputWithPast]: | ||
| r""" | ||
| image_grid_thw (`torch.LongTensor` of shape `(num_images, 3)`, *optional*): |
There was a problem hiding this comment.
Are those 2 different from Qwen ones?
| @unittest.skip( | ||
| reason="This architecture seem to not compute gradients properly when using GC, LlavaOnevision1_5VisionPretrainedModel does not support standalone training" | ||
| ) | ||
| def test_training_gradient_checkpointing(self): | ||
| pass | ||
|
|
||
| @unittest.skip | ||
| def test_training(self): | ||
| pass | ||
|
|
||
| @unittest.skip( | ||
| reason="This architecture seem to not compute gradients properly when using GC, LlavaOnevision1_5VisionPretrainedModel does not support standalone training" | ||
| ) | ||
| def test_training_gradient_checkpointing_use_reentrant(self): | ||
| pass | ||
|
|
||
| @unittest.skip( | ||
| reason="This architecture seem to not compute gradients properly when using GC, LlavaOnevision1_5VisionPretrainedModel does not support standalone training" | ||
| ) | ||
| def test_training_gradient_checkpointing_use_reentrant_false(self): | ||
| pass | ||
|
|
||
| @unittest.skip( | ||
| "VLMs need lots of steps to prepare images/mask correctly to get pad-free inputs. Can be tested as part of LLM test" | ||
| ) | ||
| def test_flash_attention_2_padding_matches_padding_free_with_position_ids(self): | ||
| pass |
There was a problem hiding this comment.
Are you sure those are not passing? Looks a lot like copy/paste
| def test_initialization(self): | ||
| config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() | ||
|
|
||
| configs_no_init = _config_zero_init(config) | ||
| for model_class in self.all_model_classes: | ||
| model = model_class(config=configs_no_init) | ||
| for name, param in model.named_parameters(): | ||
| if param.requires_grad and "class_pos_emb" not in name and "class_embedding" not in name: | ||
| self.assertIn( | ||
| ((param.data.mean() * 1e9).round() / 1e9).item(), | ||
| [0.0, 1.0], | ||
| msg=f"Parameter {name} of model {model_class} seems not properly initialized", | ||
| ) |
There was a problem hiding this comment.
Is there any reason to overload the main one?
| test_pruning = False | ||
| test_head_masking = False |
There was a problem hiding this comment.
To remove, they disappeared
CI ResultsModel CI Report❌ Failed tests
|
|
Thanks for the work on LLaVA-OneVision-1.5! This branch predates v5 and now conflicts with main (auto mappings, model init and docs moved a lot since Nov 2025). The model is still not on main, so it is still welcome: could you rebase on current main and regenerate the modeling file from the modular file (ideally reusing the shared Qwen/LLaVA components) so we can do a fresh review? |
7d10c0b to
b07d0cd
Compare
|
Thank you for your contribution 🤗! CI Security Gate — waiting for maintainer approvalCI is approved automatically only for authors who already have a contribution merged in this repository. A maintainer will review this PR and approve CI to run on it. |
Use modular generation and shared model components for the native model, Auto registrations and checkpoint loading. Add documentation, vision export support and tests for inference, training and frame isolation.
b07d0cd to
0ed53a9
Compare
|
Hi @ArthurZucker @Cyrilvallez, I’m one of the developers of the LLaVA-OneVision 2 series, helping update this OV1.5 PR. I’ve rebased the branch and regenerated the modeling file from the modular source, reusing shared components. Local CPU/GPU model tests and checkpoint integration tests passed. CI auto-approval is blocked by the two Thanks for your help! |
|
@ZijunLi402 hey 👋🏻 very niice, i will take a look now. We had a few other PRs for Revewing in a sec 👁️ |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Very nice! I might have repeated myself and commented on each nit, overall it looks good :)
Re the tests - lets clean up and remove some that arent really important or covered implicitly via IntegrationTest/ModelTesterMixin
| @@ -0,0 +1,68 @@ | |||
| <!--Copyright 2025 The HuggingFace Team. All rights reserved. | |||
There was a problem hiding this comment.
to re-check that it's 2026 everywhere :)
| LLaVA-OneVision-1.5 was introduced in [LLaVA-OneVision-1.5: Fully Open Framework for Democratized Multimodal Training](https://huggingface.co/papers/2509.23661). | ||
| It combines a native resolution vision encoder with a Qwen3 language backbone. The vision encoder adds a learned class token to each image, applies full attention, removes the class token, and merges spatial patches into visual features for the language model. The language backbone uses ordinary one dimensional rotary positions for the combined image and text sequence. | ||
|
|
||
| The implementation reuses the Qwen2.5-VL processor and supports the converted [4B checkpoint](https://huggingface.co/Deep-VLM/LLaVA-OneVision-1.5-4B-Instruct-hf). Use left padding for batched generation. |
There was a problem hiding this comment.
no need to mentioned code implem here, can just say we support these ckpts/hub collection
|
|
||
| The implementation reuses the Qwen2.5-VL processor and supports the converted [4B checkpoint](https://huggingface.co/Deep-VLM/LLaVA-OneVision-1.5-4B-Instruct-hf). Use left padding for batched generation. | ||
|
|
||
| ## Abstract |
There was a problem hiding this comment.
no new section needed, abstract is part of overview and is usually formatted in italics
| ## Usage | ||
|
|
||
| ```python | ||
| from transformers import AutoProcessor, LlavaOnevision15ForConditionalGeneration |
There was a problem hiding this comment.
can we use AutoForImageTextToText in model
| def test_mismatching_num_image_tokens(self): | ||
| """ | ||
| Tests that VLMs through an error with explicit message saying what is wrong | ||
| when number of images don't match number of image tokens in the text. | ||
| Also we need to test multi-image cases when one prompr has multiple image tokens. | ||
| """ | ||
| config, input_dict = self.model_tester.prepare_config_and_inputs_for_common() | ||
| for model_class in self.all_model_classes: |
There was a problem hiding this comment.
with VLMTester this one would not need to be overriden
| @require_torch | ||
| class LlavaOnevision15VisionModelTest(unittest.TestCase): | ||
| all_model_classes = (LlavaOnevision15VisionModel,) if is_torch_available() else () | ||
|
|
||
| @slow | ||
| @require_torch_greater_or_equal("2.11") |
There was a problem hiding this comment.
we need a single test class with all_model_class = (both classes here,)
| self.messages = [ | ||
| { | ||
| "role": "user", | ||
| "content": [ | ||
| {"type": "image"}, | ||
| {"type": "text", "text": "What kind of dog is this?"}, | ||
| ], | ||
| } | ||
| ] | ||
| url = "https://qianwen-res.oss-accelerate-overseas.aliyuncs.com/Qwen2-VL/demo_small.jpg" | ||
| self.image = Image.open(requests.get(url, stream=True).raw) |
There was a problem hiding this comment.
can we put url inside a conversation dict and use ...test_processing.url_to_local_peth to load from cached location
If possible, also lets use an existing image from other tests, we are trying to keep small number of testing images and use it across all models
| expected_input_ids = [151644, 8948, 198, 2610, 525, 264, 10950, 17847, 13, 151645, 198, 151644, 872, 198, 151652, 151655, 151655] # fmt: skip | ||
| torch.testing.assert_close(expected_input_ids, inputs.input_ids[0].tolist()[:17]) | ||
|
|
||
| expected_pixel_slice = torch.tensor( | ||
| [ | ||
| [0.8792, 0.8792, 0.9084], | ||
| [1.1858, 1.1858, 1.2296], | ||
| [1.2004, 1.2004, 1.2150], | ||
| [1.4340, 1.4340, 1.4194], | ||
| [1.3902, 1.4048, 1.4194], | ||
| [1.5216, 1.5362, 1.5362], | ||
| ], | ||
| dtype=torch.float32, | ||
| device="cpu", | ||
| ) |
There was a problem hiding this comment.
Expectations class pls to get expectation for given hardware
| messages = [{"role": "user", "content": [{"type": "video"}, {"type": "text", "text": "Describe the video."}]}] | ||
| text = self.processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) | ||
| video = np.stack([np.asarray(self.image), np.asarray(self.image.transpose(Image.Transpose.FLIP_LEFT_RIGHT))]) |
There was a problem hiding this comment.
can we use real video from https://huggingface.co/datasets/hf-internal-testing/fixtures_videos and same comment about url-to-local-path
Reuse shared model components and VLM tests, simplify configuration and checkpoint mappings, and use cached image and real video fixtures. Preserve learned CLS gradients and compatibility with published and native checkpoints.
Preserve explicit weight tying in new configurations while retaining legacy checkpoint compatibility. Restore standalone vision loading from full checkpoints and cover both paths with small regression tests.
|
Thank you for your contribution 🤗! CI Security Gate — automatic approval blockedThis PR was not automatically approved for CI because the security gate failed. Possible reasons:
See the workflow run for the exact violations. A maintainer can review and manually approve CI if a finding is a false positive. |
Regenerate the model for the unified cache API, use the current export runtime API, and follow upstream's removal of generated-file attributes.
|
Hi @zucchini-nlp, thanks for the detailed review! I’ve updated the PR based on your feedback, synced it with main, and regenerated the modeling file from the modular source, reusing existing components and the common VLM tests. I kept the version check for weight tying and the Could you take another look when you have time? Thanks! |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Oke, last comments and could you actually reply to a few questions on why it is not updated, i commented again for that :)
| if self.training and self.is_activation_checkpointing: | ||
| # Reentrant checkpointing only tracks tensors passed as positional inputs, not nested tuples. | ||
| position_embeddings = torch.stack(position_embeddings) |
There was a problem hiding this comment.
with GradientCheckpointingLayer we can just pass it all as keyword args, pls check again
There was a problem hiding this comment.
Retested: keyword arguments work with default non-reentrant checkpointing, but break backward with use_reentrant=True for the learned CLS positions. I’ve kept the positional tensor and checkpointing-only stack; the details and CUDA test results are in the related VisionBlock discussion.
There was a problem hiding this comment.
as mentioned before reentrant=True is not important and we will start deprecating support for that soon. the only blockers are essentially deepspeed / peft and they are close to being handled already
There was a problem hiding this comment.
I removed the checkpointing-only stack and now pass (cos, sin) directly.
| r""" | ||
| second_per_grid_ts (`torch.Tensor`, *optional*): | ||
| Video frame intervals supplied by the processor. Text positions remain one-dimensional. | ||
|
|
||
| Example: |
There was a problem hiding this comment.
second_per_grid_ts is not used in code, can we copy from a different more similar model pls? Qute sure there is one with 100% overlap in kwargs and body
There was a problem hiding this comment.
I’ve switched to Qwen2_5_VLForConditionalGeneration, following the modular reuse pattern in EXAONE 4.5 and GLM-4V. The parent now supplies the arguments and forward body; our forward override only supplies the documentation and example.
The shared interface accepts second_per_grid_ts, which the published processor emits for videos. Simply dropping it breaks generate() validation. It remains accepted as metadata; OV1.5 still uses 1D text positions. I’ve also removed the inherited accepts_loss_kwargs=False through the converter’s AttributeError() instruction to preserve the previous training behavior.
With the public 4B checkpoint, image/video next-token logits and the 20 generated tokens are unchanged under SDPA and FlashAttention 2. The existing model tests and common fullgraph/static-cache generation tests also pass.
There was a problem hiding this comment.
hm, what exactly breaks with generate? Exaone4_5_ForConditionalGeneration looks just right to me and requires no override except for "example docs"
There was a problem hiding this comment.
I checked with the published OV1.5 processor’s video inputs. With the EXAONE 4.5 interface, generate() raises a ValueError for mm_token_type_ids and second_per_grid_ts before the first forward pass. The current parent already accepts both, so I’d keep it to preserve model.generate(**inputs) with the published processor.
There was a problem hiding this comment.
ohhh you re-use the qwen2-vl processor...
Lets use Exaone4_5_Processor? 😆 Ideally we dont want the processor to return unused args and in this case bth are actually unused
There was a problem hiding this comment.
Yes, Exaone4_5_Processor works with the published OV1.5 checkpoint. I’ve switched the Transformers fallback to it. With the new processor selected on a local copy, the image and video inputs used by the model and the generated tokens match exactly, and the two unused fields are omitted.
The published checkpoint still explicitly selects the old processor, so the Hub metadata update is pending. I kept the model interface compatible with both kwargs so older revisions continue to work with model.generate(**inputs).
|
@zucchini-nlp Sorry about that! This is my first time contributing a PR like this, so I’m still getting familiar with the review process. I’ve now replied to each of your comments and pushed the updates. |
|
@ZijunLi402 thanks a lot for quick iteration, it lgtm and approving now. Can yo check 2 threads above hat I replied to? |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Two last q from me and will ask review from core maintainers
| @auto_docstring | ||
| class LlavaOnevision15ForConditionalGeneration(Qwen2_5_VLForConditionalGeneration): | ||
| accepts_loss_kwargs = AttributeError() | ||
|
|
||
| def forward(self, **super_kwargs): | ||
| r""" | ||
| second_per_grid_ts (`torch.Tensor`, *optional*): | ||
| Video timing metadata accepted from the shared processor. Text positions remain one-dimensional. | ||
|
|
||
| Example: | ||
|
|
||
| ```python |
There was a problem hiding this comment.
and now we can copy this from exaone and override nothing except for docsring, right? I am really not liking second_grid_ts/mm_token_type_ids in the signature coz it is misleading
There was a problem hiding this comment.
Agreed, we can reuse EXAONE’s forward() with a docstring override while keeping OV1.5’s model construction. I re-tested with the published 4B checkpoint’s current processor (revision a0e8089). With the two kwargs removed, generate(**inputs) raises a ValueError before forward() for mm_token_type_ids on images and for both mm_token_type_ids and second_per_grid_ts on videos. Filtering those fields gave identical generated tokens.
I can reach out to the checkpoint maintainers to switch the default processor config on the Hub. Should we also keep generate() compatible with older pinned revisions that still load the old processor?
vasqu
left a comment
There was a problem hiding this comment.
Careful approval because this honestly only has 1 core thing i would change but its not that major as well
Lets go through my comments and we should be ready to merge
|
|
||
| The paper describes the work as follows: | ||
|
|
||
| *The [paper's abstract](https://arxiv.org/abs/2509.23661) describes an open framework for training vision-language models from scratch at a reduced cost. Its release includes a concept-balanced collection of 85 million pretraining examples, a curated instruction dataset containing 22 million examples, and a training system that uses offline parallel packing. The authors report a training budget of $16,000. In their evaluation, the 8B model exceeds Qwen2.5-VL-7B on 18 out of 27 benchmarks, while the 4B model exceeds Qwen2.5-VL-3B on all 27. The report also describes a lightweight reinforcement learning stage that improves multimodal reasoning through chain-of-thought responses.* |
There was a problem hiding this comment.
Yep, I’ve switched the abstract link to HF Papers in my local changes.
| LLaVA-OneVision-1.5 was introduced in [LLaVA-OneVision-1.5: Fully Open Framework for Democratized Multimodal Training](https://huggingface.co/papers/2509.23661). | ||
| It combines a native resolution vision encoder with a Qwen3 language backbone. The vision encoder adds a learned class token to each image, applies full attention, removes the class token, and merges spatial patches into visual features for the language model. The language backbone uses ordinary one dimensional rotary positions for the combined image and text sequence. | ||
|
|
||
| Transformers supports the [4B checkpoint](https://huggingface.co/Deep-VLM/LLaVA-OneVision-1.5-4B-Instruct-hf). Use left padding for batched generation. |
There was a problem hiding this comment.
the left padding would wrap under a (markdown) note under usage
There was a problem hiding this comment.
Moved the left-padding tip into a note under Usage.
| include_temporal = getattr(model, "include_temporal", False) | ||
| inputs["position_ids"] = get_vision_position_ids(grid_thw, spatial_merge_size, include_temporal=include_temporal) | ||
|
|
||
| if hasattr(module, "get_vision_frame_lengths"): |
There was a problem hiding this comment.
oh nice even exporter fixes ❤️
| ("hyperclovax_vision_v2", {"torchvision": "Qwen2VLVideoProcessor"}), | ||
| ("instructblip", {"torchvision": "InstructBlipVideoVideoProcessor"}), | ||
| ("lfm3_vl", {"torchvision": "Qwen3VLVideoProcessor"}), | ||
| ("llava_onevision1_5", {"torchvision": "Qwen2VLVideoProcessor"}), |
| # Published checkpoints predate the separate vision model type. | ||
| if kwargs.get("model_type") in ("rice_vit", "llava_onevision1_5"): |
There was a problem hiding this comment.
do we not have a -hf repo? which is the owner there or rather could we change this there?
There was a problem hiding this comment.
fwiw - we have a whole llava-hf org where i kept llava models before conversion-mapping (can ask Arthur/Merve to add you, i dont have write access)
IMO this is easier than creating new repo as it happens in a few other models, and we don't need to maintain another repo on the hub
| class LlavaOnevision15ModelTest(VLMModelTest, unittest.TestCase): | ||
| model_tester_class = LlavaOnevision15ModelTester | ||
|
|
||
| def test_vision_loading_from_full_checkpoint(self): |
There was a problem hiding this comment.
imo this test is kind of pointless when we have integration tests no?
There was a problem hiding this comment.
I folded this into the existing 4B integration test. Standalone vision loading uses a separate weight mapping, so the test loads the tower on its own and checks that its image features match the full model's.
| for name, p in model.named_parameters(): | ||
| torch.testing.assert_close(p.grad, expected[name]) | ||
| self.assertGreater(model.class_embedding.grad.abs().sum().item(), 0) | ||
| self.assertGreater(model.class_pos_emb.grad.abs().sum().item(), 0) |
There was a problem hiding this comment.
see my comments re grad ckpt so may or may not change here
There was a problem hiding this comment.
I switched the CLS gradient tests to the default non-reentrant mode. The gradients match the run without checkpointing, including with FlashAttention 2. I skipped the explicit reentrant case for OV1.5.
| class LlavaOnevision15IntegrationTest(unittest.TestCase): | ||
| model_id = "Deep-VLM/LLaVA-OneVision-1.5-4B-Instruct-hf" | ||
|
|
||
| def setUp(self): | ||
| self.processor = AutoProcessor.from_pretrained(self.model_id, padding_side="left") | ||
| self.messages = [ |
There was a problem hiding this comment.
I switched the integration tests to MemoryCleanupMixin and removed the manual cleanup.
| self._check_image_generation("flash_attention_2") | ||
|
|
||
| @slow | ||
| @require_torch_gpu |
There was a problem hiding this comment.
not sure if torch_accelecator makes more sense unsure
There was a problem hiding this comment.
(in general over these tests)
There was a problem hiding this comment.
I moved require_torch_accelerator and slow to the integration test class. The FlashAttention 2 test still checks for FlashAttention support.
| @require_torch_gpu | ||
| def test_batched_generation(self): | ||
| model = LlavaOnevision15ForConditionalGeneration.from_pretrained( | ||
| self.model_id, dtype=torch.bfloat16, device_map=torch_device |
There was a problem hiding this comment.
any reason we give the dtype, we use auto by default
There was a problem hiding this comment.
I removed the explicit dtype from the integration tests. The 4B checkpoint still loads in BF16 by default, including when loading the vision tower on its own, and all five integration tests pass.
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto, llava_onevision1_5 |
What does this PR do?
This PR adds LLaVA-OneVision-1.5
Fixes #41081
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.