Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: bind H3 precision evidence to exact vision weights (#8948)

[._.]/ Adam Eivy98b9e2d529cf
diff --git a/docs/research/assets/minimax-h3-vision-precision/results.json b/docs/research/assets/minimax-h3-vision-precision/results.json
index 26a6f34f9a..2b11a461a2 100644
--- a/docs/research/assets/minimax-h3-vision-precision/results.json
+++ b/docs/research/assets/minimax-h3-vision-precision/results.json
@@ -19,7 +19,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -55,7 +56,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -91,7 +93,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -127,7 +130,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -164,7 +168,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "float32",
"mlx_enable_tf32": "1",
@@ -200,7 +205,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "float32",
"mlx_enable_tf32": "1",
@@ -236,7 +242,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -273,7 +280,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -309,7 +317,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -346,7 +355,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "0",
@@ -382,7 +392,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -416,7 +427,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -452,7 +464,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -488,7 +501,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -524,7 +538,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -561,7 +576,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "float32",
"mlx_enable_tf32": "1",
@@ -597,7 +613,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "float32",
"mlx_enable_tf32": "1",
@@ -633,7 +650,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -670,7 +688,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -706,7 +725,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -743,7 +763,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "0",
@@ -779,7 +800,8 @@
[1, 64, 36]
],
"versions": {"torch": "2.12.0", "torchvision": "0.27.0", "mlx": "0.32.0", "mlx-metal": "0.32.0", "mlx-vlm": "0.6.10", "transformers": "5.14.1"},
- "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d"
+ "vision_config_sha256": "82b48aeeea2f41d0cdb61ca43d92ce2829d8876470859f53a4ef8f941dfa252d",
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0"
},
"normalization": "native",
"mlx_enable_tf32": "default",
@@ -820,5 +842,7 @@
"reference": "gradient-torch-float32-cpu-native-native",
"outputs": {"deepstack_0": 0.019055985581729926, "deepstack_1": 0.03791796903332008, "deepstack_2": 0.05180164591959443, "merged": 0.07595725797523957}
}
- ]
+ ],
+ "vision_weights_sha256": "aa0fbed9e9cc450f914df5069ab26dfb160ff0fbaa0cc09b857ad39e596608f0",
+ "final_recheck": "All 26 configurations rerun with weight hashing; all 22 comparison-case output archives bit-identical to the earlier matrix."
}
diff --git a/docs/research/minimax-h3-vision-precision.md b/docs/research/minimax-h3-vision-precision.md
index aa6d7a4209..8a7d902513 100644
--- a/docs/research/minimax-h3-vision-precision.md
+++ b/docs/research/minimax-h3-vision-precision.md
@@ -28,7 +28,7 @@ latter has no random-library seed dependency. Both yield grid [1,64,36],
2,304 patch rows, and 576 merged rows. No private image was used.
[results.json](assets/minimax-h3-vision-precision/results.json) stores input
-hashes, configuration hash, package versions, final/deepstack metrics, selected
+hashes, configuration and vision-weight hashes, package versions, final/deepstack metrics, selected
intermediates, and all 27 block-output relative differences for native runs.
Numbers in JSON are ratios; tables below are percentages. The metric is
norm(actual-reference)/norm(reference), accumulated in NumPy float64, with
@@ -131,9 +131,11 @@ explains or repairs the accumulated bfloat16 difference.
Keep production behavior unchanged. The observations separate reference
operation rounding (interpolation), framework kernel arithmetic
(normalization and matmul), and input-dependent propagation through the tower.
-They do not demonstrate a PortOS adapter defect or a consistently beneficial
-precision correction. Adopting one of the controls solely because one fixture
-gets closer would trade one unvalidated behavior for another.
+They do not demonstrate a PortOS adapter defect, reference equivalence, or a
+visible benefit from changing production precision. The combined interpolation
+and normalization control gets modestly closer on both fixtures, but still
+leaves 12.71% and 6.75% differences. That numerical improvement alone does not
+justify an unvalidated production change.
This investigation completes the layer-level characterization requested in
#8948; it does not certify every image, precision, backend or future version.
@@ -170,7 +172,7 @@ CHECKPOINT=<cached-FL2VA>
~~~
Repeat with --fixture gradient-noise in place of --source, using new paths.
-The replay trace must have the same processed pixels and dtype. For the
+The replay trace must have the same processed pixels, grid, configuration, vision weights and dtype. For the
bfloat16 operation matrix, add --position float32, --attention eager,
--normalization float32, or the combinations in the table, only on MLX.
These flags exist solely in this diagnostic and never affect production.
diff --git a/scripts/compare_minimax_h3_vision.py b/scripts/compare_minimax_h3_vision.py
index a02978deab..51b15ebdba 100644
--- a/scripts/compare_minimax_h3_vision.py
+++ b/scripts/compare_minimax_h3_vision.py
@@ -8,7 +8,7 @@ from pathlib import Path
def compare(actual, reference):
import numpy as np
manifests = [json.loads((p / 'manifest.json').read_text()) for p in (actual, reference)]
- for key in ('pixel_sha256', 'grid_thw', 'vision_config_sha256'):
+ for key in ('pixel_sha256', 'grid_thw', 'vision_config_sha256', 'vision_weights_sha256'):
if manifests[0][key] != manifests[1][key]:
raise ValueError(f'Cannot compare different inputs: {key}')
for manifest in manifests:
diff --git a/scripts/diagnose_minimax_h3_vision.py b/scripts/diagnose_minimax_h3_vision.py
index e7367f9257..51bb1cfd0f 100644
--- a/scripts/diagnose_minimax_h3_vision.py
+++ b/scripts/diagnose_minimax_h3_vision.py
@@ -27,6 +27,30 @@ def gradient_noise_source():
return Image.fromarray(pixels.astype(np.uint8))
+
+def read_vision_weights(root, keys, digests):
+ """Hash original tensor bytes, independent of shard names and compute dtype."""
+ import torch
+ from safetensors import safe_open
+ for shard in sorted(set(keys.values())):
+ with safe_open(root / 'text_encoder' / shard, framework='pt', device='cpu') as f:
+ for key in sorted(k for k, value in keys.items() if value == shard):
+ tensor = f.get_tensor(key)
+ name = key.removeprefix('model.visual.')
+ digests[name] = {
+ 'dtype': str(tensor.dtype), 'shape': list(tensor.shape),
+ 'sha256': hashlib.sha256(tensor.contiguous().view(torch.uint8).numpy().tobytes()).hexdigest(),
+ }
+ yield name, tensor
+
+
+def weights_digest(digests, reference):
+ digest = hashlib.sha256(json.dumps(digests, sort_keys=True).encode()).hexdigest()
+ if reference is not None and reference['vision_weights_sha256'] != digest:
+ raise ValueError('Replay requires identical vision checkpoint weights')
+ return digest
+
+
def install_trace(model, backend, directory, replay=None):
"""Observe real calls; stream arrays to disk instead of retaining a full tower."""
import numpy as np
@@ -177,7 +201,6 @@ def main():
os.environ['TRANSFORMERS_OFFLINE'] = '1'
import numpy as np
from PIL import Image
- from safetensors import safe_open
root = a.checkpoint_dir
raw = json.loads((root / 'text_encoder/config.json').read_text())['vision_config']
index = json.loads((root / 'text_encoder/model.safetensors.index.json').read_text())['weight_map']
@@ -189,6 +212,7 @@ def main():
inputs = processor(images=[source], return_tensors='np')
pixel_sha256 = hashlib.sha256(inputs['pixel_values'].tobytes()).hexdigest()
config_sha256 = hashlib.sha256(json.dumps(raw, sort_keys=True).encode()).hexdigest()
+ reference = None
if a.replay_dir:
reference = json.loads((a.replay_dir / 'manifest.json').read_text())
if (reference['pixel_sha256'] != pixel_sha256 or reference['dtype'] != a.dtype
@@ -197,6 +221,7 @@ def main():
raise ValueError('Replay requires identical processed pixels, grid, configuration and dtype')
started = time.perf_counter()
records = []
+ digests = {}
if a.backend == 'torch':
import torch
from transformers.models.qwen3_vl.configuration_qwen3_vl import Qwen3VLVisionConfig
@@ -206,12 +231,9 @@ def main():
cfg._attn_implementation = 'eager'
with torch.device('meta'):
model = Qwen3VLVisionModel(cfg)
- weights = {}
- for shard in sorted(set(keys.values())):
- with safe_open(root / 'text_encoder' / shard, framework='pt', device='cpu') as f:
- for k, v in keys.items():
- if v == shard:
- weights[k.removeprefix('model.visual.')] = f.get_tensor(k).to(getattr(torch, a.dtype))
+ weights = {name: tensor.to(getattr(torch, a.dtype))
+ for name, tensor in read_vision_weights(root, keys, digests)}
+ vision_weights_sha256 = weights_digest(digests, reference)
model.load_state_dict(weights, strict=True, assign=True)
model.eval()
from transformers.models.qwen3_vl.modeling_qwen3_vl import Qwen3VLVisionRotaryEmbedding
@@ -242,12 +264,9 @@ def main():
from mlx_vlm.models.qwen3_vl.vision import VisionModel
from generate_minimax_h3 import sanitize_vision_weights
model = VisionModel(VisionConfig.from_dict(raw))
- weights = {}
- for shard in sorted(set(keys.values())):
- with safe_open(root / 'text_encoder' / shard, framework='pt', device='cpu') as f:
- for k, v in keys.items():
- if v == shard:
- weights[k.removeprefix('model.visual.')] = mx.array(f.get_tensor(k).float().numpy()).astype(getattr(mx, a.dtype))
+ weights = {name: mx.array(tensor.float().numpy()).astype(getattr(mx, a.dtype))
+ for name, tensor in read_vision_weights(root, keys, digests)}
+ vision_weights_sha256 = weights_digest(digests, reference)
expected = {key for key, _ in tree_flatten(model.parameters())}
if expected != set(weights):
raise ValueError('Vision checkpoint keys do not match the MLX model')
@@ -277,6 +296,7 @@ def main():
'replay': bool(a.replay_dir),
'grid_thw': inputs['image_grid_thw'].tolist(), 'stages': records,
'vision_config_sha256': config_sha256,
+ 'vision_weights_sha256': vision_weights_sha256,
'versions': {name: importlib.metadata.version(name) for name in
('torch', 'torchvision', 'mlx', 'mlx-metal', 'mlx-vlm', 'transformers')},
}
diff --git a/scripts/diagnose_minimax_h3_vision.test.js b/scripts/diagnose_minimax_h3_vision.test.js
index 258f61cbb9..85e226a3b0 100644
--- a/scripts/diagnose_minimax_h3_vision.test.js
+++ b/scripts/diagnose_minimax_h3_vision.test.js
@@ -39,6 +39,7 @@ with tempfile.TemporaryDirectory() as root:
root = Path(root)
actual, reference = root / 'a', root / 'b'
manifest = {'pixel_sha256': 'synthetic-pixels', 'grid_thw': [[1, 2, 2]], 'vision_config_sha256': 'synthetic-config',
+ 'vision_weights_sha256': 'synthetic-weights',
'stages': [{'name': 'merged'}]}
for directory, values in [(actual, [6., 8.]), (reference, [3., 4.])]:
directory.mkdir()
@@ -60,6 +61,12 @@ with tempfile.TemporaryDirectory() as root:
np.save(reference / 'merged.npy', [float('nan'), 4.])
assert run(root / 'invalid.json').returncode != 0
assert not (root / 'invalid.json').exists()
+ np.save(reference / 'merged.npy', [3., 4.])
+ manifest['vision_weights_sha256'] = 'different-weights'
+ (reference / 'manifest.json').write_text(json.dumps(manifest))
+ assert run(root / 'weights-mismatch.json').returncode != 0
+ assert not (root / 'weights-mismatch.json').exists()
+ manifest['vision_weights_sha256'] = 'synthetic-weights'
manifest['pixel_sha256'] = 'different-pixels'
(reference / 'manifest.json').write_text(json.dumps(manifest))
assert run(root / 'mismatch.json').returncode != 0