Skip to content

Add NVIDIA Model Optimizer FP8 quantization recipe (single-GPU EC2) - #1156

Draft
mvinci12 wants to merge 1 commit into
awslabs:mainfrom
mvinci12:model-optimizer-fp8-recipe
Draft

Add NVIDIA Model Optimizer FP8 quantization recipe (single-GPU EC2)#1156
mvinci12 wants to merge 1 commit into
awslabs:mainfrom
mvinci12:model-optimizer-fp8-recipe

Conversation

@mvinci12

Copy link
Copy Markdown
Contributor

Purpose

Adds a new test case demonstrating NVIDIA Model Optimizer (ModelOpt) FP8 post-training quantization on a single GPU EC2 instance, served with vLLM. Unlike the distributed-training test cases, ModelOpt PTQ is a single-process, single-GPU workload, so the recipe provisions one instance with Terraform and connects via SSM Session Manager (no SSH).

Changes

  • New test case: 3.test_cases/pytorch/model-optimizer/
    • terraform/ — single g6e.xlarge (L40S) instance: SSM IAM role + instance profile, egress-only security group, GPU DLAMI resolved from SSM Parameter Store, gp3 root volume, IMDSv2 enforced. Connects via SSM Session Manager (no inbound SSH, no key pair).
    • src/ — pinned setup.sh (nvidia-modelopt==0.44.0), quantize_fp8.sh (FP8 PTQ via examples/llm_ptq/hf_ptq.py, weights-only, cnn_dailymail calibration), smoke_test_vllm.py, pinned requirements.txt.
    • README.md — EC2-vs-EKS rationale, format↔GPU-architecture matrix, full walkthrough, reference results, and known issues.

Test Plan

Environment:

  • AWS Service: EC2 (single instance, provisioned via the recipe's Terraform)
  • Instance type: g6e.xlarge (1× NVIDIA L40S, 48 GB, Ada)
  • Number of nodes: 1
  • Region: us-west-2

Test commands:

# Infra (verified apply -> SSM -> nvidia-smi -> destroy)
cd 3.test_cases/pytorch/model-optimizer/terraform
terraform init && terraform validate && terraform plan
terraform apply -auto-approve
aws ssm start-session --target <instance-id>     # then: nvidia-smi
terraform destroy -auto-approve

# Workload (verified on the L40S)
cd ../src
bash setup.sh
bash quantize_fp8.sh
python smoke_test_vllm.py --model ~/qwen2.5-7b-fp8

Test Results

  • terraform init/validate/plan/apply/destroy all succeeded against a real account; AMI resolved to ami-03ee6edb81d0951b9; SSM came online ~30 s after launch; nvidia-smi reported NVIDIA L40S, 46068 MiB, 595.71.05. terraform destroy removed all 5 resources with zero left billable.
  • ModelOpt 0.44.0 installed in ~90 s; FP8 PTQ of Qwen/Qwen2.5-7B-Instruct (weights-only, cnn_dailymail) calibrated + exported in ~45 s; peak GPU memory ~16.5 GB.
  • Checkpoint size: 15 GB BF16 → 8.2 GB FP8 (~1.8×).
  • vLLM 0.23.0 loaded the checkpoint (CutlassFP8ScaledMMLinearKernel) and produced coherent output:
    • What is the capital of France?The capital of France is Paris.

Documented known issue surfaced during testing: FP8 KV-cache produces garbled output on Ada (L40S) → recipe defaults to weights-only (--kv_cache_qformat none).

Directory Structure

3.test_cases/pytorch/model-optimizer/
├── README.md
├── terraform/
│   ├── versions.tf
│   ├── providers.tf
│   ├── variables.tf
│   ├── main.tf
│   ├── outputs.tf
│   └── README.md
└── src/
    ├── requirements.txt
    ├── setup.sh
    ├── quantize_fp8.sh
    └── smoke_test_vllm.py

Checklist

  • I have read the contributing guidelines.
  • I am working against the latest main branch.
  • I have searched existing open and recently merged PRs to confirm this is not a duplicate.
  • The contribution is self-contained with documentation and scripts.
  • External dependencies are pinned to a specific version or tag (no latest).
  • A README is included with prerequisites, instructions, and known issues.
  • New test cases follow the expected directory structure.

Draft: opening for early review. The EC2 path is live-tested; the EKS/HyperPod graduation path is documented but intentionally out of scope for this PR.

New test case at 3.test_cases/pytorch/model-optimizer/ demonstrating FP8
post-training quantization with NVIDIA Model Optimizer (ModelOpt) on a single
GPU EC2 instance, served with vLLM.

- terraform/: single g6e.xlarge (L40S) via SSM Session Manager (no SSH), DLAMI
  resolved from SSM Parameter Store, egress-only SG, IMDSv2, gp3 root volume
- src/: pinned setup (nvidia-modelopt==0.44.0), FP8 PTQ via examples/llm_ptq
  hf_ptq.py (weights-only, cnn_dailymail calibration), vLLM smoke test
- README: EC2-vs-EKS rationale, format-vs-GPU-arch matrix, walkthrough,
  reference results (15GB BF16 -> 8.2GB FP8), and known issues (FP8 KV-cache
  on Ada, repo/wheel version skew, gated default dataset)

Tested: Terraform apply/SSM/nvidia-smi/destroy verified on g6e.xlarge in
us-west-2; quantization + vLLM serving validated end-to-end (L40S).
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.

1 participant