You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AUTO_NF12 embedding fallback triggers CUDA device assert for out-of-range token IDs #3922
The test creates an eligible BF16 embedding with 32 rows and IDs [[-1, 0, 7], [15, 31, 32]]. Its oracle assigns zero rows for IDs outside [0, 32), matching the native NF12 embedding contract. The native availability probe is false and the cast selects canonical packed storage (row_major=False). The forward instead raises CUDA error: device-side assert triggered from indexSelectSmallIndex: Assertion srcIndex < srcSelectDimSize failed; the CUDA context is then poisoned. The separate fallback test passes because it uses only valid IDs.
Cause
AutoNF12Embedding.forward decodes the packed weight and calls torch.nn.functional.embedding(ids, dense) on its final fallback path without masking invalid IDs. The native CUDA/HIP NF12 embedding operator returns zeros for invalid indices (also stated in gptqmodel/utils/nf12_hip.py). Thus selecting the optional-extension fallback changes public behavior and can crash a generation run.
Expected
Preserve the native embedding contract in the dense fallback: valid IDs select exact decoded rows and invalid IDs produce zero rows, without an illegal CUDA gather. Add a fallback test containing negative and num_embeddings IDs on a runtime-only CUDA host. This is distinct from #3860, which addresses choosing an unavailable native row-major layout during construction.
Activity
fix(nf12): mask out-of-range IDs in the embedding fallback (ModelClou…