Skip to content

Conversation

@panditsa
Copy link
Contributor

@panditsa panditsa commented Sep 4, 2025

Add dynamic indexing support for atomic operations in MoE alignment

For the MoE align block, we need support for dynamically indexed values in atomic operations. This change introduces mapping_dynamic_vals parameter to AtomicOp and updates the atomic operation handler to support dynamic indexing.

Key changes:

  • Add mapping_dynamic_vals parameter to atomic operations
  • Update handle_atomic_op decorator to process dynamic values
  • Convert dynamic registers to index-typed vectors and extract scalar indices
  • Pass dynamic value dictionary to _build_start_indices for proper index computation

This enables atomic operations like atomic_add to use runtime-computed indices from input data

@panditsa panditsa changed the title Sanket/dyn atomicop Use dynamic values for AtomicOps Sep 4, 2025
@panditsa panditsa force-pushed the sanket/dyn_atomicop branch 2 times, most recently from 458218d to 27db7bf Compare September 5, 2025 02:17
@panditsa panditsa marked this pull request as ready for review September 5, 2025 16:38
@panditsa panditsa marked this pull request as draft September 5, 2025 16:40
@panditsa panditsa force-pushed the sanket/dyn_atomicop branch 2 times, most recently from 3f52c02 to e989252 Compare September 5, 2025 17:00
@panditsa panditsa marked this pull request as ready for review September 5, 2025 17:01
@panditsa panditsa force-pushed the sanket/dyn_atomicop branch 2 times, most recently from ba87142 to c96ada3 Compare September 5, 2025 17:16
@panditsa panditsa force-pushed the sanket/dyn_atomicop branch 2 times, most recently from c66c964 to 66c71f0 Compare September 23, 2025 17:44
@panditsa panditsa requested a review from harsh-nod September 23, 2025 17:44
@panditsa panditsa force-pushed the sanket/dyn_atomicop branch 4 times, most recently from 2fd2856 to 09a7262 Compare September 26, 2025 03:30

elements_per_thread: Optional[Any] = None
mapping: Optional[IndexMapping] = None
mapping_dynamic_vals: tuple[fx.Node, ...] = ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR exactly, but why does AtomicOp need to inherit from both BinaryOpBase and ABC, when BinaryOpBase has ABC in its inheritance chain? Just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question, there are a couple of other classes with the same dependency. But thanks for pointing it out, I removed it for AtomicOp and everything seems fine.

Copy link
Contributor

@willghatch willghatch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me.

@panditsa panditsa force-pushed the sanket/dyn_atomicop branch 2 times, most recently from 99d7cd5 to f6b50a3 Compare September 29, 2025 21:49
panditsa and others added 8 commits September 29, 2025 14:51
Signed-off-by: Sanket Pandit <sanketp@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Signed-off-by: Sanket Pandit <sanketp@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
@panditsa panditsa merged commit 76ceb5f into iree-org:main Sep 30, 2025
19 checks passed
saladpalad pushed a commit to saladpalad/wave that referenced this pull request Oct 3, 2025
Add dynamic indexing support for atomic operations in MoE alignment

For the MoE align block, we need support for dynamically indexed values
in atomic operations. This change introduces `mapping_dynamic_vals`
parameter to AtomicOp and updates the atomic operation handler to
support dynamic indexing.

Key changes:
- Add `mapping_dynamic_vals` parameter to atomic operations 
- Update `handle_atomic_op` decorator to process dynamic values
- Convert dynamic registers to index-typed vectors and extract scalar
indices
- Pass dynamic value dictionary to `_build_start_indices` for proper
index computation

This enables atomic operations like `atomic_add` to use runtime-computed
indices from input data

---------

Signed-off-by: Sanket Pandit <sanketp@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
Megan0704-1 pushed a commit to Megan0704-1/wave that referenced this pull request Oct 28, 2025
Add dynamic indexing support for atomic operations in MoE alignment

For the MoE align block, we need support for dynamically indexed values
in atomic operations. This change introduces `mapping_dynamic_vals`
parameter to AtomicOp and updates the atomic operation handler to
support dynamic indexing.

Key changes:
- Add `mapping_dynamic_vals` parameter to atomic operations 
- Update `handle_atomic_op` decorator to process dynamic values
- Convert dynamic registers to index-typed vectors and extract scalar
indices
- Pass dynamic value dictionary to `_build_start_indices` for proper
index computation

This enables atomic operations like `atomic_add` to use runtime-computed
indices from input data

---------

Signed-off-by: Sanket Pandit <sanketp@amd.com>
Signed-off-by: Sanket Pandit <sanket.pandit@amd.com>
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.

2 participants