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

phi 4 multimodal training version 1 ( with limitations ) #1555

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

optas
Copy link
Contributor

@optas optas commented Mar 18, 2025

Description

Adds the necessary changes for SFT training (vision/text-only) with phi-4 in Oumi.

Given that we are using here the vision_language_with_padding we are limited to size batch 1, and we cannot accommodate multi-image training.

Related issues

Towards OPE-1102

Before submitting

  • This PR only changes documentation. (You can ignore the following checks in that case)
  • Did you read the contributor guideline Pull Request guidelines?
  • Did you link the issue(s) related to this PR in the section above?
  • Did you add / update tests where needed?

Reviewers

At least one review from a member of oumi-ai/oumi-staff is required.

@optas optas requested a review from nikg4 March 18, 2025 20:15
@optas optas marked this pull request as ready for review March 20, 2025 21:51
setup: |
set -e

pip install uv && uv pip install oumi[gpu] hf_transfer
Copy link
Collaborator

Choose a reason for hiding this comment

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

is Phi4 compatible with the current transformers version ?

Copy link
Contributor Author

@optas optas Mar 20, 2025

Choose a reason for hiding this comment

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

yes. please see here https://huggingface.co/microsoft/Phi-4-multimodal-instruct
flash_attn==2.7.4.post1
torch==2.6.0
transformers==4.48.2
accelerate==1.3.0
soundfile==0.13.1
pillow==11.1.0
scipy==1.15.2
torchvision==0.21.0
backoff==2.2.1
peft==0.13.2

the one place I see a potential issue is peft (they use a lower version than our lowest allowed) -- I plan to investigate this more when we publish a more LoRA oriented version of it.

@optas optas changed the title [DRAFT-Not-for-full-review] phi 4 multimodal phi 4 multimodal training version 1 ( with limitations ) Mar 20, 2025
@override
def ignore_features(self) -> list[str]:
"""Returns a list of keys of features to ignore from feeding the model."""
return self._ignore_features if self._ignore_features else []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider returning a shallow copy. Just to make sure that external users can't mutate our member variables.
return copy.copy(self._ignore_features) if self._ignore_features else []

@@ -75,6 +79,7 @@ def __init__(
self._worker_processor.image_processor
)
self._label_ignore_index: Optional[int] = label_ignore_index
self._ignore_features: Optional[list[str]] = ignore_features
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider making our own private copy. Just to make sure that external users can't mutate our member variable.

self._ignore_features: Optional[list[str]] =  copy.copy(ignore_features) if ignore_features else [] 

Configs for Phi-4-multimodal-instruct 14B model. See https://huggingface.co/microsoft/Phi-4-multimodal-instruct

This is a multimodal model that combines text, visual, and audio inputs.
It uses a "Mixture of LoRAs" approach, allowing you to plug in adapters for each
Copy link
Collaborator

Choose a reason for hiding this comment

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

if there is relevant paper for "Mixture of LoRAs" and/or the model itlself , please quote it here.

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

Successfully merging this pull request may close these issues.

2 participants