Skip to content

fix: compute auxiliary losses when denoising is disabled in D-FINE#45601

Merged
yonigozlan merged 5 commits intohuggingface:mainfrom
Abineshabee:fix/dfine-aux-loss-without-denoising
Apr 23, 2026
Merged

fix: compute auxiliary losses when denoising is disabled in D-FINE#45601
yonigozlan merged 5 commits intohuggingface:mainfrom
Abineshabee:fix/dfine-aux-loss-without-denoising

Conversation

@Abineshabee
Copy link
Copy Markdown
Contributor

@Abineshabee Abineshabee commented Apr 23, 2026

Fixes #45593

Problem

When num_denoising=0, denoising_meta_values is None, causing DFineForObjectDetectionLoss to skip auxiliary loss computation entirely since it is gated under the same condition.

However, auxiliary losses (deep supervision across decoder layers) are independent of denoising and should still be computed when config.auxiliary_loss=True. This leads to degraded training behavior when denoising is disabled.

Fix

Decoupled denoising logic from auxiliary loss computation:

  • Tensor splitting is performed only when denoising_meta_values is not None
  • Auxiliary losses are always computed when config.auxiliary_loss=True
  • Denoising-specific auxiliary losses are computed only when denoising is active

This follows the same pattern used in loss_rt_detr.py.

Testing

  • Verified that auxiliary loss keys (e.g., loss_vfl_aux_*, loss_bbox_aux_*) are present when num_denoising=0
  • Confirmed no change in behavior when denoising is enabled

@Rocketknight1
Copy link
Copy Markdown
Member

cc @molbap @yonigozlan @NielsRogge maybe

Copy link
Copy Markdown
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

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

LGTM, but can we add a small test to confirm that behavior under dfine? Would like a second opinion from @yonigozlan tho if he agrees to this as I'm not 100% familiar with this

@Abineshabee
Copy link
Copy Markdown
Contributor Author

Thanks for the review! That makes sense — I’ll add a small test to verify auxiliary losses are computed when num_denoising=0.

@Abineshabee
Copy link
Copy Markdown
Contributor Author

CI failed due to a CircleCI authentication error (not related to the code change). Could someone please re-run the workflow?

Copy link
Copy Markdown
Member

@yonigozlan yonigozlan left a comment

Choose a reason for hiding this comment

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

Looks good to me thanks for fixing @Abineshabee !

@github-actions
Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: d_fine

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@yonigozlan yonigozlan added this pull request to the merge queue Apr 23, 2026
Merged via the queue into huggingface:main with commit 5cf7951 Apr 23, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D-FINE not using any auxiliary losses when denoising is turned off

5 participants