Skip to content

Add mHC support for HybridModel on dsv4 - #4568

Closed
Connor-XY wants to merge 11 commits into
NVIDIA:dsv4from
Connor-XY:yxu1/mhc-hybridmodel-dsv4-linear
Closed

Add mHC support for HybridModel on dsv4#4568
Connor-XY wants to merge 11 commits into
NVIDIA:dsv4from
Connor-XY:yxu1/mhc-hybridmodel-dsv4-linear

Conversation

@Connor-XY

@Connor-XY Connor-XY commented May 1, 2026

Copy link
Copy Markdown
Contributor

Related PR: #3430 adds mHC support for TransformerModel targeting main. This PR targets dsv4 and builds on that work by adding initial mHC support for HybridModel / HybridStack.

Summary

This PR stacks on the mHC TransformerLayer support port for dsv4 and adds initial mHC support for HybridModel / HybridStack.

Changes include:

  • Adds HyperConnectionHybridLayer, a layer-boundary mHC wrapper for HybridStack layers.
  • Expands HybridStack hidden states to multi-residual-stream form at the first stage and contracts back at the final stage.
  • Wraps standard HybridStack layer types when enable_hyper_connections=True.
  • Adds HybridModel and HybridStack tests covering Mamba/attention/MLP, GDN, DSA-style split layers, pipeline boundary shapes, and DeepSeek-style dense / MoE proxy patterns.
  • Adds a dummy HybridModel mHC forward/backward test to verify the generic wrapper path without depending on a specific real layer implementation.

Validation

  • python3 -m py_compile tests/unit_tests/models/test_hybrid_model.py
  • git diff --check
  • Slurm + NeMo container targeted pytest:
    • tests/unit_tests/models/test_hybrid_model.py::TestHybridModel::test_dummy_hybrid_model_with_hyper_connections_forward_backward
    • Result: 1 passed, 20 warnings in 14.65s
  • Earlier targeted Hybrid mHC GPU tests passed for the HybridStack/DeepSeek proxy coverage on this branch.

Notes

This is intended as the follow-up HybridModel PR on top of the mHC TransformerLayer support for dsv4. The Hybrid path currently uses a generic layer-boundary wrapper around HybridStack layers rather than a bespoke sublayer-level integration for every hybrid layer type.

Connor-XY and others added 10 commits April 30, 2026 17:35
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The three VPP+mHC guards in transformer_config.__post_init__,
get_tensor_shapes, and forward_backward_pipelining_with_interleaving
were added during defensive review iterations and ended up rejecting
configurations that the existing test suite (test_pp_mhc_compatibility.py)
expects to work. Drop them so the layer-count, shape-consistency, and
forward-pass tests for VPP + mHC can run.

Also resolves the AttributeError on ModelParallelConfig in
test_schedules.py interleaved tests, since the guard reading
config.enable_hyper_connections without getattr is now gone.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ed schedule

The previous guard removal also dropped the n-stream hidden_dim
calculation in forward_backward_pipelining_with_interleaving, which
was part of the original mHC PR (NVIDIA#2943). Restore it. Also remove the
pp_group-None raise in get_tensor_shapes that was added defensively
later — not present in the original PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@copy-pr-bot

copy-pr-bot Bot commented May 1, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Connor-XY

Copy link
Copy Markdown
Contributor Author

/ok to test 9bced07

The test was added in the same defensive review pass that introduced a
pp_group=None ValueError raise in get_tensor_shapes. The raise was later
removed in 9bced07 to match the original PR's behavior, but this test
was missed and continued to expect the raise. Drop it to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Connor-XY

Copy link
Copy Markdown
Contributor Author

/ok to test d02e99a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant