Draft
Conversation
fleshed out _positional_embeddings.py with Qwen2_5_VLRotaryEmbedding class and Qwen2_5_VLCompatibleRotaryEmbedding. Qwen2_5_VLRotaryEmbedding is used in Qwen2_5_VLCompatibleRotaryEmbedding, which inherits from nn.Module. Qwen2_5_VLCompatibleRotaryEmbedding.forward() takes in a query or key tensor, input_pos tensor, and applies MRoPE.
wrapper function around MultiHeadAttention with MRoPE beginnings of implementation for qwen2_5_vl_text_decoder
* Qwen25VLEarlyFusionModel inherits from EarlyFusionModel * forward() calls get_rope_index with input_ids * Incorporated Qwen25VLEarlyFusionModel into _model_builders.py
* incorrect raise condition in _positional_embeddings.py * set bias=False in text decoder MLP
* added batch testing in test_full_model
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/2868
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| *, | ||
| mask: Optional[_MaskType] = None, | ||
| input_pos: Optional[torch.Tensor] = None, | ||
| window_index: Optional[torch.Tensor] = None, |
Collaborator
Author
There was a problem hiding this comment.
just a placeholder - a main dilemma we've had was where the unique window and rope index calculations should live in the stack. Currently, we've tried our best to preserve primitives and patterns but clearly not perfect, would appreciate outside input
| from torchtune.modules.model_fusion._early_fusion import EarlyFusionModel | ||
| from torchtune.modules import TransformerDecoder | ||
|
|
||
| class Qwen25VL(EarlyFusionModel): |
Collaborator
Author
There was a problem hiding this comment.
Collaborator
Author
|
a bit rocky, early looks appreciated @joecummings |
* created a _call_pos_embedding_safely function in attention.py as a workaround
Comment on lines
+19
to
+48
| def _call_pos_embedding_safely( | ||
| pos_embedding: nn.Module, | ||
| x: torch.Tensor, | ||
| input_pos: Optional[torch.Tensor] = None, | ||
| window_index: Optional[torch.Tensor] = None, | ||
| ) -> torch.Tensor: | ||
| """ | ||
| Call positional embedding with only the parameters it accepts. | ||
|
|
||
| Args: | ||
| pos_embedding (nn.Module): The positional embedding module | ||
| x (torch.Tensor): Input tensor | ||
| input_pos (Optional[torch.Tensor]): Optional input position tensor | ||
| window_index (Optional[torch.Tensor]): Optional window index tensor | ||
|
|
||
| Returns: | ||
| Output tensor from positional embedding | ||
| """ | ||
| sig = inspect.signature(pos_embedding.forward) | ||
| kwargs = {} | ||
|
|
||
| # Only add parameters that the method accepts | ||
| if "input_pos" in sig.parameters: | ||
| kwargs["input_pos"] = input_pos | ||
| if "window_index" in sig.parameters: | ||
| kwargs["window_index"] = window_index | ||
|
|
||
| return pos_embedding(x, **kwargs) | ||
|
|
||
|
|
There was a problem hiding this comment.
Current workaround for passing window_index into the positional embedding module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
What is the purpose of this PR? Is it to
Please link to any issues this PR addresses.
#2699
Changelog
What are the changes made in this PR?
*custom modules for Qwen 2.5 VL
*model + component builders for all variants
*Transform + custom collation
*Weight loading
*Added unit tests
Test plan
Please make sure to do each of the following if applicable to your PR. If you're unsure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.
so far we've done
pre-commit install)pytest testspytest tests -m integration_testUX
If your function changed a public API, please add a dummy example of what the user experience will look like when calling it.
Here is a docstring example
and a tutorial example
co-authored by @lawrencefeng17