Skip to content

Bringup/ernie 4.5 21b a3b thinking - #2680

Open
willg-nv wants to merge 3 commits into
NVIDIA:mainfrom
willg-nv:bringup/ernie-4.5-21b-a3b-thinking
Open

willg-nv wants to merge 3 commits into
NVIDIA:mainfrom
willg-nv:bringup/ernie-4.5-21b-a3b-thinking

Conversation

@willg-nv

@willg-nv willg-nv commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Add native FP32 text continuation for baidu/ERNIE-4.5-21B-A3B-Thinking through the ernie4_5_moe family.

Background

Related to #2667. The initial scope is one sequence with greedy decoding and a fixed KV-cache profile.

Exit Criteria

  • Build/load the pinned checkpoint through the family and native task interfaces.
  • Preserve the checkpoint's causal attention, routed experts, tokenizer, and incremental generation.
  • Enforce the committed independent-reference comparisons and pass the applicable repository checks before claiming full readiness.

Implementation

  • Add family-owned weight/configuration loading and the TensorRT MoE decoder builder.
  • Add native tokenization, fixed-profile KV storage, and greedy text continuation.
  • Add ownership coverage, a C++ tokenizer helper, and a pinned-checkpoint E2E recipe with exact reference comparisons for code and Chinese prompts.

This adds family-specific bundles and dependencies without changing shared public API/ABI layouts or the shared bundle container format. Family dependencies are declared in requirements.txt.

Change categories

  • Model or runtime behavior
  • Public API
  • ABI
  • Bundle or artifact format
  • Dependencies
  • Documentation only
  • CI or developer tooling

Validation

Commands and Results

The E2E test checks native tokenization against Hugging Face and requires exact generated token IDs and decoded text for both prompts. These describe tests added in the diff, not an execution result.

Reproduction after preparing the pinned checkpoint, family dependencies, and native runtime required by the test:

python3 -m pytest families/ernie4_5_moe/tests/test_support.py -q
python3 -m pytest families/ernie4_5_moe/tests/test_e2e.py --e2e-testcase ernie4.5-21b-thinking -q

These commands were not rerun for this description-only update. No build, inference, accuracy, performance, or full-premerge pass is asserted here; see the PR checks for public execution results.

Hardware, Environment, and Revisions

PR head: 95b704cf1e1f6ba3c009cb5682060c091b1d5c68. The committed recipe pins baidu/ERNIE-4.5-21B-A3B-Thinking at 4341bb42644d5422859509fa25d41544c57181f8. FP32, one sequence and one device; the committed recipe uses a 128-token KV profile and up to 16 generated tokens. Transformers is pinned by the family requirements. Execution requires a CUDA-capable GPU and TensorRT. A tested GPU/OS/CUDA/TensorRT matrix is not asserted by this description.

Not Run / Remaining Gaps

Sampling, quantization, reduced precision, dynamic KV cache, and distributed execution are outside this implementation. Broader architecture/regression checks, longer-context validation, and performance qualification remain required before a full readiness claim.

Contributor Self-Review

  • I have completed a self-review of this change.

Notes For Future Readers

Review routed-expert weight handling and KV-cache boundaries alongside the tokenizer and generation tests. The short continuation recipe does not establish reasoning benchmark quality or support for other ERNIE variants.

Public model reference: baidu/ERNIE-4.5-21B-A3B-Thinking.

Risk level

  • Low
  • Medium
  • High

This introduces a large MoE decoder, tokenizer, and incremental cache management with strict output-parity requirements.

Build ERNIE with interleaved rotary pairs, routing bias, shared experts and its tied output head. Stream the large fp32 plan directly into its bundle section and preserve fixed KV state through the native text continuation Task API.

Validate pinned checkpoint tokenization and exact generated token sequences for English code completion and Chinese text against the official fp32 reference on CUDA.

Signed-off-by: Will Guo <willg@nvidia.com>
Signed-off-by: Will Guo <willg@nvidia.com>
…runtime contracts

Signed-off-by: Will Guo <willg@nvidia.com>
@willg-nv willg-nv self-assigned this Nov 25, 2026
@willg-nv
willg-nv requested a review from yifeif-nv as a code owner November 25, 2026 08:15
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Explain Change →

Note

CodeRabbit ASCII loading animation

Currently processing new changes in this PR. This may take a few minutes, please wait...

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 46bad13 and 95b704c.

Files selected for processing: 13

  • families/ernie4_5_moe/__init__.py
  • families/ernie4_5_moe/model.py
  • families/ernie4_5_moe/requirements.txt
  • families/ernie4_5_moe/runtime/CMakeLists.txt
  • families/ernie4_5_moe/runtime/bpe_tokenizer.cpp
  • families/ernie4_5_moe/runtime/plugin.cpp
  • families/ernie4_5_moe/runtime/tokenizer.h
  • families/ernie4_5_moe/support.py
  • families/ernie4_5_moe/tests/__init__.py
  • families/ernie4_5_moe/tests/cpp/test_tokenizer.cpp
  • families/ernie4_5_moe/tests/manifests/ernie4.5-21b-thinking.json
  • families/ernie4_5_moe/tests/test_e2e.py
  • families/ernie4_5_moe/tests/test_support.py

@willg-nv willg-nv linked an issue Nov 25, 2026 that may be closed by this pull request
2 tasks done

This branch has not been deployed

No deployments
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.

Feature: support baidu/ERNIE-4.5-21B-A3B-Thinking

1 participant