Repository navigation
Conversation
| # TODO: why do we need this clone? | ||
| return out.clone() |
There was a problem hiding this comment.
Can you try removing this clone after we added out_buffer.detach() ?
There was a problem hiding this comment.
still erroring out if removing this clone
RuntimeError: Output 0 of AllToAllVDev2dBackward is a view and its base or another view of its base has been modified inplace. This view was created inside a custom Function (or because an input was returned as-is) and the autograd logic to handle view+inplace would override the custom backward associated with the custom Function, leading to incorrect gradients. This behavior is forbidden. You can fix this by cloning the output of the custom Function.
| self.output_splits = None | ||
|
|
||
| # performing all-to-all dispatch on the input | ||
| def _token_dispatch(self, mod, inputs, device_mesh): |
There was a problem hiding this comment.
i think this new implementation will get rid of the need of torch._dynamo.config.capture_scalar_outputs, avoiding the need to handle unbacked symints
| ) | ||
|
|
||
| out = func(w1, w2, w3, x, num_tokens_per_expert) | ||
| out = func(w1, w2, w3, x, num_tokens_per_expert, offsets) |
There was a problem hiding this comment.
To make it reusable with GPT-oss implementation, can we make w1, w2, w3 somehow to a list of parameters or kwargs (basically take variable number of weights and bias)? I think what we do in this wrapper is just taking these inputs and then pass it further to func().
There was a problem hiding this comment.
Another thing which gpt-oss is not reusable is the ExpertTensorParallel(). I guess for this part, if a model has different mathematical formula and variable number of weights/bias, it's user's responsible to update _partition_fn_2d in ETP, wdyt?
|
Hi @tianyu-l, I'm an engineer working on collective-communication operators. I've been studying your NVSHMEM all_to_all_vdev_2d work in #1569 and the later HybridEP PR #2207. From the output_splits layout it looks like tokens land grouped by expert, and the NVSHMEM path skips the D2H sync — so my mental model is the grouped GEMM can consume the output almost in place, no second permute. Is that right, or am I missing a permute step? If so, why move to HybridEP instead of pushing this further — mainly engineering gaps (multi-expert, the clone() TODO in backward, CUDA-graph), or does "write-directly-to-expert-major" have a deeper limit? Thanks! |
|
@7huahua This was an early attempt on utilizing NVSHMEM to do all-to-all, but I wasn't able to make it fully work. I don't think there are fundamental limit. Later we migrated to more mature solutions like DeepEP and HybridEP which also does token dedup in communication. Recently @xmfan added MinimalAsyncEP which is a more transparent, hackable attempt that
|
As titled. This PR also does some refactoring around grouped_mm calling, as NVSHMEM-based all-to-all takes
num_tokens_per_expertand preparesoffsets.What works
num_local_experts == 1What doesn't work and needs debugging
num_local_experts > 1other TODOs
ExpertTensorParallelsupport (currently only supports ETP=1)