DFlash2 Speculative Decoding
Alpamayo 2 Super NIM includes opt-in DFlash2 profiles that reduce the text generation portion of trajectory latency. Qualify the other tasks you serve separately: grounding can be slower than on the matching baseline profile (see Qualification). DFlash2 proposes seven draft tokens in parallel, and the full Alpamayo model verifies every proposal before it is accepted. Image preparation, multimodal prefill, and action diffusion still run normally, so end-to-end improvement depends on the reasoning length and draft acceptance rate.
DFlash2 profiles are opt-in and load a draft head in addition to the base
model, so they use more GPU memory than the matching baseline profile.
fp8-dflash2 fits within the same 80 GB minimum as fp8; allow headroom
for larger K. bf16-dflash2 needs a larger GPU (see
Support Matrix).
The action expert uses the same verified terminal position as the matching
baseline profile.
Prepare This Shell
Run the commands in Bash. The block below defines IMG_NAME,
LOCAL_NIM_CACHE, NIM_CONTAINER (alpamayo2-super-dflash2),
NIM_URL, GRPC_TARGET and ALPAMAYO_OUT; ALPAMAYO_OUT keeps a
value already set by another page. Online launches also need
NGC_API_KEY from Quickstart Guide. The custom-head steps add
DFLASH2_HEAD. In a new shell, re-run the block below and, for a custom
head, the DFLASH2_HEAD export.
This page covers Alpamayo 2 Super. In a new shell, define the image, cache, container name, client target and an output directory:
For a release candidate, use the exact image supplied for that review.
Export NGC_API_KEY using Quickstart Guide before an online launch.
Reuse the same cache for subsequent launches. Stop any earlier container using
that GPU before starting another profile.
Profiles
Select bf16-dflash2 or fp8-dflash2. Both use the packaged draft head
and summary metrics. Memory requirements and recommended K ranges are listed
in the Support Matrix.
Run with DFlash2
Select the profile by name with NIM_MODEL_PROFILE. The following example
uses FP8 DFlash2 on a supported H100 or H200 GPU with at least 80 GB of memory:
Stop any Alpamayo 2 Super container from the other guides first, because they use the same GPU and host ports. The loop skips names that do not exist and removes a container only after it stops:
Each container uses exactly one GPU. Replace 0 in --gpus device=0 with
the index of the GPU allocated to you; do not use --gpus all.
Use bf16-dflash2 instead only on a supported GPU with at least 120 GB of
memory. Setting NIM_PRECISION=bf16 or NIM_PRECISION=fp8 selects the
corresponding baseline profile; it does not enable DFlash2. The command
intentionally omits NIM_PRECISION: setting both NIM_PRECISION and
NIM_MODEL_PROFILE stops startup.
The launch command activates K=1, K=2, and K=3. To use other counts, list them
in NIM_ALPAMAYO_TRAJ_SAMPLES. See Support Matrix for the
recommended range on your GPU. Each configured value adds startup warmup work.
When following the quickstart request examples, replace
alpamayo2-super in each docker exec or docker cp command with
alpamayo2-super-dflash2.
Wait for Readiness
The DFlash2 profile loads its draft head and warms every configured K before it reports ready, so allow several minutes on the first start. Poll readiness, stop if the container exits, and then confirm the profile and the active K values:
Expected output after the readiness body:
Send a K=2 Request
num_traj_samples must appear in k_values, and values above 1 require a
positive temperature. The builder’s default temperature is 0.6. Build and send a K=2
trajectory request from the bundled scene, then summarize the response:
Expected output:
Each of the two samples has 64 points in pred_trajectories and
pred_rotations and its own entry in metrics.reasoning_texts; the
speculative-decoding counters sum both samples. The first request for a given
K can be slower than later ones; send it once untimed before measuring. The
gRPC client takes the same count:
Observe Acceptance
DFlash2 profiles default NIM_ALPAMAYO_SPEC_METRICS to summary. With
summary or detailed, every trajectory result includes a
metrics.speculative_decoding object: in the /v1/infer response for
task: trajectory and in the raw_json payload of a gRPC Predict
response. VQA, meta-action, auto-labeling, and grounding results do not carry
the block, and the baseline bf16 and fp8 profiles never emit it.
For K greater than one, counters and histogram bins sum all returned samples;
rates are calculated from those totals. Detailed per-step arrays concatenate
the steps in sample order rather than averaging per-sample rates.
metrics.speculative_decoding fields
The HTTP process also exports the request totals from GET /v1/metrics as
Prometheus counters labeled with method="dflash2". The counters accumulate
across HTTP and gRPC trajectory requests:
alpamayo_spec_decode_draft_tokens_total;alpamayo_spec_decode_accepted_tokens_total; andalpamayo_spec_decode_verify_steps_total.
With NIM_ALPAMAYO_SPEC_METRICS set to summary (the default) or
detailed, they are exported at zero with method="dflash2" right after
startup and increase with each trajectory request:
Expected output (values abridged):
For acceptance rate over time, use
rate(alpamayo_spec_decode_accepted_tokens_total[5m]) / rate(alpamayo_spec_decode_draft_tokens_total[5m]). Mean acceptance length is
one plus accepted tokens per verification step. Higher acceptance produces
more reasoning tokens per step; compare end-to-end latency with the matching
baseline to measure the benefit.
Set NIM_ALPAMAYO_SPEC_METRICS=detailed for per-step diagnostics or none
to disable both the response block and the counters. Detailed metrics add
response data and are intended for diagnosis, not normal production traffic.
Qualification
Compare the DFlash2 profile with its matching baseline on representative requests; use the baseline if DFlash2 does not improve end-to-end latency for your workload.
DFlash2 targets trajectory reasoning and does not speed up every task. Grounding can be slower on a DFlash2 profile than on the matching baseline profile, and grounding requests do not update the speculative-decoding counters. Qualify every task you serve, not only trajectory. For grounding-heavy or mixed deployments, consider the baseline profile.
Bring Your Own DFlash2 Head
This is an advanced workflow for users experienced in training and exporting DFlash2 heads. Use a custom head only if you can verify its compatibility with the exact Alpamayo base checkpoint and evaluate its output quality. Otherwise, use the packaged head. Passing startup checks does not establish model quality.
The NIM does not train or download custom heads. The exported directory needs:
config.jsonwith architectureDFlash2DraftModelanddflash_config.projector_type="dflash2";- the exported safetensors weights, including the DFlash2 candidate selector;
alpamayo_dflash_metadata.jsonfrom the Alpamayo export, with a non-emptybase_model_config_sha256that records the base configuration the head was trained for. This file is required; a head without it, or without that hash, is rejected. Do not invent or edit compatibility hashes.
The block size must equal the speculative-token count plus one (eight for packaged profiles). Preserve training/export provenance and compare output quality with the matching baseline on representative scenes.
To start from the packaged head, for example to check the layout before substituting your own weights, copy it to a host directory. From the cache of a DFlash2 start, locate the head’s snapshot directory by its metadata file and copy it, dereferencing links. The repository and snapshot names in the cache path follow the packaged model artifact and change between releases, so find the directory rather than typing it:
Or from a running DFlash2 container:
Set DFLASH2_HEAD to an existing host directory that contains the head
files before launching. If the host path does not exist, Docker silently
creates an empty, root-owned directory and startup rejects the empty head.
Stop and remove the packaged-head container before running a custom head; both launches use the same name and host ports. Then mount the head read-only and override the speculative-model path while selecting a DFlash2 profile:
At startup, the NIM verifies the DFlash2 architecture, token block size, tensor
shapes, and the base-configuration hash in alpamayo_dflash_metadata.json.
Incompatible or incomplete heads are rejected before the service becomes
ready, with an error that names NIM_ALPAMAYO_SPECULATIVE_MODEL and the
mounted path. Before any download, the NIM also compares each safetensors file
of the head with its header. A truncated or damaged head stops startup with
NIM_ALPAMAYO_SPECULATIVE_MODEL=... has a truncated shard model.safetensors: expected X bytes, found Y; copy the complete exported head directory again.
A custom head cannot be combined with NIM_FT_CHECKPOINT; that combination
stops startup with one cannot be combined with NIM_FT_CHECKPOINT line.
Setting NIM_ALPAMAYO_SPECULATIVE_MODEL with a baseline
profile fails at startup; select NIM_MODEL_PROFILE=bf16-dflash2 or
fp8-dflash2 (and unset NIM_PRECISION). GET /v1/models reports the container path of the active draft head as
speculative_model: the custom head’s mount path here, or
/opt/nim/workspace/dflash2 for the packaged head. It is null when
speculative decoding is off. The relaunch keeps the 1,2,3 K list of the
packaged-head launch, so the K=2 example above also runs against the custom
head; a launch without NIM_ALPAMAYO_TRAJ_SAMPLES accepts only K=1. Run the
quickstart requests with alpamayo2-super-dflash2 as the container name and
compare latency and outputs with the matching baseline profile before
deployment.
Runtime Discovery and Determinism
Use GET /v1/models and read data[0].k_values for the active sample
counts. temperature=0 requires num_traj_samples=1. For multiple
trajectories, choose a positive temperature and an explicit seed. Increasing
K or switching profiles requires a compatible GPU and a restart.