Skip to content

cann: update cross_entropy_loss op support#16886

Merged
hipudding merged 8 commits intoggml-org:masterfrom
TecJesh:cross_entropy_loss
Nov 13, 2025
Merged

cann: update cross_entropy_loss op support#16886
hipudding merged 8 commits intoggml-org:masterfrom
TecJesh:cross_entropy_loss

Conversation

@TecJesh
Copy link
Contributor

@TecJesh TecJesh commented Oct 31, 2025

The cann backend currently does not support computing cross_entropy_loss; add support for the cross_entropy_loss operator to the cann computation backend.

@github-actions github-actions bot added ggml changes relating to the ggml tensor library for machine learning Ascend NPU issues specific to Ascend NPUs labels Oct 31, 2025
@noemotiovon
Copy link
Collaborator

Could you paste your accuracy test results?

Copy link
Collaborator

@noemotiovon noemotiovon left a comment

Choose a reason for hiding this comment

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

There’s a minor issue here; I’ll review it more thoroughly later.

@@ -1777,6 +1777,12 @@ static bool ggml_cann_compute_forward(ggml_backend_cann_context & ctx, struct gg
case GGML_OP_GROUP_NORM:
ggml_cann_group_norm(ctx, dst);
break;
case GGML_OP_L2_NORM:
ggml_cann_l2_norm(ctx, dst);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You’ve already added this in another PR. I’ll take a closer look at your PR after that one gets merged.

@@ -2602,6 +2610,7 @@ static bool ggml_backend_cann_supports_op(ggml_backend_dev_t dev, const ggml_ten
return true;
}
default:
std::cout << "Unsupported op: " << ggml_op_name(op->op) << std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this print statement was left in by mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will delete it.

@hipudding
Copy link
Contributor

You need rebase to pass the failing test.

@TecJesh
Copy link
Contributor Author

TecJesh commented Nov 12, 2025

Backend 1/2: CANN0
Device description: Ascend910B4
Device memory: 30196 MB (29825 MB free)

new_pool_for_device: device 0 use vmm pool
CROSS_ENTROPY_LOSS(type=f32,ne=[10,5,4,3]): OK
CROSS_ENTROPY_LOSS(type=f32,ne=[30000,1,1,1]): OK
2/2 tests passed
Backend CANN0: OK
Backend 2/2: CPU
Skipping
2/2 backends passed
OK

@hipudding hipudding merged commit 97d5117 into ggml-org:master Nov 13, 2025
73 checks passed
Anico2 added a commit to Anico2/llama.cpp that referenced this pull request Jan 15, 2026
* update L2_NORM op support

* update L2_NORM op support

* remove extra whitespace

* cann: update cross_entropy_loss op support

* remove trailing whitespaces

* rebase the latest code in the main repository and remove the l2_norm operator that already exists in another pull request.

* undo the l2_norm operator deletion
blime4 referenced this pull request in blime4/llama.cpp Feb 5, 2026
* update L2_NORM op support

* update L2_NORM op support

* remove extra whitespace

* cann: update cross_entropy_loss op support

* remove trailing whitespaces

* rebase the latest code in the main repository and remove the l2_norm operator that already exists in another pull request.

* undo the l2_norm operator deletion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ascend NPU issues specific to Ascend NPUs ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants