Skip to content

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

Open
sayakpaul wants to merge 4 commits into
mainfrom
lora-tests-modular
Open

tests: add lora tester mixin for modular and migrate minimax h3.#14605
sayakpaul wants to merge 4 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
# A modular pipeline takes its inputs from its blocks rather than from a `__call__` signature, and the denoiser
# block of every LoRA-capable one declares `InputParam.template("attention_kwargs")`.
if issubclass(pipeline_class, ModularPipeline):
return "attention_kwargs"

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.

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
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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant