[ONNX] Add Chronos-2 covariate export validation#508
Open
Jameswlepage wants to merge 4 commits into
Open
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This builds on and supersedes the initial Chronos-2 ONNX export work in #359.
It updates the Chronos-2 ONNX export path so users can export a real Chronos-2 model with future covariates, repair the exported ONNX graph, and validate ONNX Runtime output against PyTorch.
Changes
amazon/chronos-2by default with future covariates enabled.dynamo=Falsefor compatibility with current PyTorch defaults.fix_onnx_model.pyso it fixes Gather index dtype issues without incorrectly advertising a dynamic horizon.ONNX Contract
The default export has:
context:float32[batch_size, 512]group_ids:int64[batch_size]attention_mask:float32[batch_size, 512]future_covariates:float32[batch_size, 64]num_output_patches:int64[]when exposed by the exporterquantile_preds:float32[batch_size, 21, 64]Batch size is dynamic. Context length, future covariate length, and prediction length are fixed by the traced export.
Validation
Local checks run:
python -m py_compile scripts/onnx/export_chronos2_to_onnx.py scripts/onnx/fix_onnx_model.py scripts/onnx/quantize_chronos2.py scripts/onnx/validate_chronos2_onnx.py src/chronos/chronos_bolt.pypython scripts/onnx/export_chronos2_to_onnx.py --model_id test/dummy-chronos2-model --output_dir ... --device cpu --validatepython scripts/onnx/validate_chronos2_onnx.py --model_id test/dummy-chronos2-model --onnx_path .../model.onnx --context_length 512 --num_output_patches 4python scripts/onnx/quantize_chronos2.py --input .../model.onnx --output .../model_quantized.onnx --mode dynamic --validateA real
amazon/chronos-2ONNX covariate export and parity reports are published here:https://huggingface.co/TSFM-ai/chronos-2-onnx
The real export parity report covers batch sizes 1 through 5, shared and distinct
group_ids, several future-covariate patterns, missing context values, and missing future-covariate values.