Skip to content

Fixing Linear Semantic Segmentation Bugs - #880

Merged
mrpositron merged 13 commits into
mainfrom
linear_sem_seg_bug
Jul 21, 2026
Merged

Fixing Linear Semantic Segmentation Bugs#880
mrpositron merged 13 commits into
mainfrom
linear_sem_seg_bug

Conversation

@mrpositron

@mrpositron mrpositron commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

What has changed and why?

Fixes two bugs in linear semantic segmentation with DINOv3 backbones:

  1. DINOv3 backbone crash on model creation.

DINOv3 builders hardcode drop_path_rate internally and re-splat **kwargs, so forwarding it raised got multiple values for keyword argument 'drop_path_rate'. No DINOv3 builder accepts the argument, so dinov3_package.py now drops it before building the model (a no-op for the model).

  1. Out-of-memory errors during validation on wide or tall images.

Validation previously tiled every image and forwarded all generated crops in a single batch while retaining every crop’s full-resolution logits. Because the number of crops grows with the image aspect ratio, memory usage was unbounded for very wide or tall images.

Validation now:

  • Collects crops from all images in the validation batch.
  • Processes them in chunks bounded by the dataloader batch size.
  • Pools crops across images so forward batches remain well utilized.
  • Immediately scatters each crop’s logits into per-image sum/count accumulators.
  • Averages overlapping regions without retaining logits for every crop.
  • Keeps only the first viz_max_images predictions on CPU for visualization.

This bounds forward activation and crop-logit memory while preserving correct reconstruction across overlapping crops.

How has it been tested?

  • Added test_dinov3_package.py asserting drop_path_rate is dropped and the model builds.
  • Added test_train_model.py covering the per-image validation path (loss/metrics accumulation, chunked forward, and viz_max_images capping).

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Did you update the documentation?

  • Yes
  • Not needed (internal change without effects for user)

@mrpositron mrpositron changed the title Linear sem seg bug Fixing Linear Semantic Segmentation Bugs Jul 17, 2026
@mrpositron
mrpositron marked this pull request as ready for review July 20, 2026 08:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20f45e5a10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lightly_train/_task_models/linear_semantic_segmentation/train_model.py Outdated
@mrpositron

Copy link
Copy Markdown
Contributor Author

/review

Comment thread tests/_task_models/linear_semantic_segmentation/test_train_model.py Outdated
@mrpositron
mrpositron enabled auto-merge (squash) July 21, 2026 14:42
@mrpositron
mrpositron merged commit d1a2e2b into main Jul 21, 2026
13 checks passed
@mrpositron
mrpositron deleted the linear_sem_seg_bug branch July 21, 2026 15:15
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.

2 participants