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

[WIP] [tests] test encode_prompt() in isolation #10438

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

sayakpaul
Copy link
Member

@sayakpaul sayakpaul commented Jan 3, 2025

What does this PR do?

encode_prompt() is often used in isolation to lift off memory requirements and to also compute prompt embeddings in many trainers. It's important that we test encode_prompt() properly.

This PR adds a test suite to do that. Since we cannot reliably map the outputs of encode_prompt() into keyword arguments of a pipeline call, I propose to use the ast module to determine the names of the variables returned from a particular encode_prompt() method. This PR is a PoC of what the changes might look like at the test level.

The closest test we have currently is this:

class SDXLOptionalComponentsTesterMixin:

But, IMO, this should be extended to the other pipelines on a more general level.

TODOs

  • Propagate to the rest of the pipelines once we agree on the structure.
  • Fix encode_prompt() to work in isolation in the pipelines if needed.
  • Remove SDXLOptionalComponentsTesterMixin if needed.

@sayakpaul sayakpaul requested review from DN6 and hlky January 3, 2025 06:31
@sayakpaul
Copy link
Member Author

@hlky now that the PRs have been merged to support this, let's brainstorm if this is how we want to test encode_prompt()?

@sayakpaul
Copy link
Member Author

@DN6 a gentle ping.

@HuggingFaceDocBuilderDev

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.

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