Skip to content

fix: avoid unstable duration_constructors so torchft builds on Rust < 1.91#334

Open
ajinkyajawale14499 wants to merge 1 commit into
meta-pytorch:mainfrom
ajinkyajawale14499:fix/duration-constructors
Open

fix: avoid unstable duration_constructors so torchft builds on Rust < 1.91#334
ajinkyajawale14499 wants to merge 1 commit into
meta-pytorch:mainfrom
ajinkyajawale14499:fix/duration-constructors

Conversation

@ajinkyajawale14499

Copy link
Copy Markdown

Summary

src/net.rs calls Duration::from_mins(1). Duration::from_mins/from_hours (the
duration_constructors feature, rust-lang/rust#120301) were unstable until Rust 1.91, so building
torchft on older stable Rust fails with:

error[E0658]: use of unstable library feature `duration_constructors`
  --> src/net.rs:20:36

This was reported on Rust 1.88 (#330). CI did not catch it because every workflow installs
--default-toolchain=stable, which is now >= 1.91.

The issue suggests documenting Rust 1.91 as the minimum. This PR instead removes the need for it:
from_mins(1) is exactly from_secs(60), so switching to the stable constructor lets torchft build
on the older stable Rust the reporter (and many distro/conda/CI environments) actually have, rather
than forcing everyone onto a bleeding-edge toolchain for a trivial constant.

Changes

The API was used at four sites (one in production, three in tests), all converted to the identical
from_secs(...) value:

  • src/net.rsfrom_mins(1) -> from_secs(60) (HTTP/2 keep-alive interval)
  • src/timeout.rs (tests) — from_hours(3)/from_mins(3) -> from_secs(3 * SECONDS_IN_HOUR) /
    from_secs(3 * SECONDS_IN_MINUTE), reusing the module's existing constants so the test mirrors the
    parser it covers
  • src/lighthouse.rs (test) — from_hours(10) -> from_secs(10 * 60 * 60)

No behaviour change: each replacement is the same Duration.

Verification

  • rustup toolchain install 1.88.0
  • On main: cargo +1.88.0 check --tests reproduces E0658 at all four sites.
  • With this change: cargo +1.88.0 check --tests compiles clean (build floor dropped to <= 1.88).
  • cargo +nightly fmt --check clean; cargo +stable check --tests green.
  • grep -rn "from_mins\|from_hours\|from_days" --include='*.rs' returns nothing.

Follow-up

If you would still like the minimum Rust version documented explicitly, I am happy to add a
rust-version field to Cargo.toml plus a README note in a follow-up. Removing the unstable API
first means that floor can stay conservative instead of being pinned to 1.91.

Closes #330

… 1.91

Duration::from_mins/from_hours were unstable (duration_constructors,
rust-lang/rust#120301) until Rust 1.91, so building on older stable Rust
failed with E0658 (reported on 1.88). Replace the four uses with the
identical from_secs(...) values so torchft builds on older stable Rust.

Closes meta-pytorch#330

Signed-off-by: ajinkyajawale14499 <26092430+ajinkyajawale14499@users.noreply.github.com>
@meta-cla

meta-cla Bot commented Jun 27, 2026

Copy link
Copy Markdown

Hi @ajinkyajawale14499!

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!

@meta-cla

meta-cla Bot commented Jun 27, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 27, 2026
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.

Need to specify minimal rust version to build

1 participant