FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Consolidate LR scheduler tensor-LR tests into a contract suite by delock · Pull Request #8206 · deepspeedai/DeepSpeed · GitHub

Consolidate LR scheduler tensor-LR tests into a contract suite - #8206

Merged
delock merged 1 commit into
deepspeedai:masterfrom
delock:gma/lr-scheduler-lr-tensor-test
Aug 4, 2026
Merged

Consolidate LR scheduler tensor-LR tests into a contract suite#8206
delock merged 1 commit into
deepspeedai:masterfrom
delock:gma/lr-scheduler-lr-tensor-test

Conversation

delock commented Aug 3, 2026
edited
Loading

Copy link
Copy Markdown
Collaborator

What

Replaces the three per-scheduler *_preserves_tensor_lr tests (WarmupLR, WarmupCosineLR, OneCycle) with a single parametrized contract test driven by a TENSOR_LR_CONTRACTS table, plus a registry-coverage assertion that fails collection when a scheduler listed in VALID_LR_SCHEDULES has no contract row.

Why

#8205 recently fixed OneCycle._initialize_lr bypassing update_lr(), which silently replaced a caller-supplied tensor LR with a Python scalar on construction. WarmupLR and WarmupCosineLR had the same class of bug fixed in #8202. Each fix was caught only because someone happened to write a hand-rolled regression test for that specific scheduler.

This PR turns that pattern into a contract: every scheduler in VALID_LR_SCHEDULES is pinned by one table row asserting tensor identity / shape / dtype at init and after step(1). Two failure modes are covered:

  1. Registered but buggy (writes group['lr'] = scalar in its constructor) — the parametrized contract case fails on the identity assertion.
  2. Forgotten (a new scheduler is added to VALID_LR_SCHEDULES without a contract row) — test_all_schedulers_covered_by_tensor_lr_contract fails at collection with the exact missing class name.

Both guards were verified empirically against this branch:

Test footprint

CPU-only, no GPU/distributed runner required:

pytest tests/unit/runtime/test_lr_schedulers.py -k "preserves_tensor or covered_by_tensor"
# 11 passed (5 schedulers x 2 shapes + 1 coverage)

pre-commit run --files tests/unit/runtime/test_lr_schedulers.py passes (yapf, flake8, check-torchdist, check-license, codespell).


Authored by an AI coding agent (opencode, model: glm-5.2) under interactive human direction and review.

Replace the three per-scheduler *_preserves_tensor_lr tests with one
parametrized contract test driven by TENSOR_LR_CONTRACTS, plus a
coverage assertion that fails collection when a scheduler in
VALID_LR_SCHEDULES has no contract row. A new scheduler that bypasses
update_lr() in its constructor will now regress the suite without
needing a hand-written test.

Signed-off-by: Guokai Ma <guokai.ma@intel.com>
delock force-pushed the gma/lr-scheduler-lr-tensor-test branch from 470589a to 07499c2 Compare August 3, 2026 05:05
delock marked this pull request as ready for review August 3, 2026 05:11

chatgpt-codex-connector Bot 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07499c2a24

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

# scalar, so the caller-held reference keeps its identity, shape and dtype.
# Add a row when a new scheduler is registered; the coverage test below fails
# collection if any scheduler is missing.
TENSOR_LR_CONTRACTS = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Add the missing Signed-off-by trailer

This non-merge commit has a single parent and its commit message ends without a Signed-off-by: trailer, but the repository requires every non-merge commit to be signed off. Without that trailer, DCO/CI can reject the change even though the test consolidation itself is local; please recreate or amend the commit with git commit --signoff using the configured name/email.

AGENTS.md reference: AGENTS.md:L8-L8

Useful? React with 👍 / 👎.

delock added this pull request to the merge queue Aug 4, 2026
Merged via the queue into deepspeedai:master with commit 6498adc Aug 4, 2026
14 of 18 checks passed
delock deleted the gma/lr-scheduler-lr-tensor-test branch August 4, 2026 00:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL