Fix/test plugin registration stub - #21
Merged
heavyrain-lzy merged 2 commits intoSep 22, 2026
Merged
Conversation
…test fixture _stub_training_engine_runtimes (session-scoped, autouse) stubs verl.workers.engine.fsdp in sys.modules so registration tests don't need real GPU training runtimes. It only defined FSDPEngine and FSDPEngineWithLMHead, but verl-core's fsdp/__init__.py now also exports FSDPTurboEngineWithLMHead -- every vendor's test that imports through this stub (confirmed: XPU, MLU) fails with ImportError, not just XPU's. Not device-specific -- this stub is shared across all vendor tests.
_ImportPlaceholder was assigned first, sys.modules got mocked with it still in place, THEN _StubEngine got defined and re-assigned -- but the BaseEngine import in between (from verl.workers.engine.base import BaseEngine) is what actually triggers verl/workers/engine/__init__.py to run, including its mindspeed import (MindspeedEngineWithLMHead subclasses MegatronEngineWithLMHead under a live @EngineRegistry.register(...) decorator that asserts issubclass(engine_class, BaseEngine) at class-definition time). That assertion saw the still-unpromoted _ImportPlaceholder and failed for real -- confirmed via AssertionError at verl/workers/engine/base.py:376 on real B60 hardware. Fix: import BaseEngine and populate every stub module with _StubEngine before patching sys.modules at all, so nothing ever observes a bare placeholder.
kahlun
marked this pull request as ready for review
September 22, 2026 06:21
kahlun
requested review from
heavyrain-lzy and
physics31415926
as code owners
September 22, 2026 06:21
kahlun
added a commit
to kahlun/verl-hardware-plugin-fork
that referenced
this pull request
Sep 22, 2026
…tform-unit-tests PR #4 depends on the fixture fix from PR #3/verl-project#21 to pass in isolation -- without it, verl>=0.9.1 breaks at fixture setup with ImportError before ever reaching the new XPU tests this branch adds.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Move the BaseEngine import under the environment patch to preserve runtime isolation.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR updates the shared plugin-registration fixture for newer verl-core versions.
Changes:
- Adds the missing
FSDPTurboEngineWithLMHeadstub. - Initializes stub classes before patching runtime modules.
| File | Summary |
|---|---|
tests/test_plugin_registration.py |
Updates engine stubs, but BaseEngine is imported before the environment patch, potentially loading hardware plugins and defeating fixture isolation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # cleanly on its own (its try/except ImportError guards handle the | ||
| # genuinely-missing torchtitan/veomni/automodel/mindspeed/megatron | ||
| # packages already). | ||
| from verl.workers.engine.base import BaseEngine |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes a pre-existing bug in the shared, session-scoped
_stub_training_engine_runtimesfixture in
tests/test_plugin_registration.py. This fixture backs the registrationtests for every vendor in this repo (TPU, MLU, MetaX, Iluvatar, FlagOS, XPU, ...),
not just XPU — it was already broken for all of them against current verl-core, it
just hadn't been exercised yet (see Motivation). Fix the issue #20
Motivation
While retesting the XPU plugin against a newer verl-core checkout,
pytest tests/test_plugin_registration.pyfailed at fixture setup with:Root cause: verl-core's
verl/workers/engine/__init__.pydoesfrom .fsdp import FSDPEngine, FSDPEngineWithLMHead, FSDPTurboEngineWithLMHead.This fixture replaces
verl.workers.engine.fsdpinsys.moduleswith a barestand-in module so the full registration suite can run without a real FSDP/Megatron
runtime — but the stand-in predates
FSDPTurboEngineWithLMHead, which verl-coreadded upstream on 2026-08-17 (
d4701e4e, "add fsdpturbo backend engine support"),and was never updated to include it.
This is not XPU-specific and not something introduced by this repo's own history:
this repo's CI has not hit it yet only because
pyproject.tomlpinsverl>=0.7.0,and the latest PyPI release stayed at
0.9.0(2026-08-14, predates the new class)until
0.9.1shipped on 2026-09-20. Any CI run against0.9.1or a currentverl-core
mainwill hit this same error regardless of which vendor's test runsfirst — confirmed by reproducing it with an unmodified verl-core checkout and the
unmodified fixture on
main.A second, related bug surfaced once the missing symbol above was patched: the
fixture built its
_StubEngineclass and only assigned it to the mocked moduleattributes after entering
mock.patch.dict(sys.modules, ...). In that window,verl-core's own internal
mindspeedwiring re-importsverl.workers.engine, whichruns a live
@EngineRegistry.register(...)decorator that assertsissubclass(engine_class, BaseEngine)at class-definition time. It observed thepre-assignment placeholder instead of
_StubEngineand failed withAssertionErroratverl/workers/engine/base.py:376.Changes
tests/test_plugin_registration.py—_stub_training_engine_runtimesfixture:FSDPTurboEngineWithLMHeadstub to the mockedverl.workers.engine.fsdpmodule, matching the real module's__all__.BaseEngineis imported for real and_StubEngineis definedand assigned to every mocked module attribute before
mock.patch.dict(sys.modules, ...)takes effect, instead of after. Removes the placeholder/real-stub split that let
verl-core's own internal imports observe a non-
BaseEngineobject mid-setup.No new test cases are added and no XPU-specific code is touched — this is scoped
entirely to the shared fixture (1 file changed, 28 insertions, 22 deletions).
Testing
pytest tests/ -vpasses —62 passed, 6 warningson real B60 hardware.Before this fix: 1 error (
ImportErrorabove). After stubbing the missingsymbol alone (partial fix): 1 error (
AssertionErrorabove). Both resolvedtogether by this PR.
change; no engine or runtime behavior is touched.
Acceptance Baseline (for new hardware adaptation PRs)
N/A — this PR does not add or modify a hardware platform/engine. It fixes a bug in
shared test infrastructure used by every vendor in this repo.
Checklist
pre-commitchecks