-
Notifications
You must be signed in to change notification settings - Fork 422
Add Alpamayo-1 example #1594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rohansjoshi
wants to merge
3
commits into
main
Choose a base branch
from
rohjoshi/alpamayo-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Alpamayo-1 example #1594
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+3.86 KB
examples/alpamayo/0417_16rows_train_set_for_calibration_25.10.parquet
Binary file not shown.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Quantizing Alpamayo 1 | ||
|
|
||
| [Alpamayo 1](https://github.com/nvlabs/alpamayo) (formerly Alpamayo-R1) is a | ||
| ~10B vision-language-action model trained by NVIDIA for autonomous vehicle | ||
| research. It takes multi-camera video and egomotion history as input and | ||
| produces a Chain-of-Causation reasoning trace plus a future driving trajectory. | ||
| See the paper, [*Alpamayo-R1: Bridging Reasoning and Action Prediction for | ||
| Generalizable Autonomous Driving in the Long | ||
| Tail*](https://arxiv.org/abs/2511.00088), and the | ||
| [nvlabs/alpamayo](https://github.com/nvlabs/alpamayo) repository for details. | ||
|
|
||
| This example produces FP8, NVFP4, and mixed-precision quantized checkpoints of | ||
| Alpamayo using ModelOpt. Quantization calibration runs on a small dataset of 16 | ||
| AV clips (`0417_16rows_train_set_for_calibration_25.10.parquet`). | ||
|
|
||
| ## Setup | ||
|
|
||
| Clone Alpamayo and install it into the current environment so `alpamayo_r1` is | ||
| importable: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/nvlabs/alpamayo | ||
| pip install ./alpamayo | ||
| ``` | ||
|
|
||
| Follow the Alpamayo README to request access to the gated model weights and the | ||
| Physical AI AV dataset, then authenticate with `hf auth login`. | ||
|
|
||
| ## Usage | ||
|
|
||
| `quantize.py` loads an Alpamayo checkpoint, calibrates it on the 16 clips, and | ||
| exports an HF-style quantized checkpoint. | ||
|
|
||
| ### FP8 / NVFP4 | ||
|
|
||
| By default the script saves **fake-quantized** weights (fp16 weights plus | ||
| quantizer state) — useful for accuracy evaluation: | ||
|
|
||
| ```bash | ||
| python quantize.py --ckpt nvidia/Alpamayo-R1-10B --output-dir ./alpamayo-fp8 --quantize fp8 | ||
| ``` | ||
|
|
||
| Pass `--real-quant` to save **real-quantized** weights packed into the | ||
| low-precision storage format (NVFP4 = E2M1 nibbles + per-block FP8 scales), | ||
| which run on the hardware low-precision GEMM path: | ||
|
|
||
| ```bash | ||
| python quantize.py --ckpt nvidia/Alpamayo-R1-10B --output-dir ./alpamayo-nvfp4 --quantize nvfp4 --real-quant | ||
| ``` | ||
|
|
||
| The vision tower is always kept in high precision, and small action-projection | ||
| heads whose dimensions are not multiples of 16 are left unquantized (they break | ||
| the real-quant GEMM backends). | ||
|
|
||
| ### AutoQuantize (mixed precision) | ||
|
|
||
| `--quantize auto` runs ModelOpt's AutoQuantize, which searches per layer between | ||
| NVFP4 and FP8 under an effective-bits budget (`--auto_quantize_bits`, default | ||
| 6.5): | ||
|
|
||
| ```bash | ||
| python quantize.py --ckpt nvidia/Alpamayo-R1-10B --output-dir ./alpamayo-auto --quantize auto --auto_quantize_bits 6.5 | ||
| ``` | ||
|
|
||
| AutoQuantize chooses a per-layer format using a **gradient-based sensitivity | ||
| score**: it backpropagates a loss through the model and estimates how much each | ||
| candidate format perturbs that loss, then picks the cheapest assignment that | ||
| stays within the bit budget. Here the loss is the flow-matching objective — an | ||
| MSE between the action expert's predicted velocity field `v_pred` and the | ||
| target `v_target = x_1 - x_0` from a teacher-forced forward pass on the | ||
| calibration clips. Layers the loss is sensitive to keep more bits (FP8); the | ||
| rest go to NVFP4. | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setup says
git clone https://github.com/nvlabs/alpamayowithout pinning a commit. Given that this example monkey-patches an internal method ontoAlpamayoR1, please pin a known-good SHA so future upstream changes don't silently break calibration.