Skip to content

Conversation

@vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Mar 27, 2025

Description:

  • Fixes for pytorch<2.0 in average precision

https://github.com/pytorch/ignite/actions/runs/14102362634

@github-actions github-actions bot added the module: metrics Metrics module label Mar 27, 2025
@vfdev-5 vfdev-5 force-pushed the fix-pth-versions-ci branch from e1ff650 to 9444581 Compare March 27, 2025 00:54
@vfdev-5 vfdev-5 requested a review from Copilot March 27, 2025 00:58
Copy link

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 addresses fixes for PyTorch versions below 2.0 in the computation of average precision and recall for object detection metrics. Key changes include conditional use of the "stable" parameter in torch.argsort based on the torch version, updated device type comparisons (using device.type instead of direct torch.device comparisons), and adapting precision aggregation logic to mitigate type issues on different backends.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
ignite/metrics/vision/object_detection_average_precision_recall.py Adds a torch version check and conditionally passes the "stable" flag to torch.argsort; adjusts precision aggregation logic.
ignite/metrics/mean_average_precision.py Introduces a similar torch version check and updates device type checks for consistency.
tests/ignite/metrics/vision/test_object_detection_map.py Updates device comparison to use device.type for handling the MPS backend.
Comments suppressed due to low confidence (4)

ignite/metrics/vision/object_detection_average_precision_recall.py:221

  • Confirm that the conditional kwargs usage for torch.argsort maintains consistent sorting behavior across different torch versions without performance regressions.
indices = torch.argsort(scores, descending=True, **kwargs)

ignite/metrics/vision/object_detection_average_precision_recall.py:267

  • Ensure that the fallback value 0.0 is of the same dtype as precision_integrand to avoid potential type mismatches in the average precision calculation.
precision_integrand = torch.where(
            recall_mask,
            precision_integrand.take_along_dim(torch.where(recall_mask, rec_thresh_indices, 0), dim=-1),
            0.0,
        )

ignite/metrics/mean_average_precision.py:348

  • The updated device type check using device.type is more robust; verify that this pattern is applied consistently across similar device comparisons.
if tp_summation.device.type != "mps":

tests/ignite/metrics/vision/test_object_detection_map.py:867

  • The test now correctly uses device.type for checking the MPS backend; ensure that all MPS-specific skips use this updated checking method.
if device.type == "mps":

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Oct 14, 2025

Failed tests:

2025-10-14T20:04:58.8918828Z =========================== short test summary info ============================
2025-10-14T20:04:58.8920862Z FAILED tests/ignite/contrib/engines/test_common.py::test_setup_clearml_logging - ValueError: ClearML configuration could not be found (missing `~/clearml.conf` or Environment CLEARML_API_HOST)
2025-10-14T20:04:58.8923253Z To get started with ClearML: setup your own `clearml-server`, or create a free account at https://app.community.clear.ml
2025-10-14T20:04:58.8924993Z FAILED tests/ignite/distributed/test_auto.py::test_dist_proxy_sampler - AssertionError: Regex pattern did not match.
2025-10-14T20:04:58.8926505Z  Regex: 'Argument sampler should have length'
2025-10-14T20:04:58.8927356Z  Input: "Sampler.__init__() missing 1 required positional argument: 'data_source'"
2025-10-14T20:04:58.8929327Z FAILED tests/ignite/handlers/test_clearml_logger.py::test_integration - ValueError: ClearML configuration could not be found (missing `~/clearml.conf` or Environment CLEARML_API_HOST)
2025-10-14T20:04:58.8931618Z To get started with ClearML: setup your own `clearml-server`, or create a free account at https://app.community.clear.ml
2025-10-14T20:04:58.8933924Z FAILED tests/ignite/handlers/test_clearml_logger.py::test_integration_as_context_manager - ValueError: ClearML configuration could not be found (missing `~/clearml.conf` or Environment CLEARML_API_HOST)
2025-10-14T20:04:58.8935930Z To get started with ClearML: setup your own `clearml-server`, or create a free account at https://app.community.clear.ml
2025-10-14T20:04:58.8937892Z FAILED tests/ignite/handlers/test_clearml_logger.py::test_clearml_logger_getattr_method - ValueError: ClearML configuration could not be found (missing `~/clearml.conf` or Environment CLEARML_API_HOST)
2025-10-14T20:04:58.8940054Z To get started with ClearML: setup your own `clearml-server`, or create a free account at https://app.community.clear.ml
2025-10-14T20:04:58.8941781Z FAILED tests/ignite/handlers/test_clearml_logger.py::test_clearml_logger_get_task_bypass - ValueError: ClearML configuration could not be found (missing `~/clearml.conf` or Environment CLEARML_API_HOST)
2025-10-14T20:04:58.8943495Z To get started with ClearML: setup your own `clearml-server`, or create a free account at https://app.community.clear.ml

https://github.com/pytorch/ignite/actions/runs/18508418511/job/52743076044

@vfdev-5 vfdev-5 force-pushed the fix-pth-versions-ci branch from 4a5e6ca to 71e63c8 Compare October 15, 2025 11:32
@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Oct 15, 2025

@vfdev-5 vfdev-5 closed this Oct 16, 2025
@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Oct 16, 2025

Closing as removed 1.X pytorch version support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: metrics Metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants