Skip to content

Update nn.Sequential signature to match PyTorch (*modules varargs)#2827

Merged
justinchuby merged 3 commits intomainfrom
copilot/update-nn-sequential-signature
Feb 26, 2026
Merged

Update nn.Sequential signature to match PyTorch (*modules varargs)#2827
justinchuby merged 3 commits intomainfrom
copilot/update-nn-sequential-signature

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

nn.Sequential.__init__ accepted a list[Module] | None parameter, diverging from PyTorch's torch.nn.Sequential which takes variadic positional args.

Changes

  • nn/_sequential.py: Added __init__(self, *modules: Module) override that accepts variadic args and delegates to ModuleList.__init__; updated docstring example.
  • nn/_module_test.py: Migrated all Sequential([...]) call sites to Sequential(...).

Before / After

# Before
seq = Sequential([SiLU(), Linear(4, 4)])
seq_empty = Sequential([])

# After — matches torch.nn.Sequential
seq = Sequential(SiLU(), Linear(4, 4))
seq_empty = Sequential()
Original prompt

This section details on the original issue you should resolve

<issue_title>Update nn.Sequential signature to match pytorch</issue_title>
<issue_description>def __init__(self, modules: list[Module] | None = None) -> None should become def __init__(self, *modules: Module = None) -> None: to match pytorch signature.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…PyTorch

Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Copilot AI changed the title [WIP] Update nn.Sequential signature to match PyTorch Update nn.Sequential signature to match PyTorch (*modules varargs) Feb 25, 2026
Copilot AI requested a review from justinchuby February 25, 2026 05:25
@justinchuby justinchuby marked this pull request as ready for review February 25, 2026 05:44
@justinchuby justinchuby enabled auto-merge (squash) February 25, 2026 05:44
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.78%. Comparing base (ef2bc22) to head (5b6d35c).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2827   +/-   ##
=======================================
  Coverage   71.78%   71.78%           
=======================================
  Files         239      239           
  Lines       28989    28991    +2     
  Branches     2859     2859           
=======================================
+ Hits        20809    20811    +2     
  Misses       7209     7209           
  Partials      971      971           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justinchuby justinchuby assigned gramalingam and unassigned Copilot Feb 25, 2026
@justinchuby
Copy link
Collaborator

@gramalingam

@justinchuby justinchuby merged commit 1fdfb1b into main Feb 26, 2026
32 of 34 checks passed
@justinchuby justinchuby deleted the copilot/update-nn-sequential-signature branch February 26, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Update nn.Sequential signature to match pytorch

3 participants