[BUG]AutoTP compile pass silently dropping tensor-parallel collectives
[DeepCompile] Fix AutoTP compile pass silently dropping tensor-parallel collectives
Summary
The AutoTP compile pass can leave a tensor-parallel layer with no collective at all — neither the module-level one it switched off, nor a graph-level replacement. The run does not fail. It produces wrong forward values and wrong gradients, and exits 0.
Any model using activation checkpointing hits this, which includes anything calling
HuggingFace's model.gradient_checkpointing_enable().
The bug
defer_collectives_to_compiler switches off the module-level collective on every injected
TensorParallel_Layer, on the promise that the graph pass will emit a replacement:
for module in tp_modules:
module.defer_collectives_to_compiler = True # module-level collective now off
pass_insert_tp_collectives then walks gm.graph.nodes and inserts f/g for the parallel
matmuls it finds. Nothing checks that the two sets agree.
Under activation checkpointing they do not. Dynamo lifts a checkpointed region into a child
GraphModule behind a tag_activation_checkpoint node, and the pass never descends into it. The
layers inside keep neither collective, so a row-parallel matmul's output stays a partial sum.
fullgraph=True does not protect against this — the higher-order op is a full-graph capture, so
nothing graph-breaks and nothing warns.
Why this is not a niche configuration
HuggingFace's gradient_checkpointing_enable() defaults to
gradient_checkpointing_kwargs={"use_reentrant": False} (transformers/modeling_utils.py), and
use_reentrant=False is exactly the variant Dynamo captures into a subgraph rather than
graph-breaking on. So model.gradient_checkpointing_enable() plus "passes": ["autotp"] silently
corrupts training.
Measured
2×H200, tp=2, compared against the module-level AutoTP path — the same reference the pass's own tests use:
| model | forward / loss max diff | worst grad diff | collectives inserted | parallel matmuls hidden in subgraphs |
|---|---|---|---|---|
| MLP, no checkpointing | 2.4e-07 | 7.2e-07 | 6 of 6 | 0 |
| MLP, checkpointing | 2.7e-01 | 9.2e-01 | 2 of 8 | 6 |
HF Llama + gradient_checkpointing_enable() |
3.1e-02 | 2.6e-01 | 0 of 14 | 14 |
Exit code 0 in every row.
Worth noting the middle row: insertion is partial, not absent. Layers outside a checkpointed block still receive their collectives, so the graph looks instrumented on inspection.