Coverage for / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / components / losses / __init__.py: 82%
11 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-12-05 05:12 +0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-12-05 05:12 +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.aux_loss import (
18 aux_loss_auto_scale,
19 aux_loss_scale_context,
20 bind_aux_loss_scale,
21 set_aux_loss_scale,
22)
23from hyper_parallel.components.losses.chunked_cross_entropy import (
24 ChunkedCausalLMLoss,
25 ChunkedCausalLMOutput,
26 chunked_cross_entropy,
27)
28from hyper_parallel.components.losses.dispatcher import calculate_loss
29from hyper_parallel.components.losses.masked_ce import MaskedCrossEntropy
30from hyper_parallel.components.losses.model_output import ModelOutputLoss
31from hyper_parallel.components.losses.mtp import calculate_mtp_loss, compute_mtp_loss
33# FusedLinearCrossEntropy — optional, requires cut_cross_entropy
34try:
35 from hyper_parallel.components.losses.linear_ce import FusedLinearCrossEntropy # noqa: F401
36except ImportError:
37 pass
39__all__ = [
40 "ChunkedCausalLMLoss",
41 "ChunkedCausalLMOutput",
42 "MaskedCrossEntropy",
43 "ModelOutputLoss",
44 "FusedLinearCrossEntropy",
45 "aux_loss_auto_scale",
46 "aux_loss_scale_context",
47 "bind_aux_loss_scale",
48 "calculate_loss",
49 "chunked_cross_entropy",
50 "calculate_mtp_loss",
51 "compute_mtp_loss",
52 "set_aux_loss_scale",
53]