Skip to content

[FT] Add torchft to CI - #1398

Merged
H-Huang merged 1 commit into
pytorch:mainfrom
H-Huang:torchft
Jul 22, 2025
Merged

H-Huang merged 1 commit into
pytorch:mainfrom
H-Huang:torchft

Conversation

@H-Huang

@H-Huang H-Huang commented Jul 15, 2025 •

Copy link
Copy Markdown
Contributor

based off of @fegin previous PR: #907

This sets up CI for torchft in torchtitan, it only runs when torchtitan/components/ft.py is changed, but we can expand it as necessary. This also makes it easier to run torchft tests / configs by just calling:

python tests/integration_tests_ft.py --test_id ...

TODO:

  • There is an issue with our CI where we cannot set CUDA_VISIBLE_DEVICES to partition the devices per replica group (I get error Cuda failure 217 'peer access is not supported between these two devices'), as a result this PR only runs with 1 replica group. In follow up PRs need to look into manually setting the cuda device when using torchft?

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 15, 2025
@H-Huang H-Huang mentioned this pull request Jul 15, 2025
@H-Huang
H-Huang marked this pull request as draft July 15, 2025 19:43
@H-Huang
H-Huang force-pushed the torchft branch 2 times, most recently from d577a46 to 19593e2 Compare July 15, 2025 20:08
@tianyu-l

Copy link
Copy Markdown
Contributor

cc @wwwjn who's considering refactor tests in torchtitan

@H-Huang
H-Huang force-pushed the torchft branch 3 times, most recently from b3ddb1a to b8102b1 Compare July 16, 2025 14:45
@H-Huang

H-Huang commented Jul 16, 2025

Copy link
Copy Markdown
Contributor Author

TorchFT CI has PHB connections:

+ nvidia-smi topo -m
	GPU0	GPU1	GPU2	GPU3	GPU4	GPU5	GPU6	GPU7	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	PHB	PHB	PHB	PHB	PHB	PHB	PHB	0-191	0-1		N/A
GPU1	PHB	 X 	PHB	PHB	PHB	PHB	PHB	PHB	0-191	0-1		N/A
GPU2	PHB	PHB	 X 	PHB	PHB	PHB	PHB	PHB	0-191	0-1		N/A
GPU3	PHB	PHB	PHB	 X 	PHB	PHB	PHB	PHB	0-191	0-1		N/A
GPU4	PHB	PHB	PHB	PHB	 X 	PHB	PHB	PHB	0-191	0-1		N/A
GPU5	PHB	PHB	PHB	PHB	PHB	 X 	PHB	PHB	0-191	0-1		N/A
GPU6	PHB	PHB	PHB	PHB	PHB	PHB	 X 	PHB	0-191	0-1		N/A
GPU7	PHB	PHB	PHB	PHB	PHB	PHB	PHB	 X 	0-191	0-1		N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

hitting this error on comms:

[rank0]:[titan] 2025-07-16 14:52:25,796 - torchft.manager - INFO - [torchtitan_ft_0:8bda5fa5-ce1b-492d-a443-49029367658c/0 - step 0] should_commit=False enough_replicas=True, errored=NCCL error in: /pytorch/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp:3726, unhandled cuda error (run with NCCL_DEBUG=INFO for details), NCCL version 2.27.5
[rank0]:ncclUnhandledCudaError: Call to CUDA function failed.
[rank0]:Last error:
[rank0]:Cuda failure 217 'peer access is not supported between these two devices'
[rank0]:Traceback (most recent call last):
[rank0]:  File "/opt/conda/envs/py_3.11/lib/python3.11/site-packages/torchft/process_group.py", line 1125, in allreduce
[rank0]:    work = super().allreduce(tensors, opts)
[rank0]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:  File "/opt/conda/envs/py_3.11/lib/python3.11/site-packages/torchft/process_group.py", line 467, in allreduce
[rank0]:    self.parent.allreduce(tensors, self._opts_hook(opts)), opts
[rank0]:    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:  File "/opt/conda/envs/py_3.11/lib/python3.11/site-packages/torchft/process_group.py", line 467, in allreduce
[rank0]:    self.parent.allreduce(tensors, self._opts_hook(opts)), opts
[rank0]:    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]:torch.distributed.DistBackendError: NCCL error in: /pytorch/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp:3726, unhandled cuda error (run with NCCL_DEBUG=INFO for details), NCCL version 2.27.5
[rank0]:ncclUnhandledCudaError: Call to CUDA function failed.
[rank0]:Last error:
[rank0]:Cuda failure 217 'peer access is not supported between these two devices'

