Skip to content

Add Llama4VisionModel for multimodal decoding #1809

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

hengtaoguo
Copy link
Collaborator

@hengtaoguo hengtaoguo commented Jun 5, 2025

Description

This PR implements a complete class Llama4VisionModel, by integrating all Llama4 basic vision components. It allows Llama4 multimodal decode by describing an input image. Joint by @hengtaoguo and @aireenmei .

  • Core change Llama4VisionModel, which converts image tiles (batch_size, num_tiles, C, H, W) to feature activations (batch_size, num_tiles, num_patches, vision_output_dim_for_vit). Then Llama4MultiModalProjector projects it to (batch_size, num_tiles, num_patches, base_emb_dim). Example: (8, 5, 3, 336, 336) -> (8, 5, 144, 4096) -> (8, 5, 144, 5120). After that, the image tokens will be merged into text tokens by re-using merge_mm_embeddings.
  • Refactor by adding a get_dummy_image_shape_for_init() to create desired dummy images for different models, for jit init purpose.

Tests

Tested full multimodal decode on v5p-16 cluster with this command, and workload with screenshot.
image

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed.

@hengtaoguo hengtaoguo force-pushed the hengtaoguo-vision branch 2 times, most recently from ed26908 to 02adb51 Compare June 20, 2025 05:34
@hengtaoguo hengtaoguo marked this pull request as ready for review June 20, 2025 05:35
@hengtaoguo hengtaoguo self-assigned this Jun 20, 2025
@hengtaoguo hengtaoguo changed the title [WIP] Full Llama4 VisionModel Implement Llama4VisionModel for multimodal decoding Jun 20, 2025
@hengtaoguo hengtaoguo changed the title Implement Llama4VisionModel for multimodal decoding Add Llama4VisionModel for multimodal decoding Jun 20, 2025
Copy link
Collaborator

@aireenmei aireenmei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Hengtao, great work!

Copy link
Collaborator

@gagika gagika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@hengtaoguo hengtaoguo force-pushed the hengtaoguo-vision branch 2 times, most recently from 5c6e38d to e0946fa Compare June 23, 2025 21:47
@hengtaoguo hengtaoguo force-pushed the hengtaoguo-vision branch 3 times, most recently from b10022f to c70bdc3 Compare June 23, 2025 23:03
@copybara-service copybara-service bot merged commit d5ecf6d into main Jun 23, 2025
18 checks passed
@copybara-service copybara-service bot deleted the hengtaoguo-vision branch June 23, 2025 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants