Coverage for / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / components / losses / __init__.py: 80%
10 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-25 05:45 +0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-25 05:45 +0800
1# Copyright 2026 Huawei Technologies Co., Ltd
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ============================================================================
15"""Model-level loss objectives and calling adapters — design doc §10 + §10.0."""
17from hyper_parallel.components.losses.dispatcher import calculate_loss
18from hyper_parallel.components.losses.chunked_cross_entropy import (
19 ChunkedCausalLMLoss,
20 ChunkedCausalLMOutput,
21 chunked_cross_entropy,
22)
23from hyper_parallel.components.losses.masked_ce import MaskedCrossEntropy
24from hyper_parallel.components.losses.model_output import ModelOutputLoss
25from hyper_parallel.components.losses.mtp import calculate_mtp_loss
27# FusedLinearCrossEntropy — optional, requires cut_cross_entropy
28try:
29 from hyper_parallel.components.losses.linear_ce import FusedLinearCrossEntropy # noqa: F401
30except ImportError:
31 pass
33__all__ = [
34 "ChunkedCausalLMLoss",
35 "ChunkedCausalLMOutput",
36 "MaskedCrossEntropy",
37 "ModelOutputLoss",
38 "FusedLinearCrossEntropy",
39 "calculate_loss",
40 "chunked_cross_entropy",
41 "calculate_mtp_loss",
42]