Skip to content

F-ROSETTA-CONVERT-001: SafeTensors conversion fails with NaN in tensor blk.0.attn_k.weight #190

@noahgift

Description

@noahgift

Summary

apr rosetta convert fails when converting GGUF to SafeTensors format due to NaN values detected in tensor data during conversion.

Reproduction

apr rosetta convert \
  ~/.cache/pacha/models/e910cab26ae116eb.gguf \
  /tmp/test.safetensors

Error Output

=== Rosetta Stone Conversion ===

Source: /home/noah/.cache/apr-models/qwen2-5-coder-0-5b-instruct/gguf/model.gguf
Target: /home/noah/.cache/apr-models/qwen2-5-coder-0-5b-instruct/safetensors/model.safetensors

--- Source Inspection ---
  Format: GGUF
  File Size: 491400064 bytes
  Tensors: 291
  Parameters: 630167424
  Architecture: qwen2
  Quantization: 0

Converting...
[GH-185] Embedding 151387 BPE merge rules into APR metadata
error: Validation failed: Conversion failed: Invalid model format: PMAT-187: 
Tensor 'blk.0.attn_k.weight' contains 108 NaN values (data corruption detected). 
Toyota Way: Stop the line - do not pass defects downstream.

Analysis

The NaN values appear during conversion, suggesting one of:

  1. Dequantization bug - Q4_K_M or other quantized format produces NaN during float conversion
  2. Source corruption - Original GGUF has bad data (unlikely - GGUF→APR works)
  3. SafeTensors path bug - Something specific to the SafeTensors writer path

Note: GGUF→APR conversion succeeds for the same source file, which suggests the bug is specific to the SafeTensors conversion path.

Impact

Environment

apr 0.2.12
Model: Qwen/Qwen2.5-Coder-0.5B-Instruct (from pacha cache)
Source: GGUF (491MB, 291 tensors, qwen2 arch)

Expected Behavior

If source GGUF is valid (which it appears to be since APR conversion works), SafeTensors conversion should also succeed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions