Skip to content

Add YOLOv13 multitask task heads, preflight validation, and Turing flash backend controls#79

Open
ahmedelbamby-aast wants to merge 3 commits intoiMoonLab:mainfrom
ahmedelbamby-aast:y13-upstream-sync
Open

Add YOLOv13 multitask task heads, preflight validation, and Turing flash backend controls#79
ahmedelbamby-aast wants to merge 3 commits intoiMoonLab:mainfrom
ahmedelbamby-aast:y13-upstream-sync

Conversation

@ahmedelbamby-aast
Copy link
Copy Markdown

Summary

  • Add YOLOv13 multitask model config support for detect/segment/pose/obb with safe scale variants () under .
  • Add task-aware dataset preflight checks to validate label schema earlier for , , and , and wire that validation through trainer/validator/world trainer entry points.
  • Fix OBB metric compatibility by exposing consistently.
  • Add flash-attention backend control improvements for deterministic backend selection and DDP propagation, including support path.

Why

  • In our production fork, these changes removed early failure points (dataset/schema mismatch), made OBB metric reporting consistent, and enabled robust multitask config loading.
  • We also needed deterministic flash backend behavior for T4/Turing environments in DDP.

What we validated in our fork

  • Task preflight smoke checks pass after schema-validation updates.
  • Safe multitask config matrix () loads successfully across detect/segment/pose/obb.
  • Backend selection correctly differentiates fallback and turing runs in benchmark summaries when flags are applied before runtime initialization.

What we request from maintainers

  1. Review and consider merging the task preflight + OBB metric compatibility fixes as a baseline reliability improvement.
  2. Review multitask v13 config set and advise if you prefer splitting by task/scale in a different structure.
  3. Confirm whether you want Turing flash backend controls upstreamed as-is, or guarded behind additional feature flags/docs.
  4. If preferred, we can split this PR into smaller targeted PRs (metrics/preflight, configs, flash backend controls) for easier review.

Notes

  • We intentionally did not include Kaggle-specific scripts and benchmark artifacts in this upstream PR.
  • Our fork includes broader benchmark docs and plots; happy to share links/artifacts if useful for review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends Ultralytics’ YOLOv13 support and training/validation robustness by adding task-specific v13 model configs, introducing task-aware dataset label-schema “preflight” validation, making OBB metric outputs consistent with other tasks, and adding deterministic FlashAttention backend selection (including a Turing-specific path) with DDP propagation.

Changes:

  • Add YOLOv13 model YAMLs for detect/segment/pose/obb across multiple scales (n/s/l/x) and base “v13” variants.
  • Add task-aware dataset preflight validation in check_det_dataset(..., task=...) and wire it through trainer/validator/world trainer dataset loading.
  • Standardize detection/OBB metrics keys/results to include mAP75, and add FlashAttention backend selection controls + DDP propagation hooks.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ultralytics/utils/metrics.py Align detection/OBB metric keys/outputs to include mAP75 consistently.
