[NVBUG-6379624][fix] Enable W4A8 checkpoint loading for Gemma4 K=V layers#16797
Conversation
Signed-off-by: Tianrui 'Hudayday' Hu <32944717+Hudayday@users.noreply.github.com>
WalkthroughChangesGemma4 weight preprocessing
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unittest/_torch/modeling/test_modeling_gemma4.py`:
- Around line 455-457: Update the idempotency check around
mapper.preprocess_weights so it snapshots result’s keys before the second pass,
then verifies second_result contains exactly that original key set while
retaining the existing identity assertions for values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0c51b53f-6f79-4110-85ce-eb60a36b33f9
📒 Files selected for processing (2)
tensorrt_llm/_torch/models/checkpoints/hf/gemma4_weight_mapper.pytests/unittest/_torch/modeling/test_modeling_gemma4.py
|
/bot run --disable-fail-fast |
|
PR_Github #61327 [ run ] triggered by Bot. Commit: |
|
PR_Github #61327 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #61454 [ run ] triggered by Bot. Commit: |
|
PR_Github #61454 [ run ] completed with state |
Description
Gemma4 full-attention layers may set
attention_k_eq_v=True. Hugging Face/ModelOpt checkpoints then omitv_projtensors and reusek_projfor V.The Gemma4 HF weight mapper previously synthesized only
v_proj.weight. For W4A8_AWQ checkpoints, the missing V quantization tensors left the fused QKVweight_scalewidth at 18432 while the target expected 20480, causing modelinitialization to fail.
This PR:
k_projprojection tensors tov_projfor full-attention K=V layers, including W4A8 quantization metadata.k_scale/k_biasmetadata tov_scale/v_bias.The change is limited to Gemma4 HF checkpoint preprocessing. It does not change public APIs or inference kernels.
Test Coverage
pytest -q tests/unittest/_torch/modeling/test_modeling_gemma4.py \ -k duplicate_full_attention_kv_projection_tensorsPassed for both text and multimodal checkpoint layouts.
Static checks:
ruff check
tensorrt_llm/_torch/models/checkpoints/hf/gemma4_weight_mapper.py
tests/unittest/_torch/modeling/test_modeling_gemma4.py
ruff format --check
tensorrt_llm/_torch/models/checkpoints/hf/gemma4_weight_mapper.py
tests/unittest/_torch/modeling/test_modeling_gemma4.py
B200 end-to-end validation:
Generic dense W4A8 control:
The B200 runs used calib_size=8 as a structural and functional smoke test; no accuracy claim is made.
Dev Engineer Review
layer_scalarandk_projkeys independently of dictionary order and optionallanguage_model.prefixes.attention_k_eq_v=True, missingv_projtensors are derived from K tensors, including W4A8k_scale/k_biasmetadata mapped to V equivalents.QA Engineer Review
TestGemma4HfWeightMapper.test_duplicate_full_attention_kv_projection_tensors.tests/integration/test_lists/changes are included, so test-list coverage is not explicitly registered.