🕵️ SicherheitslückenWhat continuous operational resilience looks like under DORA(09.09.2026 um 17:53 Uhr)
🔧 AI Nachrichten OpenAI seeks tougher AI rules. CIOs may feel the ripple effects(10.09.2026 um 12:11 Uhr)
🔧 AI Nachrichten Mistral valued at €21bn after €3bn Series D funding round(08.09.2026 um 10:19 Uhr)
🪟 Windows TippsWindows XP's Cursor Indicator Is Getting a Windows 11 Refresh(25.08.2026 um 13:00 Uhr)
🕵️ SicherheitslückenWhat continuous operational resilience looks like under DORA(09.09.2026 um 17:53 Uhr)
🔧 AI Nachrichten OpenAI seeks tougher AI rules. CIOs may feel the ripple effects(10.09.2026 um 12:11 Uhr)
🔧 AI Nachrichten Mistral valued at €21bn after €3bn Series D funding round(08.09.2026 um 10:19 Uhr)
🪟 Windows TippsWindows XP's Cursor Indicator Is Getting a Windows 11 Refresh(25.08.2026 um 13:00 Uhr)

💾 Downloads 🕛 vor 3 Monaten 3 Min Lesezeit
0

trunk/180b3630b44c3f9f40a29d5f9e636fb1d190dffb: [MPS] Migrate randperm off MPSGraph to Metal (#182528)

↗ Quelle (GitHub · github.com)
🗣️ Stimme:
🐙
$ git clone https://github.com/pytorch/pytorch.git

Drops the MPSGraph randperm path (mps::random_mps_impl<int64_t> plus the RandomCachedGraph / RandomOpBlock machinery, which had no other callers after the dispatch unification) and reimplements randperm_out_mps with three Metal-native paths selected by n:



  • Small n (n <= 384, int32/int64 contiguous result): a single-threadgroup Fisher-Yates kernel writes the permutation directly into result. Thread 0 walks i = n - 1 .. 1 swapping buf[i] with buf[Philox % (i + 1)] in threadgroup memory; the rest of the threadgroup cooperates on the identity init and the writeout. No keys buffer, no argsort, no cast. The 384 cutoff is the measured crossover where the serial swap loop starts losing to launching a sort.

  • Mid n (384 < n < 32768, or non-int dtypes): uniform float keys + argsort, routing int64 indices straight into result via at::sort_out when the result is already int64 and contiguous.

  • Large n (n >= 32768): random integer keys + a partial radix sort, then an island-dedup pass. A permutation of [0, n) does not need a full sort - sorting random keys by only their low bits already orders the distinct keys uniformly. We generate 24-bit keys and sort just those 24 bits (3 radix passes instead of the 4 a full 32-bit-key sort needs), then randperm_dedup_islands runs an exact Fisher-Yates shuffle within each equal-key island to scrub the residual tie-bias. The result is uniform over all n!, matching CPU (Fisher-Yates) and CUDA (radix_sort_pairs + randperm_handle_duplicate_keys). The limited-bit sort reuses the existing Metal radix sorter in Sort.mm via a new max_passes cap (default -1, so the general sort/argsort path is unchanged).


M4 Max, int64 result, per-call latency, baseline is the 2.12 release (still MPSGraph):























































n torch 2.12 (MPSGraph) Metal (this) vs MPSGraph
10 0.172 ms 0.118 ms 1.46x
100 0.171 ms 0.109 ms 1.57x
1K 0.169 ms 0.149 ms 1.13x
2K 0.172 ms 0.155 ms 1.11x
10K 0.204 ms 0.185 ms 1.10x
1M 0.570 ms 0.741 ms 0.77x
10M 7.78 ms 5.76 ms 1.35x

We beat MPSGraph at every size except n=1M, where its fused randperm still edges out the 3-pass radix (0.57 vs 0.74 ms). The island-dedup costs ~7% at 10M and is essentially free at 1M. Fully beating MPSGraph at 1M would need a non-sort algorithm (e.g. a fused random-slot scatter), left as follow-up.


Validity (sort(randperm(n)) == arange(n)) checked for n in {32768, 1e5, 1e6, 2e6} across int32/int64. Uniformity verified with a full-distribution chi-square (n=7, all 5040 permutations) and an adjacent-ascending-pair test at n=1M: this path matches CPU and the 2.12 MPSGraph baseline (z within +-1 of uniform), while a deliberately tie-biased sort-without-dedup control is flagged at z=+62.


Authored with Claude.

Pull Request resolved:

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf github.com.
↗ Original-Artikel auf github.com lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Sam Altman calls GPT-6 Astra rollout ‘messy’ as enterprise users wait for access
1 Quelle
Swiss government explores replacing Microsoft 365 with open-source software
1 Quelle
What continuous operational resilience looks like under DORA
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten trunk/180b3630b44c3f9f40a29d5f9e636fb1d190dffb: [MPS] Migrate randperm off MPSGraph to Metal (#182528)

Thematisch verwandte Begriffe: trunk180b3630b44c3f9f40a29d5f9e636fb1d190dffb, Migrate, randperm, MPSGraph · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...