tests: add lora tester mixin for modular and migrate minimax h3. by sayakpaul · Pull Request #14605 · huggingface/diffusers · GitHub
Skip to content

tests: add lora tester mixin for modular and migrate minimax h3. - #14605

Merged
sayakpaul merged 11 commits into
mainfrom
lora-tests-modular
Sep 9, 2026
Merged

sayakpaul merged 11 commits into
mainfrom
lora-tests-modular

Conversation

@sayakpaul

@sayakpaul sayakpaul commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

With more and more pipelines being released with Modular and supporting LoRA, it's important for us to ensure we test them as good as we do for standard pipelines that support LoRAs.

This PR, hence, adds a LoRA tester mixin class to our testing suite for Modular Pipelines. The mixin overrides tests/pipelines/testing_utils/lora.py and migrates the existing MiniMax H3 LoRA testing suite with it (as the existing one already makes use of Modular).

We can add a LoRA tester class for the remaining Modular Pipelines that support it in a follow-up PR.

@github-actions github-actions Bot added tests size/L PR with diff > 200 LOC labels Aug 26, 2026
Comment on lines +70 to +73

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't like the pipeline-specific condition here but I think it's a fair compromise.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you can also check the inputs from pipe.blocks.inputs, you do need to build the pipeline first though

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I preferred that solution for a bit more optimization (i.e., skipping just after inspecting if the inputs don't exist) without having to build the pipeline. Is that okay for this test?

pass


class TestMiniMaxH3ModularPipelineLoRA(MiniMaxH3ModularPipelineTesterConfig, ModularLoraTesterMixin):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The extra methods are specific to the transformer and transformer_ref related voodoo going on in the pipeline.

class ModularLoraMemoryTesterMixin(BaseModularPipelineOutputMixin, LoraMemoryTesterMixin):
"""LoRA x offloading tests for modular pipelines: group offloading composed with `load_lora_weights`."""

@pytest.mark.skip(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can add testing for this later.

"transformer_ref": ["to_q", "to_k", "to_v", "to_out.0"],
}

def get_dummy_diffusers_lora_state_dict(self, transformer, prefix="transformer", rank=8, adaln_rank=2):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In the process, I also optimized the runtime of these tests. Previously, we were building the entire pipeline just to get the transformer from it. We already have all the components available when we're calling this method. So, this method now simply reuses them unlike:

def get_dummy_diffusers_lora_state_dict(self, prefix="transformer", rank=8, adaln_rank=2):
r"""
The same adapter already converted to diffusers keys and republished — which is how the public turbo LoRA also
circulates. Mixed-rank, still alpha-less, so it needs the same treatment as the original layout even though no
conversion runs.
"""
transformer = self.get_pipeline().transformer
config = transformer.config
hidden = config.hidden_size
inner = config.num_attention_heads * config.attention_head_dim

@github-actions github-actions Bot added the CI label Aug 26, 2026
@sayakpaul
sayakpaul requested a review from yiyixuxu August 26, 2026 04:57

@yiyixuxu yiyixuxu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks! I left some comments!

Comment thread tests/modular_pipelines/testing_utils/common.py Outdated
denoiser components are not named `transformer`.
"""

@pytest.mark.skip(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it does save the weights though, for these components that are loaded at the time you run save_pretrained()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I decided to delete the skip altogether because it can be tested with some additions to the base test suite. But so far our modular pipelines supporting LoRAs don't have this feature to be tested. So, when we do add something along these lines, we can revisit it. WDYT?

Comment on lines +70 to +73

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you can also check the inputs from pipe.blocks.inputs, you do need to build the pipeline first though

@yiyixuxu yiyixuxu added this to the Release 0.41.0 milestone Sep 8, 2026
@sayakpaul
sayakpaul requested a review from yiyixuxu September 8, 2026 21:11

@yiyixuxu yiyixuxu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks!

@sayakpaul
sayakpaul merged commit d30c748 into main Sep 9, 2026
16 of 18 checks passed
@sayakpaul
sayakpaul deleted the lora-tests-modular branch September 9, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI size/L PR with diff > 200 LOC tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants