Skip to content

transformers 5.16 moves TP to DTensor: all_gather/split are gone, CI red on every PR #702

Description

@Hotragn

Summary

transformers 5.16 moved tensor parallelism onto DTensor. transformers.integrations.tensor_parallel is now a back-compat shim over transformers.distributed.tensor_parallel, and the two functions nnsight/modeling/tp/fragments.py depends on — all_gather and splitno longer exist anywhere in transformers.

pyproject.toml pins "transformers" unbounded, so pip install ".[dev]" now resolves 5.16.1 and every PR against 0.8 fails in CI.

CI is currently red for every PR

Same 6 failures on unrelated branches (mine, #699 and #701 — neither touches TP):

FAILED tests/test_tensor_parallel_rules.py::TestStyleCoverage::test_no_upstream_style_is_unaccounted_for
  AssertionError: transformers has parallel styles this version has no rule for:
  ['colwise_rep', 'rowwise_rep']. Add each to SIDES (with the sides that carry a
  shard) or to UNSUPPORTED.

FAILED tests/test_tensor_parallel_rules.py::TestStyleCoverage::test_no_rule_names_a_style_that_no_longer_exists
  AssertionError: rules name parallel styles transformers no longer has:
  ['embedding_colwise'] — probably renamed upstream.

FAILED tests/test_tensor_parallel_rules.py::TestReshardGuard::test_a_value_the_gather_skipped_is_not_split[tensor0-integer position_ids]
FAILED tests/test_tensor_parallel_rules.py::TestReshardGuard::test_a_value_the_gather_skipped_is_not_split[tensor1-a boolean mask]
FAILED tests/test_tensor_parallel_rules.py::TestReshardGuard::test_a_value_the_gather_skipped_is_not_split[tensor2-a 0-dim scalar]
FAILED tests/test_tensor_parallel_rules.py::TestReshardGuard::test_a_real_shard_still_round_trips
  AttributeError: <module 'transformers.integrations.tensor_parallel'> has no attribute 'split'

6 failed, 882 passed, 8 skipped, 1 xfailed

Bisected to the transformers release, not to any nnsight change:

transformers tests/test_tensor_parallel_rules.py
5.15.1 87 passed
5.16.1 6 failed, 81 passed

The last green run I can see on 0.8 is feat/vllm-graph-taps on 2026-08-24; 5.16 landed after that.

The failing tests understate the problem

The guard tests catch split only because TestReshardGuard monkeypatches it. The imports in fragments.py are function-local, so nothing surfaces until the code actually runs — and _gather's import is never exercised on a CPU runner:

# src/nnsight/modeling/tp/fragments.py:175
def _gather(value, mesh):
    from transformers.integrations.tensor_parallel import all_gather   # <- gone

# src/nnsight/modeling/tp/fragments.py:207
def _reshard(value, mesh):
    from transformers.integrations.tensor_parallel import split        # <- gone

Both now raise:

>>> from transformers.integrations.tensor_parallel import all_gather
ImportError: cannot import name 'all_gather' from 'transformers.integrations.tensor_parallel'
>>> from transformers.integrations.tensor_parallel import split
ImportError: cannot import name 'split' from 'transformers.integrations.tensor_parallel'

So on transformers ≥5.16 a sharded trace should fail at the first fragment handoff, on hardware, with an ImportError from inside a hook. I can't confirm that end to end — no multi-GPU box here — but the imports are unambiguous.

What changed upstream

transformers/integrations/tensor_parallel.py is now:

Backward-compatibility shim for the tensor parallel API.
The canonical implementation lives in transformers.distributed.tensor_parallel.

and the canonical module exports DTensor primitives instead of collectives:

ALL_PARALLEL_STYLES, ColwiseParallel, RowwiseParallel, SequenceParallel, ...
DTensor, Shard, Replicate, Partial, distribute_tensor,
apply_tensor_parallelism, gather_state_dict_for_save, verify_tp_plan

No all_gather, no split, nothing *split*- or *gather*-named besides gather_state_dict_for_save. shard_and_distribute_module is kept but raises:

shard_and_distribute_module is unavailable with the DTensor tensor-parallel loading path.

Style registry deltas:

  • added colwise_rep → a ColwiseParallel instance, rowwise_rep → a RowwiseParallel instance (the _rep variants differ in output placement)
  • removed embedding_colwise

colwise_rep is the one plan.py already calls out by name — "Llama4Config does exactly this: its plan is colwise_rep, which is in no list and no registry" — it is in the registry now.

Why I'm not sending a patch

The SIDES table is built on "this rank's slice, made whole by an all-gather" / "this rank's term of a sum, made whole by an all-reduce". Under DTensor those handoffs are placements (Shard/Partial/Replicate) rather than explicit collectives, so this reads like a port of modeling/tp/fragments.py rather than a rename — and fragments.py is explicit that the table's inferred entries were the ones that misled before (moe_tp_experts), and that entries were measured on Llama-3.2-3B at tp=4.

I have no multi-GPU machine, so I can't measure which side carries the shard for colwise_rep / rowwise_rep, and guessing into SIDES is exactly what the comments there warn against. Adding them to UNSUPPORTED would turn CI green while preserving today's behaviour (both are currently refused by plan.py, since a style in neither table means "cannot be split") — but that only papers over the missing all_gather/split, so it seemed better to report than to make CI green on a broken path.

Happy to do any of these if you tell me which you want:

  1. Unblock CI onlycolwise_rep/rowwise_repUNSUPPORTED, drop embedding_colwise, and skip TestReshardGuard when split is absent. Green CI, TP still broken on ≥5.16, no false claim of support.
  2. Cap the dependencytransformers<5.16 in pyproject.toml plus a MAXIMUM_TRANSFORMERS guard next to the existing MINIMUM_TRANSFORMERS = "5.15.0", so users get UnsupportedTransformersVersion instead of an ImportError from inside a hook.
  3. Nothing — if the DTensor port is already in progress on a branch (the TP work in Pipeline parallelism for the vLLM runtime #691/Gather tensor-parallel sharded parameters on read in a trace #677 is yours and @khaiwang's), this is just a heads-up that main-line CI is red meanwhile.

Environment

0.8 @ 96c85fc, transformers 5.16.1 (broken) vs 5.15.1 (fine), torch 2.9.1, Python 3.14.3 locally / 3.12 in CI, CPU.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions