Skip to content

docs: fix the default devices example in the Fabric arguments page - #22029

Open
ZainnQureshii wants to merge 1 commit into
Lightning-AI:masterfrom
ZainnQureshii:docs/fabric-devices-default
Open

ZainnQureshii wants to merge 1 commit into
Lightning-AI:masterfrom
ZainnQureshii:docs/fabric-devices-default

Conversation

@ZainnQureshii

Copy link
Copy Markdown

What does this PR do?

The devices section of the Fabric arguments page (docs/source-fabric/api/fabric_args.rst) shows two examples as the default, and neither works:

  • Fabric(devices=None) with the comment "default used by Fabric, i.e., use the CPU". The default is devices="auto" (src/lightning/fabric/fabric.py:139), and None raises a TypeError on CPU and on GPU/MPS: _parse_cpu_cores rejects it on CPU (src/lightning/fabric/accelerators/cpu.py:98-99) and _check_data_type rejects it for GPU/MPS device IDs (src/lightning/fabric/utilities/device_parser.py:197-199).
  • Fabric(devices=0) with the comment "equivalent". _check_device_config_and_set_final_flags rejects 0 with a ValueError (src/lightning/fabric/connector.py:305-314).

This PR replaces them with Fabric(devices="auto") for the default and Fabric(devices=1, accelerator="cpu") for an explicit CPU run, and adds "auto" to the str bullet above the block. The comment wording follows the Trainer reference (docs/source-pytorch/common/trainer.rst:429-433).

Ran each call against this branch's src/ (dependencies from lightning 2.6.6) on an Apple Silicon Mac (the auto accelerator picks MPS there), plus the old calls with accelerator="cpu":

{'devices': None} TypeError Device IDs (GPU/TPU) must be an int, a string, a sequence of ints, but you passed None
{'devices': 0} ValueError `Fabric(devices=0)` value is not a valid input using auto accelerator.
{'devices': None, 'accelerator': 'cpu'} TypeError `devices` selected with `CPUAccelerator` should be an int > 0.
{'devices': 0, 'accelerator': 'cpu'} ValueError `Fabric(devices=0)` value is not a valid input using cpu accelerator.
{'devices': 'auto'} OK mps:0
{'devices': 1, 'accelerator': 'cpu'} OK cpu

The docs build was not run locally.

Docs only, so no linked issue, tests or CHANGELOG entry.

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.

🤖 Generated with Claude Code

`Fabric(devices=None)` and `Fabric(devices=0)` were shown as the
default, but the default is `devices="auto"`, `0` raises a ValueError
and `None` fails CPU device parsing. Show the real default and a valid
CPU example instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant