Repository navigation
Fea transformer hstu inference 456 - #491
Junyi-Zheng wants to merge 3 commits into
Conversation
Reuse recommendation preprocessing and paged KV interfaces, separate checkpoint handling, and wire inference/export entry points. Add numerical and export regression coverage; document pending CUDA and serving validation. Signed-off-by: Junyi Zheng <[email protected]>
Add public API docstrings and distinguish private layer metadata and capture buffers from the documented checkpoint and graph interfaces. Signed-off-by: Junyi Zheng <[email protected]>
[Medium impact] The changes since the previous review appear safe to merge. SummaryAdds an opt-in Transformer backbone while keeping HSTU as the default.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Ranking inputs] --> B[Shared preprocessing]
B --> C{Backbone selection}
C --> D[HSTU layers]
C --> E[Transformer layers]
F[Paged KV cache] <--> D
F <--> E
D --> G[Shared candidate extraction]
E --> G
G --> H[Prediction heads]
Reviews (2) · Last reviewed commit: "Fix Transformer graph metadata refresh a..." · Reviewed by Greptile |
|
hi @Junyi-Zheng thanks for your interests to recsys-examples! @geoffreyQiu could you help review this PR? thanks! |
| torch.testing.assert_close(layer._linear_proj_weight, proj) | ||
|
|
||
|
|
||
| def test_export_real_layer_dynamic_batch_and_tokens(tmp_path): |
There was a problem hiding this comment.
question: this fails for me in the repo's Docker image (torch 2.12.0a0 nv26.05). The exported layer rejects batch_size=1 at replay ("Guard failed: -1 + offsets.size()[0] >= 2"), so the ([2], [1]) case fails. The guard seems to come from tracing offsets[1:] - offsets[:-1] in _pad. The HSTU preprocessing exports and replays fine with batch_size=1, so this looks specific to the Transformer layer. Which torch version did you run this with?
There was a problem hiding this comment.
Thanks for the detailed review and GPU reproductions! I’ve pushed fixes in eb6ffe0:
- Changed the CUDA append test to head_dim=64.
- Added total_history_lengths to metadata copying and extended the graph test to replay with changed metadata against eager results.
- Corrected action lengths, KJT inputs, and expected indexing, and switched preprocessing tests to BF16.
- Fixed the batch-size-one export failure by avoiding the derived offset-dimension guard.
My original tests used PyTorch 2.5.1. I reproduced the export failure on 2.12.0; after the fix, both versions pass 135 tests. The 3 CUDA tests remain skipped locally, and the exact NVIDIA 26.05 image still needs verification.
I’d appreciate a recheck in your environment when you have time. Thanks again!
There was a problem hiding this comment.
Thanks for the quick fixes. I re-ran the validation command on eb6ffe0 on an RTX PRO 6000 (SM120) in the repo's 26.07 Docker image: 138 passed, and the three CUDA tests really ran on the GPU, so the four items from my first pass are resolved.
Refresh cached history lengths across graph replays and cover requests with changed metadata. Use the candidate batch dimension for offset gathers so PyTorch 2.12 exports accept a single user. Correct CUDA test head dimensions, action slots and dtype; document pending GPU validation. Signed-off-by: Junyi Zheng <[email protected]>
| position_encoding_config=position_encoding_config, | ||
| contextual_max_seqlen=num_contextual_features, | ||
| backbone=network_args.backbone, | ||
| transformer_ffn_dim=network_args.transformer_ffn_dim, |
There was a problem hiding this comment.
question: the exporters now pass hstu_preprocessing_config, but this call doesn't (nor the one in triton/hstu_model/model.py L213). With a config that enables the item/contextual preprocessing MLPs (e.g. training/configs/benchmark_ranking.gin), the exported model has those MLPs and this one doesn't, so the same checkpoint fails to load here. Could this call and the Triton model pass it too, built the same way as training/trainer/utils.py L85-91?
Brings in main up to 4466f9d (NVIDIA#478 exportable embedding collections, its CI follow-ups, DynamicEmb fixes). The one conflict is at the top of get_exportable_model_for_inference in inference_aoti/export_inference_gr_ranking.py, where NVIDIA#478 added the checkpoint_table_capacities lookup and NVIDIA#491 had added a docstring. It takes main's lines and drops the docstring: no other function of either AOTI exporter has one, and the Transformer branch's comment says the same. NVIDIA#478 also renamed the function's dynamic_table_configs parameter to embedding_collection_configs. The Transformer branch still passes the old name; the next commit adapts it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Runchu Zhao <[email protected]>
|
merged in #531 . Thanks! |
Description
Related to #456.
Add an opt-in Transformer backbone to the existing HSTU recommendation inference workflow, while keeping HSTU as the default.
Validation
git diff --checkpassed.Limitations
CUDA-only tests were skipped because the local environment has no NVIDIA GPU. Native cache transfers, CUDA graph execution, complete GPU export, and Triton serving still require validation.
This is a reference padded-SDPA backend; GPU memory and performance have not been benchmarked. It requires its documented Transformer checkpoint layout.
Checklist