Skip to content

[train][torchft][doc] Document ray train + torchft + ray data - #63563

Closed
TimothySeah wants to merge 1 commit into
ray-project:masterfrom
TimothySeah:tseah/document-torchft
Closed

TimothySeah wants to merge 1 commit into
ray-project:masterfrom
TimothySeah:tseah/document-torchft

Conversation

@TimothySeah

Copy link
Copy Markdown
Contributor

Disclaimer: this is a draft PR. I will improve the wording and clean up / test the code examples before submitting.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new user guide for "Continuous Training Across Failures" using torchft with Ray Train, including a new code example file. The review feedback suggests improving code portability by using ray.train.torch.get_device() instead of hardcoding "cuda" and using a dynamic storage path. Additionally, several TODO items in the documentation regarding API links and Ray Data integration need to be resolved before finalization.

model.conv1 = torch.nn.Conv2d(
1, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False
)
model.to("cuda")

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.

medium

Hardcoding "cuda" is discouraged in Ray Train. It is better to use ray.train.torch.get_device() to ensure the code is portable and correctly uses the device assigned by Ray, especially in multi-GPU environments.

Suggested change
model.to("cuda")
device = ray.train.torch.get_device()
model.to(device)

transport = PGTransport(
pg,
timeout=timedelta(seconds=10),
device="cuda",

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.

medium

Use the device variable obtained from ray.train.torch.get_device() instead of hardcoding "cuda".

Suggested change
device="cuda",
device=device,


# Training loop
for images, labels in train_loader:
images, labels = images.to("cuda"), labels.to("cuda")

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.

medium

Use the device variable obtained from ray.train.torch.get_device() instead of hardcoding "cuda".

Suggested change
images, labels = images.to("cuda"), labels.to("cuda")
images, labels = images.to(device), labels.to(device)

run_config=ray.train.RunConfig(
# In a multi-node cluster set storage_path to a path accessible
# from every worker node (e.g. NFS or cloud storage).
storage_path="/mnt/cluster_storage",

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.

medium

The hardcoded path "/mnt/cluster_storage" might not exist on all systems. For a more portable example, consider using a temporary directory or a clearer placeholder.

Suggested change
storage_path="/mnt/cluster_storage",
storage_path=os.path.join(tempfile.gettempdir(), "ray_results"),

Comment on lines +176 to +177
**TODO:** replace the inline class reference once ``TorchftConfig`` is in
the public API reference, and link to it from here.

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.

medium

This TODO should be resolved before merging the PR to ensure the documentation provides valid links to the API reference.

Comment on lines +200 to +202
**TODO:** document the Ray Data + torchft DDP path, including the dataset
construction, the per-worker iterator pattern, and any ``TorchftConfig``
differences.

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.

medium

The documentation for the Ray Data + torchft DDP path is currently a TODO. Since this is a key part of the guide (and mentioned in the PR title), it should be completed before the PR is finalized.

@TimothySeah

Copy link
Copy Markdown
Contributor Author

Another thing to note: report only works when replacement worker recovers and also reports!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jun 16, 2026
@TimothySeah TimothySeah removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jun 16, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jul 1, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

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

Labels

stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant