Repository navigation
Description
What
Decision Transformer (decision_transformer, offline-RL sequence models) is not quantizable today. This issue records what blocks it, what already works in our favor, and a plan that keeps the blast radius inside a new definition plus one opt-in calibration path.
Evidence: today's failure
A tiny DecisionTransformerModel checkpoint (config.json + model.safetensors, no tokenizer) fails before model selection:
GPTQModel.load(ckpt, quantize_config=QuantizeConfig(bits=4, group_size=32))
ValueError: Couldn't instantiate the backend tokenizer from one of:
(1) a `tokenizers` library serialization file, ...
Passing tokenizer=None does not change it. Decision-Transformer checkpoints never ship a tokenizer, so the text path cannot start.
Three things need to change
1. The registry has no definition
SUPPORTED_MODELS has 206 entries and no decision_transformer:
>>> [m for m in SUPPORTED_MODELS if "decision" in m]
[](openvla is present, so robot VLA policies that sit on a Llama decoder are already covered; this issue is about the tensor-input sequence models.)
2. Calibration rejects tensor-only samples
gptqmodel/utils/calibration.py:641:
raise ValueError(
f"Quantize: unsupported calibration example structure at index {idx}: keys={list(example.keys())}"
)Observed with a real sample:
ValueError: Quantize: unsupported calibration example structure at index 0:
keys=['states', 'actions', 'returns_to_go', 'timesteps']
The accepted columns are _CALIBRATION_COLUMNS = ("input_ids", "attention_mask", "text", "messages").
3. The model forward needs named tensors, not input_ids
DecisionTransformerModel.forward(states, actions, rewards, returns_to_go, timesteps, attention_mask, ...).
What already works in our favor
- The forward already passes arbitrary kwargs through.
stage_inputs_capturecallsgptq_model.run_input_capture(example, ...), and that isself.model(**example, use_cache=use_cache). A batch of named tensors would reach the model unchanged. - Conv1D quantization exists. DT's blocks are GPT-2 blocks (
DecisionTransformerGPT2Block→ln_1,attn.c_attn64x192,attn.c_proj64x64,ln_2,mlp.c_fc,mlp.c_proj), the same shape asgpt2/codegen, which we already support.SUPPORTS_MODULE_TYPESincludesConv1D. - The module tree is mechanical.
definitions/gpt2.pymaps directly, only the root changes (transformer→encoder):
module_tree = [
"encoder", "h", "#",
{"ln_1": ("ln_1:!:norm",), "attn": ("c_attn:0", "c_proj:1"),
"ln_2": ("ln_2:!:norm",), "mlp": ("c_fc:0", "c_proj:1")},
]- The non-block layers are tiny and probably should not be quantized:
embed_return(64x1),embed_state(64x8),embed_action(64x3),predict_state(8x64),predict_action.0(3x64),predict_return(1x64). Only the GPT-2 blocks carry real weight mass.
Proposed plan
- Tokenizer-optional load (~20 lines): a definition flag (mirroring
require_load_processor) that skips tokenizer instantiation andprepare_datasettokenization for tensor-calibrated models. definitions/decision_transformer.py(~80 lines): tree above, nolm_head, heads left in native dtype,modalityset to whatever the loader expects for tensor-only models.- Opt-in raw-tensor calibration (~40 lines): a definition flag (suggested
calibration_inputs = "tensor_kwargs"), and incalibration.pya branch that acceptsMapping[str, Tensor]when the flag is set, bypassing_tokenize_*and packing. Everything else (batching,move_input_capture_example, capture) already handles tensors. - Tests (~150 lines, CPU): tiny DT (2 layers, hidden 64), quantize 4-bit, compare
action_predsagainst the float reference with a tolerance, assert the six heads stayed native, and assert a text sample still takes the old path for regular models.
Risks and questions
- Blast radius. Step 3 touches the calibration core that every model uses. Gating it on a definition flag keeps other paths byte-identical, but it is the part that needs review.
- Should the heads be quantized? They are 1-8 wide; quantizing
embed_state(64x8) to 4-bit with group_size 32 is degenerate. Proposal: leave them native and document it, matching how OpenVLA keeps the vision stack native. - Naming.
calibration_inputs = "token_ids" | "tensor_kwargs"or a richercalibration_builderhook - the hook generalizes better (e.g. π0/GR00T later) but is more API.
Why this is worth it
Offline-RL and robot-policy checkpoints are the main non-text decoder family we cannot touch today. The decoder itself is a plain GPT-2 stack we already quantize; only the tokenizer assumption and the calibration whitelist stand in the way.
Activity
Qubitium commentedon Nov 17, 2026
@Lumea-art I have not looked at decision transformer. Will do so and get back to you.
Qubitium commentedon Nov 17, 2026
Agent claim:
agent-root-4755is working on this issue now.Qubitium commentedon Nov 17, 2026
Agent release:
agent-root-4755completed this issue in #4894 (squash-merged tomainas 76fd2c7).What shipped:
DecisionTransformerQModelwith the GPT-2 decoder tree underencoder; the 1-8 wideembed_*/predict_*heads stay native and are declared base modules.require_load_tokenizer = Falseskips tokenizer loading in bothfrom_pretrainedandfrom_quantized(and tolerates models without the embedding accessors on reload).calibration_inputs = "tensor_kwargs"validates non-emptyMapping[str, Tensor]rows, one row per batch, and fails closed on non-tensors, 0-D tensors,concat_size, or an empty dataset. Token/text models keep the old path.docs/decision-transformer-calibration.md.Tests: the new
tests/test_decision_transformer_4755.pyis 4 failed, 1 passed onorigin/mainand 5 passed here; the real-modeltests/module_tree/test_decision_transformer_model_tree.pyadds 6 passing nodes. Calibration (170), module-tree registry (538 passed, 15 skipped, 3 xfailed), ordering/tags (95), explicit-plan/auto-detect (26), loader (11), and the fusion registry contract all pass.AWQ remains explicitly unverified for this definition; only the GPTQ path is claimed.
feat(decision-transformer): tokenizer-optional load and tensor calibr…