Skip to content

Conversation

Kanya-Mo
Copy link
Contributor

@Kanya-Mo Kanya-Mo commented Oct 15, 2025

This is to fix #2021.
The current algorithm uses the following formula to calculate index and is numerically unstable at cases when n goes large (and j=n-1). Need sqrt to be in double precision to ensure correct results after casting into int. This change also aligns with cuda implementation.

(n2_val_ - device_sqrt<accscalar_t>(n2_squared_minus_1_val_ - 2 * k)));

image

@Kanya-Mo Kanya-Mo changed the title (WIP) Fix pdist numerical issue on large input (WIP) Fix pdist numerical issue on large input size Oct 15, 2025
@Kanya-Mo Kanya-Mo changed the title (WIP) Fix pdist numerical issue on large input size Fix pdist numerical issue on large input size Oct 16, 2025
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.

TestTorchDeviceTypeXPU::test_pdist_norm_large_xpu AssertionError: False is not true

1 participant