Skip to content

[Fix][Relax] Allow callers to specify scan index-width budget - #20336

Open
akaashrp wants to merge 2 commits into
apache:mainfrom
akaashrp:metal-cumsum-index-width
Open

akaashrp wants to merge 2 commits into
apache:mainfrom
akaashrp:metal-cumsum-index-width

Conversation

@akaashrp

Copy link
Copy Markdown
Contributor

Add an optional index_bits argument to DispatchSortScan so pipelines that subsequently force indices to int32 can generate compatible continuous GPU cumsum hierarchies. The hierarchy calculation can otherwise emit 64-bit thresholds that fail forced int32 narrowing, as seen in MLC's Metal compilation path. Existing callers retain the upstream defaults: 32 bits for WebGPU and 64 bits for other targets.

Generate the cumsum hierarchy for the signed index width supported by Metal, matching the existing WebGPU path. This prevents ForceNarrowIndexToInt32 from rejecting unreachable 64-bit thresholds.

Add target-dispatch coverage for Metal, WebGPU, and CUDA, and execute the numerical cumsum test on Metal.
Restore the default 64-bit continuous cumsum hierarchy for Metal. Add an optional index_bits argument to DispatchSortScan so callers using forced int32 narrowing can request a compatible hierarchy without restricting other Metal pipelines.

Preserve the 32-bit WebGPU default and reject explicit 64-bit WebGPU scan budgets. Validate defaults, overrides, invalid budgets, and numerical Metal execution with both index policies. Document that the option neither changes tensor dtypes nor inserts narrowing or runtime bounds checks.
@akaashrp
akaashrp requested a review from tlopex September 16, 2026 02:50
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.

1 participant