Repository navigation
Conversation
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
| # Distributed log-sum-exp: 2 all-reduces for numerical stability | ||
| with torch.no_grad(): | ||
| local_max = logits_2d.max(dim=-1).values | ||
| global_max = funcol.all_reduce(local_max, "MAX", tp_pg) |
There was a problem hiding this comment.
this needs {tp: R} annot
[ghstack-poisoned]
[ghstack-poisoned]
| lora_a_sharding = ShardingConfig( | ||
| state_shardings={"weight": dense_param_placement(tp=spmd.S(1))}, | ||
| ) | ||
| return lora_a_sharding, replicated_weight |
There was a problem hiding this comment.
@tianyu-l lora feature test has implicit weight redistribution (for rowwise vs. colwise), checking if this makes sense
There was a problem hiding this comment.
hmm, this makes sense to me. I must have missed the point when I was reviewing it. Curious what redistribution happens.
| lse_NT, spmd.V, spmd.PartitionSpec("tp", ("dp", "cp")) | ||
| ) | ||
|
|
||
| out_BLNH = out_TNH.view(B, L, -1, H).to(q_BLNH.dtype) |
[ghstack-poisoned]
| assert isinstance(result, torch.Tensor) | ||
| if get_spmd_backend() == "spmd_types" and spmd.is_type_checking(): | ||
| spmd.assert_type( | ||
| result, spmd.V, spmd.PartitionSpec(("dp", "cp"), "tp", None) |
There was a problem hiding this comment.
Whenever there's any tensor dim sharded as (dp, cp), that's likely incorrect, because it must be coming from folding [S(0), S(1)], which should've resulted in StridedShard.
Maybe no_typecheck() the entire region for now and leave a TODO.
There was a problem hiding this comment.
the folding is needed for VarLen's signature (in the code above), but I just realized VarLen + CP is supported yet, so removing CP from assert_type for now, adding a comment.
| src_spmd_layout.axis_types, | ||
| src_spmd_layout.partition_spec, | ||
| ) | ||
| if spmd.is_type_checking(): |
There was a problem hiding this comment.
maybe mention why it doesn't work with compile during erasure, if not having this if/else
[ghstack-poisoned]
[ghstack-poisoned]
Stack from ghstack (oldest at bottom):