Add YOLOv13 multitask task heads, preflight validation, and Turing flash backend controls#79
Conversation
There was a problem hiding this comment.
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 includingap75. 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, butself.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.
| self.model = nn.parallel.DistributedDataParallel( | ||
| self.model, | ||
| device_ids=[RANK], | ||
| find_unused_parameters=True, | ||
| gradient_as_bucket_view=False, | ||
| ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I have made a custom enviroment using UV and Upgraded the enviroment without breaking any of the modules
| serialized["augmentations"] = [A.to_dict(t) for t in augmentations] | ||
| serialized["_augmentations_serialized"] = True | ||
| except Exception: | ||
| serialized["augmentations"] = None | ||
| serialized["_augmentations_serialized"] = False |
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Why
What we validated in our fork
What we request from maintainers
Notes