ultralytics/utils/flash_turing_interface.py Add a FlashAttention autograd wrapper for a Turing-specific backend module.
ultralytics/utils/dist.py Improve DDP subprocess entrypoint generation (override serialization + env propagation for flash backend controls).
ultralytics/nn/modules/block.py Add configurable flash-attention backend selection (Ampere+ and optional Turing path) and tighten attention tensor contiguity handling.
ultralytics/models/yolo/world/train_world.py Pass task into dataset checking for YOLO-World training data.
ultralytics/engine/validator.py Pass task into detection dataset checking during standalone validation.
ultralytics/engine/trainer.py Pass task into dataset checking; improve AMP broadcast robustness; add non-finite loss guard; tweak DDP init args.
ultralytics/data/utils.py Add label-schema preflight validation for segment/pose/obb tasks and extend check_det_dataset() signature to accept task.
ultralytics/cfg/models/v13/yolov13x.yaml Add YOLOv13 “x” detect model definition.
ultralytics/cfg/models/v13/yolov13x-seg.yaml Add YOLOv13 “x” segmentation model definition.
ultralytics/cfg/models/v13/yolov13x-pose.yaml Add YOLOv13 “x” pose model definition.
ultralytics/cfg/models/v13/yolov13x-obb.yaml Add YOLOv13 “x” OBB model definition.
ultralytics/cfg/models/v13/yolov13s.yaml Add YOLOv13 “s” detect model definition.
ultralytics/cfg/models/v13/yolov13s-seg.yaml Add YOLOv13 “s” segmentation model definition.
ultralytics/cfg/models/v13/yolov13s-pose.yaml Add YOLOv13 “s” pose model definition.
ultralytics/cfg/models/v13/yolov13s-obb.yaml Add YOLOv13 “s” OBB model definition.
ultralytics/cfg/models/v13/yolov13n-seg.yaml Add YOLOv13 “n” segmentation model definition.
ultralytics/cfg/models/v13/yolov13n-pose.yaml Add YOLOv13 “n” pose model definition.
ultralytics/cfg/models/v13/yolov13n-obb.yaml Add YOLOv13 “n” OBB model definition.
ultralytics/cfg/models/v13/yolov13l.yaml Add YOLOv13 “l” detect model definition.
ultralytics/cfg/models/v13/yolov13l-seg.yaml Add YOLOv13 “l” segmentation model definition.
ultralytics/cfg/models/v13/yolov13l-pose.yaml Add YOLOv13 “l” pose model definition.
ultralytics/cfg/models/v13/yolov13l-obb.yaml Add YOLOv13 “l” OBB model definition.
ultralytics/cfg/models/v13/yolov13-seg.yaml Add base YOLOv13 segmentation model definition (multi-scale).
ultralytics/cfg/models/v13/yolov13-pose.yaml Add base YOLOv13 pose model definition (multi-scale).
ultralytics/cfg/models/v13/yolov13-obb.yaml Add base YOLOv13 OBB model definition (multi-scale).
Comments suppressed due to low confidence (2)

ultralytics/utils/metrics.py:748

  • The Metric.class_result() docstring still describes returning AP50 and AP (50-95) only, but the method now returns five values including ap75. Please update the docstring to match the returned tuple order.
    def class_result(self, i):
        """Class-aware result, return p[i], r[i], ap50[i], ap[i]."""
        return self.p[i], self.r[i], self.ap50[i], self.ap75[i], self.ap[i]

ultralytics/utils/metrics.py:878

  • DetMetrics.mean_results() docstring is outdated after adding mAP75 support: it still says it returns precision/recall/mAP50/mAP50-95, but self.box.mean_results() now includes mAP75 as well. Please update the docstring so it matches the actual metric keys/values.
    def mean_results(self):
        """Calculate mean of detected objects & return precision, recall, mAP50, and mAP50-95."""
        return self.box.mean_results()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +274 to +279
self.model = nn.parallel.DistributedDataParallel(
self.model,
device_ids=[RANK],
find_unused_parameters=True,
gradient_as_bucket_view=False,
)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

DistributedDataParallel(..., gradient_as_bucket_view=False) is not supported in older PyTorch versions (the project allows torch>=1.8). This can raise a TypeError at runtime on those versions. Consider only passing this argument when the installed torch supports it (e.g., via a version/feature check) or omit it entirely.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have made a custom enviroment using UV and Upgraded the enviroment without breaking any of the modules

Comment on lines +33 to +37
serialized["augmentations"] = [A.to_dict(t) for t in augmentations]
serialized["_augmentations_serialized"] = True
except Exception:
serialized["augmentations"] = None
serialized["_augmentations_serialized"] = False
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

In _serialize_overrides(), any exception while serializing augmentations is swallowed and the value is silently set to None. This can cause unexpected behavior changes between single-process and DDP runs without any indication to the user. Consider logging a warning (including the exception) when serialization fails so it’s clear that augmentations were dropped for the subprocess.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

ahmedelbamby-aast and others added 2 commits April 3, 2026 01:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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