Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self.image_newline inside the forward pass question #321

Open
YerongLi opened this issue Oct 24, 2024 · 1 comment
Open

self.image_newline inside the forward pass question #321

YerongLi opened this issue Oct 24, 2024 · 1 comment

Comments

@YerongLi
Copy link

YerongLi commented Oct 24, 2024

I'm currently working with the code and I'm having some trouble OVERRIDE forward where the self.module.image_newline attribute is set or initialized in the model.

I've traced the model through the forward pass, but I'm unable to find any explicit assignment to self.module.image_newline. Could you clarify where this attribute is being initialized or set?

Before the forward pass self.module.image_newline is empty

Parameter containing:
tensor([], device='cuda:0', dtype=torch.bfloat16)

Inside the forward pass it is a constant which is not empty

Parameter containing:
tensor([ 0.0123,  0.0142, -0.0299,  ..., -0.0332, -0.0041,  0.0240],
       device='cuda:0', dtype=torch.bfloat16)

Could anyone get me hint where self.image_newline is set?

Specifically, I am referring to this section of the code:https://github.com/huggingface/transformers/blob/f0e640adfa3cedea53912b95e3093f05cc2b66b5/src/transformers/models/llava_onevision/modeling_llava_onevision.py#L677

  image_features, feature_lens = self.pack_image_features(
      image_features,
      image_sizes,
      image_newline=self.image_newline,
      vision_aspect_ratio=vision_aspect_ratio,
  )
@YerongLi
Copy link
Author

In torch module, image_newline is editted with a pre_forward_hook

torch/nn/modules/module.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant