Skip to content

Fix remaining nonexistent AdamOptions::beta1 calls in C++ frontend tutorial#3934

Open
David-Wu1119 wants to merge 1 commit into
pytorch:mainfrom
David-Wu1119:fix-adamoptions-beta1
Open

Fix remaining nonexistent AdamOptions::beta1 calls in C++ frontend tutorial#3934
David-Wu1119 wants to merge 1 commit into
pytorch:mainfrom
David-Wu1119:fix-adamoptions-beta1

Conversation

@David-Wu1119

Copy link
Copy Markdown

Fixes pytorch/pytorch#47351

The checkpoint-restore snippet in the C++ frontend tutorial still uses torch::optim::AdamOptions(2e-4).beta1(0.5) — the beta1 member no longer exists (adam.h defines only TORCH_ARG(betas_t, betas)), so the snippet doesn't compile.

#2260 fixed the identical calls earlier in the tutorial (training-loop section) but missed these two occurrences in the checkpoint-restore block. This applies the same betas(std::make_tuple(0.5, 0.5)) form to the remaining two, making the file consistent.

(Prepared with AI assistance; reviewed by the author.)

Copilot AI review requested due to automatic review settings July 9, 2026 19:09
@pytorch-bot

pytorch-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3934

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla

meta-cla Bot commented Jul 9, 2026

Copy link
Copy Markdown

Hi @David-Wu1119!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the C++ frontend tutorial (advanced_source/cpp_frontend.rst) so the checkpoint-restore code snippet compiles with current LibTorch by removing calls to the nonexistent AdamOptions::beta1 setter and using AdamOptions::betas(...) instead.

Changes:

  • Replace torch::optim::AdamOptions(...).beta1(0.5) with torch::optim::AdamOptions(...).betas(std::make_tuple(...)) in the checkpoint-restore snippet.
  • Align the checkpoint-restore snippet with the approach already applied elsewhere in the tutorial (per PR #2260).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1209 to +1212
torch::optim::Adam generator_optimizer(
generator->parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5));
generator->parameters(), torch::optim::AdamOptions(2e-4).betas(std::make_tuple(0.5, 0.5)));
torch::optim::Adam discriminator_optimizer(
discriminator->parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5));
discriminator->parameters(), torch::optim::AdamOptions(2e-4).betas(std::make_tuple(0.5, 0.5)));
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.

no member named 'beta1' in 'torch::optim::AdamOptions'

2 participants