@H-Huang
H-Huang force-pushed the torchft branch 11 times, most recently from fc623e8 to 26d655f Compare July 18, 2025 16:44
@H-Huang H-Huang changed the title [WIP] Add torchft to CI Add torchft to CI Jul 18, 2025
@H-Huang
H-Huang marked this pull request as ready for review July 18, 2025 16:52
@H-Huang H-Huang changed the title Add torchft to CI [FT] Add torchft to CI Jul 18, 2025
@H-Huang
H-Huang requested a review from d4l3k July 18, 2025 17:28
@H-Huang
H-Huang requested a review from tushar00jain July 18, 2025 17:28
Comment on lines +117 to +118
if args.ngpu < 8:
logger.info("Skipping TorchFT integration tests as we need 8 GPUs.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow arbitrary number gpu's so we can also run this test locally? i guess we just need to pass the ngpu to run_tests and create the list of ranks based on ngpu arg instead of 8?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I dont like how its hard-coded right now. But on the flip-side integration tests are only meant to be used on one machine and so all the integration tests and our CI assume 8 GPUs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can still ensure it's run on a single machine right? plus we can also use less than the number of gpu's on the machine on the ci e.g. run locally or set up a different config on the ci. don't have a strong pref, we can also come back to this later when needed

Comment thread tests/integration_tests_ft.py Resolved
cmds = []

for replica_id, ranks in enumerate(all_ranks):
cmd = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make this a list and join later

push:
branches: [ main ]
paths:
- 'torchtitan/components/ft.py'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean you are ok if train.py / something else break FT integration.
btw the test won't be triggered for this PR if you specify this way.

@tushar00jain tushar00jain Jul 18, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah might be good to run this on all diffs to make sure some unrelated changes don't break the ft integration (this is an integration test anyway)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the tests aren't triggered for this PR, but previously I did try it out by changing ft.py and the CI did pass.

yeah might be good to run this on all diffs

Yeah this is up to us to decide and how much we would want torchft changes to potentially block titan CI. Considering FT is not a hard dependency for titan, i took a pretty conservative approach. Also the test doesn't actually test multiple replica groups in CI yet due to the issue mentioned in the description so the tests are still basic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add more to the tests later but i feel we should consider ft as a hard dependency because if we don't, things can break for people who use titan with ft e.g. i remember pipeline parallel working with ft before but started seeing some issues around backward pass called multiple times. might be good to catch these issues in diffs. (we should probably also run titan test in torchft probably)

don't have a strong pref for now though, we can change things later. may be a broader discussion on how to approach ft integrations, we may integrate with more than just titan

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stamp to unblock -- I think we still have the regular per 6 hour tests running, so if CI is broken, you can get notified and help fix. Hope it's not too much for now. If it's becoming a headache, we can revisit.

@H-Huang
H-Huang merged commit ad7f644 into pytorch:main Jul 22, 2025
idoh pushed a commit to idoh/torchtitan that referenced this pull request Jul 28, 2025
based off of @fegin previous PR:
pytorch#907

This sets up CI for torchft in torchtitan, it only runs when
`torchtitan/components/ft.py` is changed, but we can expand it as
necessary. This also makes it easier to run torchft tests / configs by
just calling:

`python tests/integration_tests_ft.py --test_id ...`

TODO:
- There is an issue with our CI where we cannot set
`CUDA_VISIBLE_DEVICES` to partition the devices per replica group (I get
error Cuda failure 217 'peer access is not supported between these two
devices'), as a result this PR only runs with 1 replica group. In follow
up PRs need to look into manually setting the cuda device when using
torchft?
bentherien pushed a commit to bentherien/torchtitan_ that referenced this pull request Aug 5, 2025
based off of @fegin previous PR:
pytorch#907

This sets up CI for torchft in torchtitan, it only runs when
`torchtitan/components/ft.py` is changed, but we can expand it as
necessary. This also makes it easier to run torchft tests / configs by
just calling:

`python tests/integration_tests_ft.py --test_id ...`

TODO:
- There is an issue with our CI where we cannot set
`CUDA_VISIBLE_DEVICES` to partition the devices per replica group (I get
error Cuda failure 217 'peer access is not supported between these two
devices'), as a result this PR only runs with 1 replica group. In follow
up PRs need to look into manually setting the cuda device when using
torchft?
joellidin pushed a commit to one-covenant/torchtitan that referenced this pull request Aug 8, 2025
based off of @fegin previous PR:
pytorch#907

This sets up CI for torchft in torchtitan, it only runs when
`torchtitan/components/ft.py` is changed, but we can expand it as
necessary. This also makes it easier to run torchft tests / configs by
just calling:

`python tests/integration_tests_ft.py --test_id ...`

TODO:
- There is an issue with our CI where we cannot set
`CUDA_VISIBLE_DEVICES` to partition the devices per replica group (I get
error Cuda failure 217 'peer access is not supported between these two
devices'), as a result this PR only runs with 1 replica group. In follow
up PRs need to look into manually setting the cuda device when using
torchft?
joellidin pushed a commit to one-covenant/torchtitan that referenced this pull request Aug 8, 2025
based off of @fegin previous PR:
pytorch#907

This sets up CI for torchft in torchtitan, it only runs when
`torchtitan/components/ft.py` is changed, but we can expand it as
necessary. This also makes it easier to run torchft tests / configs by
just calling:

`python tests/integration_tests_ft.py --test_id ...`

TODO:
- There is an issue with our CI where we cannot set
`CUDA_VISIBLE_DEVICES` to partition the devices per replica group (I get
error Cuda failure 217 'peer access is not supported between these two
devices'), as a result this PR only runs with 1 replica group. In follow
up PRs need to look into manually setting the cuda device when using
torchft?
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
based off of @fegin previous PR:
pytorch#907

This sets up CI for torchft in torchtitan, it only runs when
`torchtitan/components/ft.py` is changed, but we can expand it as
necessary. This also makes it easier to run torchft tests / configs by
just calling:

`python tests/integration_tests_ft.py --test_id ...`

TODO:
- There is an issue with our CI where we cannot set
`CUDA_VISIBLE_DEVICES` to partition the devices per replica group (I get
error Cuda failure 217 'peer access is not supported between these two
devices'), as a result this PR only runs with 1 replica group. In follow
up PRs need to look into manually setting the cuda device when using
torchft?
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 25, 2026
based off of @fegin previous PR:
pytorch#907

This sets up CI for torchft in torchtitan, it only runs when
`torchtitan/components/ft.py` is changed, but we can expand it as
necessary. This also makes it easier to run torchft tests / configs by
just calling:

`python tests/integration_tests_ft.py --test_id ...`

TODO:
- There is an issue with our CI where we cannot set
`CUDA_VISIBLE_DEVICES` to partition the devices per replica group (I get
error Cuda failure 217 'peer access is not supported between these two
devices'), as a result this PR only runs with 1 replica group. In follow
up PRs need to look into manually setting the cuda device when using
torchft?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants