← Back to Pull requests

AutoEP: read and write the transformers output-capture registry as a dict #9029

Closed
unknown closed this pull request without merging on Nov 07, 2026 06:30 UTC
View on GitHub
unknown unknown commented on Nov 06, 2026 21:55 UTC
Author

AutoEP: read and write the transformers output-capture registry as a dict

Problem

cpu-torch-latest installs transformers from git main, and since 2026-11-06 it fails on every PR with:

FAILED unit/v1/moe/test_autoep_unit.py::TestModelDetectionAndReplacement::test_hf_mixtral_causal_lm_matches_autoep_with_router_logits
FAILED unit/v1/moe/test_autoep_unit.py::TestModelDetectionAndReplacement::test_hf_minimax_m3_causal_lm_matches_autoep_with_router_logits
E       TypeError: _CanRecordRegistry.get() takes 2 positional arguments but 3 were given
deepspeed/module_inject/auto_ep_presets/base.py:326

Cause

huggingface/transformers#49594 (commit c5bd76ec51, 2026-11-06) changed transformers.utils.output_capturing._CAN_RECORD_REGISTRY from a plain dict to class _CanRecordRegistry(dict), whose get(model) and __setitem__(model, value) take a model and use str(model.__class__) as the key. The released transformers 5.22.1 and 5.22.2 still have the plain dict.

AutoEP's router_logits retargeting (deepspeed/module_inject/auto_ep_presets/base.py) uses the registry as a plain dict keyed by str(module.__class__):

| Line | Call | With the new class |
|---|---|---|
| 326 | registry.get(key, default) | TypeError (the failure above) |
| 364 | registry.get(key) | looks up "<class 'str'>" and returns {} |
| 305 | registry[key] = entry (restore) | stores under "<class 'str'>" |

registry.pop and registry.update are not overridden and keep working.

Change

| Where | What |
|---|---|
| deepspeed/module_inject/auto_ep_presets/base.py | Two helpers, _registry_get and _registry_set, call dict.get and dict.__setitem__ directly; lines 305, 326 and 364 use them. The keys stay str(module.__class__), which is also what the subclass stores under, so this works for both registry shapes. |
| tests/unit/v1/moe/test_autoep_unit.py | TestTransformersOutputRecorderRegistry: runs _install_instance_transformers_output_recorders with a plain dict and with a dict subclass that mirrors the new get(model) / __setitem__(model, value); checks that the retargeted entries are visible under the class key while the hooks are installed, and that the registry is restored exactly afterwards (the original entry back, the added one removed). CI runs one transformers version, so this covers both shapes in every run. |

Duplicate check

Searched open PRs and issues on 2026-11-06 for "_CanRecordRegistry", "_CAN_RECORD_REGISTRY", "output capture registry" and the error message: none found.

Tests

Hardware: CPU only (DS_ACCELERATOR=cpu), Intel Xeon Platinum 8375C, Ubuntu 22.04.5, CPython 3.12.14, torch 2.10.0, pytest 8.3.5, pytest-xdist 3.8.0. Command, from tests/: pytest --forked -n 4 unit/v1/moe/test_autoep_unit.py (as in cpu-torch-latest).

| unit/v1/moe/test_autoep_unit.py | transformers 5.22.1 (plain dict) | transformers main at 073a202c6 (_CanRecordRegistry) |
|---|---|---|
| master (8af59b2e7) | 197 passed, 6 skipped | 2 failed (the two tests above), 195 passed, 6 skipped |
| this PR | 199 passed, 6 skipped | 199 passed, 6 skipped |
| the new test on master's code | plain_dict passes, model_keyed fails | plain_dict passes, model_keyed fails |

pre-commit run --files on both changed files: all hooks pass.

Not run: GPU (the change touches only registry reads and writes on the host).

Compatibility

AutoEP with Hugging Face models that record router_logits: the Mixtral, MiniMax-M3 and Qwen3-MoE presets (through TransformersTopLevelRouterLogitsAdapter) and the Qwen3.5-MoE preset use this path. Works with transformers 5.22.x and with transformers main. No ZeRO, offload, precision or parallelism behavior changes.

AI assistance

This change, its test and this description were prepared with AI assistance (Claude), which also ran the tests above.

🤖 Generated with Claude Code

Diff: 494 lines (+370 / -124) across 6 files Reviewer: delock Review duration: 515m
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 494 lines diff across 6 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.371
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9029"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.4% (MEDIUM) · Higher = larger blast radius
47.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 18.7% · Safe to merge
18.7%