trunk/59b2295274d0aca035a0d29864d510a34a568466: [BE] [MPS] Validate random ops by metadata + stats (#182881)
MPS and CPU random ops can’t match—PyTorch finally admits it.
MPS (Apple Metal Performance Shaders) and CPU backends in PyTorch use independent random number generators (RNGs) with different algorithms. Seeded calls still produce divergent draws. The test suite included `assertEqual` comparisons that were structurally meaningless for random ops, requiring a pile of entries in `UNDEFINED_XFAILLIST` and `XFAILLIST_GRAD` just to suppress inevitable failures. Those entries validated nothing. PR #182881 removes this dead weight by introducing `RANDOM_OP_NAMES`, a list of 13+ random ops, and a `_assert_random_op_match` helper that checks only metadata (shape, dtype, layout) and aggregate statistics, not exact values.
The PR also fixes a bug in the MPSGraph normal implementation where the op didn't work when the shapes of `mean` and `std` were broadcastable to each other. The dropout family retains its grad-leg xfail because backward reuses the forward random mask, and MPS/CPU masks diverge by construction. The result is a cleaner, faster CI pipeline that actually validates MPS random ops meaningfully, removing the temptation to ignore broken tests. This is a quality-of-life improvement for Apple Silicon PyTorch developers and a step toward better MPS backend reliability.
- Removes over a dozen xfaillist entries for random ops (normal, uniform, rand_like, etc.) that suppressed meaningless CPU–MPS comparisons
- New `_assert_random_op_match` helper validates only shape, dtype, and layout—not exact numeric equality
- Fixes MPSGraph normal op broadcast bug when mean and std shapes are broadcastable
Why It Matters
Cleaner MPS tests and real random op validation for Apple Silicon users, reducing CI noise.