Source code for nemo_automodel.components.flow_matching

# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Flow Matching components for diffusion model training.

Provides FlowMatchingPipeline and model-specific adapters for training
diffusion models using the flow matching objective.
"""

import importlib

_LAZY_ATTRS = {
    "FlowMatchingPipeline": (".pipeline", "FlowMatchingPipeline"),
    "create_adapter": (".pipeline", "create_adapter"),
    "create_pipeline": (".pipeline", "create_pipeline"),
    "FlowMatchingContext": (".adapters", "FlowMatchingContext"),
    "ModelAdapter": (".adapters", "ModelAdapter"),
    "FluxAdapter": (".adapters", "FluxAdapter"),
    "HunyuanAdapter": (".adapters", "HunyuanAdapter"),
    "SimpleAdapter": (".adapters", "SimpleAdapter"),
}

__all__ = sorted(_LAZY_ATTRS.keys())


[docs] def __getattr__(name: str): if name in _LAZY_ATTRS: module_path, attr_name = _LAZY_ATTRS[name] module = importlib.import_module(module_path, __name__) attr = getattr(module, attr_name) globals()[name] = attr return attr raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
[docs] def __dir__(): return sorted(__all__)