Skip to content

Refresh fused AllGather layout after shard resets - #373

Open
zhangming700 wants to merge 1 commit into
hf1s:masterfrom
zhangming700:fix/fsdp-gather-layout-reset-master
Open

zhangming700 wants to merge 1 commit into
hf1s:masterfrom
zhangming700:fix/fsdp-gather-layout-reset-master

Conversation

@zhangming700

Copy link
Copy Markdown

/kind bug

Change

After the first BF16 forward, converting the sharded weights to FP32 could leave the fused AllGather buckets and their unpack buffers configured for BF16. A subsequent forward read updated weights but rounded away their FP32 low bits. Both settings of comm_fusion_zero_copy were affected.

Refresh the cached gather layout when the effective parameter dtype or shard layout changes. Recreate incompatible unpack buffers with their unsharded parameter views. Validate flat-buffer views by storage, offset, size, dtype and contiguity before reusing a bucket. Retain each parameter’s resolved mixed-precision policy on reset.

Verification

The original change on c9e7fca was validated on eight Ascend 910B3 devices with the full Qwen3-30B-A3B checkpoint. After a warm BF16-to-FP32 reset, all 49 gathers per rank used FP32. Rank-specific sentinels retained their low bits on all eight devices. With zero-copy enabled, the next forward issued 49 direct gathers and zero copy-ins or rebinds. With zero-copy disabled it issued 49 copy-ins.

Cold and warm resets produced identical per-rank losses and gradient norms with zero-copy enabled and disabled at gradient accumulation 1, 2 and 4. Meta initialization, an explicit BF16 communication policy and same-dtype storage replacement also passed. CPU offload with unpinned file-backed CPU weights passed forward and backward. A separate check on ordinary CPU shards observed both consecutive weight updates on every rank.

In one profiled FP32 training step per mode, median per-rank cumulative AllGather time over 98 calls was 1962 ms with zero-copy disabled and 1761 ms with it enabled. Step-time gains varied by accumulation setting.

This port targets master at 79f1597. Syntax and diff checks passed on the master port. The eight-device measurements were collected on the original test base. Supersedes #368.

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