DmitryDB commited on
Commit
b9f4ef9
·
verified ·
1 Parent(s): ba5016f

Add model card, ComfyUI patch, validation reports, and tools

Browse files
.gitattributes CHANGED
@@ -1,35 +1 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.safetensors filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
FL2VA/SHA256SUMS ADDED
@@ -0,0 +1 @@
 
 
1
+ c57e85fc299ca399a5c84e7888b0f61c532da05ddbf3f92e521690b07cb72b0a minimax-h3-fl2va-int8-lean-convrot-dynamic-k16-quality21.safetensors
LICENSE ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MiniMax H3 COMMUNITY LICENSE AGREEMENT
2
+ MiniMax H3 release date/License date: August 2, 2026.
3
+ The scope of this License Agreement (this “Agreement”) is expressly limited to the “Applicable Territory” as defined below.
4
+ By clicking to accept, or by using, reproducing, modifying, distributing, running, or displaying any portion or element of the MiniMax H3 Works (including through any Hosted Services) in any manner, you acknowledge and accept the terms of this Agreement, and this Agreement shall take immediate effect upon the occurrence of such act.
5
+ I. Definitions
6
+ 1. “Acceptable Use Policy” means the policy published by MiniMax in Exhibit A.
7
+ 2. “Agreement” means the terms and conditions set forth herein that govern the use, reproduction, distribution, modification, running, and display of the MiniMax H3 Works or any portion or element thereof.
8
+ 3. “Applicable Territory” means worldwide, excluding the Excluded Territories.
9
+ 4. “Documentation” means the specifications, manuals, and documentation concerning MiniMax H3 that are publicly released by MiniMax.
10
+ 5. “Excluded Territories” means the European Union, the United Kingdom, the Republic of Korea and the United States of America.
11
+ 6. “MiniMax H3” means the video generation model, together with its software and algorithms, including trained model weights, parameters (including optimizer states), machine-learning model code, inference-supporting code, and other elements thereof made publicly available by Us, as released at https://huggingface.co/MiniMaxAI/MiniMax-H3.
12
+ 7. “MiniMax H3 Works” means (i) the Materials, (ii) the Model Derivatives, and (iii) all derivatives thereof.
13
+ 8. “Hosted Services” means hosted services provided via application programming interfaces (APIs), web access, or any other electronic or remote means.
14
+ 9. “Licensee,” “you,” or “your” means the natural or legal person exercising rights and/or using the MiniMax H3 Works for any purpose in any field of use under this Agreement.
15
+ 10. “Materials” means, collectively, MiniMax H3 and the Documentation (and any portion thereof), in each case as made available by MiniMax under this Agreement and proprietary to MiniMax.
16
+ 11. “Model Derivatives” means all of the following: (i) any modification of MiniMax H3 or any Model Derivative thereof; (ii) any work based on MiniMax H3 or any Model Derivative thereof; or (iii) any other machine learning model created by transferring the patterns of the weights, parameters, operational patterns, or Outputs of MiniMax H3 or any Model Derivative thereof to another model, such that the latter model exhibits behavior similar to MiniMax H3 or its Model Derivatives, including by distillation methods, methods using intermediate data representations, or methods based on training using synthetic-data Outputs generated by MiniMax H3 or its Model Derivatives. For the avoidance of doubt, Outputs are not deemed Model Derivatives.
17
+ 12. “Output” means any result of operating or otherwise using MiniMax H3 or any Model Derivatives (including through Hosted Services).
18
+ 13. “Third Party” means any natural or legal person that is not under common control with us or with you.
19
+ 14. “Including” means “including but not limited to.”
20
+ 15. “We,” “Us” or “MiniMax” means Nanonoble Pte. Ltd..
21
+ II. Grant of Rights
22
+ Solely within the Applicable Territory, we grant you a non-exclusive, non-transferable, royalty-free, limited license to use, reproduce, distribute, create derivative works (including Model Derivatives), and modify the Materials in accordance with the terms of this Agreement and the Acceptable Use Policy, based on the intellectual property and other rights owned by MiniMax that are embodied in or used by the Materials. You shall not violate (or encourage or permit any person to violate) any term of this Agreement or the Acceptable Use Policy.
23
+ We will continuously evaluate the applicable laws, regulations and compliance requirements for the Excluded Territories. In the meantime, should any person in such Excluded Territories be interested in deploying our models, you are welcome to contact us about obtaining a license, which will be granted based on robust controls and guardrails for purposes of complying with the laws, regulations and compliance requirements of the Excluded Territories.
24
+ III. Distribution and Redistribution
25
+ Subject to and conditioned on your continuing compliance with this Agreement, including its territorial restrictions and the Acceptable Use Policy, and solely within the Applicable Territory, you may distribute or make available the MiniMax H3 Works to Third Parties within the Applicable Territory; provided, that all of the following conditions are met:
26
+ 1. You must provide a copy of this Agreement to all such Third Parties who receive the MiniMax H3 Works or use your products or services related thereto;
27
+ 2. You must cause any modified files to carry prominent notices stating that you have modified such files;
28
+ 3. You are encouraged to:
29
+ a. display a notice on any product or service developed using MiniMax H3 indicating that the product or service is “Powered by MiniMax H3”;
30
+ b. add an AI-generation identifier to files produced using generative AI models including MiniMax H3; and
31
+ c. publish at least one technical blog post or a public statement describing your experience using MiniMax H3 Works;
32
+ 4. All distributions to Third Parties (other than through Hosted Services) must be accompanied by a “NOTICE” text file containing the following notice:
33
+ “MiniMax H3 is licensed under the MiniMax H3 Community License Agreement, Copyright © 2026 MiniMax. All Rights Reserved.”
34
+ You may add your own copyright notices on your modifications; except as provided in this Section and in Section V, however, you may not impose additional or different terms and conditions on the use, reproduction, or distribution of your modifications or of any aggregate Model Derivatives, and your use, reproduction, modification, distribution, running, and display of the work must otherwise comply with the terms and conditions of this Agreement (including the provisions concerning the Applicable Territory). If you receive the MiniMax H3 Works from a Licensee as part of an integrated end-user product, the provisions of Section III of this Agreement do not apply to you, but Section V and Exhibit A remain applicable.
35
+ IV. Additional Commercial Terms
36
+ 1. You shall obtain a separate, prior written authorization from MiniMax by contacting api@minimax.io with the subject line “MiniMax H3 licensing - authorization request”, if your commercial products and services generate more than 20 million US dollars (or equivalent in other currencies) in yearly revenue.
37
+ 2. You shall prominently display “MiniMax H3”on the user interface of commercial product or service that uses MiniMax H3 or MiniMax H3 Works.
38
+ V. Use Restrictions
39
+ 1. Your use of the MiniMax H3 Works must comply with applicable laws and regulations (including trade-compliance laws and regulations) and must comply with the Acceptable Use Policy for the MiniMax H3 Works, which is incorporated into this Agreement by reference.
40
+ 2. Before providing access to the MiniMax H3 Works or any product, service, or Hosted Service incorporating them, you must bind each recipient or user to enforceable terms at least as protective as the use restrictions in this Section V and Exhibit A, and you must notify each recipient or user that those restrictions apply.
41
+ 3. You may not use the MiniMax H3 Works or any of their Outputs or results to improve any other artificial intelligence model (other than MiniMax H3 or its Model Derivatives).
42
+ 4. You may not use, reproduce, modify, distribute, or display the MiniMax H3 Works or any of their Outputs or results outside the Applicable Territory. Any such use outside the Applicable Territory is not authorized by this Agreement.
43
+ 5. If you provide or make available to any Third Party a product, service, or Hosted Service that permits the generation of Outputs using MiniMax H3 or any Model Derivative, you must, before making that product or service available and throughout its operation, implement, maintain, test, and periodically review reasonable and proportionate technical and organizational safeguards designed to prevent and mitigate access, uses, and Outputs that violate this Section V or Exhibit A, including uses or Outputs that infringe, misappropriate, or otherwise violate any Third Party’s intellectual-property or other rights. You must not knowingly disable, materially weaken, or permit the circumvention of those safeguards. You must maintain a reasonably accessible mechanism for reporting suspected violations. Upon receiving a good-faith report or otherwise obtaining actual knowledge of a violation, you must promptly investigate and take reasonable steps within your control to stop or mitigate the violation, including removing or disabling access to offending content or services and suspending or terminating repeat violators where appropriate. You are responsible for implementing and enforcing these requirements with respect to your products, services, systems, users, and downstream recipients.
44
+ VI. Intellectual Property
45
+ 1. Subject to MiniMax’s rights in the MiniMax H3 Works (and the intellectual property therein), and to your compliance with the terms and conditions of this Agreement, as between you and MiniMax, you will own the derivative works and modifications of the Materials that you have created or had created, as well as any Model Derivatives.
46
+ 2. Except for the limited license expressly granted in this paragraph, no trademark license is granted under this Agreement; with respect to MiniMax H3 Works, the Licensee may not use any name or mark owned by or associated with MiniMax or any of its affiliates, except as reasonably and customarily necessary to describe and distribute the MiniMax H3 Works. MiniMax hereby grants you a license to use the “MiniMax H3” mark (the “Mark”) within the Applicable Territory solely for the purpose of complying with Section III.3; provided, that you comply with all applicable trademark-protection laws. All goodwill arising from your use of the Mark shall inure to the benefit of MiniMax.
47
+ 3. If you bring or assert any suit or other legal proceeding (including a cross-claim or counterclaim in any action) against us or any other natural or legal person alleging that the Materials, any Output, or any portion of the foregoing infringes any intellectual property right or other right owned by you or for which you can obtain a license, all licenses granted to you under this Agreement will terminate as of the date such suit or proceeding is filed. You shall defend, indemnify, and hold us harmless against any Third-Party claim arising out of or related to the use or distribution of the MiniMax H3 Works by you or by any Third Party.
48
+ 4. MiniMax claims no rights over the Outputs you generate. You and your users are entirely responsible for the Outputs and any subsequent use thereof.
49
+ VII. Disclaimers and Limitations of Liability
50
+ 1. We have no obligation to support, update, provide training for, or develop any further version of the MiniMax H3 Works, or to grant any license with respect thereto.
51
+ 2. UNLESS AND ONLY TO THE EXTENT REQUIRED BY APPLICABLE LAW, THE MINIMAX H3 WORKS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED “AS IS” WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND INCLUDING ANY WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, COURSE OF DEALING, USAGE OF TRADE, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING, REPRODUCING, MODIFYING, PERFORMING, DISPLAYING OR DISTRIBUTING ANY OF THE MINIMAX H3 WORKS OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR OR A THIRD PARTY’S USE OR DISTRIBUTION OF ANY OF THE MINIMAX H3 WORKS OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND PERMISSIONS UNDER THIS AGREEMENT.
52
+ 3. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL MINIMAX OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, FOR ANY DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR LOST PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO ANY OF THE MINIMAX H3 WORKS OR OUTPUTS, EVEN IF MINIMAX OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
53
+ VIII. Term and Termination
54
+ 1. This Agreement is effective from the moment you accept this Agreement or begin accessing the Materials, and, subject to your compliance with its terms and conditions, will remain in effect until terminated as provided herein.
55
+ 2. If you breach any term or condition of this Agreement, we have the right to terminate this Agreement. Upon termination, you must immediately cease accessing, using, and distributing the MiniMax H3 Works; delete or destroy all copies within your possession or control; and notify each downstream recipient that your authorization has ended. The obligations in the preceding sentence and Sections VI.1, VI.3, VII, and IX survive termination.
56
+ IX. Governing Law and Jurisdiction
57
+ 1. This Agreement, and any dispute arising out of or related to this Agreement, shall be governed by the laws of the Hong Kong Special Administrative Region of the People’s Republic of China, without regard to its conflict-of-laws rules. The United Nations Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
58
+ 2. Any dispute arising out of or related to this Agreement shall be subject to the exclusive jurisdiction of the courts of the Hong Kong Special Administrative Region of the People’s Republic of China with competent jurisdiction. Both MiniMax and the Licensee hereby consent to the exclusive jurisdiction of such courts for any such dispute.
59
+ Additional Note: Please note that the encoder of MiniMax H3 uses Qwen3-VL-32B, which is licensed under Apache 2.0 License: https://github.com/QwenLM/Qwen3-VL/blob/main/LICENSE.
60
+
61
+ Exhibit A — Acceptable Use Policy
62
+ MiniMax reserves the right to update this Acceptable Use Policy from time to time.
63
+ Last revised: August 2, 2026.
64
+ MiniMax is committed to promoting the safe and fair use of its tools and features, including MiniMax H3. You agree not to use MiniMax H3, any Model Derivatives, or any Output in any of the following ways:
65
+ 1. Use outside the Applicable Territory;
66
+ 2. Use in any manner that violates any applicable national, federal, state, local, or international law, regulation, or other legal requirement, or that infringes, misappropriates, or otherwise violates any Third Party’s intellectual-property or other proprietary rights, including through unauthorized reproduction, distribution, public display, public performance, or creation of derivative works;
67
+ 3. Use in any manner that may harm yourself or others;
68
+ 4. Use to repurpose or distribute the Outputs of MiniMax H3 or any Model Derivatives in order to harm yourself or others;
69
+ 5. Use to circumvent or bypass any safety guardrails or safeguards we have implemented;
70
+ 6. Use in any manner that exploits or harms, or intends to exploit or harm, minors;
71
+ 7. Use to generate or disseminate verifiably false information and/or content for the purpose of harming others or influencing elections;
72
+ 8. Use to manufacture or facilitate false online engagement, including fake reviews and other means of false online engagement;
73
+ 9. Use to intentionally defame, disparage, or otherwise harass others;
74
+ 10. Use to generate and/or disseminate malware (including ransomware) or any other content intended to damage electronic systems;
75
+ 11. Use to generate or disseminate personally identifiable information for the purpose of harming others;
76
+ 12. Use to generate or disseminate information (including images, code, posts, or articles) in or to any public environment (including via bot tweets or similar means) without clearly and prominently disclosing that such information and/or content is machine-generated;
77
+ 13. Use to impersonate another person without that person’s consent, authorization, or lawful right to do so;
78
+ 14. Use to make high-risk automated decisions in critical domains that affect individual safety, rights, or well-being (such as law enforcement, immigration, healthcare or medical services, critical-infrastructure management, product-safety components, essential services, credit, employment, housing, education, social scoring, or insurance);
79
+ 15. Use in any manner that violates or disregards the social, ethical, or moral standards of other countries or regions;
80
+ 16. Use to carry out, assist, threaten, incite, plan, advocate for, or encourage violent extremism or terrorism;
81
+ 17. Use for any purpose intended to discriminate against, or harm, individuals or groups based on protected characteristics or categories, online or offline social behavior, or known or predicted personality traits;
82
+ 18. Use to intentionally exploit the vulnerabilities of specific populations based on age, social, physical, or psychological characteristics, so as to materially distort the behavior of a member of that group in a manner that causes, or is likely to cause, physical or psychological harm to that person or to others;
83
+ 19. Use for military purposes;
84
+ 20. Use to engage in any unauthorized or unlicensed professional activity, including but not limited to financial, legal, medical or healthcare, or other professional practice.
NOTICE ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ MiniMax H3 is licensed under the MiniMax H3 Community License Agreement, Copyright © 2026 MiniMax. All Rights Reserved.
2
+
3
+ Modification notice
4
+
5
+ The FL2VA safetensors checkpoint in this repository is a modified derivative of
6
+ MiniMax H3. It was converted from the original Diffusers tensor layout to the
7
+ ComfyUI layout, selectively quantized to INT8 ConvRot, and compressed with a
8
+ dynamic rank-16 representation of the AdaLN time-conditioning curve. The
9
+ included ComfyUI patch and conversion/validation scripts are also modified or
10
+ new files provided for this derivative release.
README.md ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: minimax-h3-community-license-agreement
4
+ license_link: LICENSE
5
+ base_model: MiniMaxAI/MiniMax-H3
6
+ library_name: comfyui
7
+ pipeline_tag: image-text-to-video
8
+ tags:
9
+ - minimax-h3
10
+ - comfyui
11
+ - quantization
12
+ - int8
13
+ - convrot
14
+ - video
15
+ - audio
16
+ - fl2va
17
+ ---
18
+
19
+ # MiniMax-H3 INT8 Lean ConvRot
20
+
21
+ This repository contains a quality-oriented mixed-precision ComfyUI derivative
22
+ of [`MiniMaxAI/MiniMax-H3`](https://huggingface.co/MiniMaxAI/MiniMax-H3).
23
+ The currently released checkpoint is the **FL2VA** diffusion transformer. It is
24
+ designed as a first 24 GiB GPU candidate while preserving more of the original
25
+ model than the official pruned INT8 checkpoint.
26
+
27
+ The release is not an official MiniMax or ComfyOrg checkpoint. It requires the
28
+ small ComfyUI core patch included in [`comfy_patch/`](comfy_patch/).
29
+
30
+ ## Included files
31
+
32
+ | Path | Purpose |
33
+ |---|---|
34
+ | [`FL2VA/minimax-h3-fl2va-int8-lean-convrot-dynamic-k16-quality21.safetensors`](FL2VA/minimax-h3-fl2va-int8-lean-convrot-dynamic-k16-quality21.safetensors) | FL2VA diffusion transformer, 20.999 GiB |
35
+ | [`comfy_patch/minimax_h3_dynamic_basis.patch`](comfy_patch/minimax_h3_dynamic_basis.patch) | Required dynamic AdaLN basis support for ComfyUI |
36
+ | [`reports/layer_policy.json`](reports/layer_policy.json) | Exact per-layer precision policy |
37
+ | [`reports/validation.json`](reports/validation.json) | Structural, numerical, and CPU-load results |
38
+ | [`reports/mm_quant_profile_fl2va.json`](reports/mm_quant_profile_fl2va.json) | Row-sampled reconstruction profile for all 200 main matrices |
39
+ | [`tools/`](tools/) | Audited converter, profiler, and validator sources |
40
+
41
+ This repository intentionally does **not** include the MiniMax-H3 text encoder,
42
+ tokenizer, or video/audio VAEs. The text encoder is being prepared as a separate
43
+ repository. Obtain the remaining standard components from the
44
+ [`MiniMaxAI/MiniMax-H3`](https://huggingface.co/MiniMaxAI/MiniMax-H3) or
45
+ [`Comfy-Org/MiniMax-H3`](https://huggingface.co/Comfy-Org/MiniMax-H3)
46
+ repositories. Ref2VA is not included in this release.
47
+
48
+ ## What was changed
49
+
50
+ The original FL2VA Diffusers shards contain 50 transformer blocks with separate
51
+ Q, K, and V tensors. The converter streams those shards directly and performs
52
+ the layout changes required by current ComfyUI MiniMax-H3 support:
53
+
54
+ - packs attention rows as global `cat(Q, K, V)`;
55
+ - swaps the two `fc1` halves from `[value, gate]` to `[gate, value]`;
56
+ - stores 170 selected main attention/MLP matrices as INT8 ConvRot with group
57
+ size 256 and per-row FP32 scales;
58
+ - keeps 30 high-error main matrices as exact BF16 copies;
59
+ - keeps the two-block token refiner, norms, Q/K norms, and condition projection
60
+ at their source precision;
61
+ - keeps patch projections and video/audio output heads in source FP32;
62
+ - keeps the original four-tensor FP32 time embedder bit-for-bit;
63
+ - replaces only the redundant width of the 51 large AdaLN projections with a
64
+ shared dynamic rank-16 FP32 basis while keeping every AdaLN projection
65
+ separate.
66
+
67
+ The checkpoint contains 877 tensor entries: 170 INT8 weights, 170 quantization
68
+ configuration blobs, 250 BF16 entries, and 287 FP32 entries.
69
+
70
+ ## Precision policy
71
+
72
+ Every DiT block has four main matrices: QKV, attention output, MLP `fc1`, and
73
+ MLP `fc2`, for 200 matrices total. The `quality21` profile stores 170 in INT8
74
+ and 30 in BF16.
75
+
76
+ The BF16 island is:
77
+
78
+ - attention output projections in blocks 0–15, 17, 19, 20, 27, 38, 43–47,
79
+ and 49 (27 matrices);
80
+ - MLP `fc2` in blocks 39, 45, and 49 (3 matrices).
81
+
82
+ These were selected from a deterministic reconstruction audit using 64 output
83
+ rows and every input column of each matrix. Attention output projections were
84
+ the most error-prone family and are considerably cheaper to retain in BF16 than
85
+ QKV or `fc1`. The exact machine-readable list is in
86
+ [`reports/layer_policy.json`](reports/layer_policy.json).
87
+
88
+ ## Why preserve the time embedder?
89
+
90
+ The official pruned checkpoint removes the time MLP and uses a small
91
+ interpolated AdaLN table. This release instead evaluates the original FP32 time
92
+ MLP at runtime and projects its 2,688-dimensional output onto a shared
93
+ 16-dimensional basis:
94
+
95
+ ```text
96
+ u(t) = SiLU(time_embedder(t))
97
+ z(t) = (u(t) - mean) @ basis
98
+ AdaLN_i(t) = linear_i(z(t))
99
+ ```
100
+
101
+ Each of the 50 block AdaLN projections and the final AdaLN projection remains a
102
+ different FP32 linear layer. Only their common, smooth time-conditioning input
103
+ space is compressed. There is no lookup-table interpolation in this path.
104
+
105
+ On nine validation timesteps, the relative AdaLN output error against the raw
106
+ HF weights was between `2.82e-7` and `3.29e-7` for blocks 0, 24, 49, and the
107
+ final layer. For context, the official pruned table path measured about
108
+ `0.016%–0.021%` on the same four projections. This comparison covers only the
109
+ time/AdaLN path, not end-to-end generation quality.
110
+
111
+ ## Comparison with official ComfyOrg files
112
+
113
+ | Checkpoint | Size | Main matrices | Time/AdaLN representation |
114
+ |---|---:|---:|---|
115
+ | Official regular INT8 ConvRot | about 31.70 GiB | 200 INT8 | full AdaLN weights |
116
+ | Official pruned INT8 ConvRot | 19.530 GiB | 200 INT8 | FP16 rank-8 table |
117
+ | This `quality21` release | 20.999 GiB | 170 INT8 + 30 BF16 | original FP32 time MLP + FP32 dynamic rank-16 basis |
118
+
119
+ This file is 1.469 GiB (7.52%) larger than the official pruned INT8 checkpoint.
120
+ The added space is intentionally spent on the original time behavior and a
121
+ BF16 island for the most sensitive main matrices.
122
+
123
+ The full 200-matrix sampled reconstruction proxy produced:
124
+
125
+ | Metric | Official-style absmax INT8 | This profile |
126
+ |---|---:|---:|
127
+ | Unweighted mean relative matrix error | 0.9345% | 0.7639% |
128
+
129
+ For this profile, selected BF16 matrices count as zero storage reconstruction
130
+ error. On the remaining 170 INT8 matrices, searched scales reduced the mean
131
+ proxy from 0.9109% to 0.8987%. The overall 18.26% reduction is a sampled weight
132
+ reconstruction result, **not** a perceptual or generation benchmark.
133
+
134
+ ## ComfyUI installation
135
+
136
+ 1. Use a ComfyUI checkout compatible with MiniMax-H3. This release was
137
+ CPU-load-tested at commit `14b05228cef127ce529bc0c08660770d4af3e9a8`.
138
+ 2. Apply [`comfy_patch/minimax_h3_dynamic_basis.patch`](comfy_patch/minimax_h3_dynamic_basis.patch)
139
+ from the ComfyUI repository root.
140
+ 3. Place the safetensors file in `ComfyUI/models/diffusion_models/`.
141
+ 4. Load it with the standard diffusion-model loader in a MiniMax-H3 FL2VA
142
+ workflow. Supply the text encoder and video/audio VAEs separately.
143
+
144
+ The patch adds a third MiniMax-H3 time-conditioning mode and leaves existing
145
+ full and official `adaln_t_table` checkpoints on their original paths. Do not
146
+ apply it blindly if upstream ComfyUI has since implemented equivalent support.
147
+
148
+ ## Validation status
149
+
150
+ Completed:
151
+
152
+ - safetensors structure, shapes, dtypes, and all 170 ConvRot descriptors;
153
+ - SHA-256: `c57e85fc299ca399a5c84e7888b0f61c532da05ddbf3f92e521690b07cb72b0a`;
154
+ - original FP32 time embedder: 4/4 tensors bitwise equal to raw HF;
155
+ - BF16 main island: 30/30 matrices bitwise equal to raw HF;
156
+ - dynamic-basis orthogonality and numerical AdaLN checks;
157
+ - full CPU load through ComfyUI as `ModelPatcher -> MiniMaxH3Model`, with
158
+ dynamic basis enabled and table mode disabled.
159
+
160
+ Not completed at release time:
161
+
162
+ - CUDA/GPU loading of this exact checkpoint;
163
+ - peak VRAM measurement for a target resolution and frame count;
164
+ - end-to-end FL2VA generation;
165
+ - same-seed visual/audio A/B against BF16 and official pruned variants.
166
+
167
+ Therefore, 20.999 GiB is the on-disk tensor payload, not a promise that every
168
+ workflow will remain under 24 GiB. Activations, runtime buffers, resolution,
169
+ frame count, batch size, and offloading policy determine peak VRAM.
170
+
171
+ ## Reproduction
172
+
173
+ The converter reads the original top-level `transformer/` Diffusers shards from
174
+ MiniMaxAI directly; it does not create a 61+ GiB merged BF16 intermediate. The
175
+ nested task-specific transformer folder was not used because its already-packed
176
+ QKV is head-major, while current ComfyUI expects global `cat(Q,K,V)` packing.
177
+
178
+ See [`tools/README.md`](tools/README.md) for exact dry-run, CPU-build, and
179
+ validation commands. The official
180
+ [`minimax_h3_fl2va_pruned_int8_convrot.safetensors`](https://huggingface.co/Comfy-Org/MiniMax-H3/blob/main/diffusion_models/minimax_h3_fl2va_pruned_int8_convrot.safetensors)
181
+ was used only as a layout reference and as the source of the FP32
182
+ `rope.inv_freq` tensor absent from the raw Diffusers state dict.
183
+
184
+ ## Limitations and intended use
185
+
186
+ This release is intended for research and local ComfyUI inference. It is a
187
+ new, structurally validated operating point, not a completed quality benchmark.
188
+ The current layer policy was profiled on FL2VA and must not be assumed optimal
189
+ for Ref2VA without a separate audit.
190
+
191
+ ## License
192
+
193
+ This derivative is distributed under the
194
+ [MiniMax H3 Community License Agreement](LICENSE). The license limits use and
195
+ distribution to its defined Applicable Territory, excludes the European Union,
196
+ United Kingdom, Republic of Korea, and United States, and includes additional
197
+ use and redistribution conditions. Read the full license and [`NOTICE`](NOTICE)
198
+ before downloading, using, or redistributing these files.
199
+
200
+ ## Links
201
+
202
+ - [Original MiniMax-H3 repository](https://huggingface.co/MiniMaxAI/MiniMax-H3)
203
+ - [Official ComfyOrg MiniMax-H3 files](https://huggingface.co/Comfy-Org/MiniMax-H3)
204
+ - [ComfyUI](https://github.com/Comfy-Org/ComfyUI)
comfy_patch/README.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Required ComfyUI patch
2
+
3
+ The dynamic-basis checkpoint is intentionally different from the official
4
+ table-pruned format and needs the accompanying core patch.
5
+
6
+ The patch was created and CPU-load-tested against ComfyUI commit
7
+ `14b05228cef127ce529bc0c08660770d4af3e9a8`.
8
+
9
+ From the root of a compatible ComfyUI checkout:
10
+
11
+ ```bash
12
+ git apply /path/to/minimax_h3_dynamic_basis.patch
13
+ ```
14
+
15
+ The patch changes only:
16
+
17
+ - `comfy/ldm/minimax/model.py`
18
+ - `comfy/model_detection.py`
19
+
20
+ It adds detection and runtime support for `adaln_curve_basis` and
21
+ `adaln_curve_mean`. Existing full and official `adaln_t_table` checkpoints keep
22
+ their previous paths. If a later ComfyUI release already contains equivalent
23
+ support, do not apply the patch blindly; inspect the upstream implementation
24
+ first.
comfy_patch/minimax_h3_dynamic_basis.patch ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/comfy/ldm/minimax/model.py b/comfy/ldm/minimax/model.py
2
+ index 494350d4..112efbe2 100644
3
+ --- a/comfy/ldm/minimax/model.py
4
+ +++ b/comfy/ldm/minimax/model.py
5
+ @@ -416,7 +416,7 @@ class MiniMaxH3Model(nn.Module):
6
+ timestep_input_dim=256, time_embed_hidden_size=5376, time_embed_dim=2688,
7
+ rope_inv_freq_len=16, norm_eps=1e-5, qk_norm_eps=1e-5, final_norm_eps=1e-5,
8
+ sigma_shift_video=12.0, sigma_shift_audio=3.0,
9
+ - adaln_curve_grid=None,
10
+ + adaln_curve_grid=None, adaln_curve_basis_dim=None,
11
+ image_model=None, dtype=None, device=None, operations=None, **kwargs):
12
+ super().__init__()
13
+ self.dtype = dtype
14
+ @@ -426,20 +426,30 @@ class MiniMaxH3Model(nn.Module):
15
+ self.audio_latents_dim = audio_latents_dim
16
+ self.sigma_shift_video = sigma_shift_video
17
+ self.sigma_shift_audio = sigma_shift_audio
18
+ - self.use_adaln_curves = adaln_curve_grid is not None
19
+ - # curve-form checkpoints replace the time embedder and full-width adaln weights with a small shared basis of the time-embedding curve
20
+ + if adaln_curve_grid is not None and adaln_curve_basis_dim is not None:
21
+ + raise ValueError("adaln table and dynamic basis modes are mutually exclusive")
22
+ + self.use_adaln_table = adaln_curve_grid is not None
23
+ + self.use_adaln_basis = adaln_curve_basis_dim is not None
24
+ + self.use_adaln_curves = self.use_adaln_table or self.use_adaln_basis
25
+ + # Curve checkpoints replace full-width adaLN weights with projections
26
+ + # over a small shared basis. Table mode also replaces the time MLP;
27
+ + # dynamic-basis mode retains it and projects its exact fp32 output.
28
+ curve = {"apply_silu": not self.use_adaln_curves,
29
+ "adaln_dtype": torch.float32 if self.use_adaln_curves else dtype}
30
+ + adaln_dim = adaln_curve_basis_dim if self.use_adaln_basis else time_embed_dim
31
+ video_patch_dim = latents_dim * self.patch_size[0] * self.patch_size[1] * self.patch_size[2]
32
+
33
+ self.video_patch_proj = operations.Linear(video_patch_dim, hidden_size, bias=True, dtype=torch.float32, device=device)
34
+ self.audio_patch_proj = operations.Linear(audio_latents_dim, hidden_size, bias=True, dtype=torch.float32, device=device)
35
+ self.condition_proj = operations.Linear(text_dim, hidden_size, bias=True, dtype=dtype, device=device)
36
+ - if self.use_adaln_curves:
37
+ + if self.use_adaln_table:
38
+ self.register_buffer("adaln_t_table", torch.empty(adaln_curve_grid, time_embed_dim, dtype=torch.float32))
39
+ else:
40
+ self.time_embedder = TimeEmbedder(timestep_input_dim, time_embed_hidden_size, time_embed_dim,
41
+ dtype=torch.float32, device=device, operations=operations)
42
+ + if self.use_adaln_basis:
43
+ + self.register_buffer("adaln_curve_basis", torch.empty(time_embed_dim, adaln_curve_basis_dim, dtype=torch.float32))
44
+ + self.register_buffer("adaln_curve_mean", torch.empty(time_embed_dim, dtype=torch.float32))
45
+ self.rope = nn.Module()
46
+ self.rope.register_buffer("inv_freq", torch.empty(rope_inv_freq_len, dtype=torch.float32))
47
+ self.token_refiner = TokenRefiner(token_refiner_num_layers, hidden_size, num_attention_heads,
48
+ @@ -447,9 +457,9 @@ class MiniMaxH3Model(nn.Module):
49
+ final_norm_eps, dtype=dtype, device=device, operations=operations)
50
+ self.blocks = nn.ModuleList([
51
+ DiTBlock(hidden_size, num_attention_heads, attention_head_dim, ffn_hidden_size,
52
+ - time_embed_dim, norm_eps, qk_norm_eps, **curve, dtype=dtype, device=device, operations=operations)
53
+ + adaln_dim, norm_eps, qk_norm_eps, **curve, dtype=dtype, device=device, operations=operations)
54
+ for _ in range(num_layers)])
55
+ - self.final_layer = FinalLayer(hidden_size, time_embed_dim, video_patch_dim, audio_latents_dim,
56
+ + self.final_layer = FinalLayer(hidden_size, adaln_dim, video_patch_dim, audio_latents_dim,
57
+ final_norm_eps, **curve, dtype=dtype, device=device, operations=operations)
58
+
59
+ def preprocess_text_embeds(self, text_states):
60
+ @@ -599,12 +609,19 @@ class MiniMaxH3Model(nn.Module):
61
+ aoff += n
62
+
63
+ t_vals = torch.tensor(unique_t, dtype=torch.float32, device=device)
64
+ - if self.use_adaln_curves:
65
+ + if self.use_adaln_table:
66
+ # adaln projections consume interpolated coordinates of the time-embedding curve
67
+ table = comfy.model_management.cast_to(self.adaln_t_table, device=device)
68
+ pos = t_vals.clamp(0.0, 1.0) * (table.shape[0] - 1) # t in [0,1] -> fractional grid index, out-of-range t clamps to the curve ends
69
+ i0 = pos.floor().long().clamp(max=table.shape[0] - 2) # lower grid row, max-clamp keeps t=1.0 on the last interval instead of reading past the table
70
+ t_emb = torch.lerp(table[i0], table[i0 + 1], (pos - i0).unsqueeze(1)) # blend the two rows by the fractional part
71
+ + elif self.use_adaln_basis:
72
+ + # Preserve the original fp32 time MLP and remove only the redundant
73
+ + # directions that its smooth one-dimensional output curve never uses.
74
+ + full_t_emb = nn.functional.silu(self.time_embedder(t_vals))
75
+ + basis = comfy.model_management.cast_to(self.adaln_curve_basis, device=device)
76
+ + mean = comfy.model_management.cast_to(self.adaln_curve_mean, device=device)
77
+ + t_emb = (full_t_emb - mean) @ basis
78
+ else:
79
+ t_emb = self.time_embedder(t_vals).to(dtype)
80
+
81
+ diff --git a/comfy/model_detection.py b/comfy/model_detection.py
82
+ index 103680fd..eaafd3ec 100644
83
+ --- a/comfy/model_detection.py
84
+ +++ b/comfy/model_detection.py
85
+ @@ -373,6 +373,7 @@ def detect_unet_config(state_dict, key_prefix, metadata=None):
86
+ dit_config["ffn_hidden_size"] = state_dict['{}blocks.0.mlp.fc1.weight'.format(key_prefix)].shape[0] // 2
87
+ dit_config["text_dim"] = state_dict['{}condition_proj.weight'.format(key_prefix)].shape[1]
88
+ table_key = '{}adaln_t_table'.format(key_prefix)
89
+ + basis_key = '{}adaln_curve_basis'.format(key_prefix)
90
+ if table_key in state_dict_keys:
91
+ # adaln shipped over a precomputed curve basis: the adaln linears span a small shared basis of the time-embedding curve (no time embedder)
92
+ table = state_dict[table_key].shape # [grid, k]
93
+ @@ -383,6 +384,11 @@ def detect_unet_config(state_dict, key_prefix, metadata=None):
94
+ dit_config["timestep_input_dim"] = te.shape[1]
95
+ dit_config["time_embed_hidden_size"] = te.shape[0]
96
+ dit_config["time_embed_dim"] = state_dict['{}time_embedder.proj_out.weight'.format(key_prefix)].shape[0]
97
+ + if basis_key in state_dict_keys:
98
+ + basis = state_dict[basis_key].shape # [full time dim, compact adaLN dim]
99
+ + if basis[0] != dit_config["time_embed_dim"]:
100
+ + raise ValueError("MiniMax H3 adaLN basis input does not match time embedder output")
101
+ + dit_config["adaln_curve_basis_dim"] = basis[1]
102
+ dit_config["rope_inv_freq_len"] = state_dict['{}rope.inv_freq'.format(key_prefix)].shape[0]
103
+ if metadata is not None and "config" in metadata:
104
+ dit_config.update(json.loads(metadata["config"]).get("transformer", {}))
reports/layer_policy.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "variant": "FL2VA",
3
+ "profile": "quality21",
4
+ "main_matrix_count": 200,
5
+ "int8_convrot_group_256_count": 170,
6
+ "bf16_main_count": 30,
7
+ "bf16_main_layers": [
8
+ "blocks.0.attn.out_proj",
9
+ "blocks.1.attn.out_proj",
10
+ "blocks.2.attn.out_proj",
11
+ "blocks.3.attn.out_proj",
12
+ "blocks.4.attn.out_proj",
13
+ "blocks.5.attn.out_proj",
14
+ "blocks.6.attn.out_proj",
15
+ "blocks.7.attn.out_proj",
16
+ "blocks.8.attn.out_proj",
17
+ "blocks.9.attn.out_proj",
18
+ "blocks.10.attn.out_proj",
19
+ "blocks.11.attn.out_proj",
20
+ "blocks.12.attn.out_proj",
21
+ "blocks.13.attn.out_proj",
22
+ "blocks.14.attn.out_proj",
23
+ "blocks.15.attn.out_proj",
24
+ "blocks.17.attn.out_proj",
25
+ "blocks.19.attn.out_proj",
26
+ "blocks.20.attn.out_proj",
27
+ "blocks.27.attn.out_proj",
28
+ "blocks.38.attn.out_proj",
29
+ "blocks.43.attn.out_proj",
30
+ "blocks.44.attn.out_proj",
31
+ "blocks.45.attn.out_proj",
32
+ "blocks.46.attn.out_proj",
33
+ "blocks.47.attn.out_proj",
34
+ "blocks.49.attn.out_proj",
35
+ "blocks.39.mlp.fc2",
36
+ "blocks.45.mlp.fc2",
37
+ "blocks.49.mlp.fc2"
38
+ ],
39
+ "other_precision": {
40
+ "token_refiner": "source BF16",
41
+ "normalization_and_qk_norm": "source BF16",
42
+ "condition_projection": "source BF16",
43
+ "video_audio_patch_and_output_projections": "source FP32",
44
+ "time_embedder": "source FP32, bitwise copy",
45
+ "adaln_projections": "51 separate FP32 rank-16 projections",
46
+ "adaln_shared_basis": "FP32 [2688, 16] plus FP32 mean [2688]",
47
+ "rope_inv_freq": "FP32 [16]"
48
+ },
49
+ "packing": {
50
+ "qkv": "global cat(Q,K,V) for current ComfyUI MiniMax-H3 split",
51
+ "mlp_fc1": "halves reordered from [value,gate] to [gate,value]"
52
+ }
53
+ }
reports/mm_quant_profile_fl2va.json ADDED
@@ -0,0 +1,3011 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "variant": "fl2va",
3
+ "source": "MiniMaxAI/MiniMax-H3:transformer/",
4
+ "groupsize": 256,
5
+ "rows": 64,
6
+ "search_min": 0.8,
7
+ "clip_margin": 0.05,
8
+ "elapsed_seconds": 59.14021396636963,
9
+ "layers": [
10
+ {
11
+ "layer": "blocks.0.attn.qkv_proj",
12
+ "block": 0,
13
+ "kind": "attn.qkv_proj",
14
+ "shape": [
15
+ 21504,
16
+ 5376
17
+ ],
18
+ "sample_rows": 64,
19
+ "absmax_error": 0.009152177721261978,
20
+ "searched_error": 0.009113732725381851,
21
+ "improvement": 3.844499588012695e-05,
22
+ "clipped_row_fraction": 0.140625,
23
+ "bf16_delta_bytes": 115519416
24
+ },
25
+ {
26
+ "layer": "blocks.0.attn.out_proj",
27
+ "block": 0,
28
+ "kind": "attn.out_proj",
29
+ "shape": [
30
+ 5376,
31
+ 7168
32
+ ],
33
+ "sample_rows": 64,
34
+ "absmax_error": 0.011882137507200241,
35
+ "searched_error": 0.011777178384363651,
36
+ "improvement": 0.00010495912283658981,
37
+ "clipped_row_fraction": 0.3125,
38
+ "bf16_delta_bytes": 38513592
39
+ },
40
+ {
41
+ "layer": "blocks.0.mlp.fc1",
42
+ "block": 0,
43
+ "kind": "mlp.fc1",
44
+ "shape": [
45
+ 28672,
46
+ 5376
47
+ ],
48
+ "sample_rows": 64,
49
+ "absmax_error": 0.00878384243696928,
50
+ "searched_error": 0.00870873685926199,
51
+ "improvement": 7.510557770729065e-05,
52
+ "clipped_row_fraction": 0.265625,
53
+ "bf16_delta_bytes": 154025912
54
+ },
55
+ {
56
+ "layer": "blocks.0.mlp.fc2",
57
+ "block": 0,
58
+ "kind": "mlp.fc2",
59
+ "shape": [
60
+ 5376,
61
+ 14336
62
+ ],
63
+ "sample_rows": 64,
64
+ "absmax_error": 0.009269612841308117,
65
+ "searched_error": 0.008981985971331596,
66
+ "improvement": 0.00028762686997652054,
67
+ "clipped_row_fraction": 0.859375,
68
+ "bf16_delta_bytes": 77048760
69
+ },
70
+ {
71
+ "layer": "blocks.1.attn.qkv_proj",
72
+ "block": 1,
73
+ "kind": "attn.qkv_proj",
74
+ "shape": [
75
+ 21504,
76
+ 5376
77
+ ],
78
+ "sample_rows": 64,
79
+ "absmax_error": 0.008961416780948639,
80
+ "searched_error": 0.008927497081458569,
81
+ "improvement": 3.391969949007034e-05,
82
+ "clipped_row_fraction": 0.109375,
83
+ "bf16_delta_bytes": 115519416
84
+ },
85
+ {
86
+ "layer": "blocks.1.attn.out_proj",
87
+ "block": 1,
88
+ "kind": "attn.out_proj",
89
+ "shape": [
90
+ 5376,
91
+ 7168
92
+ ],
93
+ "sample_rows": 64,
94
+ "absmax_error": 0.012739170342683792,
95
+ "searched_error": 0.012587778270244598,
96
+ "improvement": 0.00015139207243919373,
97
+ "clipped_row_fraction": 0.375,
98
+ "bf16_delta_bytes": 38513592
99
+ },
100
+ {
101
+ "layer": "blocks.1.mlp.fc1",
102
+ "block": 1,
103
+ "kind": "mlp.fc1",
104
+ "shape": [
105
+ 28672,
106
+ 5376
107
+ ],
108
+ "sample_rows": 64,
109
+ "absmax_error": 0.008769280277192593,
110
+ "searched_error": 0.008701339364051819,
111
+ "improvement": 6.794091314077377e-05,
112
+ "clipped_row_fraction": 0.328125,
113
+ "bf16_delta_bytes": 154025912
114
+ },
115
+ {
116
+ "layer": "blocks.1.mlp.fc2",
117
+ "block": 1,
118
+ "kind": "mlp.fc2",
119
+ "shape": [
120
+ 5376,
121
+ 14336
122
+ ],
123
+ "sample_rows": 64,
124
+ "absmax_error": 0.009266164153814316,
125
+ "searched_error": 0.00898699089884758,
126
+ "improvement": 0.00027917325496673584,
127
+ "clipped_row_fraction": 0.8125,
128
+ "bf16_delta_bytes": 77048760
129
+ },
130
+ {
131
+ "layer": "blocks.2.attn.qkv_proj",
132
+ "block": 2,
133
+ "kind": "attn.qkv_proj",
134
+ "shape": [
135
+ 21504,
136
+ 5376
137
+ ],
138
+ "sample_rows": 64,
139
+ "absmax_error": 0.008809692226350307,
140
+ "searched_error": 0.008738144300878048,
141
+ "improvement": 7.154792547225952e-05,
142
+ "clipped_row_fraction": 0.25,
143
+ "bf16_delta_bytes": 115519416
144
+ },
145
+ {
146
+ "layer": "blocks.2.attn.out_proj",
147
+ "block": 2,
148
+ "kind": "attn.out_proj",
149
+ "shape": [
150
+ 5376,
151
+ 7168
152
+ ],
153
+ "sample_rows": 64,
154
+ "absmax_error": 0.012884954921901226,
155
+ "searched_error": 0.0127450842410326,
156
+ "improvement": 0.00013987068086862564,
157
+ "clipped_row_fraction": 0.265625,
158
+ "bf16_delta_bytes": 38513592
159
+ },
160
+ {
161
+ "layer": "blocks.2.mlp.fc1",
162
+ "block": 2,
163
+ "kind": "mlp.fc1",
164
+ "shape": [
165
+ 28672,
166
+ 5376
167
+ ],
168
+ "sample_rows": 64,
169
+ "absmax_error": 0.00894160382449627,
170
+ "searched_error": 0.008885352872312069,
171
+ "improvement": 5.625095218420029e-05,
172
+ "clipped_row_fraction": 0.203125,
173
+ "bf16_delta_bytes": 154025912
174
+ },
175
+ {
176
+ "layer": "blocks.2.mlp.fc2",
177
+ "block": 2,
178
+ "kind": "mlp.fc2",
179
+ "shape": [
180
+ 5376,
181
+ 14336
182
+ ],
183
+ "sample_rows": 64,
184
+ "absmax_error": 0.009285910055041313,
185
+ "searched_error": 0.009044776670634747,
186
+ "improvement": 0.00024113338440656662,
187
+ "clipped_row_fraction": 0.765625,
188
+ "bf16_delta_bytes": 77048760
189
+ },
190
+ {
191
+ "layer": "blocks.3.attn.qkv_proj",
192
+ "block": 3,
193
+ "kind": "attn.qkv_proj",
194
+ "shape": [
195
+ 21504,
196
+ 5376
197
+ ],
198
+ "sample_rows": 64,
199
+ "absmax_error": 0.008725655265152454,
200
+ "searched_error": 0.008664319291710854,
201
+ "improvement": 6.13359734416008e-05,
202
+ "clipped_row_fraction": 0.21875,
203
+ "bf16_delta_bytes": 115519416
204
+ },
205
+ {
206
+ "layer": "blocks.3.attn.out_proj",
207
+ "block": 3,
208
+ "kind": "attn.out_proj",
209
+ "shape": [
210
+ 5376,
211
+ 7168
212
+ ],
213
+ "sample_rows": 64,
214
+ "absmax_error": 0.011724220588803291,
215
+ "searched_error": 0.011615997180342674,
216
+ "improvement": 0.00010822340846061707,
217
+ "clipped_row_fraction": 0.34375,
218
+ "bf16_delta_bytes": 38513592
219
+ },
220
+ {
221
+ "layer": "blocks.3.mlp.fc1",
222
+ "block": 3,
223
+ "kind": "mlp.fc1",
224
+ "shape": [
225
+ 28672,
226
+ 5376
227
+ ],
228
+ "sample_rows": 64,
229
+ "absmax_error": 0.008707783184945583,
230
+ "searched_error": 0.00865384191274643,
231
+ "improvement": 5.39412721991539e-05,
232
+ "clipped_row_fraction": 0.1875,
233
+ "bf16_delta_bytes": 154025912
234
+ },
235
+ {
236
+ "layer": "blocks.3.mlp.fc2",
237
+ "block": 3,
238
+ "kind": "mlp.fc2",
239
+ "shape": [
240
+ 5376,
241
+ 14336
242
+ ],
243
+ "sample_rows": 64,
244
+ "absmax_error": 0.00944015197455883,
245
+ "searched_error": 0.00914775114506483,
246
+ "improvement": 0.0002924008294939995,
247
+ "clipped_row_fraction": 0.859375,
248
+ "bf16_delta_bytes": 77048760
249
+ },
250
+ {
251
+ "layer": "blocks.4.attn.qkv_proj",
252
+ "block": 4,
253
+ "kind": "attn.qkv_proj",
254
+ "shape": [
255
+ 21504,
256
+ 5376
257
+ ],
258
+ "sample_rows": 64,
259
+ "absmax_error": 0.009004554711282253,
260
+ "searched_error": 0.008930174633860588,
261
+ "improvement": 7.438007742166519e-05,
262
+ "clipped_row_fraction": 0.265625,
263
+ "bf16_delta_bytes": 115519416
264
+ },
265
+ {
266
+ "layer": "blocks.4.attn.out_proj",
267
+ "block": 4,
268
+ "kind": "attn.out_proj",
269
+ "shape": [
270
+ 5376,
271
+ 7168
272
+ ],
273
+ "sample_rows": 64,
274
+ "absmax_error": 0.010641911998391151,
275
+ "searched_error": 0.010547509416937828,
276
+ "improvement": 9.440258145332336e-05,
277
+ "clipped_row_fraction": 0.265625,
278
+ "bf16_delta_bytes": 38513592
279
+ },
280
+ {
281
+ "layer": "blocks.4.mlp.fc1",
282
+ "block": 4,
283
+ "kind": "mlp.fc1",
284
+ "shape": [
285
+ 28672,
286
+ 5376
287
+ ],
288
+ "sample_rows": 64,
289
+ "absmax_error": 0.00890740193426609,
290
+ "searched_error": 0.008863168768584728,
291
+ "improvement": 4.423316568136215e-05,
292
+ "clipped_row_fraction": 0.140625,
293
+ "bf16_delta_bytes": 154025912
294
+ },
295
+ {
296
+ "layer": "blocks.4.mlp.fc2",
297
+ "block": 4,
298
+ "kind": "mlp.fc2",
299
+ "shape": [
300
+ 5376,
301
+ 14336
302
+ ],
303
+ "sample_rows": 64,
304
+ "absmax_error": 0.009372618049383163,
305
+ "searched_error": 0.009068206883966923,
306
+ "improvement": 0.0003044111654162407,
307
+ "clipped_row_fraction": 0.90625,
308
+ "bf16_delta_bytes": 77048760
309
+ },
310
+ {
311
+ "layer": "blocks.5.attn.qkv_proj",
312
+ "block": 5,
313
+ "kind": "attn.qkv_proj",
314
+ "shape": [
315
+ 21504,
316
+ 5376
317
+ ],
318
+ "sample_rows": 64,
319
+ "absmax_error": 0.008844029158353806,
320
+ "searched_error": 0.008820337243378162,
321
+ "improvement": 2.3691914975643158e-05,
322
+ "clipped_row_fraction": 0.09375,
323
+ "bf16_delta_bytes": 115519416
324
+ },
325
+ {
326
+ "layer": "blocks.5.attn.out_proj",
327
+ "block": 5,
328
+ "kind": "attn.out_proj",
329
+ "shape": [
330
+ 5376,
331
+ 7168
332
+ ],
333
+ "sample_rows": 64,
334
+ "absmax_error": 0.01112278364598751,
335
+ "searched_error": 0.011005363427102566,
336
+ "improvement": 0.00011742021888494492,
337
+ "clipped_row_fraction": 0.3125,
338
+ "bf16_delta_bytes": 38513592
339
+ },
340
+ {
341
+ "layer": "blocks.5.mlp.fc1",
342
+ "block": 5,
343
+ "kind": "mlp.fc1",
344
+ "shape": [
345
+ 28672,
346
+ 5376
347
+ ],
348
+ "sample_rows": 64,
349
+ "absmax_error": 0.008900557644665241,
350
+ "searched_error": 0.008855637162923813,
351
+ "improvement": 4.4920481741428375e-05,
352
+ "clipped_row_fraction": 0.15625,
353
+ "bf16_delta_bytes": 154025912
354
+ },
355
+ {
356
+ "layer": "blocks.5.mlp.fc2",
357
+ "block": 5,
358
+ "kind": "mlp.fc2",
359
+ "shape": [
360
+ 5376,
361
+ 14336
362
+ ],
363
+ "sample_rows": 64,
364
+ "absmax_error": 0.009373556822538376,
365
+ "searched_error": 0.009093226864933968,
366
+ "improvement": 0.00028032995760440826,
367
+ "clipped_row_fraction": 0.8125,
368
+ "bf16_delta_bytes": 77048760
369
+ },
370
+ {
371
+ "layer": "blocks.6.attn.qkv_proj",
372
+ "block": 6,
373
+ "kind": "attn.qkv_proj",
374
+ "shape": [
375
+ 21504,
376
+ 5376
377
+ ],
378
+ "sample_rows": 64,
379
+ "absmax_error": 0.008842005394399166,
380
+ "searched_error": 0.00879959762096405,
381
+ "improvement": 4.2407773435115814e-05,
382
+ "clipped_row_fraction": 0.203125,
383
+ "bf16_delta_bytes": 115519416
384
+ },
385
+ {
386
+ "layer": "blocks.6.attn.out_proj",
387
+ "block": 6,
388
+ "kind": "attn.out_proj",
389
+ "shape": [
390
+ 5376,
391
+ 7168
392
+ ],
393
+ "sample_rows": 64,
394
+ "absmax_error": 0.010709479451179504,
395
+ "searched_error": 0.010630433447659016,
396
+ "improvement": 7.904600352048874e-05,
397
+ "clipped_row_fraction": 0.234375,
398
+ "bf16_delta_bytes": 38513592
399
+ },
400
+ {
401
+ "layer": "blocks.6.mlp.fc1",
402
+ "block": 6,
403
+ "kind": "mlp.fc1",
404
+ "shape": [
405
+ 28672,
406
+ 5376
407
+ ],
408
+ "sample_rows": 64,
409
+ "absmax_error": 0.008929567411541939,
410
+ "searched_error": 0.008865898475050926,
411
+ "improvement": 6.366893649101257e-05,
412
+ "clipped_row_fraction": 0.203125,
413
+ "bf16_delta_bytes": 154025912
414
+ },
415
+ {
416
+ "layer": "blocks.6.mlp.fc2",
417
+ "block": 6,
418
+ "kind": "mlp.fc2",
419
+ "shape": [
420
+ 5376,
421
+ 14336
422
+ ],
423
+ "sample_rows": 64,
424
+ "absmax_error": 0.00941010843962431,
425
+ "searched_error": 0.0091486144810915,
426
+ "improvement": 0.0002614939585328102,
427
+ "clipped_row_fraction": 0.765625,
428
+ "bf16_delta_bytes": 77048760
429
+ },
430
+ {
431
+ "layer": "blocks.7.attn.qkv_proj",
432
+ "block": 7,
433
+ "kind": "attn.qkv_proj",
434
+ "shape": [
435
+ 21504,
436
+ 5376
437
+ ],
438
+ "sample_rows": 64,
439
+ "absmax_error": 0.00882177148014307,
440
+ "searched_error": 0.008771982975304127,
441
+ "improvement": 4.978850483894348e-05,
442
+ "clipped_row_fraction": 0.15625,
443
+ "bf16_delta_bytes": 115519416
444
+ },
445
+ {
446
+ "layer": "blocks.7.attn.out_proj",
447
+ "block": 7,
448
+ "kind": "attn.out_proj",
449
+ "shape": [
450
+ 5376,
451
+ 7168
452
+ ],
453
+ "sample_rows": 64,
454
+ "absmax_error": 0.011009636335074902,
455
+ "searched_error": 0.010906275361776352,
456
+ "improvement": 0.00010336097329854965,
457
+ "clipped_row_fraction": 0.28125,
458
+ "bf16_delta_bytes": 38513592
459
+ },
460
+ {
461
+ "layer": "blocks.7.mlp.fc1",
462
+ "block": 7,
463
+ "kind": "mlp.fc1",
464
+ "shape": [
465
+ 28672,
466
+ 5376
467
+ ],
468
+ "sample_rows": 64,
469
+ "absmax_error": 0.008888943120837212,
470
+ "searched_error": 0.00882368441671133,
471
+ "improvement": 6.52587041258812e-05,
472
+ "clipped_row_fraction": 0.234375,
473
+ "bf16_delta_bytes": 154025912
474
+ },
475
+ {
476
+ "layer": "blocks.7.mlp.fc2",
477
+ "block": 7,
478
+ "kind": "mlp.fc2",
479
+ "shape": [
480
+ 5376,
481
+ 14336
482
+ ],
483
+ "sample_rows": 64,
484
+ "absmax_error": 0.00938947219401598,
485
+ "searched_error": 0.00911177508533001,
486
+ "improvement": 0.0002776971086859703,
487
+ "clipped_row_fraction": 0.796875,
488
+ "bf16_delta_bytes": 77048760
489
+ },
490
+ {
491
+ "layer": "blocks.8.attn.qkv_proj",
492
+ "block": 8,
493
+ "kind": "attn.qkv_proj",
494
+ "shape": [
495
+ 21504,
496
+ 5376
497
+ ],
498
+ "sample_rows": 64,
499
+ "absmax_error": 0.008989319205284119,
500
+ "searched_error": 0.00893863569945097,
501
+ "improvement": 5.0683505833148956e-05,
502
+ "clipped_row_fraction": 0.1875,
503
+ "bf16_delta_bytes": 115519416
504
+ },
505
+ {
506
+ "layer": "blocks.8.attn.out_proj",
507
+ "block": 8,
508
+ "kind": "attn.out_proj",
509
+ "shape": [
510
+ 5376,
511
+ 7168
512
+ ],
513
+ "sample_rows": 64,
514
+ "absmax_error": 0.010419621132314205,
515
+ "searched_error": 0.010341066867113113,
516
+ "improvement": 7.855426520109177e-05,
517
+ "clipped_row_fraction": 0.265625,
518
+ "bf16_delta_bytes": 38513592
519
+ },
520
+ {
521
+ "layer": "blocks.8.mlp.fc1",
522
+ "block": 8,
523
+ "kind": "mlp.fc1",
524
+ "shape": [
525
+ 28672,
526
+ 5376
527
+ ],
528
+ "sample_rows": 64,
529
+ "absmax_error": 0.00879050511866808,
530
+ "searched_error": 0.008731446228921413,
531
+ "improvement": 5.9058889746665955e-05,
532
+ "clipped_row_fraction": 0.21875,
533
+ "bf16_delta_bytes": 154025912
534
+ },
535
+ {
536
+ "layer": "blocks.8.mlp.fc2",
537
+ "block": 8,
538
+ "kind": "mlp.fc2",
539
+ "shape": [
540
+ 5376,
541
+ 14336
542
+ ],
543
+ "sample_rows": 64,
544
+ "absmax_error": 0.009295894764363766,
545
+ "searched_error": 0.009004893712699413,
546
+ "improvement": 0.0002910010516643524,
547
+ "clipped_row_fraction": 0.84375,
548
+ "bf16_delta_bytes": 77048760
549
+ },
550
+ {
551
+ "layer": "blocks.9.attn.qkv_proj",
552
+ "block": 9,
553
+ "kind": "attn.qkv_proj",
554
+ "shape": [
555
+ 21504,
556
+ 5376
557
+ ],
558
+ "sample_rows": 64,
559
+ "absmax_error": 0.008668643422424793,
560
+ "searched_error": 0.008617810904979706,
561
+ "improvement": 5.083251744508743e-05,
562
+ "clipped_row_fraction": 0.1875,
563
+ "bf16_delta_bytes": 115519416
564
+ },
565
+ {
566
+ "layer": "blocks.9.attn.out_proj",
567
+ "block": 9,
568
+ "kind": "attn.out_proj",
569
+ "shape": [
570
+ 5376,
571
+ 7168
572
+ ],
573
+ "sample_rows": 64,
574
+ "absmax_error": 0.010687579400837421,
575
+ "searched_error": 0.010574358515441418,
576
+ "improvement": 0.00011322088539600372,
577
+ "clipped_row_fraction": 0.375,
578
+ "bf16_delta_bytes": 38513592
579
+ },
580
+ {
581
+ "layer": "blocks.9.mlp.fc1",
582
+ "block": 9,
583
+ "kind": "mlp.fc1",
584
+ "shape": [
585
+ 28672,
586
+ 5376
587
+ ],
588
+ "sample_rows": 64,
589
+ "absmax_error": 0.008629563264548779,
590
+ "searched_error": 0.008573157712817192,
591
+ "improvement": 5.6405551731586456e-05,
592
+ "clipped_row_fraction": 0.203125,
593
+ "bf16_delta_bytes": 154025912
594
+ },
595
+ {
596
+ "layer": "blocks.9.mlp.fc2",
597
+ "block": 9,
598
+ "kind": "mlp.fc2",
599
+ "shape": [
600
+ 5376,
601
+ 14336
602
+ ],
603
+ "sample_rows": 64,
604
+ "absmax_error": 0.009348033927381039,
605
+ "searched_error": 0.009073112159967422,
606
+ "improvement": 0.0002749217674136162,
607
+ "clipped_row_fraction": 0.8125,
608
+ "bf16_delta_bytes": 77048760
609
+ },
610
+ {
611
+ "layer": "blocks.10.attn.qkv_proj",
612
+ "block": 10,
613
+ "kind": "attn.qkv_proj",
614
+ "shape": [
615
+ 21504,
616
+ 5376
617
+ ],
618
+ "sample_rows": 64,
619
+ "absmax_error": 0.008851743303239346,
620
+ "searched_error": 0.008800441399216652,
621
+ "improvement": 5.1301904022693634e-05,
622
+ "clipped_row_fraction": 0.21875,
623
+ "bf16_delta_bytes": 115519416
624
+ },
625
+ {
626
+ "layer": "blocks.10.attn.out_proj",
627
+ "block": 10,
628
+ "kind": "attn.out_proj",
629
+ "shape": [
630
+ 5376,
631
+ 7168
632
+ ],
633
+ "sample_rows": 64,
634
+ "absmax_error": 0.01040264405310154,
635
+ "searched_error": 0.010317868553102016,
636
+ "improvement": 8.477549999952316e-05,
637
+ "clipped_row_fraction": 0.234375,
638
+ "bf16_delta_bytes": 38513592
639
+ },
640
+ {
641
+ "layer": "blocks.10.mlp.fc1",
642
+ "block": 10,
643
+ "kind": "mlp.fc1",
644
+ "shape": [
645
+ 28672,
646
+ 5376
647
+ ],
648
+ "sample_rows": 64,
649
+ "absmax_error": 0.00881904549896717,
650
+ "searched_error": 0.00878453440964222,
651
+ "improvement": 3.451108932495117e-05,
652
+ "clipped_row_fraction": 0.171875,
653
+ "bf16_delta_bytes": 154025912
654
+ },
655
+ {
656
+ "layer": "blocks.10.mlp.fc2",
657
+ "block": 10,
658
+ "kind": "mlp.fc2",
659
+ "shape": [
660
+ 5376,
661
+ 14336
662
+ ],
663
+ "sample_rows": 64,
664
+ "absmax_error": 0.009316526353359222,
665
+ "searched_error": 0.009032001718878746,
666
+ "improvement": 0.0002845246344804764,
667
+ "clipped_row_fraction": 0.859375,
668
+ "bf16_delta_bytes": 77048760
669
+ },
670
+ {
671
+ "layer": "blocks.11.attn.qkv_proj",
672
+ "block": 11,
673
+ "kind": "attn.qkv_proj",
674
+ "shape": [
675
+ 21504,
676
+ 5376
677
+ ],
678
+ "sample_rows": 64,
679
+ "absmax_error": 0.008875393308699131,
680
+ "searched_error": 0.008854538202285767,
681
+ "improvement": 2.085510641336441e-05,
682
+ "clipped_row_fraction": 0.09375,
683
+ "bf16_delta_bytes": 115519416
684
+ },
685
+ {
686
+ "layer": "blocks.11.attn.out_proj",
687
+ "block": 11,
688
+ "kind": "attn.out_proj",
689
+ "shape": [
690
+ 5376,
691
+ 7168
692
+ ],
693
+ "sample_rows": 64,
694
+ "absmax_error": 0.010382995009422302,
695
+ "searched_error": 0.010304039344191551,
696
+ "improvement": 7.895566523075104e-05,
697
+ "clipped_row_fraction": 0.28125,
698
+ "bf16_delta_bytes": 38513592
699
+ },
700
+ {
701
+ "layer": "blocks.11.mlp.fc1",
702
+ "block": 11,
703
+ "kind": "mlp.fc1",
704
+ "shape": [
705
+ 28672,
706
+ 5376
707
+ ],
708
+ "sample_rows": 64,
709
+ "absmax_error": 0.008945159614086151,
710
+ "searched_error": 0.008855168707668781,
711
+ "improvement": 8.999090641736984e-05,
712
+ "clipped_row_fraction": 0.28125,
713
+ "bf16_delta_bytes": 154025912
714
+ },
715
+ {
716
+ "layer": "blocks.11.mlp.fc2",
717
+ "block": 11,
718
+ "kind": "mlp.fc2",
719
+ "shape": [
720
+ 5376,
721
+ 14336
722
+ ],
723
+ "sample_rows": 64,
724
+ "absmax_error": 0.009415395557880402,
725
+ "searched_error": 0.009122848510742188,
726
+ "improvement": 0.0002925470471382141,
727
+ "clipped_row_fraction": 0.859375,
728
+ "bf16_delta_bytes": 77048760
729
+ },
730
+ {
731
+ "layer": "blocks.12.attn.qkv_proj",
732
+ "block": 12,
733
+ "kind": "attn.qkv_proj",
734
+ "shape": [
735
+ 21504,
736
+ 5376
737
+ ],
738
+ "sample_rows": 64,
739
+ "absmax_error": 0.008705309592187405,
740
+ "searched_error": 0.008628779090940952,
741
+ "improvement": 7.653050124645233e-05,
742
+ "clipped_row_fraction": 0.296875,
743
+ "bf16_delta_bytes": 115519416
744
+ },
745
+ {
746
+ "layer": "blocks.12.attn.out_proj",
747
+ "block": 12,
748
+ "kind": "attn.out_proj",
749
+ "shape": [
750
+ 5376,
751
+ 7168
752
+ ],
753
+ "sample_rows": 64,
754
+ "absmax_error": 0.010260747745633125,
755
+ "searched_error": 0.01013985276222229,
756
+ "improvement": 0.00012089498341083527,
757
+ "clipped_row_fraction": 0.40625,
758
+ "bf16_delta_bytes": 38513592
759
+ },
760
+ {
761
+ "layer": "blocks.12.mlp.fc1",
762
+ "block": 12,
763
+ "kind": "mlp.fc1",
764
+ "shape": [
765
+ 28672,
766
+ 5376
767
+ ],
768
+ "sample_rows": 64,
769
+ "absmax_error": 0.008776841685175896,
770
+ "searched_error": 0.008733909577131271,
771
+ "improvement": 4.293210804462433e-05,
772
+ "clipped_row_fraction": 0.171875,
773
+ "bf16_delta_bytes": 154025912
774
+ },
775
+ {
776
+ "layer": "blocks.12.mlp.fc2",
777
+ "block": 12,
778
+ "kind": "mlp.fc2",
779
+ "shape": [
780
+ 5376,
781
+ 14336
782
+ ],
783
+ "sample_rows": 64,
784
+ "absmax_error": 0.009360354393720627,
785
+ "searched_error": 0.009091442450881004,
786
+ "improvement": 0.0002689119428396225,
787
+ "clipped_row_fraction": 0.796875,
788
+ "bf16_delta_bytes": 77048760
789
+ },
790
+ {
791
+ "layer": "blocks.13.attn.qkv_proj",
792
+ "block": 13,
793
+ "kind": "attn.qkv_proj",
794
+ "shape": [
795
+ 21504,
796
+ 5376
797
+ ],
798
+ "sample_rows": 64,
799
+ "absmax_error": 0.008797130547463894,
800
+ "searched_error": 0.008764015510678291,
801
+ "improvement": 3.311503678560257e-05,
802
+ "clipped_row_fraction": 0.140625,
803
+ "bf16_delta_bytes": 115519416
804
+ },
805
+ {
806
+ "layer": "blocks.13.attn.out_proj",
807
+ "block": 13,
808
+ "kind": "attn.out_proj",
809
+ "shape": [
810
+ 5376,
811
+ 7168
812
+ ],
813
+ "sample_rows": 64,
814
+ "absmax_error": 0.01025098841637373,
815
+ "searched_error": 0.010134506039321423,
816
+ "improvement": 0.00011648237705230713,
817
+ "clipped_row_fraction": 0.34375,
818
+ "bf16_delta_bytes": 38513592
819
+ },
820
+ {
821
+ "layer": "blocks.13.mlp.fc1",
822
+ "block": 13,
823
+ "kind": "mlp.fc1",
824
+ "shape": [
825
+ 28672,
826
+ 5376
827
+ ],
828
+ "sample_rows": 64,
829
+ "absmax_error": 0.008742579258978367,
830
+ "searched_error": 0.008683488704264164,
831
+ "improvement": 5.909055471420288e-05,
832
+ "clipped_row_fraction": 0.1875,
833
+ "bf16_delta_bytes": 154025912
834
+ },
835
+ {
836
+ "layer": "blocks.13.mlp.fc2",
837
+ "block": 13,
838
+ "kind": "mlp.fc2",
839
+ "shape": [
840
+ 5376,
841
+ 14336
842
+ ],
843
+ "sample_rows": 64,
844
+ "absmax_error": 0.009341541677713394,
845
+ "searched_error": 0.009044078178703785,
846
+ "improvement": 0.0002974634990096092,
847
+ "clipped_row_fraction": 0.90625,
848
+ "bf16_delta_bytes": 77048760
849
+ },
850
+ {
851
+ "layer": "blocks.14.attn.qkv_proj",
852
+ "block": 14,
853
+ "kind": "attn.qkv_proj",
854
+ "shape": [
855
+ 21504,
856
+ 5376
857
+ ],
858
+ "sample_rows": 64,
859
+ "absmax_error": 0.008731739595532417,
860
+ "searched_error": 0.00866743829101324,
861
+ "improvement": 6.430130451917648e-05,
862
+ "clipped_row_fraction": 0.234375,
863
+ "bf16_delta_bytes": 115519416
864
+ },
865
+ {
866
+ "layer": "blocks.14.attn.out_proj",
867
+ "block": 14,
868
+ "kind": "attn.out_proj",
869
+ "shape": [
870
+ 5376,
871
+ 7168
872
+ ],
873
+ "sample_rows": 64,
874
+ "absmax_error": 0.010588740929961205,
875
+ "searched_error": 0.0104738874360919,
876
+ "improvement": 0.00011485349386930466,
877
+ "clipped_row_fraction": 0.296875,
878
+ "bf16_delta_bytes": 38513592
879
+ },
880
+ {
881
+ "layer": "blocks.14.mlp.fc1",
882
+ "block": 14,
883
+ "kind": "mlp.fc1",
884
+ "shape": [
885
+ 28672,
886
+ 5376
887
+ ],
888
+ "sample_rows": 64,
889
+ "absmax_error": 0.008739639073610306,
890
+ "searched_error": 0.008686761371791363,
891
+ "improvement": 5.2877701818943024e-05,
892
+ "clipped_row_fraction": 0.1875,
893
+ "bf16_delta_bytes": 154025912
894
+ },
895
+ {
896
+ "layer": "blocks.14.mlp.fc2",
897
+ "block": 14,
898
+ "kind": "mlp.fc2",
899
+ "shape": [
900
+ 5376,
901
+ 14336
902
+ ],
903
+ "sample_rows": 64,
904
+ "absmax_error": 0.009477745741605759,
905
+ "searched_error": 0.009174283593893051,
906
+ "improvement": 0.0003034621477127075,
907
+ "clipped_row_fraction": 0.875,
908
+ "bf16_delta_bytes": 77048760
909
+ },
910
+ {
911
+ "layer": "blocks.15.attn.qkv_proj",
912
+ "block": 15,
913
+ "kind": "attn.qkv_proj",
914
+ "shape": [
915
+ 21504,
916
+ 5376
917
+ ],
918
+ "sample_rows": 64,
919
+ "absmax_error": 0.008885015733540058,
920
+ "searched_error": 0.00882111955434084,
921
+ "improvement": 6.389617919921875e-05,
922
+ "clipped_row_fraction": 0.25,
923
+ "bf16_delta_bytes": 115519416
924
+ },
925
+ {
926
+ "layer": "blocks.15.attn.out_proj",
927
+ "block": 15,
928
+ "kind": "attn.out_proj",
929
+ "shape": [
930
+ 5376,
931
+ 7168
932
+ ],
933
+ "sample_rows": 64,
934
+ "absmax_error": 0.010997327975928783,
935
+ "searched_error": 0.010905122384428978,
936
+ "improvement": 9.220559149980545e-05,
937
+ "clipped_row_fraction": 0.3125,
938
+ "bf16_delta_bytes": 38513592
939
+ },
940
+ {
941
+ "layer": "blocks.15.mlp.fc1",
942
+ "block": 15,
943
+ "kind": "mlp.fc1",
944
+ "shape": [
945
+ 28672,
946
+ 5376
947
+ ],
948
+ "sample_rows": 64,
949
+ "absmax_error": 0.008847352117300034,
950
+ "searched_error": 0.008780043572187424,
951
+ "improvement": 6.730854511260986e-05,
952
+ "clipped_row_fraction": 0.234375,
953
+ "bf16_delta_bytes": 154025912
954
+ },
955
+ {
956
+ "layer": "blocks.15.mlp.fc2",
957
+ "block": 15,
958
+ "kind": "mlp.fc2",
959
+ "shape": [
960
+ 5376,
961
+ 14336
962
+ ],
963
+ "sample_rows": 64,
964
+ "absmax_error": 0.009283319115638733,
965
+ "searched_error": 0.009016971103847027,
966
+ "improvement": 0.0002663480117917061,
967
+ "clipped_row_fraction": 0.734375,
968
+ "bf16_delta_bytes": 77048760
969
+ },
970
+ {
971
+ "layer": "blocks.16.attn.qkv_proj",
972
+ "block": 16,
973
+ "kind": "attn.qkv_proj",
974
+ "shape": [
975
+ 21504,
976
+ 5376
977
+ ],
978
+ "sample_rows": 64,
979
+ "absmax_error": 0.008748023770749569,
980
+ "searched_error": 0.008716645650565624,
981
+ "improvement": 3.13781201839447e-05,
982
+ "clipped_row_fraction": 0.109375,
983
+ "bf16_delta_bytes": 115519416
984
+ },
985
+ {
986
+ "layer": "blocks.16.attn.out_proj",
987
+ "block": 16,
988
+ "kind": "attn.out_proj",
989
+ "shape": [
990
+ 5376,
991
+ 7168
992
+ ],
993
+ "sample_rows": 64,
994
+ "absmax_error": 0.009902860969305038,
995
+ "searched_error": 0.00981918629258871,
996
+ "improvement": 8.367467671632767e-05,
997
+ "clipped_row_fraction": 0.328125,
998
+ "bf16_delta_bytes": 38513592
999
+ },
1000
+ {
1001
+ "layer": "blocks.16.mlp.fc1",
1002
+ "block": 16,
1003
+ "kind": "mlp.fc1",
1004
+ "shape": [
1005
+ 28672,
1006
+ 5376
1007
+ ],
1008
+ "sample_rows": 64,
1009
+ "absmax_error": 0.008831686340272427,
1010
+ "searched_error": 0.008767331019043922,
1011
+ "improvement": 6.435532122850418e-05,
1012
+ "clipped_row_fraction": 0.203125,
1013
+ "bf16_delta_bytes": 154025912
1014
+ },
1015
+ {
1016
+ "layer": "blocks.16.mlp.fc2",
1017
+ "block": 16,
1018
+ "kind": "mlp.fc2",
1019
+ "shape": [
1020
+ 5376,
1021
+ 14336
1022
+ ],
1023
+ "sample_rows": 64,
1024
+ "absmax_error": 0.009359601885080338,
1025
+ "searched_error": 0.009068690240383148,
1026
+ "improvement": 0.00029091164469718933,
1027
+ "clipped_row_fraction": 0.828125,
1028
+ "bf16_delta_bytes": 77048760
1029
+ },
1030
+ {
1031
+ "layer": "blocks.17.attn.qkv_proj",
1032
+ "block": 17,
1033
+ "kind": "attn.qkv_proj",
1034
+ "shape": [
1035
+ 21504,
1036
+ 5376
1037
+ ],
1038
+ "sample_rows": 64,
1039
+ "absmax_error": 0.008687121793627739,
1040
+ "searched_error": 0.00865284912288189,
1041
+ "improvement": 3.427267074584961e-05,
1042
+ "clipped_row_fraction": 0.15625,
1043
+ "bf16_delta_bytes": 115519416
1044
+ },
1045
+ {
1046
+ "layer": "blocks.17.attn.out_proj",
1047
+ "block": 17,
1048
+ "kind": "attn.out_proj",
1049
+ "shape": [
1050
+ 5376,
1051
+ 7168
1052
+ ],
1053
+ "sample_rows": 64,
1054
+ "absmax_error": 0.010405216366052628,
1055
+ "searched_error": 0.010322467423975468,
1056
+ "improvement": 8.274894207715988e-05,
1057
+ "clipped_row_fraction": 0.296875,
1058
+ "bf16_delta_bytes": 38513592
1059
+ },
1060
+ {
1061
+ "layer": "blocks.17.mlp.fc1",
1062
+ "block": 17,
1063
+ "kind": "mlp.fc1",
1064
+ "shape": [
1065
+ 28672,
1066
+ 5376
1067
+ ],
1068
+ "sample_rows": 64,
1069
+ "absmax_error": 0.008705413900315762,
1070
+ "searched_error": 0.0086616026237607,
1071
+ "improvement": 4.381127655506134e-05,
1072
+ "clipped_row_fraction": 0.203125,
1073
+ "bf16_delta_bytes": 154025912
1074
+ },
1075
+ {
1076
+ "layer": "blocks.17.mlp.fc2",
1077
+ "block": 17,
1078
+ "kind": "mlp.fc2",
1079
+ "shape": [
1080
+ 5376,
1081
+ 14336
1082
+ ],
1083
+ "sample_rows": 64,
1084
+ "absmax_error": 0.009333509020507336,
1085
+ "searched_error": 0.009056181646883488,
1086
+ "improvement": 0.00027732737362384796,
1087
+ "clipped_row_fraction": 0.828125,
1088
+ "bf16_delta_bytes": 77048760
1089
+ },
1090
+ {
1091
+ "layer": "blocks.18.attn.qkv_proj",
1092
+ "block": 18,
1093
+ "kind": "attn.qkv_proj",
1094
+ "shape": [
1095
+ 21504,
1096
+ 5376
1097
+ ],
1098
+ "sample_rows": 64,
1099
+ "absmax_error": 0.008936939761042595,
1100
+ "searched_error": 0.008889943361282349,
1101
+ "improvement": 4.699639976024628e-05,
1102
+ "clipped_row_fraction": 0.1875,
1103
+ "bf16_delta_bytes": 115519416
1104
+ },
1105
+ {
1106
+ "layer": "blocks.18.attn.out_proj",
1107
+ "block": 18,
1108
+ "kind": "attn.out_proj",
1109
+ "shape": [
1110
+ 5376,
1111
+ 7168
1112
+ ],
1113
+ "sample_rows": 64,
1114
+ "absmax_error": 0.009594418108463287,
1115
+ "searched_error": 0.009486166760325432,
1116
+ "improvement": 0.00010825134813785553,
1117
+ "clipped_row_fraction": 0.375,
1118
+ "bf16_delta_bytes": 38513592
1119
+ },
1120
+ {
1121
+ "layer": "blocks.18.mlp.fc1",
1122
+ "block": 18,
1123
+ "kind": "mlp.fc1",
1124
+ "shape": [
1125
+ 28672,
1126
+ 5376
1127
+ ],
1128
+ "sample_rows": 64,
1129
+ "absmax_error": 0.008742792531847954,
1130
+ "searched_error": 0.008695181459188461,
1131
+ "improvement": 4.761107265949249e-05,
1132
+ "clipped_row_fraction": 0.1875,
1133
+ "bf16_delta_bytes": 154025912
1134
+ },
1135
+ {
1136
+ "layer": "blocks.18.mlp.fc2",
1137
+ "block": 18,
1138
+ "kind": "mlp.fc2",
1139
+ "shape": [
1140
+ 5376,
1141
+ 14336
1142
+ ],
1143
+ "sample_rows": 64,
1144
+ "absmax_error": 0.009461008943617344,
1145
+ "searched_error": 0.009183678776025772,
1146
+ "improvement": 0.0002773301675915718,
1147
+ "clipped_row_fraction": 0.78125,
1148
+ "bf16_delta_bytes": 77048760
1149
+ },
1150
+ {
1151
+ "layer": "blocks.19.attn.qkv_proj",
1152
+ "block": 19,
1153
+ "kind": "attn.qkv_proj",
1154
+ "shape": [
1155
+ 21504,
1156
+ 5376
1157
+ ],
1158
+ "sample_rows": 64,
1159
+ "absmax_error": 0.008822006173431873,
1160
+ "searched_error": 0.008770683780312538,
1161
+ "improvement": 5.1322393119335175e-05,
1162
+ "clipped_row_fraction": 0.203125,
1163
+ "bf16_delta_bytes": 115519416
1164
+ },
1165
+ {
1166
+ "layer": "blocks.19.attn.out_proj",
1167
+ "block": 19,
1168
+ "kind": "attn.out_proj",
1169
+ "shape": [
1170
+ 5376,
1171
+ 7168
1172
+ ],
1173
+ "sample_rows": 64,
1174
+ "absmax_error": 0.010611477307975292,
1175
+ "searched_error": 0.010500634089112282,
1176
+ "improvement": 0.0001108432188630104,
1177
+ "clipped_row_fraction": 0.328125,
1178
+ "bf16_delta_bytes": 38513592
1179
+ },
1180
+ {
1181
+ "layer": "blocks.19.mlp.fc1",
1182
+ "block": 19,
1183
+ "kind": "mlp.fc1",
1184
+ "shape": [
1185
+ 28672,
1186
+ 5376
1187
+ ],
1188
+ "sample_rows": 64,
1189
+ "absmax_error": 0.008817723952233791,
1190
+ "searched_error": 0.008774425834417343,
1191
+ "improvement": 4.329811781644821e-05,
1192
+ "clipped_row_fraction": 0.15625,
1193
+ "bf16_delta_bytes": 154025912
1194
+ },
1195
+ {
1196
+ "layer": "blocks.19.mlp.fc2",
1197
+ "block": 19,
1198
+ "kind": "mlp.fc2",
1199
+ "shape": [
1200
+ 5376,
1201
+ 14336
1202
+ ],
1203
+ "sample_rows": 64,
1204
+ "absmax_error": 0.009473009034991264,
1205
+ "searched_error": 0.009183146059513092,
1206
+ "improvement": 0.0002898629754781723,
1207
+ "clipped_row_fraction": 0.84375,
1208
+ "bf16_delta_bytes": 77048760
1209
+ },
1210
+ {
1211
+ "layer": "blocks.20.attn.qkv_proj",
1212
+ "block": 20,
1213
+ "kind": "attn.qkv_proj",
1214
+ "shape": [
1215
+ 21504,
1216
+ 5376
1217
+ ],
1218
+ "sample_rows": 64,
1219
+ "absmax_error": 0.008687637746334076,
1220
+ "searched_error": 0.008649254217743874,
1221
+ "improvement": 3.838352859020233e-05,
1222
+ "clipped_row_fraction": 0.140625,
1223
+ "bf16_delta_bytes": 115519416
1224
+ },
1225
+ {
1226
+ "layer": "blocks.20.attn.out_proj",
1227
+ "block": 20,
1228
+ "kind": "attn.out_proj",
1229
+ "shape": [
1230
+ 5376,
1231
+ 7168
1232
+ ],
1233
+ "sample_rows": 64,
1234
+ "absmax_error": 0.010098835453391075,
1235
+ "searched_error": 0.010017567314207554,
1236
+ "improvement": 8.126813918352127e-05,
1237
+ "clipped_row_fraction": 0.265625,
1238
+ "bf16_delta_bytes": 38513592
1239
+ },
1240
+ {
1241
+ "layer": "blocks.20.mlp.fc1",
1242
+ "block": 20,
1243
+ "kind": "mlp.fc1",
1244
+ "shape": [
1245
+ 28672,
1246
+ 5376
1247
+ ],
1248
+ "sample_rows": 64,
1249
+ "absmax_error": 0.00895522441715002,
1250
+ "searched_error": 0.008894613943994045,
1251
+ "improvement": 6.061047315597534e-05,
1252
+ "clipped_row_fraction": 0.203125,
1253
+ "bf16_delta_bytes": 154025912
1254
+ },
1255
+ {
1256
+ "layer": "blocks.20.mlp.fc2",
1257
+ "block": 20,
1258
+ "kind": "mlp.fc2",
1259
+ "shape": [
1260
+ 5376,
1261
+ 14336
1262
+ ],
1263
+ "sample_rows": 64,
1264
+ "absmax_error": 0.009419957175850868,
1265
+ "searched_error": 0.009130561724305153,
1266
+ "improvement": 0.00028939545154571533,
1267
+ "clipped_row_fraction": 0.828125,
1268
+ "bf16_delta_bytes": 77048760
1269
+ },
1270
+ {
1271
+ "layer": "blocks.21.attn.qkv_proj",
1272
+ "block": 21,
1273
+ "kind": "attn.qkv_proj",
1274
+ "shape": [
1275
+ 21504,
1276
+ 5376
1277
+ ],
1278
+ "sample_rows": 64,
1279
+ "absmax_error": 0.00888002384454012,
1280
+ "searched_error": 0.008830714970827103,
1281
+ "improvement": 4.930887371301651e-05,
1282
+ "clipped_row_fraction": 0.203125,
1283
+ "bf16_delta_bytes": 115519416
1284
+ },
1285
+ {
1286
+ "layer": "blocks.21.attn.out_proj",
1287
+ "block": 21,
1288
+ "kind": "attn.out_proj",
1289
+ "shape": [
1290
+ 5376,
1291
+ 7168
1292
+ ],
1293
+ "sample_rows": 64,
1294
+ "absmax_error": 0.009559880010783672,
1295
+ "searched_error": 0.009482322260737419,
1296
+ "improvement": 7.75577500462532e-05,
1297
+ "clipped_row_fraction": 0.21875,
1298
+ "bf16_delta_bytes": 38513592
1299
+ },
1300
+ {
1301
+ "layer": "blocks.21.mlp.fc1",
1302
+ "block": 21,
1303
+ "kind": "mlp.fc1",
1304
+ "shape": [
1305
+ 28672,
1306
+ 5376
1307
+ ],
1308
+ "sample_rows": 64,
1309
+ "absmax_error": 0.008936901576817036,
1310
+ "searched_error": 0.00889648962765932,
1311
+ "improvement": 4.0411949157714844e-05,
1312
+ "clipped_row_fraction": 0.171875,
1313
+ "bf16_delta_bytes": 154025912
1314
+ },
1315
+ {
1316
+ "layer": "blocks.21.mlp.fc2",
1317
+ "block": 21,
1318
+ "kind": "mlp.fc2",
1319
+ "shape": [
1320
+ 5376,
1321
+ 14336
1322
+ ],
1323
+ "sample_rows": 64,
1324
+ "absmax_error": 0.009269020520150661,
1325
+ "searched_error": 0.00896172784268856,
1326
+ "improvement": 0.000307292677462101,
1327
+ "clipped_row_fraction": 0.890625,
1328
+ "bf16_delta_bytes": 77048760
1329
+ },
1330
+ {
1331
+ "layer": "blocks.22.attn.qkv_proj",
1332
+ "block": 22,
1333
+ "kind": "attn.qkv_proj",
1334
+ "shape": [
1335
+ 21504,
1336
+ 5376
1337
+ ],
1338
+ "sample_rows": 64,
1339
+ "absmax_error": 0.008947743102908134,
1340
+ "searched_error": 0.008884221315383911,
1341
+ "improvement": 6.352178752422333e-05,
1342
+ "clipped_row_fraction": 0.21875,
1343
+ "bf16_delta_bytes": 115519416
1344
+ },
1345
+ {
1346
+ "layer": "blocks.22.attn.out_proj",
1347
+ "block": 22,
1348
+ "kind": "attn.out_proj",
1349
+ "shape": [
1350
+ 5376,
1351
+ 7168
1352
+ ],
1353
+ "sample_rows": 64,
1354
+ "absmax_error": 0.009753851220011711,
1355
+ "searched_error": 0.009624251164495945,
1356
+ "improvement": 0.00012960005551576614,
1357
+ "clipped_row_fraction": 0.453125,
1358
+ "bf16_delta_bytes": 38513592
1359
+ },
1360
+ {
1361
+ "layer": "blocks.22.mlp.fc1",
1362
+ "block": 22,
1363
+ "kind": "mlp.fc1",
1364
+ "shape": [
1365
+ 28672,
1366
+ 5376
1367
+ ],
1368
+ "sample_rows": 64,
1369
+ "absmax_error": 0.008831880986690521,
1370
+ "searched_error": 0.008773558773100376,
1371
+ "improvement": 5.832221359014511e-05,
1372
+ "clipped_row_fraction": 0.234375,
1373
+ "bf16_delta_bytes": 154025912
1374
+ },
1375
+ {
1376
+ "layer": "blocks.22.mlp.fc2",
1377
+ "block": 22,
1378
+ "kind": "mlp.fc2",
1379
+ "shape": [
1380
+ 5376,
1381
+ 14336
1382
+ ],
1383
+ "sample_rows": 64,
1384
+ "absmax_error": 0.009388533420860767,
1385
+ "searched_error": 0.009097986854612827,
1386
+ "improvement": 0.00029054656624794006,
1387
+ "clipped_row_fraction": 0.84375,
1388
+ "bf16_delta_bytes": 77048760
1389
+ },
1390
+ {
1391
+ "layer": "blocks.23.attn.qkv_proj",
1392
+ "block": 23,
1393
+ "kind": "attn.qkv_proj",
1394
+ "shape": [
1395
+ 21504,
1396
+ 5376
1397
+ ],
1398
+ "sample_rows": 64,
1399
+ "absmax_error": 0.008868304081261158,
1400
+ "searched_error": 0.008819671347737312,
1401
+ "improvement": 4.863273352384567e-05,
1402
+ "clipped_row_fraction": 0.203125,
1403
+ "bf16_delta_bytes": 115519416
1404
+ },
1405
+ {
1406
+ "layer": "blocks.23.attn.out_proj",
1407
+ "block": 23,
1408
+ "kind": "attn.out_proj",
1409
+ "shape": [
1410
+ 5376,
1411
+ 7168
1412
+ ],
1413
+ "sample_rows": 64,
1414
+ "absmax_error": 0.009776268154382706,
1415
+ "searched_error": 0.009708729572594166,
1416
+ "improvement": 6.753858178853989e-05,
1417
+ "clipped_row_fraction": 0.21875,
1418
+ "bf16_delta_bytes": 38513592
1419
+ },
1420
+ {
1421
+ "layer": "blocks.23.mlp.fc1",
1422
+ "block": 23,
1423
+ "kind": "mlp.fc1",
1424
+ "shape": [
1425
+ 28672,
1426
+ 5376
1427
+ ],
1428
+ "sample_rows": 64,
1429
+ "absmax_error": 0.008618944324553013,
1430
+ "searched_error": 0.008562471717596054,
1431
+ "improvement": 5.647260695695877e-05,
1432
+ "clipped_row_fraction": 0.21875,
1433
+ "bf16_delta_bytes": 154025912
1434
+ },
1435
+ {
1436
+ "layer": "blocks.23.mlp.fc2",
1437
+ "block": 23,
1438
+ "kind": "mlp.fc2",
1439
+ "shape": [
1440
+ 5376,
1441
+ 14336
1442
+ ],
1443
+ "sample_rows": 64,
1444
+ "absmax_error": 0.009360692463815212,
1445
+ "searched_error": 0.009071816690266132,
1446
+ "improvement": 0.0002888757735490799,
1447
+ "clipped_row_fraction": 0.84375,
1448
+ "bf16_delta_bytes": 77048760
1449
+ },
1450
+ {
1451
+ "layer": "blocks.24.attn.qkv_proj",
1452
+ "block": 24,
1453
+ "kind": "attn.qkv_proj",
1454
+ "shape": [
1455
+ 21504,
1456
+ 5376
1457
+ ],
1458
+ "sample_rows": 64,
1459
+ "absmax_error": 0.008849837817251682,
1460
+ "searched_error": 0.008781054988503456,
1461
+ "improvement": 6.878282874822617e-05,
1462
+ "clipped_row_fraction": 0.25,
1463
+ "bf16_delta_bytes": 115519416
1464
+ },
1465
+ {
1466
+ "layer": "blocks.24.attn.out_proj",
1467
+ "block": 24,
1468
+ "kind": "attn.out_proj",
1469
+ "shape": [
1470
+ 5376,
1471
+ 7168
1472
+ ],
1473
+ "sample_rows": 64,
1474
+ "absmax_error": 0.009803637862205505,
1475
+ "searched_error": 0.009698456153273582,
1476
+ "improvement": 0.00010518170893192291,
1477
+ "clipped_row_fraction": 0.375,
1478
+ "bf16_delta_bytes": 38513592
1479
+ },
1480
+ {
1481
+ "layer": "blocks.24.mlp.fc1",
1482
+ "block": 24,
1483
+ "kind": "mlp.fc1",
1484
+ "shape": [
1485
+ 28672,
1486
+ 5376
1487
+ ],
1488
+ "sample_rows": 64,
1489
+ "absmax_error": 0.008830823004245758,
1490
+ "searched_error": 0.00879497081041336,
1491
+ "improvement": 3.585219383239746e-05,
1492
+ "clipped_row_fraction": 0.15625,
1493
+ "bf16_delta_bytes": 154025912
1494
+ },
1495
+ {
1496
+ "layer": "blocks.24.mlp.fc2",
1497
+ "block": 24,
1498
+ "kind": "mlp.fc2",
1499
+ "shape": [
1500
+ 5376,
1501
+ 14336
1502
+ ],
1503
+ "sample_rows": 64,
1504
+ "absmax_error": 0.009445111267268658,
1505
+ "searched_error": 0.009153909049928188,
1506
+ "improvement": 0.00029120221734046936,
1507
+ "clipped_row_fraction": 0.859375,
1508
+ "bf16_delta_bytes": 77048760
1509
+ },
1510
+ {
1511
+ "layer": "blocks.25.attn.qkv_proj",
1512
+ "block": 25,
1513
+ "kind": "attn.qkv_proj",
1514
+ "shape": [
1515
+ 21504,
1516
+ 5376
1517
+ ],
1518
+ "sample_rows": 64,
1519
+ "absmax_error": 0.009023238904774189,
1520
+ "searched_error": 0.008959091268479824,
1521
+ "improvement": 6.414763629436493e-05,
1522
+ "clipped_row_fraction": 0.21875,
1523
+ "bf16_delta_bytes": 115519416
1524
+ },
1525
+ {
1526
+ "layer": "blocks.25.attn.out_proj",
1527
+ "block": 25,
1528
+ "kind": "attn.out_proj",
1529
+ "shape": [
1530
+ 5376,
1531
+ 7168
1532
+ ],
1533
+ "sample_rows": 64,
1534
+ "absmax_error": 0.009833511896431446,
1535
+ "searched_error": 0.009738020598888397,
1536
+ "improvement": 9.549129754304886e-05,
1537
+ "clipped_row_fraction": 0.328125,
1538
+ "bf16_delta_bytes": 38513592
1539
+ },
1540
+ {
1541
+ "layer": "blocks.25.mlp.fc1",
1542
+ "block": 25,
1543
+ "kind": "mlp.fc1",
1544
+ "shape": [
1545
+ 28672,
1546
+ 5376
1547
+ ],
1548
+ "sample_rows": 64,
1549
+ "absmax_error": 0.008853540755808353,
1550
+ "searched_error": 0.008794158697128296,
1551
+ "improvement": 5.9382058680057526e-05,
1552
+ "clipped_row_fraction": 0.203125,
1553
+ "bf16_delta_bytes": 154025912
1554
+ },
1555
+ {
1556
+ "layer": "blocks.25.mlp.fc2",
1557
+ "block": 25,
1558
+ "kind": "mlp.fc2",
1559
+ "shape": [
1560
+ 5376,
1561
+ 14336
1562
+ ],
1563
+ "sample_rows": 64,
1564
+ "absmax_error": 0.009346915408968925,
1565
+ "searched_error": 0.009076721034944057,
1566
+ "improvement": 0.000270194374024868,
1567
+ "clipped_row_fraction": 0.765625,
1568
+ "bf16_delta_bytes": 77048760
1569
+ },
1570
+ {
1571
+ "layer": "blocks.26.attn.qkv_proj",
1572
+ "block": 26,
1573
+ "kind": "attn.qkv_proj",
1574
+ "shape": [
1575
+ 21504,
1576
+ 5376
1577
+ ],
1578
+ "sample_rows": 64,
1579
+ "absmax_error": 0.008902003057301044,
1580
+ "searched_error": 0.008850892074406147,
1581
+ "improvement": 5.111098289489746e-05,
1582
+ "clipped_row_fraction": 0.1875,
1583
+ "bf16_delta_bytes": 115519416
1584
+ },
1585
+ {
1586
+ "layer": "blocks.26.attn.out_proj",
1587
+ "block": 26,
1588
+ "kind": "attn.out_proj",
1589
+ "shape": [
1590
+ 5376,
1591
+ 7168
1592
+ ],
1593
+ "sample_rows": 64,
1594
+ "absmax_error": 0.010004710406064987,
1595
+ "searched_error": 0.009898032993078232,
1596
+ "improvement": 0.00010667741298675537,
1597
+ "clipped_row_fraction": 0.390625,
1598
+ "bf16_delta_bytes": 38513592
1599
+ },
1600
+ {
1601
+ "layer": "blocks.26.mlp.fc1",
1602
+ "block": 26,
1603
+ "kind": "mlp.fc1",
1604
+ "shape": [
1605
+ 28672,
1606
+ 5376
1607
+ ],
1608
+ "sample_rows": 64,
1609
+ "absmax_error": 0.008825123310089111,
1610
+ "searched_error": 0.008754185400903225,
1611
+ "improvement": 7.093790918588638e-05,
1612
+ "clipped_row_fraction": 0.265625,
1613
+ "bf16_delta_bytes": 154025912
1614
+ },
1615
+ {
1616
+ "layer": "blocks.26.mlp.fc2",
1617
+ "block": 26,
1618
+ "kind": "mlp.fc2",
1619
+ "shape": [
1620
+ 5376,
1621
+ 14336
1622
+ ],
1623
+ "sample_rows": 64,
1624
+ "absmax_error": 0.0092239361256361,
1625
+ "searched_error": 0.008974296040832996,
1626
+ "improvement": 0.0002496400848031044,
1627
+ "clipped_row_fraction": 0.765625,
1628
+ "bf16_delta_bytes": 77048760
1629
+ },
1630
+ {
1631
+ "layer": "blocks.27.attn.qkv_proj",
1632
+ "block": 27,
1633
+ "kind": "attn.qkv_proj",
1634
+ "shape": [
1635
+ 21504,
1636
+ 5376
1637
+ ],
1638
+ "sample_rows": 64,
1639
+ "absmax_error": 0.008917473256587982,
1640
+ "searched_error": 0.008879797533154488,
1641
+ "improvement": 3.767572343349457e-05,
1642
+ "clipped_row_fraction": 0.15625,
1643
+ "bf16_delta_bytes": 115519416
1644
+ },
1645
+ {
1646
+ "layer": "blocks.27.attn.out_proj",
1647
+ "block": 27,
1648
+ "kind": "attn.out_proj",
1649
+ "shape": [
1650
+ 5376,
1651
+ 7168
1652
+ ],
1653
+ "sample_rows": 64,
1654
+ "absmax_error": 0.010261861607432365,
1655
+ "searched_error": 0.010153005830943584,
1656
+ "improvement": 0.00010885577648878098,
1657
+ "clipped_row_fraction": 0.296875,
1658
+ "bf16_delta_bytes": 38513592
1659
+ },
1660
+ {
1661
+ "layer": "blocks.27.mlp.fc1",
1662
+ "block": 27,
1663
+ "kind": "mlp.fc1",
1664
+ "shape": [
1665
+ 28672,
1666
+ 5376
1667
+ ],
1668
+ "sample_rows": 64,
1669
+ "absmax_error": 0.008872292935848236,
1670
+ "searched_error": 0.008831623010337353,
1671
+ "improvement": 4.066992551088333e-05,
1672
+ "clipped_row_fraction": 0.1875,
1673
+ "bf16_delta_bytes": 154025912
1674
+ },
1675
+ {
1676
+ "layer": "blocks.27.mlp.fc2",
1677
+ "block": 27,
1678
+ "kind": "mlp.fc2",
1679
+ "shape": [
1680
+ 5376,
1681
+ 14336
1682
+ ],
1683
+ "sample_rows": 64,
1684
+ "absmax_error": 0.009318964555859566,
1685
+ "searched_error": 0.0090524572879076,
1686
+ "improvement": 0.00026650726795196533,
1687
+ "clipped_row_fraction": 0.78125,
1688
+ "bf16_delta_bytes": 77048760
1689
+ },
1690
+ {
1691
+ "layer": "blocks.28.attn.qkv_proj",
1692
+ "block": 28,
1693
+ "kind": "attn.qkv_proj",
1694
+ "shape": [
1695
+ 21504,
1696
+ 5376
1697
+ ],
1698
+ "sample_rows": 64,
1699
+ "absmax_error": 0.008684765547513962,
1700
+ "searched_error": 0.008628505282104015,
1701
+ "improvement": 5.626026540994644e-05,
1702
+ "clipped_row_fraction": 0.21875,
1703
+ "bf16_delta_bytes": 115519416
1704
+ },
1705
+ {
1706
+ "layer": "blocks.28.attn.out_proj",
1707
+ "block": 28,
1708
+ "kind": "attn.out_proj",
1709
+ "shape": [
1710
+ 5376,
1711
+ 7168
1712
+ ],
1713
+ "sample_rows": 64,
1714
+ "absmax_error": 0.010002732276916504,
1715
+ "searched_error": 0.009931528940796852,
1716
+ "improvement": 7.12033361196518e-05,
1717
+ "clipped_row_fraction": 0.203125,
1718
+ "bf16_delta_bytes": 38513592
1719
+ },
1720
+ {
1721
+ "layer": "blocks.28.mlp.fc1",
1722
+ "block": 28,
1723
+ "kind": "mlp.fc1",
1724
+ "shape": [
1725
+ 28672,
1726
+ 5376
1727
+ ],
1728
+ "sample_rows": 64,
1729
+ "absmax_error": 0.008683769032359123,
1730
+ "searched_error": 0.008647016249597073,
1731
+ "improvement": 3.675278276205063e-05,
1732
+ "clipped_row_fraction": 0.140625,
1733
+ "bf16_delta_bytes": 154025912
1734
+ },
1735
+ {
1736
+ "layer": "blocks.28.mlp.fc2",
1737
+ "block": 28,
1738
+ "kind": "mlp.fc2",
1739
+ "shape": [
1740
+ 5376,
1741
+ 14336
1742
+ ],
1743
+ "sample_rows": 64,
1744
+ "absmax_error": 0.009296281263232231,
1745
+ "searched_error": 0.00901525653898716,
1746
+ "improvement": 0.0002810247242450714,
1747
+ "clipped_row_fraction": 0.828125,
1748
+ "bf16_delta_bytes": 77048760
1749
+ },
1750
+ {
1751
+ "layer": "blocks.29.attn.qkv_proj",
1752
+ "block": 29,
1753
+ "kind": "attn.qkv_proj",
1754
+ "shape": [
1755
+ 21504,
1756
+ 5376
1757
+ ],
1758
+ "sample_rows": 64,
1759
+ "absmax_error": 0.008713721297681332,
1760
+ "searched_error": 0.008659077808260918,
1761
+ "improvement": 5.464348942041397e-05,
1762
+ "clipped_row_fraction": 0.21875,
1763
+ "bf16_delta_bytes": 115519416
1764
+ },
1765
+ {
1766
+ "layer": "blocks.29.attn.out_proj",
1767
+ "block": 29,
1768
+ "kind": "attn.out_proj",
1769
+ "shape": [
1770
+ 5376,
1771
+ 7168
1772
+ ],
1773
+ "sample_rows": 64,
1774
+ "absmax_error": 0.009850416332483292,
1775
+ "searched_error": 0.009744553826749325,
1776
+ "improvement": 0.00010586250573396683,
1777
+ "clipped_row_fraction": 0.34375,
1778
+ "bf16_delta_bytes": 38513592
1779
+ },
1780
+ {
1781
+ "layer": "blocks.29.mlp.fc1",
1782
+ "block": 29,
1783
+ "kind": "mlp.fc1",
1784
+ "shape": [
1785
+ 28672,
1786
+ 5376
1787
+ ],
1788
+ "sample_rows": 64,
1789
+ "absmax_error": 0.008692266419529915,
1790
+ "searched_error": 0.008643834851682186,
1791
+ "improvement": 4.843156784772873e-05,
1792
+ "clipped_row_fraction": 0.203125,
1793
+ "bf16_delta_bytes": 154025912
1794
+ },
1795
+ {
1796
+ "layer": "blocks.29.mlp.fc2",
1797
+ "block": 29,
1798
+ "kind": "mlp.fc2",
1799
+ "shape": [
1800
+ 5376,
1801
+ 14336
1802
+ ],
1803
+ "sample_rows": 64,
1804
+ "absmax_error": 0.009496194310486317,
1805
+ "searched_error": 0.00922020897269249,
1806
+ "improvement": 0.00027598533779382706,
1807
+ "clipped_row_fraction": 0.84375,
1808
+ "bf16_delta_bytes": 77048760
1809
+ },
1810
+ {
1811
+ "layer": "blocks.30.attn.qkv_proj",
1812
+ "block": 30,
1813
+ "kind": "attn.qkv_proj",
1814
+ "shape": [
1815
+ 21504,
1816
+ 5376
1817
+ ],
1818
+ "sample_rows": 64,
1819
+ "absmax_error": 0.008765683509409428,
1820
+ "searched_error": 0.00874114129692316,
1821
+ "improvement": 2.454221248626709e-05,
1822
+ "clipped_row_fraction": 0.109375,
1823
+ "bf16_delta_bytes": 115519416
1824
+ },
1825
+ {
1826
+ "layer": "blocks.30.attn.out_proj",
1827
+ "block": 30,
1828
+ "kind": "attn.out_proj",
1829
+ "shape": [
1830
+ 5376,
1831
+ 7168
1832
+ ],
1833
+ "sample_rows": 64,
1834
+ "absmax_error": 0.009816651232540607,
1835
+ "searched_error": 0.00971936620771885,
1836
+ "improvement": 9.728502482175827e-05,
1837
+ "clipped_row_fraction": 0.34375,
1838
+ "bf16_delta_bytes": 38513592
1839
+ },
1840
+ {
1841
+ "layer": "blocks.30.mlp.fc1",
1842
+ "block": 30,
1843
+ "kind": "mlp.fc1",
1844
+ "shape": [
1845
+ 28672,
1846
+ 5376
1847
+ ],
1848
+ "sample_rows": 64,
1849
+ "absmax_error": 0.008752512745559216,
1850
+ "searched_error": 0.008692821487784386,
1851
+ "improvement": 5.9691257774829865e-05,
1852
+ "clipped_row_fraction": 0.21875,
1853
+ "bf16_delta_bytes": 154025912
1854
+ },
1855
+ {
1856
+ "layer": "blocks.30.mlp.fc2",
1857
+ "block": 30,
1858
+ "kind": "mlp.fc2",
1859
+ "shape": [
1860
+ 5376,
1861
+ 14336
1862
+ ],
1863
+ "sample_rows": 64,
1864
+ "absmax_error": 0.009255063720047474,
1865
+ "searched_error": 0.008998647332191467,
1866
+ "improvement": 0.0002564163878560066,
1867
+ "clipped_row_fraction": 0.75,
1868
+ "bf16_delta_bytes": 77048760
1869
+ },
1870
+ {
1871
+ "layer": "blocks.31.attn.qkv_proj",
1872
+ "block": 31,
1873
+ "kind": "attn.qkv_proj",
1874
+ "shape": [
1875
+ 21504,
1876
+ 5376
1877
+ ],
1878
+ "sample_rows": 64,
1879
+ "absmax_error": 0.008724010549485683,
1880
+ "searched_error": 0.008665692992508411,
1881
+ "improvement": 5.8317556977272034e-05,
1882
+ "clipped_row_fraction": 0.234375,
1883
+ "bf16_delta_bytes": 115519416
1884
+ },
1885
+ {
1886
+ "layer": "blocks.31.attn.out_proj",
1887
+ "block": 31,
1888
+ "kind": "attn.out_proj",
1889
+ "shape": [
1890
+ 5376,
1891
+ 7168
1892
+ ],
1893
+ "sample_rows": 64,
1894
+ "absmax_error": 0.009994729422032833,
1895
+ "searched_error": 0.009889819659292698,
1896
+ "improvement": 0.00010490976274013519,
1897
+ "clipped_row_fraction": 0.375,
1898
+ "bf16_delta_bytes": 38513592
1899
+ },
1900
+ {
1901
+ "layer": "blocks.31.mlp.fc1",
1902
+ "block": 31,
1903
+ "kind": "mlp.fc1",
1904
+ "shape": [
1905
+ 28672,
1906
+ 5376
1907
+ ],
1908
+ "sample_rows": 64,
1909
+ "absmax_error": 0.00875474326312542,
1910
+ "searched_error": 0.008676552213728428,
1911
+ "improvement": 7.819104939699173e-05,
1912
+ "clipped_row_fraction": 0.265625,
1913
+ "bf16_delta_bytes": 154025912
1914
+ },
1915
+ {
1916
+ "layer": "blocks.31.mlp.fc2",
1917
+ "block": 31,
1918
+ "kind": "mlp.fc2",
1919
+ "shape": [
1920
+ 5376,
1921
+ 14336
1922
+ ],
1923
+ "sample_rows": 64,
1924
+ "absmax_error": 0.009443852119147778,
1925
+ "searched_error": 0.009161427617073059,
1926
+ "improvement": 0.0002824245020747185,
1927
+ "clipped_row_fraction": 0.796875,
1928
+ "bf16_delta_bytes": 77048760
1929
+ },
1930
+ {
1931
+ "layer": "blocks.32.attn.qkv_proj",
1932
+ "block": 32,
1933
+ "kind": "attn.qkv_proj",
1934
+ "shape": [
1935
+ 21504,
1936
+ 5376
1937
+ ],
1938
+ "sample_rows": 64,
1939
+ "absmax_error": 0.008674316108226776,
1940
+ "searched_error": 0.008613810874521732,
1941
+ "improvement": 6.050523370504379e-05,
1942
+ "clipped_row_fraction": 0.25,
1943
+ "bf16_delta_bytes": 115519416
1944
+ },
1945
+ {
1946
+ "layer": "blocks.32.attn.out_proj",
1947
+ "block": 32,
1948
+ "kind": "attn.out_proj",
1949
+ "shape": [
1950
+ 5376,
1951
+ 7168
1952
+ ],
1953
+ "sample_rows": 64,
1954
+ "absmax_error": 0.00985008291900158,
1955
+ "searched_error": 0.009747494012117386,
1956
+ "improvement": 0.00010258890688419342,
1957
+ "clipped_row_fraction": 0.328125,
1958
+ "bf16_delta_bytes": 38513592
1959
+ },
1960
+ {
1961
+ "layer": "blocks.32.mlp.fc1",
1962
+ "block": 32,
1963
+ "kind": "mlp.fc1",
1964
+ "shape": [
1965
+ 28672,
1966
+ 5376
1967
+ ],
1968
+ "sample_rows": 64,
1969
+ "absmax_error": 0.008692612871527672,
1970
+ "searched_error": 0.008645152673125267,
1971
+ "improvement": 4.7460198402404785e-05,
1972
+ "clipped_row_fraction": 0.1875,
1973
+ "bf16_delta_bytes": 154025912
1974
+ },
1975
+ {
1976
+ "layer": "blocks.32.mlp.fc2",
1977
+ "block": 32,
1978
+ "kind": "mlp.fc2",
1979
+ "shape": [
1980
+ 5376,
1981
+ 14336
1982
+ ],
1983
+ "sample_rows": 64,
1984
+ "absmax_error": 0.00947093777358532,
1985
+ "searched_error": 0.009159333072602749,
1986
+ "improvement": 0.00031160470098257065,
1987
+ "clipped_row_fraction": 0.859375,
1988
+ "bf16_delta_bytes": 77048760
1989
+ },
1990
+ {
1991
+ "layer": "blocks.33.attn.qkv_proj",
1992
+ "block": 33,
1993
+ "kind": "attn.qkv_proj",
1994
+ "shape": [
1995
+ 21504,
1996
+ 5376
1997
+ ],
1998
+ "sample_rows": 64,
1999
+ "absmax_error": 0.008766084909439087,
2000
+ "searched_error": 0.008694433607161045,
2001
+ "improvement": 7.165130227804184e-05,
2002
+ "clipped_row_fraction": 0.25,
2003
+ "bf16_delta_bytes": 115519416
2004
+ },
2005
+ {
2006
+ "layer": "blocks.33.attn.out_proj",
2007
+ "block": 33,
2008
+ "kind": "attn.out_proj",
2009
+ "shape": [
2010
+ 5376,
2011
+ 7168
2012
+ ],
2013
+ "sample_rows": 64,
2014
+ "absmax_error": 0.00954029243439436,
2015
+ "searched_error": 0.009445435367524624,
2016
+ "improvement": 9.485706686973572e-05,
2017
+ "clipped_row_fraction": 0.328125,
2018
+ "bf16_delta_bytes": 38513592
2019
+ },
2020
+ {
2021
+ "layer": "blocks.33.mlp.fc1",
2022
+ "block": 33,
2023
+ "kind": "mlp.fc1",
2024
+ "shape": [
2025
+ 28672,
2026
+ 5376
2027
+ ],
2028
+ "sample_rows": 64,
2029
+ "absmax_error": 0.008781595155596733,
2030
+ "searched_error": 0.008732284419238567,
2031
+ "improvement": 4.931073635816574e-05,
2032
+ "clipped_row_fraction": 0.171875,
2033
+ "bf16_delta_bytes": 154025912
2034
+ },
2035
+ {
2036
+ "layer": "blocks.33.mlp.fc2",
2037
+ "block": 33,
2038
+ "kind": "mlp.fc2",
2039
+ "shape": [
2040
+ 5376,
2041
+ 14336
2042
+ ],
2043
+ "sample_rows": 64,
2044
+ "absmax_error": 0.009335415437817574,
2045
+ "searched_error": 0.00904041063040495,
2046
+ "improvement": 0.00029500480741262436,
2047
+ "clipped_row_fraction": 0.828125,
2048
+ "bf16_delta_bytes": 77048760
2049
+ },
2050
+ {
2051
+ "layer": "blocks.34.attn.qkv_proj",
2052
+ "block": 34,
2053
+ "kind": "attn.qkv_proj",
2054
+ "shape": [
2055
+ 21504,
2056
+ 5376
2057
+ ],
2058
+ "sample_rows": 64,
2059
+ "absmax_error": 0.008966388180851936,
2060
+ "searched_error": 0.008931505493819714,
2061
+ "improvement": 3.488268703222275e-05,
2062
+ "clipped_row_fraction": 0.140625,
2063
+ "bf16_delta_bytes": 115519416
2064
+ },
2065
+ {
2066
+ "layer": "blocks.34.attn.out_proj",
2067
+ "block": 34,
2068
+ "kind": "attn.out_proj",
2069
+ "shape": [
2070
+ 5376,
2071
+ 7168
2072
+ ],
2073
+ "sample_rows": 64,
2074
+ "absmax_error": 0.009540051221847534,
2075
+ "searched_error": 0.009449652396142483,
2076
+ "improvement": 9.039882570505142e-05,
2077
+ "clipped_row_fraction": 0.328125,
2078
+ "bf16_delta_bytes": 38513592
2079
+ },
2080
+ {
2081
+ "layer": "blocks.34.mlp.fc1",
2082
+ "block": 34,
2083
+ "kind": "mlp.fc1",
2084
+ "shape": [
2085
+ 28672,
2086
+ 5376
2087
+ ],
2088
+ "sample_rows": 64,
2089
+ "absmax_error": 0.008829145692288876,
2090
+ "searched_error": 0.008788610808551311,
2091
+ "improvement": 4.053488373756409e-05,
2092
+ "clipped_row_fraction": 0.171875,
2093
+ "bf16_delta_bytes": 154025912
2094
+ },
2095
+ {
2096
+ "layer": "blocks.34.mlp.fc2",
2097
+ "block": 34,
2098
+ "kind": "mlp.fc2",
2099
+ "shape": [
2100
+ 5376,
2101
+ 14336
2102
+ ],
2103
+ "sample_rows": 64,
2104
+ "absmax_error": 0.009387649595737457,
2105
+ "searched_error": 0.009096373803913593,
2106
+ "improvement": 0.000291275791823864,
2107
+ "clipped_row_fraction": 0.875,
2108
+ "bf16_delta_bytes": 77048760
2109
+ },
2110
+ {
2111
+ "layer": "blocks.35.attn.qkv_proj",
2112
+ "block": 35,
2113
+ "kind": "attn.qkv_proj",
2114
+ "shape": [
2115
+ 21504,
2116
+ 5376
2117
+ ],
2118
+ "sample_rows": 64,
2119
+ "absmax_error": 0.008860242553055286,
2120
+ "searched_error": 0.008821065537631512,
2121
+ "improvement": 3.917701542377472e-05,
2122
+ "clipped_row_fraction": 0.171875,
2123
+ "bf16_delta_bytes": 115519416
2124
+ },
2125
+ {
2126
+ "layer": "blocks.35.attn.out_proj",
2127
+ "block": 35,
2128
+ "kind": "attn.out_proj",
2129
+ "shape": [
2130
+ 5376,
2131
+ 7168
2132
+ ],
2133
+ "sample_rows": 64,
2134
+ "absmax_error": 0.009603094309568405,
2135
+ "searched_error": 0.009491439908742905,
2136
+ "improvement": 0.00011165440082550049,
2137
+ "clipped_row_fraction": 0.390625,
2138
+ "bf16_delta_bytes": 38513592
2139
+ },
2140
+ {
2141
+ "layer": "blocks.35.mlp.fc1",
2142
+ "block": 35,
2143
+ "kind": "mlp.fc1",
2144
+ "shape": [
2145
+ 28672,
2146
+ 5376
2147
+ ],
2148
+ "sample_rows": 64,
2149
+ "absmax_error": 0.008813166990876198,
2150
+ "searched_error": 0.008791708387434483,
2151
+ "improvement": 2.145860344171524e-05,
2152
+ "clipped_row_fraction": 0.09375,
2153
+ "bf16_delta_bytes": 154025912
2154
+ },
2155
+ {
2156
+ "layer": "blocks.35.mlp.fc2",
2157
+ "block": 35,
2158
+ "kind": "mlp.fc2",
2159
+ "shape": [
2160
+ 5376,
2161
+ 14336
2162
+ ],
2163
+ "sample_rows": 64,
2164
+ "absmax_error": 0.009444838389754295,
2165
+ "searched_error": 0.009172103367745876,
2166
+ "improvement": 0.00027273502200841904,
2167
+ "clipped_row_fraction": 0.765625,
2168
+ "bf16_delta_bytes": 77048760
2169
+ },
2170
+ {
2171
+ "layer": "blocks.36.attn.qkv_proj",
2172
+ "block": 36,
2173
+ "kind": "attn.qkv_proj",
2174
+ "shape": [
2175
+ 21504,
2176
+ 5376
2177
+ ],
2178
+ "sample_rows": 64,
2179
+ "absmax_error": 0.008860931731760502,
2180
+ "searched_error": 0.00881150271743536,
2181
+ "improvement": 4.942901432514191e-05,
2182
+ "clipped_row_fraction": 0.171875,
2183
+ "bf16_delta_bytes": 115519416
2184
+ },
2185
+ {
2186
+ "layer": "blocks.36.attn.out_proj",
2187
+ "block": 36,
2188
+ "kind": "attn.out_proj",
2189
+ "shape": [
2190
+ 5376,
2191
+ 7168
2192
+ ],
2193
+ "sample_rows": 64,
2194
+ "absmax_error": 0.009988026693463326,
2195
+ "searched_error": 0.009919547475874424,
2196
+ "improvement": 6.847921758890152e-05,
2197
+ "clipped_row_fraction": 0.234375,
2198
+ "bf16_delta_bytes": 38513592
2199
+ },
2200
+ {
2201
+ "layer": "blocks.36.mlp.fc1",
2202
+ "block": 36,
2203
+ "kind": "mlp.fc1",
2204
+ "shape": [
2205
+ 28672,
2206
+ 5376
2207
+ ],
2208
+ "sample_rows": 64,
2209
+ "absmax_error": 0.0088988421484828,
2210
+ "searched_error": 0.008851088583469391,
2211
+ "improvement": 4.775356501340866e-05,
2212
+ "clipped_row_fraction": 0.1875,
2213
+ "bf16_delta_bytes": 154025912
2214
+ },
2215
+ {
2216
+ "layer": "blocks.36.mlp.fc2",
2217
+ "block": 36,
2218
+ "kind": "mlp.fc2",
2219
+ "shape": [
2220
+ 5376,
2221
+ 14336
2222
+ ],
2223
+ "sample_rows": 64,
2224
+ "absmax_error": 0.009266898967325687,
2225
+ "searched_error": 0.008992289192974567,
2226
+ "improvement": 0.00027460977435112,
2227
+ "clipped_row_fraction": 0.796875,
2228
+ "bf16_delta_bytes": 77048760
2229
+ },
2230
+ {
2231
+ "layer": "blocks.37.attn.qkv_proj",
2232
+ "block": 37,
2233
+ "kind": "attn.qkv_proj",
2234
+ "shape": [
2235
+ 21504,
2236
+ 5376
2237
+ ],
2238
+ "sample_rows": 64,
2239
+ "absmax_error": 0.008839167654514313,
2240
+ "searched_error": 0.00880094151943922,
2241
+ "improvement": 3.8226135075092316e-05,
2242
+ "clipped_row_fraction": 0.171875,
2243
+ "bf16_delta_bytes": 115519416
2244
+ },
2245
+ {
2246
+ "layer": "blocks.37.attn.out_proj",
2247
+ "block": 37,
2248
+ "kind": "attn.out_proj",
2249
+ "shape": [
2250
+ 5376,
2251
+ 7168
2252
+ ],
2253
+ "sample_rows": 64,
2254
+ "absmax_error": 0.010024740360677242,
2255
+ "searched_error": 0.009966987185180187,
2256
+ "improvement": 5.7753175497055054e-05,
2257
+ "clipped_row_fraction": 0.203125,
2258
+ "bf16_delta_bytes": 38513592
2259
+ },
2260
+ {
2261
+ "layer": "blocks.37.mlp.fc1",
2262
+ "block": 37,
2263
+ "kind": "mlp.fc1",
2264
+ "shape": [
2265
+ 28672,
2266
+ 5376
2267
+ ],
2268
+ "sample_rows": 64,
2269
+ "absmax_error": 0.008853678591549397,
2270
+ "searched_error": 0.008804235607385635,
2271
+ "improvement": 4.944298416376114e-05,
2272
+ "clipped_row_fraction": 0.171875,
2273
+ "bf16_delta_bytes": 154025912
2274
+ },
2275
+ {
2276
+ "layer": "blocks.37.mlp.fc2",
2277
+ "block": 37,
2278
+ "kind": "mlp.fc2",
2279
+ "shape": [
2280
+ 5376,
2281
+ 14336
2282
+ ],
2283
+ "sample_rows": 64,
2284
+ "absmax_error": 0.009491628967225552,
2285
+ "searched_error": 0.009205091744661331,
2286
+ "improvement": 0.00028653722256422043,
2287
+ "clipped_row_fraction": 0.8125,
2288
+ "bf16_delta_bytes": 77048760
2289
+ },
2290
+ {
2291
+ "layer": "blocks.38.attn.qkv_proj",
2292
+ "block": 38,
2293
+ "kind": "attn.qkv_proj",
2294
+ "shape": [
2295
+ 21504,
2296
+ 5376
2297
+ ],
2298
+ "sample_rows": 64,
2299
+ "absmax_error": 0.008884002454578876,
2300
+ "searched_error": 0.008830550126731396,
2301
+ "improvement": 5.3452327847480774e-05,
2302
+ "clipped_row_fraction": 0.21875,
2303
+ "bf16_delta_bytes": 115519416
2304
+ },
2305
+ {
2306
+ "layer": "blocks.38.attn.out_proj",
2307
+ "block": 38,
2308
+ "kind": "attn.out_proj",
2309
+ "shape": [
2310
+ 5376,
2311
+ 7168
2312
+ ],
2313
+ "sample_rows": 64,
2314
+ "absmax_error": 0.01087699644267559,
2315
+ "searched_error": 0.01077630091458559,
2316
+ "improvement": 0.00010069552809000015,
2317
+ "clipped_row_fraction": 0.296875,
2318
+ "bf16_delta_bytes": 38513592
2319
+ },
2320
+ {
2321
+ "layer": "blocks.38.mlp.fc1",
2322
+ "block": 38,
2323
+ "kind": "mlp.fc1",
2324
+ "shape": [
2325
+ 28672,
2326
+ 5376
2327
+ ],
2328
+ "sample_rows": 64,
2329
+ "absmax_error": 0.008931271731853485,
2330
+ "searched_error": 0.008866948075592518,
2331
+ "improvement": 6.432365626096725e-05,
2332
+ "clipped_row_fraction": 0.21875,
2333
+ "bf16_delta_bytes": 154025912
2334
+ },
2335
+ {
2336
+ "layer": "blocks.38.mlp.fc2",
2337
+ "block": 38,
2338
+ "kind": "mlp.fc2",
2339
+ "shape": [
2340
+ 5376,
2341
+ 14336
2342
+ ],
2343
+ "sample_rows": 64,
2344
+ "absmax_error": 0.009255966171622276,
2345
+ "searched_error": 0.008989330381155014,
2346
+ "improvement": 0.00026663579046726227,
2347
+ "clipped_row_fraction": 0.796875,
2348
+ "bf16_delta_bytes": 77048760
2349
+ },
2350
+ {
2351
+ "layer": "blocks.39.attn.qkv_proj",
2352
+ "block": 39,
2353
+ "kind": "attn.qkv_proj",
2354
+ "shape": [
2355
+ 21504,
2356
+ 5376
2357
+ ],
2358
+ "sample_rows": 64,
2359
+ "absmax_error": 0.008898977190256119,
2360
+ "searched_error": 0.008829842321574688,
2361
+ "improvement": 6.913486868143082e-05,
2362
+ "clipped_row_fraction": 0.234375,
2363
+ "bf16_delta_bytes": 115519416
2364
+ },
2365
+ {
2366
+ "layer": "blocks.39.attn.out_proj",
2367
+ "block": 39,
2368
+ "kind": "attn.out_proj",
2369
+ "shape": [
2370
+ 5376,
2371
+ 7168
2372
+ ],
2373
+ "sample_rows": 64,
2374
+ "absmax_error": 0.00986478291451931,
2375
+ "searched_error": 0.00979786366224289,
2376
+ "improvement": 6.69192522764206e-05,
2377
+ "clipped_row_fraction": 0.234375,
2378
+ "bf16_delta_bytes": 38513592
2379
+ },
2380
+ {
2381
+ "layer": "blocks.39.mlp.fc1",
2382
+ "block": 39,
2383
+ "kind": "mlp.fc1",
2384
+ "shape": [
2385
+ 28672,
2386
+ 5376
2387
+ ],
2388
+ "sample_rows": 64,
2389
+ "absmax_error": 0.008810189552605152,
2390
+ "searched_error": 0.008753194473683834,
2391
+ "improvement": 5.6995078921318054e-05,
2392
+ "clipped_row_fraction": 0.21875,
2393
+ "bf16_delta_bytes": 154025912
2394
+ },
2395
+ {
2396
+ "layer": "blocks.39.mlp.fc2",
2397
+ "block": 39,
2398
+ "kind": "mlp.fc2",
2399
+ "shape": [
2400
+ 5376,
2401
+ 14336
2402
+ ],
2403
+ "sample_rows": 64,
2404
+ "absmax_error": 0.009537908248603344,
2405
+ "searched_error": 0.009237056598067284,
2406
+ "improvement": 0.00030085165053606033,
2407
+ "clipped_row_fraction": 0.859375,
2408
+ "bf16_delta_bytes": 77048760
2409
+ },
2410
+ {
2411
+ "layer": "blocks.40.attn.qkv_proj",
2412
+ "block": 40,
2413
+ "kind": "attn.qkv_proj",
2414
+ "shape": [
2415
+ 21504,
2416
+ 5376
2417
+ ],
2418
+ "sample_rows": 64,
2419
+ "absmax_error": 0.008767694234848022,
2420
+ "searched_error": 0.00870572030544281,
2421
+ "improvement": 6.19739294052124e-05,
2422
+ "clipped_row_fraction": 0.234375,
2423
+ "bf16_delta_bytes": 115519416
2424
+ },
2425
+ {
2426
+ "layer": "blocks.40.attn.out_proj",
2427
+ "block": 40,
2428
+ "kind": "attn.out_proj",
2429
+ "shape": [
2430
+ 5376,
2431
+ 7168
2432
+ ],
2433
+ "sample_rows": 64,
2434
+ "absmax_error": 0.009701002389192581,
2435
+ "searched_error": 0.009602167643606663,
2436
+ "improvement": 9.883474558591843e-05,
2437
+ "clipped_row_fraction": 0.328125,
2438
+ "bf16_delta_bytes": 38513592
2439
+ },
2440
+ {
2441
+ "layer": "blocks.40.mlp.fc1",
2442
+ "block": 40,
2443
+ "kind": "mlp.fc1",
2444
+ "shape": [
2445
+ 28672,
2446
+ 5376
2447
+ ],
2448
+ "sample_rows": 64,
2449
+ "absmax_error": 0.008829804137349129,
2450
+ "searched_error": 0.008786809630692005,
2451
+ "improvement": 4.2994506657123566e-05,
2452
+ "clipped_row_fraction": 0.15625,
2453
+ "bf16_delta_bytes": 154025912
2454
+ },
2455
+ {
2456
+ "layer": "blocks.40.mlp.fc2",
2457
+ "block": 40,
2458
+ "kind": "mlp.fc2",
2459
+ "shape": [
2460
+ 5376,
2461
+ 14336
2462
+ ],
2463
+ "sample_rows": 64,
2464
+ "absmax_error": 0.009279806166887283,
2465
+ "searched_error": 0.009015350602567196,
2466
+ "improvement": 0.00026445556432008743,
2467
+ "clipped_row_fraction": 0.78125,
2468
+ "bf16_delta_bytes": 77048760
2469
+ },
2470
+ {
2471
+ "layer": "blocks.41.attn.qkv_proj",
2472
+ "block": 41,
2473
+ "kind": "attn.qkv_proj",
2474
+ "shape": [
2475
+ 21504,
2476
+ 5376
2477
+ ],
2478
+ "sample_rows": 64,
2479
+ "absmax_error": 0.00888835359364748,
2480
+ "searched_error": 0.008865226991474628,
2481
+ "improvement": 2.3126602172851562e-05,
2482
+ "clipped_row_fraction": 0.09375,
2483
+ "bf16_delta_bytes": 115519416
2484
+ },
2485
+ {
2486
+ "layer": "blocks.41.attn.out_proj",
2487
+ "block": 41,
2488
+ "kind": "attn.out_proj",
2489
+ "shape": [
2490
+ 5376,
2491
+ 7168
2492
+ ],
2493
+ "sample_rows": 64,
2494
+ "absmax_error": 0.009856064803898335,
2495
+ "searched_error": 0.009737283922731876,
2496
+ "improvement": 0.00011878088116645813,
2497
+ "clipped_row_fraction": 0.40625,
2498
+ "bf16_delta_bytes": 38513592
2499
+ },
2500
+ {
2501
+ "layer": "blocks.41.mlp.fc1",
2502
+ "block": 41,
2503
+ "kind": "mlp.fc1",
2504
+ "shape": [
2505
+ 28672,
2506
+ 5376
2507
+ ],
2508
+ "sample_rows": 64,
2509
+ "absmax_error": 0.008642565459012985,
2510
+ "searched_error": 0.008587867952883244,
2511
+ "improvement": 5.469750612974167e-05,
2512
+ "clipped_row_fraction": 0.203125,
2513
+ "bf16_delta_bytes": 154025912
2514
+ },
2515
+ {
2516
+ "layer": "blocks.41.mlp.fc2",
2517
+ "block": 41,
2518
+ "kind": "mlp.fc2",
2519
+ "shape": [
2520
+ 5376,
2521
+ 14336
2522
+ ],
2523
+ "sample_rows": 64,
2524
+ "absmax_error": 0.009489201940596104,
2525
+ "searched_error": 0.009183059446513653,
2526
+ "improvement": 0.00030614249408245087,
2527
+ "clipped_row_fraction": 0.859375,
2528
+ "bf16_delta_bytes": 77048760
2529
+ },
2530
+ {
2531
+ "layer": "blocks.42.attn.qkv_proj",
2532
+ "block": 42,
2533
+ "kind": "attn.qkv_proj",
2534
+ "shape": [
2535
+ 21504,
2536
+ 5376
2537
+ ],
2538
+ "sample_rows": 64,
2539
+ "absmax_error": 0.00878732930868864,
2540
+ "searched_error": 0.008722234517335892,
2541
+ "improvement": 6.509479135274887e-05,
2542
+ "clipped_row_fraction": 0.265625,
2543
+ "bf16_delta_bytes": 115519416
2544
+ },
2545
+ {
2546
+ "layer": "blocks.42.attn.out_proj",
2547
+ "block": 42,
2548
+ "kind": "attn.out_proj",
2549
+ "shape": [
2550
+ 5376,
2551
+ 7168
2552
+ ],
2553
+ "sample_rows": 64,
2554
+ "absmax_error": 0.009849688038229942,
2555
+ "searched_error": 0.009761529974639416,
2556
+ "improvement": 8.815806359052658e-05,
2557
+ "clipped_row_fraction": 0.3125,
2558
+ "bf16_delta_bytes": 38513592
2559
+ },
2560
+ {
2561
+ "layer": "blocks.42.mlp.fc1",
2562
+ "block": 42,
2563
+ "kind": "mlp.fc1",
2564
+ "shape": [
2565
+ 28672,
2566
+ 5376
2567
+ ],
2568
+ "sample_rows": 64,
2569
+ "absmax_error": 0.00881112739443779,
2570
+ "searched_error": 0.008781219832599163,
2571
+ "improvement": 2.990756183862686e-05,
2572
+ "clipped_row_fraction": 0.140625,
2573
+ "bf16_delta_bytes": 154025912
2574
+ },
2575
+ {
2576
+ "layer": "blocks.42.mlp.fc2",
2577
+ "block": 42,
2578
+ "kind": "mlp.fc2",
2579
+ "shape": [
2580
+ 5376,
2581
+ 14336
2582
+ ],
2583
+ "sample_rows": 64,
2584
+ "absmax_error": 0.009377618320286274,
2585
+ "searched_error": 0.009100445546209812,
2586
+ "improvement": 0.0002771727740764618,
2587
+ "clipped_row_fraction": 0.8125,
2588
+ "bf16_delta_bytes": 77048760
2589
+ },
2590
+ {
2591
+ "layer": "blocks.43.attn.qkv_proj",
2592
+ "block": 43,
2593
+ "kind": "attn.qkv_proj",
2594
+ "shape": [
2595
+ 21504,
2596
+ 5376
2597
+ ],
2598
+ "sample_rows": 64,
2599
+ "absmax_error": 0.00880368147045374,
2600
+ "searched_error": 0.00876226183027029,
2601
+ "improvement": 4.141964018344879e-05,
2602
+ "clipped_row_fraction": 0.171875,
2603
+ "bf16_delta_bytes": 115519416
2604
+ },
2605
+ {
2606
+ "layer": "blocks.43.attn.out_proj",
2607
+ "block": 43,
2608
+ "kind": "attn.out_proj",
2609
+ "shape": [
2610
+ 5376,
2611
+ 7168
2612
+ ],
2613
+ "sample_rows": 64,
2614
+ "absmax_error": 0.010473590344190598,
2615
+ "searched_error": 0.010342192836105824,
2616
+ "improvement": 0.00013139750808477402,
2617
+ "clipped_row_fraction": 0.40625,
2618
+ "bf16_delta_bytes": 38513592
2619
+ },
2620
+ {
2621
+ "layer": "blocks.43.mlp.fc1",
2622
+ "block": 43,
2623
+ "kind": "mlp.fc1",
2624
+ "shape": [
2625
+ 28672,
2626
+ 5376
2627
+ ],
2628
+ "sample_rows": 64,
2629
+ "absmax_error": 0.00889844261109829,
2630
+ "searched_error": 0.008808812126517296,
2631
+ "improvement": 8.963048458099365e-05,
2632
+ "clipped_row_fraction": 0.34375,
2633
+ "bf16_delta_bytes": 154025912
2634
+ },
2635
+ {
2636
+ "layer": "blocks.43.mlp.fc2",
2637
+ "block": 43,
2638
+ "kind": "mlp.fc2",
2639
+ "shape": [
2640
+ 5376,
2641
+ 14336
2642
+ ],
2643
+ "sample_rows": 64,
2644
+ "absmax_error": 0.009177000261843204,
2645
+ "searched_error": 0.008896099403500557,
2646
+ "improvement": 0.00028090085834264755,
2647
+ "clipped_row_fraction": 0.859375,
2648
+ "bf16_delta_bytes": 77048760
2649
+ },
2650
+ {
2651
+ "layer": "blocks.44.attn.qkv_proj",
2652
+ "block": 44,
2653
+ "kind": "attn.qkv_proj",
2654
+ "shape": [
2655
+ 21504,
2656
+ 5376
2657
+ ],
2658
+ "sample_rows": 64,
2659
+ "absmax_error": 0.008935483172535896,
2660
+ "searched_error": 0.008860749192535877,
2661
+ "improvement": 7.473398000001907e-05,
2662
+ "clipped_row_fraction": 0.296875,
2663
+ "bf16_delta_bytes": 115519416
2664
+ },
2665
+ {
2666
+ "layer": "blocks.44.attn.out_proj",
2667
+ "block": 44,
2668
+ "kind": "attn.out_proj",
2669
+ "shape": [
2670
+ 5376,
2671
+ 7168
2672
+ ],
2673
+ "sample_rows": 64,
2674
+ "absmax_error": 0.010236470960080624,
2675
+ "searched_error": 0.010147100314497948,
2676
+ "improvement": 8.937064558267593e-05,
2677
+ "clipped_row_fraction": 0.3125,
2678
+ "bf16_delta_bytes": 38513592
2679
+ },
2680
+ {
2681
+ "layer": "blocks.44.mlp.fc1",
2682
+ "block": 44,
2683
+ "kind": "mlp.fc1",
2684
+ "shape": [
2685
+ 28672,
2686
+ 5376
2687
+ ],
2688
+ "sample_rows": 64,
2689
+ "absmax_error": 0.008784499950706959,
2690
+ "searched_error": 0.00872789416462183,
2691
+ "improvement": 5.6605786085128784e-05,
2692
+ "clipped_row_fraction": 0.21875,
2693
+ "bf16_delta_bytes": 154025912
2694
+ },
2695
+ {
2696
+ "layer": "blocks.44.mlp.fc2",
2697
+ "block": 44,
2698
+ "kind": "mlp.fc2",
2699
+ "shape": [
2700
+ 5376,
2701
+ 14336
2702
+ ],
2703
+ "sample_rows": 64,
2704
+ "absmax_error": 0.009541667997837067,
2705
+ "searched_error": 0.009210311807692051,
2706
+ "improvement": 0.0003313561901450157,
2707
+ "clipped_row_fraction": 0.953125,
2708
+ "bf16_delta_bytes": 77048760
2709
+ },
2710
+ {
2711
+ "layer": "blocks.45.attn.qkv_proj",
2712
+ "block": 45,
2713
+ "kind": "attn.qkv_proj",
2714
+ "shape": [
2715
+ 21504,
2716
+ 5376
2717
+ ],
2718
+ "sample_rows": 64,
2719
+ "absmax_error": 0.008662065491080284,
2720
+ "searched_error": 0.008622739464044571,
2721
+ "improvement": 3.9326027035713196e-05,
2722
+ "clipped_row_fraction": 0.234375,
2723
+ "bf16_delta_bytes": 115519416
2724
+ },
2725
+ {
2726
+ "layer": "blocks.45.attn.out_proj",
2727
+ "block": 45,
2728
+ "kind": "attn.out_proj",
2729
+ "shape": [
2730
+ 5376,
2731
+ 7168
2732
+ ],
2733
+ "sample_rows": 64,
2734
+ "absmax_error": 0.010617692954838276,
2735
+ "searched_error": 0.010556809604167938,
2736
+ "improvement": 6.088335067033768e-05,
2737
+ "clipped_row_fraction": 0.203125,
2738
+ "bf16_delta_bytes": 38513592
2739
+ },
2740
+ {
2741
+ "layer": "blocks.45.mlp.fc1",
2742
+ "block": 45,
2743
+ "kind": "mlp.fc1",
2744
+ "shape": [
2745
+ 28672,
2746
+ 5376
2747
+ ],
2748
+ "sample_rows": 64,
2749
+ "absmax_error": 0.00887010246515274,
2750
+ "searched_error": 0.008804753422737122,
2751
+ "improvement": 6.53490424156189e-05,
2752
+ "clipped_row_fraction": 0.265625,
2753
+ "bf16_delta_bytes": 154025912
2754
+ },
2755
+ {
2756
+ "layer": "blocks.45.mlp.fc2",
2757
+ "block": 45,
2758
+ "kind": "mlp.fc2",
2759
+ "shape": [
2760
+ 5376,
2761
+ 14336
2762
+ ],
2763
+ "sample_rows": 64,
2764
+ "absmax_error": 0.009545751847326756,
2765
+ "searched_error": 0.009240850806236267,
2766
+ "improvement": 0.00030490104109048843,
2767
+ "clipped_row_fraction": 0.859375,
2768
+ "bf16_delta_bytes": 77048760
2769
+ },
2770
+ {
2771
+ "layer": "blocks.46.attn.qkv_proj",
2772
+ "block": 46,
2773
+ "kind": "attn.qkv_proj",
2774
+ "shape": [
2775
+ 21504,
2776
+ 5376
2777
+ ],
2778
+ "sample_rows": 64,
2779
+ "absmax_error": 0.008876703679561615,
2780
+ "searched_error": 0.008820494636893272,
2781
+ "improvement": 5.620904266834259e-05,
2782
+ "clipped_row_fraction": 0.234375,
2783
+ "bf16_delta_bytes": 115519416
2784
+ },
2785
+ {
2786
+ "layer": "blocks.46.attn.out_proj",
2787
+ "block": 46,
2788
+ "kind": "attn.out_proj",
2789
+ "shape": [
2790
+ 5376,
2791
+ 7168
2792
+ ],
2793
+ "sample_rows": 64,
2794
+ "absmax_error": 0.010161706246435642,
2795
+ "searched_error": 0.010050925426185131,
2796
+ "improvement": 0.00011078082025051117,
2797
+ "clipped_row_fraction": 0.359375,
2798
+ "bf16_delta_bytes": 38513592
2799
+ },
2800
+ {
2801
+ "layer": "blocks.46.mlp.fc1",
2802
+ "block": 46,
2803
+ "kind": "mlp.fc1",
2804
+ "shape": [
2805
+ 28672,
2806
+ 5376
2807
+ ],
2808
+ "sample_rows": 64,
2809
+ "absmax_error": 0.008911539800465107,
2810
+ "searched_error": 0.008827130310237408,
2811
+ "improvement": 8.440949022769928e-05,
2812
+ "clipped_row_fraction": 0.265625,
2813
+ "bf16_delta_bytes": 154025912
2814
+ },
2815
+ {
2816
+ "layer": "blocks.46.mlp.fc2",
2817
+ "block": 46,
2818
+ "kind": "mlp.fc2",
2819
+ "shape": [
2820
+ 5376,
2821
+ 14336
2822
+ ],
2823
+ "sample_rows": 64,
2824
+ "absmax_error": 0.009484718553721905,
2825
+ "searched_error": 0.009192200377583504,
2826
+ "improvement": 0.00029251817613840103,
2827
+ "clipped_row_fraction": 0.828125,
2828
+ "bf16_delta_bytes": 77048760
2829
+ },
2830
+ {
2831
+ "layer": "blocks.47.attn.qkv_proj",
2832
+ "block": 47,
2833
+ "kind": "attn.qkv_proj",
2834
+ "shape": [
2835
+ 21504,
2836
+ 5376
2837
+ ],
2838
+ "sample_rows": 64,
2839
+ "absmax_error": 0.008795163594186306,
2840
+ "searched_error": 0.00872830580919981,
2841
+ "improvement": 6.685778498649597e-05,
2842
+ "clipped_row_fraction": 0.25,
2843
+ "bf16_delta_bytes": 115519416
2844
+ },
2845
+ {
2846
+ "layer": "blocks.47.attn.out_proj",
2847
+ "block": 47,
2848
+ "kind": "attn.out_proj",
2849
+ "shape": [
2850
+ 5376,
2851
+ 7168
2852
+ ],
2853
+ "sample_rows": 64,
2854
+ "absmax_error": 0.010367481037974358,
2855
+ "searched_error": 0.010297443717718124,
2856
+ "improvement": 7.003732025623322e-05,
2857
+ "clipped_row_fraction": 0.234375,
2858
+ "bf16_delta_bytes": 38513592
2859
+ },
2860
+ {
2861
+ "layer": "blocks.47.mlp.fc1",
2862
+ "block": 47,
2863
+ "kind": "mlp.fc1",
2864
+ "shape": [
2865
+ 28672,
2866
+ 5376
2867
+ ],
2868
+ "sample_rows": 64,
2869
+ "absmax_error": 0.008772429078817368,
2870
+ "searched_error": 0.00872031506150961,
2871
+ "improvement": 5.211401730775833e-05,
2872
+ "clipped_row_fraction": 0.203125,
2873
+ "bf16_delta_bytes": 154025912
2874
+ },
2875
+ {
2876
+ "layer": "blocks.47.mlp.fc2",
2877
+ "block": 47,
2878
+ "kind": "mlp.fc2",
2879
+ "shape": [
2880
+ 5376,
2881
+ 14336
2882
+ ],
2883
+ "sample_rows": 64,
2884
+ "absmax_error": 0.00934167392551899,
2885
+ "searched_error": 0.009070958010852337,
2886
+ "improvement": 0.0002707159146666527,
2887
+ "clipped_row_fraction": 0.796875,
2888
+ "bf16_delta_bytes": 77048760
2889
+ },
2890
+ {
2891
+ "layer": "blocks.48.attn.qkv_proj",
2892
+ "block": 48,
2893
+ "kind": "attn.qkv_proj",
2894
+ "shape": [
2895
+ 21504,
2896
+ 5376
2897
+ ],
2898
+ "sample_rows": 64,
2899
+ "absmax_error": 0.00887906365096569,
2900
+ "searched_error": 0.008829780854284763,
2901
+ "improvement": 4.9282796680927277e-05,
2902
+ "clipped_row_fraction": 0.15625,
2903
+ "bf16_delta_bytes": 115519416
2904
+ },
2905
+ {
2906
+ "layer": "blocks.48.attn.out_proj",
2907
+ "block": 48,
2908
+ "kind": "attn.out_proj",
2909
+ "shape": [
2910
+ 5376,
2911
+ 7168
2912
+ ],
2913
+ "sample_rows": 64,
2914
+ "absmax_error": 0.009912649169564247,
2915
+ "searched_error": 0.009812348522245884,
2916
+ "improvement": 0.00010030064731836319,
2917
+ "clipped_row_fraction": 0.328125,
2918
+ "bf16_delta_bytes": 38513592
2919
+ },
2920
+ {
2921
+ "layer": "blocks.48.mlp.fc1",
2922
+ "block": 48,
2923
+ "kind": "mlp.fc1",
2924
+ "shape": [
2925
+ 28672,
2926
+ 5376
2927
+ ],
2928
+ "sample_rows": 64,
2929
+ "absmax_error": 0.008999514393508434,
2930
+ "searched_error": 0.008927279151976109,
2931
+ "improvement": 7.223524153232574e-05,
2932
+ "clipped_row_fraction": 0.25,
2933
+ "bf16_delta_bytes": 154025912
2934
+ },
2935
+ {
2936
+ "layer": "blocks.48.mlp.fc2",
2937
+ "block": 48,
2938
+ "kind": "mlp.fc2",
2939
+ "shape": [
2940
+ 5376,
2941
+ 14336
2942
+ ],
2943
+ "sample_rows": 64,
2944
+ "absmax_error": 0.009443627670407295,
2945
+ "searched_error": 0.009146802127361298,
2946
+ "improvement": 0.0002968255430459976,
2947
+ "clipped_row_fraction": 0.84375,
2948
+ "bf16_delta_bytes": 77048760
2949
+ },
2950
+ {
2951
+ "layer": "blocks.49.attn.qkv_proj",
2952
+ "block": 49,
2953
+ "kind": "attn.qkv_proj",
2954
+ "shape": [
2955
+ 21504,
2956
+ 5376
2957
+ ],
2958
+ "sample_rows": 64,
2959
+ "absmax_error": 0.008813359774649143,
2960
+ "searched_error": 0.008786115795373917,
2961
+ "improvement": 2.7243979275226593e-05,
2962
+ "clipped_row_fraction": 0.171875,
2963
+ "bf16_delta_bytes": 115519416
2964
+ },
2965
+ {
2966
+ "layer": "blocks.49.attn.out_proj",
2967
+ "block": 49,
2968
+ "kind": "attn.out_proj",
2969
+ "shape": [
2970
+ 5376,
2971
+ 7168
2972
+ ],
2973
+ "sample_rows": 64,
2974
+ "absmax_error": 0.010824794881045818,
2975
+ "searched_error": 0.010720481164753437,
2976
+ "improvement": 0.00010431371629238129,
2977
+ "clipped_row_fraction": 0.296875,
2978
+ "bf16_delta_bytes": 38513592
2979
+ },
2980
+ {
2981
+ "layer": "blocks.49.mlp.fc1",
2982
+ "block": 49,
2983
+ "kind": "mlp.fc1",
2984
+ "shape": [
2985
+ 28672,
2986
+ 5376
2987
+ ],
2988
+ "sample_rows": 64,
2989
+ "absmax_error": 0.008785880170762539,
2990
+ "searched_error": 0.008741860277950764,
2991
+ "improvement": 4.401989281177521e-05,
2992
+ "clipped_row_fraction": 0.15625,
2993
+ "bf16_delta_bytes": 154025912
2994
+ },
2995
+ {
2996
+ "layer": "blocks.49.mlp.fc2",
2997
+ "block": 49,
2998
+ "kind": "mlp.fc2",
2999
+ "shape": [
3000
+ 5376,
3001
+ 14336
3002
+ ],
3003
+ "sample_rows": 64,
3004
+ "absmax_error": 0.009804457426071167,
3005
+ "searched_error": 0.009507114998996258,
3006
+ "improvement": 0.0002973424270749092,
3007
+ "clipped_row_fraction": 0.8125,
3008
+ "bf16_delta_bytes": 77048760
3009
+ }
3010
+ ]
3011
+ }
reports/validation.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "release_date": "2026-08-04",
3
+ "checkpoint": "FL2VA/minimax-h3-fl2va-int8-lean-convrot-dynamic-k16-quality21.safetensors",
4
+ "bytes": 22547336976,
5
+ "gib": 20.998843923211098,
6
+ "sha256": "c57e85fc299ca399a5c84e7888b0f61c532da05ddbf3f92e521690b07cb72b0a",
7
+ "tensor_keys": 877,
8
+ "dtype_key_counts": {
9
+ "F32": 287,
10
+ "BF16": 250,
11
+ "I8": 170,
12
+ "U8": 170
13
+ },
14
+ "checks": {
15
+ "safetensors_open": "pass",
16
+ "int8_quant_blobs": "170/170, ConvRot group size 256",
17
+ "bf16_main_policy": "30/30 present and bitwise equal to raw HF",
18
+ "fp32_time_embedder": "4/4 tensors bitwise equal to raw HF",
19
+ "basis_orthogonality_max_abs": 5.364418029785156e-7,
20
+ "adaln_relative_error_9_timesteps": {
21
+ "block_0": 3.260e-7,
22
+ "block_24": 3.290e-7,
23
+ "block_49": 3.192e-7,
24
+ "final": 2.820e-7
25
+ },
26
+ "comfyui_cpu_load": "pass: ModelPatcher -> MiniMaxH3Model; dynamic basis enabled; table mode disabled",
27
+ "comfyui_tested_commit": "14b05228cef127ce529bc0c08660770d4af3e9a8"
28
+ },
29
+ "sampled_main_matrix_proxy": {
30
+ "method": "deterministic 64 output rows per matrix, all input columns, 200/200 main matrices",
31
+ "official_absmax_mean_relative_error_percent": 0.934502442367375,
32
+ "quality21_effective_mean_relative_error_percent": 0.7638806365430355,
33
+ "relative_reduction_percent": 18.258037442053465,
34
+ "selected_bf16_official_proxy_mean_percent": 1.0684306019296248,
35
+ "remaining_int8_absmax_mean_percent": 0.9108680612681544,
36
+ "remaining_int8_searched_scale_mean_percent": 0.898683101815336,
37
+ "remaining_int8_relative_reduction_percent": 1.3377304541619235,
38
+ "warning": "This is a weight-reconstruction proxy, not an end-to-end generation or perceptual benchmark."
39
+ },
40
+ "not_yet_tested": [
41
+ "GPU load through ComfyUI",
42
+ "peak VRAM at a target resolution/frame count",
43
+ "end-to-end FL2VA generation",
44
+ "same-seed visual/audio A/B against BF16 and official pruned checkpoints"
45
+ ]
46
+ }
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ safetensors
3
+ comfy-kitchen
tools/README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Reproduction tools
2
+
3
+ These are the exact converter, profiler, and validator used for this release,
4
+ with local paths replaced by CLI arguments. They are research utilities, not a
5
+ general MiniMax-H3 conversion library.
6
+
7
+ Requirements:
8
+
9
+ - Python 3.10+
10
+ - PyTorch
11
+ - `safetensors`
12
+ - `comfy-kitchen` from a current ComfyUI environment
13
+
14
+ The converter reads the original top-level Diffusers shards directly; it does
15
+ not need a merged BF16 file. Use `MiniMaxAI/MiniMax-H3`'s `transformer/` folder,
16
+ not the nested task folder whose already-packed QKV uses a different row order.
17
+ It also uses the official pruned ComfyOrg file as a structural reference and to
18
+ copy `rope.inv_freq`, which is absent from the raw Diffusers state dict.
19
+
20
+ Dry run:
21
+
22
+ ```bash
23
+ python tools/mm_quantize_lean.py fl2va \
24
+ --src /path/to/MiniMax-H3/transformer \
25
+ --reference /path/to/minimax_h3_fl2va_pruned_int8_convrot.safetensors \
26
+ --dst /path/to/output.safetensors \
27
+ --profile quality21 --time-mode dynamic --rank 16 --device cpu --dry-run
28
+ ```
29
+
30
+ Build on CPU:
31
+
32
+ ```bash
33
+ python tools/mm_quantize_lean.py fl2va \
34
+ --src /path/to/MiniMax-H3/transformer \
35
+ --reference /path/to/minimax_h3_fl2va_pruned_int8_convrot.safetensors \
36
+ --dst /path/to/output.safetensors \
37
+ --profile quality21 --time-mode dynamic --rank 16 --device cpu --overwrite
38
+ ```
39
+
40
+ Validate:
41
+
42
+ ```bash
43
+ python tools/mm_validate_dynamic_built.py fl2va /path/to/output.safetensors \
44
+ --src /path/to/MiniMax-H3/transformer --profile quality21
45
+ ```
46
+
47
+ The public scripts preserve the exact mapping and quantization behavior used by
48
+ the release. Some diagnostic messages remain in Russian because these files are
49
+ the audited build sources rather than a rewritten approximation.
tools/convert_int8_convrot.py ADDED
@@ -0,0 +1,556 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ r"""Конвертер моделей ComfyUI в INT8 ConvRot.
3
+
4
+ Берёт safetensors (bf16/fp16/fp32) и квантует линейные слои в int8 с поворотом
5
+ Адамара, как это делают официальные сборки Comfy-Org (int8_tensorwise + convrot).
6
+
7
+ Не трогает: нормализации, эмбеддеры, bias, 1D-тензоры и матрицы, у которых
8
+ входная размерность не кратна размеру группы — они остаются в исходной точности.
9
+
10
+ Запуск:
11
+ python_embeded\python.exe -s tools\convert_int8_convrot.py <вход.safetensors> <выход.safetensors>
12
+ [--groupsize 256] [--device cuda:0] [--dry-run]
13
+ """
14
+ import argparse
15
+ import json
16
+ import os
17
+ import re
18
+ import sys
19
+ import time
20
+
21
+ import torch
22
+ from safetensors import safe_open
23
+ from safetensors.torch import save_file
24
+
25
+
26
+ class HFShardReader:
27
+ """Читает HF-репозиторий (папку с шардами) так же, как safe_open один файл.
28
+
29
+ Нужно, чтобы квантовать прямо из оригинала, не складывая на диск
30
+ промежуточный файл на десятки гигабайт. Значения при этом те же самые:
31
+ склейка ничего не меняла, но лишняя запись и чтение никому не нужны.
32
+
33
+ Имена приводятся к раскладке ComfyUI теми же правилами, что в
34
+ merge_hf_to_comfy.py, визуальная часть остаётся на месте.
35
+ """
36
+
37
+ RENAME = [
38
+ ("model.language_model.", "model."),
39
+ ("language_model.model.", "model."),
40
+ ("language_model.", ""),
41
+ ("vision_tower.", ""),
42
+ ]
43
+
44
+ def __init__(self, path: str):
45
+ import glob
46
+ self._files = {}
47
+ self._map = {}
48
+ shards = sorted(glob.glob(os.path.join(path, "*.safetensors")))
49
+ if not shards:
50
+ raise SystemExit(f"в папке нет файлов safetensors: {path}")
51
+ for shard in shards:
52
+ f = safe_open(shard, framework="pt")
53
+ self._files[shard] = f
54
+ for k in f.keys():
55
+ self._map[self._rename(k)] = (shard, k)
56
+ print(f" прочитано шардов: {len(shards)}, тензоров: {len(self._map)}")
57
+
58
+ @classmethod
59
+ def _rename(cls, key: str) -> str:
60
+ for old, new in cls.RENAME:
61
+ if key.startswith(old):
62
+ rest = key[len(old):]
63
+ return rest if rest.startswith("model.") or not new else new + rest
64
+ return key
65
+
66
+ def keys(self):
67
+ return list(self._map)
68
+
69
+ def get_tensor(self, key: str):
70
+ shard, orig = self._map[key]
71
+ return self._files[shard].get_tensor(orig)
72
+
73
+ def metadata(self):
74
+ return {"format": "pt"}
75
+
76
+ def __enter__(self):
77
+ return self
78
+
79
+ def __exit__(self, *exc):
80
+ self._files.clear()
81
+
82
+ sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "ComfyUI"))
83
+
84
+ # Слои, которые официальные сборки Comfy-Org оставляют в исходной точности:
85
+ # нормализации, эмбеддеры, входной/выходной слой. Их квантование заметно бьёт по качеству.
86
+ SKIP_TOKENS = (
87
+ # диффузионные трансформеры
88
+ # "_emb." с точкой, а не "_emb": иначе под запрет попадают модули вида
89
+ # video_embeddings_connector - а это обычные блоки внимания и полносвязные
90
+ # слои на 4 ГБ, которые квантовать можно и нужно
91
+ "norm", "embedder", "pad_token", "emb.", "_emb.",
92
+ "final_layer", "x_embedder", "proj_out", "time_in", "vector_in",
93
+ # Слои модуляции: выдают масштаб и сдвиг для каждого блока, поэтому ошибка
94
+ # в них умножается на всю сеть. Мы их не квантуем НИКОГДА - это наше решение
95
+ # по замеру, а не подражание чужим сборкам.
96
+ #
97
+ # Единодушия у авторов тут нет, пересчитано по файлам на диске 31.07.2026:
98
+ # LTX 2.3 0 из 24 квантовано
99
+ # Anima 0 из 170
100
+ # Z-Image 32 из 33 <- квантует, вопреки прежней записи в этом коде
101
+ # Поэтому по Z-Image и Ideogram сверка audit_reference_int8.py всегда будет
102
+ # показывать ~84 %, и это ОСОЗНАННОЕ расхождение, а не промах правила.
103
+ "adaln", "modulation",
104
+ # входные проекции (diffusers-нейминг): в эталонных сборках Comfy-Org,
105
+ # obsxrver и supermind они всегда остаются в исходной точности - проверено
106
+ # по файлам LTX 2.3, Z-Image, Krea 2 и Qwen-Image
107
+ "img_in", "txt_in", "patch_embed", "context_embedder",
108
+ # языковые модели (текст-энкодеры)
109
+ "lm_head", "embed_tokens", "token_embd", "shared.", "wte", "wpe",
110
+ # части полных чекпоинтов, которые квантовать нельзя: VAE свёрточный и к
111
+ # int8 чувствителен, текстовая проекция маленькая и стоит на входе, а
112
+ # per_channel_statistics - это вообще не веса, а нормировочные константы
113
+ "vae.", "text_embedding_projection", "per_channel_statistics", "vocoder.",
114
+ )
115
+
116
+ # Коэффициенты подрезания выбросов при подборе масштаба.
117
+ # У диффузионных моделей оптимум почти всегда в 0.95-1.00 (медиана 0.982), поэтому
118
+ # основная часть сетки плотная: шаг 0.001 в диапазоне 1.000-0.940. Но у текст-энкодеров
119
+ # хвосты тяжелее: у qwen2.5-VL 3.2% строк упирались в край 0.940, то есть их оптимум
120
+ # лежал ещё ниже и просто не находился. Поэтому дальше идёт разреженный хвост до 0.80 -
121
+ # он почти не стоит времени, зато снимает обрезание перебора. См. tools/check_range.py.
122
+ def build_ratios(lo: float = 0.80) -> tuple:
123
+ """Сетка от 1.0 вниз до lo: плотно у единицы, дальше всё разреженнее."""
124
+ out = [round(1.0 - i * 0.001, 4) for i in range(61)] # 1.000 .. 0.940
125
+ out += [round(0.938 - i * 0.002, 4) for i in range(20)] # 0.938 .. 0.900
126
+ out += [round(0.895 - i * 0.005, 4) for i in range(20)] # 0.895 .. 0.800
127
+ return tuple(r for r in out if r >= lo - 1e-9)
128
+
129
+
130
+ SEARCH_RATIOS = build_ratios()
131
+
132
+
133
+ # Поворот Адамара строится удвоением матрицы 4x4, поэтому размер группы обязан
134
+ # быть степенью четвёрки (см. _build_hadamard: "Regular Hadamard size must be a
135
+ # power of 4"). Отсюда и лесенка: 256 -> 64 -> 16.
136
+ GROUPSIZE_LADDER = (256, 64, 16)
137
+
138
+ _DIGITS = re.compile(r"\d+")
139
+ # Порог повторяемости. Два - это ещё не стопка: linear_fc1/linear_fc2 одного
140
+ # модуля дают ровно два совпадения по шаблону.
141
+ REPEAT_MIN = 3
142
+
143
+
144
+ def block_patterns(layer: str) -> tuple[str, ...]:
145
+ """Варианты имени, где обезличена ровно одна числовая позиция.
146
+
147
+ Одновременная замена всех цифр смешивала независимые роли. Например,
148
+ ``blocks.0.mlp.fc1`` и ``blocks.1.mlp.fc2`` превращались в один шаблон.
149
+ Из-за этого два блока token_refiner с fc1/fc2 давали ложную стопку из
150
+ четырёх слоёв и проходили порог повторяемости 3.
151
+ """
152
+ return tuple(layer[:m.start()] + "#" + layer[m.end():] for m in _DIGITS.finditer(layer))
153
+
154
+
155
+ def repeated_layers(layer_names, repeat_min: int = REPEAT_MIN) -> set:
156
+ """Слои, которые входят в повторяющуюся стопку блоков.
157
+
158
+ Зачем это вместо списка подстрок. Эталонные сборки квантуют тело сети и
159
+ оставляют в исходной точности края: входные проекции, выходные головы,
160
+ таблицы вложений, мост зрение->язык. Объединяет их не название, а то, что
161
+ они существуют в единственном экземпляре, тогда как тело - это одна и та же
162
+ ноd, повторённая по числу блоков. Номер блока в имени и есть тот признак,
163
+ который отличает тело от края, и он не зависит от того, как автор модели
164
+ назвал свои модули.
165
+
166
+ Проверено сверкой с эталонами (tools/audit_reference_int8.py): по этому
167
+ признаку сами собой отсеиваются lm_head, embed_tokens, patchify_proj,
168
+ visual.merger, visual.pos_embed, adaln_single.emb.* - всё то, что раньше
169
+ приходилось перечислять руками.
170
+ """
171
+ counts: dict[str, int] = {}
172
+ for name in layer_names:
173
+ for pattern in set(block_patterns(name)):
174
+ counts[pattern] = counts.get(pattern, 0) + 1
175
+ return {
176
+ name for name in layer_names
177
+ if any(counts[pattern] >= repeat_min for pattern in block_patterns(name))
178
+ }
179
+
180
+
181
+ def pick_groupsize(out_f: int, in_f: int, groupsize) -> int | None:
182
+ """Какую группу взять этому слою. Число - взять его же или отказать.
183
+
184
+ "auto" спускается по лесенке до первой группы, на которую делится входная
185
+ размерность. Это нужно зрительным башням: у Qwen3-VL ширина 1152 и 4304, ни
186
+ одна из них не кратна 256, поэтому при фиксированной группе всё зрение
187
+ оставалось в bf16. Эталонные сборки supermind делают ровно так же - проверено
188
+ по comfy_quant в qwen3vl_8b_int8_convrot: 256 у языковой части, 64 у
189
+ visual.attn, 16 у visual.mlp.linear_fc2.
190
+ """
191
+ if groupsize != "auto":
192
+ g = int(groupsize)
193
+ return g if in_f % g == 0 and min(out_f, in_f) >= g else None
194
+ # Мелкая группа - способ достать слой с неудобной шириной, а не разрешение
195
+ # квантовать что угодно узкое. Порог по узкой стороне остаётся базовым (256),
196
+ # иначе в отбор лезут краевые слои: gate_logits (32 x 4096) и входные
197
+ # проекции с пикселей patchify_proj (4096 x 128). Эталонные сборки LTX их не
198
+ # берут - сверено поимённо в tools/audit_reference_int8.py.
199
+ if min(out_f, in_f) < GROUPSIZE_LADDER[0]:
200
+ return None
201
+ for g in GROUPSIZE_LADDER:
202
+ if in_f % g == 0:
203
+ return g
204
+ return None
205
+
206
+
207
+ def should_quantize(name: str, t: torch.Tensor, groupsize,
208
+ skip_tokens=None, repeated=None) -> tuple[bool, str, int]:
209
+ if not name.endswith(".weight"):
210
+ return False, "не weight", 0
211
+ if t.ndim != 2:
212
+ return False, f"ndim={t.ndim}", 0
213
+ if repeated is not None and name[: -len(".weight")] not in repeated:
214
+ return False, "одиночный слой (не повторяется по блокам)", 0
215
+ low = name.lower()
216
+ for tok in (SKIP_TOKENS if skip_tokens is None else skip_tokens):
217
+ if tok in low:
218
+ return False, f"имя содержит '{tok}'", 0
219
+ out_f, in_f = t.shape
220
+ g = pick_groupsize(out_f, in_f, groupsize)
221
+ if g is None:
222
+ if in_f % (int(groupsize) if groupsize != "auto" else GROUPSIZE_LADDER[-1]):
223
+ return False, f"in_features {in_f} не кратно {groupsize}", 0
224
+ return False, f"слишком маленький слой {tuple(t.shape)}", 0
225
+ return True, "", g
226
+
227
+
228
+ def _cost(residual: torch.Tensor, objective: str, step: torch.Tensor,
229
+ chan_w: torch.Tensor | None = None) -> torch.Tensor:
230
+ """Во что нам обходится остаток. Сетка значений всегда равномерная - ядро
231
+ разжимает строго как q*scale, кодбука в формате нет. Свободен только критерий,
232
+ по которому выбирается точка подрезания, и от него зависит, насколько сильно
233
+ мы готовы жертвовать выбросами ради основной массы весов.
234
+
235
+ mse - квадрат: выбросы дороги, подрезаем осторожно
236
+ l1 - модуль: выбросы дешевле, подрезаем смелее
237
+ huber - квадрат вблизи нуля, модуль дальше: компромисс
238
+ """
239
+ # Взвешивание по каналам (AWQ-стиль): ошибка в канале, по которому приходят
240
+ # большие активации, стоит дороже. chan_w - средний квадрат входа по каналам,
241
+ # снятый capture_activations.py уже в повёрнутом пространстве. Это в точности
242
+ # диагональ гессиана слоя, то есть переход от "ошибки весов" к "ошибке выхода".
243
+ if objective == "mse":
244
+ sq = residual ** 2
245
+ if chan_w is not None:
246
+ sq = sq * chan_w
247
+ return sq.sum(dim=1, keepdim=True)
248
+ if objective == "l1":
249
+ a = residual.abs()
250
+ if chan_w is not None:
251
+ a = a * chan_w
252
+ return a.sum(dim=1, keepdim=True)
253
+ if objective == "huber":
254
+ d = step # порог - один шаг кванта
255
+ a = residual.abs()
256
+ quad = torch.minimum(a, d)
257
+ h = 0.5 * quad ** 2 + d * (a - quad)
258
+ if chan_w is not None:
259
+ h = h * chan_w
260
+ return h.sum(dim=1, keepdim=True)
261
+ raise SystemExit(f"неизвестный критерий {objective}")
262
+
263
+
264
+ def quantize_search(w: torch.Tensor, groupsize: int, ratios,
265
+ objective: str = "mse",
266
+ qmin: int = -127,
267
+ sign_aware: bool = False,
268
+ ls_refit: bool = False,
269
+ chan_w: torch.Tensor | None = None,
270
+ clip_margin: float = 0.0) -> tuple[torch.Tensor, torch.Tensor]:
271
+ """INT8 ConvRot с подбором масштаба по минимуму ошибки (вместо простого absmax).
272
+
273
+ Официальные сборки берут scale = absmax/127. Небольшое подрезание выбросов
274
+ почти всегда уменьшает суммарную ошибку: редкие большие веса округляются
275
+ чуть грубее, зато основная масса значений ложится на сетку точнее.
276
+ """
277
+ from comfy_kitchen.backends.eager.quantization import _build_hadamard, _rotate_weight
278
+
279
+ h = _build_hadamard(groupsize, device=w.device, dtype=w.dtype)
280
+ w_rot = _rotate_weight(w, h, groupsize)
281
+
282
+ absmax = w_rot.abs().amax(dim=1, keepdim=True).clamp(min=1e-12)
283
+ best_scale = absmax / 127.0
284
+ best_err = torch.full_like(absmax, float("inf"))
285
+
286
+ if sign_aware:
287
+ # Единственный честный способ дотянуться до -128: разрешать его только
288
+ # тем строкам, у которых отрицательный хвост и так длиннее положительного.
289
+ # Тогда несимметричная сетка не создаёт перекос, а повторяет уже имеющийся.
290
+ neg_heavy = w_rot.amin(dim=1, keepdim=True).abs() > w_rot.amax(dim=1, keepdim=True)
291
+ lo = torch.where(neg_heavy, -128.0, -127.0).to(w_rot.dtype)
292
+ else:
293
+ lo = torch.full_like(absmax, float(qmin))
294
+ hi = torch.full_like(absmax, 127.0)
295
+
296
+ # qmin=-127 (симметрично) по умолчанию. Значение -128 формально доступно и
297
+ # уменьшает ошибку весов, но вносит односторонний сдвиг: сетка перестаёт быть
298
+ # симметричной, у ошибки появляется ненулевое среднее, и на генерации это
299
+ # выходит дороже выигрыша. Проверено на стенде - см. bench_quant.py.
300
+ for r in ratios:
301
+ scale = absmax * r / 127.0
302
+ q = torch.minimum(torch.maximum(torch.round(w_rot / scale), lo), hi)
303
+ err = _cost(q * scale - w_rot, objective, scale, chan_w)
304
+ better = err < best_err
305
+ best_err = torch.where(better, err, best_err)
306
+ best_scale = torch.where(better, scale, best_scale)
307
+
308
+ if clip_margin > 0.0:
309
+ # Порог на подрезание. Эталонные сборки оставляют без подрезания заметно
310
+ # больше строк, чем даёт чистый минимум MSE (у qwen3-4b 9.4% против наших
311
+ # 2-3%), и на выходе энкодера это оказывается лучше. Похоже, у выбросов
312
+ # есть функциональная роль, которую квадрат ошибки не видит. Поэтому режем
313
+ # только там, где выигрыш действительно заметный.
314
+ s0 = absmax / 127.0
315
+ q0 = torch.minimum(torch.maximum(torch.round(w_rot / s0), lo), hi)
316
+ e0 = _cost(q0 * s0 - w_rot, objective, s0, chan_w)
317
+ keep = best_err >= e0 * (1.0 - clip_margin)
318
+ best_scale = torch.where(keep, s0, best_scale)
319
+ del q0
320
+
321
+ q = torch.minimum(torch.maximum(torch.round(w_rot / best_scale), lo), hi)
322
+
323
+ if ls_refit:
324
+ # При фиксированных целых q оптимальный по МНК масштаб - это (q·w)/(q·q),
325
+ # а не absmax/127. Пересчёт убирает систематический сдвиг реконструкции,
326
+ # который и появляется, когда сетка перестаёт быть симметричной.
327
+ num = (q * w_rot).sum(dim=1, keepdim=True)
328
+ den = (q * q).sum(dim=1, keepdim=True).clamp(min=1.0)
329
+ best_scale = torch.where(num > 0, num / den, best_scale)
330
+
331
+ return q.to(torch.int8), best_scale.to(torch.float32)
332
+
333
+
334
+ def quantize_int4(w: torch.Tensor, groupsize: int):
335
+ """Тот же поворот Адамара, но 4 бита вместо 8.
336
+
337
+ Ядро читает такой слой по маркеру format=convrot_w4a4 и жёстко ожидает
338
+ quant_group_size=64 (см. comfy/ops.py, ветка convrot_w4a4), поэтому размер
339
+ группы квантования не настраиваем.
340
+ """
341
+ from comfy_kitchen.tensor.convrot_w4a4 import TensorCoreConvRotW4A4Layout
342
+ qdata, params = TensorCoreConvRotW4A4Layout.quantize(
343
+ w, convrot_groupsize=groupsize, quant_group_size=64, linear_dtype="int4")
344
+ return qdata, params.scale
345
+
346
+
347
+ def int4_error(w: torch.Tensor, groupsize: int) -> float:
348
+ """Во сколько раз 4 бита дороже 8 на этом слое. Нужно, чтобы выбрать,
349
+ какие слои не жалко ужать сильнее."""
350
+ from comfy_kitchen.tensor.convrot_w4a4 import TensorCoreConvRotW4A4Layout
351
+ q8, s8 = quantize_search(w, groupsize, SEARCH_RATIOS)
352
+ from comfy_kitchen.tensor.int8 import TensorWiseINT8Layout
353
+ p8 = TensorWiseINT8Layout.Params(scale=s8, orig_dtype=torch.float32,
354
+ orig_shape=tuple(q8.shape), is_weight=True,
355
+ convrot=True, convrot_groupsize=groupsize)
356
+ e8 = (TensorWiseINT8Layout.dequantize(q8.to(w.device), p8) - w).norm().item()
357
+
358
+ q4, params4 = TensorCoreConvRotW4A4Layout.quantize(
359
+ w, convrot_groupsize=groupsize, quant_group_size=64, linear_dtype="int4")
360
+ e4 = (TensorCoreConvRotW4A4Layout.dequantize(q4, params4).float() - w).norm().item()
361
+ return e4 / max(e8, 1e-12)
362
+
363
+
364
+ def load_calib(path: str, alpha: float, device: str):
365
+ """Статистика активаций из capture_activations.py -> веса каналов."""
366
+ if not path:
367
+ return None
368
+ blob = torch.load(path, map_location="cpu")
369
+ stats = blob["stats"]
370
+ out = {}
371
+ for name, v in stats.items():
372
+ w = v.to(device=device, dtype=torch.float32).clamp(min=1e-12)
373
+ w = w / w.mean() # нормируем, чтобы масштаб ошибки не поехал
374
+ out[name] = w.pow(alpha).reshape(1, -1)
375
+ print(f"калибровка: {path}\n слоёв {len(out)}, промптов {blob.get('prompts')}, "
376
+ f"шагов {blob.get('steps')}, показатель {alpha}")
377
+ return out
378
+
379
+
380
+ def calib_for(calib, tensor_name: str):
381
+ """Ключи калибровки - пути модулей, ключи файла - они же плюс '.weight'."""
382
+ if not calib:
383
+ return None
384
+ layer = tensor_name[: -len(".weight")]
385
+ if layer in calib:
386
+ return calib[layer]
387
+ for prefix in ("model.diffusion_model.", "diffusion_model.", "model."):
388
+ if layer.startswith(prefix) and layer[len(prefix):] in calib:
389
+ return calib[layer[len(prefix):]]
390
+ return None
391
+
392
+
393
+ def convert(src: str, dst: str, groupsize: int, device: str, dry_run: bool,
394
+ search: bool = False, objective: str = "mse", qmin: int = -127,
395
+ sign_aware: bool = False, ls_refit: bool = False,
396
+ calib_path: str = "", calib_alpha: float = 1.0,
397
+ search_min: float = 0.80, clip_margin: float = 0.0,
398
+ quant_adaln: bool = False, skip_connectors: bool = False,
399
+ select: str = "names", drop_prefixes: tuple = (),
400
+ passthrough_dtype: str = "") -> None:
401
+ t0 = time.time()
402
+ ratios = build_ratios(search_min)
403
+ skip = SKIP_TOKENS
404
+ if skip_connectors:
405
+ # Вернуть старое поведение: не трогать *_embeddings_connector. Это 96 слоёв
406
+ # обычного внимания и полносвязных на 4 ГБ, которые эталонные сборки
407
+ # пропускают. Нужно, чтобы отделить вклад коннекторов от вклада подрезания.
408
+ skip = tuple(t for t in skip if t != "_emb.") + ("_emb",)
409
+ print("режим: коннекторы НЕ квантуются (как в эталонных сборках)")
410
+ if quant_adaln:
411
+ # AdaLN задаёт масштаб и сдвиг каждому блоку, поэтому его везде защищают.
412
+ # Но это восьмибитный шаг, а не четырёхбитный - проверяем замером, а не верой.
413
+ skip = tuple(t for t in SKIP_TOKENS if t not in ("adaln", "modulation"))
414
+ print("режим: AdaLN тоже квантуется")
415
+ if groupsize == "auto":
416
+ print(f"режим: группа подбирается послойно по лесенке {GROUPSIZE_LADDER}")
417
+ out: dict[str, torch.Tensor] = {}
418
+ quantized = skipped = 0
419
+ skip_reasons: dict[str, int] = {}
420
+ gs_used: dict[int, int] = {}
421
+ calib = load_calib(calib_path, calib_alpha, device)
422
+ calib_hits = 0
423
+
424
+ # папка = HF-репозиторий, читаем шарды напрямую; файл = как раньше
425
+ opener = HFShardReader(src) if os.path.isdir(src) else safe_open(src, framework="pt")
426
+ with opener as f:
427
+ keys = list(f.keys())
428
+ # ComfyUI читает конфигурацию модели из метаданных файла (model_detection.py:
429
+ # dit_config.update(json.loads(metadata["config"])...). Без них он строит
430
+ # ��одель по умолчанию, и чекпоинт не грузится: "size mismatch for
431
+ # scale_shift_table: [9, 4096] vs [6, 4096]". Переносим как есть.
432
+ meta = f.metadata()
433
+ print(f"вход: {src}\n тензоров: {len(keys)}"
434
+ f"{', метаданных: ' + str(len(meta)) if meta else ', метаданных нет'}")
435
+
436
+ repeated = None
437
+ if select in ("structure", "both"):
438
+ names = [k[: -len(".weight")] for k in keys if k.endswith(".weight")]
439
+ repeated = repeated_layers(names)
440
+ print(f" повторяющихся по блокам слоёв: {len(repeated)} из {len(names)}")
441
+ if select == "structure":
442
+ skip = () # имена больше не участвуют, отбор чисто структурный
443
+
444
+ for i, k in enumerate(keys, 1):
445
+ if drop_prefixes and k.startswith(drop_prefixes):
446
+ skip_reasons["выброшен(--drop)"] = skip_reasons.get("выброшен(--drop)", 0) + 1
447
+ continue
448
+ t = f.get_tensor(k)
449
+ ok, why, gs = should_quantize(k, t, groupsize, skip, repeated)
450
+ if not ok:
451
+ skipped += 1
452
+ skip_reasons[why.split()[0]] = skip_reasons.get(why.split()[0], 0) + 1
453
+ if passthrough_dtype == "bf16" and t.dtype == torch.float32:
454
+ t = t.to(torch.bfloat16)
455
+ out[k] = t
456
+ continue
457
+ gs_used[gs] = gs_used.get(gs, 0) + 1
458
+
459
+ if dry_run:
460
+ quantized += 1
461
+ continue
462
+
463
+ # поворот и подбор масштаба считаем в float32: в bf16 сама ротация
464
+ # вносит заметную ошибку (проверено на эталонных сборках)
465
+ w = t.to(device=device, dtype=torch.float32)
466
+ # оба режима идут через один и тот же код: absmax - это просто подбор
467
+ # по единственному коэффициенту 1.0
468
+ cw = calib_for(calib, k)
469
+ calib_hits += cw is not None
470
+ qdata, scale = quantize_search(
471
+ w, gs, ratios if search else (1.0,), objective, qmin,
472
+ sign_aware, ls_refit, cw, clip_margin)
473
+ layer = k[: -len(".weight")]
474
+ out[k] = qdata.cpu()
475
+ out[f"{layer}.weight_scale"] = scale.cpu()
476
+ conf = {"format": "int8_tensorwise", "convrot": True, "convrot_groupsize": gs}
477
+ out[f"{layer}.comfy_quant"] = torch.tensor(
478
+ list(json.dumps(conf).encode("utf-8")), dtype=torch.uint8)
479
+ quantized += 1
480
+ del w, qdata, scale
481
+
482
+ if i % 50 == 0 or i == len(keys):
483
+ done = quantized + skipped
484
+ print(f" [{done}/{len(keys)}] квантовано {quantized}, пропущено {skipped}",
485
+ flush=True)
486
+
487
+ print(f"\nитог: квантовано {quantized}, оставлено {skipped}")
488
+ print(" причины пропуска:", skip_reasons)
489
+ print(" размеры групп:", dict(sorted(gs_used.items(), reverse=True)))
490
+ if calib:
491
+ print(f" калибровка нашлась для {calib_hits} из {quantized} слоёв")
492
+ if calib_hits < quantized:
493
+ print(" ВНИМАНИЕ: часть слоёв квантована без калибровки - проверь имена")
494
+ if dry_run:
495
+ print("(dry-run: файл не записан)")
496
+ return
497
+
498
+ os.makedirs(os.path.dirname(os.path.abspath(dst)), exist_ok=True)
499
+ save_file(out, dst, metadata=meta if meta else None)
500
+ src_gb = os.path.getsize(src) / 1e9
501
+ dst_gb = os.path.getsize(dst) / 1e9
502
+ print(f"\nзаписано: {dst}\n {src_gb:.2f} GB -> {dst_gb:.2f} GB за {time.time()-t0:.0f} c")
503
+
504
+
505
+ if __name__ == "__main__":
506
+ ap = argparse.ArgumentParser()
507
+ ap.add_argument("src")
508
+ ap.add_argument("dst")
509
+ ap.add_argument("--groupsize", default=256,
510
+ type=lambda v: v if v == "auto" else int(v),
511
+ help="число или auto — тогда группа подбирается послойно "
512
+ f"по лесенке {GROUPSIZE_LADDER}, как в эталонных сборках")
513
+ ap.add_argument("--device", default="cuda:0")
514
+ ap.add_argument("--dry-run", action="store_true")
515
+ ap.add_argument("--no-search-scale", action="store_true",
516
+ help="взять простой absmax вместо подбора масштаба (быстрее, но хуже эталона)")
517
+ ap.add_argument("--objective", default="mse", choices=("mse", "l1", "huber"),
518
+ help="критерий выбора точки подрезания выбросов")
519
+ ap.add_argument("--asymmetric", action="store_true",
520
+ help="р��зрешить -128 всем строкам (ошибка весов меньше, на генерации хуже)")
521
+ ap.add_argument("--sign-aware", action="store_true",
522
+ help="разрешать -128 только строкам с длинным отрицательным хвостом")
523
+ ap.add_argument("--ls-refit", action="store_true",
524
+ help="пересчитать масштаб по МНК после выбора целых значений")
525
+ ap.add_argument("--calib", default="",
526
+ help="файл статистики активаций от capture_activations.py")
527
+ ap.add_argument("--calib-alpha", type=float, default=1.0,
528
+ help="показатель степени для веса канала: 1.0 - диагональ гессиана, "
529
+ "0.5 - мягче, 0.0 - как без калибровки")
530
+ ap.add_argument("--search-min", type=float, default=0.80,
531
+ help="нижняя граница перебора коэффициентов подрезания")
532
+ ap.add_argument("--skip-connectors", action="store_true",
533
+ help="не квантовать *_embeddings_connector, как в эталонных сборках")
534
+ ap.add_argument("--quant-adaln", action="store_true",
535
+ help="квантовать и слои модуляции AdaLN (ещё ~0.34 ГБ экономии)")
536
+ ap.add_argument("--clip-margin", type=float, default=0.0,
537
+ help="подрезать строку, только если ошибка падает больше чем на эту долю "
538
+ "(0.03 = на 3%%); иначе оставить absmax")
539
+ ap.add_argument("--select", default="names", choices=("names", "structure", "both"),
540
+ help="как отбирать слои: names — по списку подстрок (как раньше); "
541
+ "structure — по повторяемости в стопке блоков, без имён; "
542
+ "both — оба условия сразу")
543
+ ap.add_argument("--drop-prefixes", default="",
544
+ help="префиксы через запятую: такие тензоры НЕ переносить в выход "
545
+ "вовсе (для LTX: vae.,audio_vae.,vocoder.,text_embedding_projection. "
546
+ "— компоненты лежат отдельными файлами, дубли не нужны)")
547
+ ap.add_argument("--passthrough-dtype", default="", choices=("", "bf16"),
548
+ help="во что кастовать НЕквантуемые тензоры (для fp32-исходников "
549
+ "вроде HiDream-O1: без этого эмбеддинги уедут в выход в fp32)")
550
+ a = ap.parse_args()
551
+ convert(a.src, a.dst, a.groupsize, a.device, a.dry_run,
552
+ not a.no_search_scale, a.objective, -128 if a.asymmetric else -127,
553
+ a.sign_aware, a.ls_refit, a.calib, a.calib_alpha, a.search_min,
554
+ a.clip_margin, a.quant_adaln, a.skip_connectors, a.select,
555
+ tuple(p for p in a.drop_prefixes.split(",") if p),
556
+ a.passthrough_dtype)
tools/mm_profile_main_quant.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Profile sampled INT8 convrot reconstruction error for all MiniMax-H3 DiT weights.
3
+
4
+ The profiler keeps every input column (so Hadamard rotation is exact) but samples
5
+ output rows deterministically. It is intended for choosing a small BF16 island;
6
+ the final converter still quantizes every retained INT8 tensor in full.
7
+ """
8
+ import argparse
9
+ import json
10
+ import os
11
+ import sys
12
+ import time
13
+
14
+ import torch
15
+
16
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
17
+ ROOT = os.environ.get("MINIMAX_H3_ROOT", os.getcwd())
18
+ TOOLS = SCRIPT_DIR
19
+ sys.path.insert(0, TOOLS)
20
+
21
+ from convert_int8_convrot import build_ratios, quantize_search # noqa: E402
22
+ from mm_quantize_lean import ShardReader # noqa: E402
23
+ from comfy_kitchen.backends.eager.quantization import _build_hadamard, _rotate_weight # noqa: E402
24
+
25
+ sys.stdout.reconfigure(encoding="utf-8")
26
+ torch.set_grad_enabled(False)
27
+
28
+
29
+ SHAPES = {
30
+ "attn.qkv_proj": (21504, 5376),
31
+ "attn.out_proj": (5376, 7168),
32
+ "mlp.fc1": (28672, 5376),
33
+ "mlp.fc2": (5376, 14336),
34
+ }
35
+
36
+
37
+ def source_weight(reader, block, kind):
38
+ prefix = f"transformer_blocks.{block}"
39
+ if kind == "attn.qkv_proj":
40
+ return torch.cat([reader.get_tensor(f"{prefix}.attn.to_{part}.weight") for part in "qkv"], dim=0)
41
+ if kind == "attn.out_proj":
42
+ return reader.get_tensor(f"{prefix}.attn.to_out.0.weight")
43
+ if kind == "mlp.fc1":
44
+ weight = reader.get_tensor(f"{prefix}.ff.net.0.proj.weight")
45
+ half = weight.shape[0] // 2
46
+ return torch.cat((weight[half:], weight[:half]), dim=0)
47
+ if kind == "mlp.fc2":
48
+ return reader.get_tensor(f"{prefix}.ff.net.2.weight")
49
+ raise ValueError(kind)
50
+
51
+
52
+ def sampled_rows(weight, count):
53
+ if weight.shape[0] <= count:
54
+ return weight
55
+ index = torch.linspace(0, weight.shape[0] - 1, count, dtype=torch.float64).round().long()
56
+ return weight.index_select(0, index)
57
+
58
+
59
+ def profile(weight, groupsize, rows, ratios, device, clip_margin):
60
+ sample = sampled_rows(weight, rows).to(device=device, dtype=torch.float32)
61
+ hadamard = _build_hadamard(groupsize, device=sample.device, dtype=sample.dtype)
62
+ rotated = _rotate_weight(sample, hadamard, groupsize)
63
+ absmax = rotated.abs().amax(dim=1, keepdim=True).clamp(min=1e-12)
64
+ scale0 = absmax / 127.0
65
+ q0 = torch.round(rotated / scale0).clamp(-127, 127)
66
+ err0 = ((q0 * scale0 - rotated).norm() / rotated.norm()).item()
67
+ q, scale = quantize_search(sample, groupsize, ratios, clip_margin=clip_margin)
68
+ err = ((q.float() * scale - rotated).norm() / rotated.norm()).item()
69
+ clipped = (scale < scale0 * 0.9999).float().mean().item()
70
+ del sample, hadamard, rotated, absmax, scale0, q0, q, scale
71
+ return err0, err, clipped
72
+
73
+
74
+ def main():
75
+ ap = argparse.ArgumentParser()
76
+ ap.add_argument("variant", choices=("fl2va", "ref2va"))
77
+ ap.add_argument("--src", default="", help="raw diffusers transformer directory")
78
+ ap.add_argument("--device", default="cuda:1")
79
+ ap.add_argument("--rows", type=int, default=192)
80
+ ap.add_argument("--blocks", type=int, default=50,
81
+ help="число первых блоков; только для короткой проверки профайлера")
82
+ ap.add_argument("--groupsize", type=int, choices=(16, 64, 256), default=256)
83
+ ap.add_argument("--search-min", type=float, default=0.80)
84
+ ap.add_argument("--clip-margin", type=float, default=0.05)
85
+ ap.add_argument("--out", default="")
86
+ args = ap.parse_args()
87
+
88
+ source = args.src or os.path.join(ROOT, "HF",
89
+ "transformer" if args.variant == "fl2va" else "transformer_ref")
90
+ out = args.out or os.path.join(ROOT, "comfy_headless", f"mm_quant_profile_{args.variant}.json")
91
+ ratios = build_ratios(args.search_min)
92
+ results = []
93
+ started = time.time()
94
+ print(f"source={source}\ndevice={args.device} rows={args.rows} g={args.groupsize}\nout={out}", flush=True)
95
+
96
+ with ShardReader(source) as reader:
97
+ for block in range(args.blocks):
98
+ block_started = time.time()
99
+ for kind, shape in SHAPES.items():
100
+ weight = source_weight(reader, block, kind)
101
+ if tuple(weight.shape) != shape:
102
+ raise RuntimeError(f"blocks.{block}.{kind}: {tuple(weight.shape)} != {shape}")
103
+ err0, err, clipped = profile(weight, args.groupsize, args.rows, ratios,
104
+ args.device, args.clip_margin)
105
+ count = weight.numel()
106
+ out_features = weight.shape[0]
107
+ int8_bytes = count + out_features * 4 + len(json.dumps({
108
+ "format": "int8_tensorwise", "convrot": True,
109
+ "convrot_groupsize": args.groupsize}).encode("utf-8"))
110
+ bf16_delta = count * 2 - int8_bytes
111
+ results.append({
112
+ "layer": f"blocks.{block}.{kind}",
113
+ "block": block,
114
+ "kind": kind,
115
+ "shape": list(weight.shape),
116
+ "sample_rows": min(args.rows, weight.shape[0]),
117
+ "absmax_error": err0,
118
+ "searched_error": err,
119
+ "improvement": err0 - err,
120
+ "clipped_row_fraction": clipped,
121
+ "bf16_delta_bytes": bf16_delta,
122
+ })
123
+ del weight
124
+ print(f"block {block:02d}/49: {time.time() - block_started:.1f}s, total {time.time() - started:.0f}s",
125
+ flush=True)
126
+
127
+ payload = {
128
+ "variant": args.variant,
129
+ "source": source,
130
+ "groupsize": args.groupsize,
131
+ "rows": args.rows,
132
+ "search_min": args.search_min,
133
+ "clip_margin": args.clip_margin,
134
+ "elapsed_seconds": time.time() - started,
135
+ "layers": results,
136
+ }
137
+ with open(out, "w", encoding="utf-8") as stream:
138
+ json.dump(payload, stream, ensure_ascii=False, indent=2)
139
+ print(f"готово: {out}; слоёв={len(results)}, {time.time() - started:.0f}s", flush=True)
140
+
141
+
142
+ if __name__ == "__main__":
143
+ main()
tools/mm_quantize_lean.py ADDED
@@ -0,0 +1,562 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Build MiniMax-H3 INT8 lean-convrot + high-precision adaLN curve.
3
+
4
+ The input is the original diffusers transformer/transformer_ref directory.
5
+ Q/K/V packing and fc1 ordering are converted while streaming, so the script
6
+ does not need a 61.7 GiB merged BF16 file or a 20-44 GiB tensor dictionary in
7
+ RAM.
8
+ """
9
+ import argparse
10
+ import json
11
+ import math
12
+ import os
13
+ import re
14
+ import struct
15
+ import sys
16
+ import time
17
+
18
+ import torch
19
+ import torch.nn.functional as F
20
+ from safetensors import safe_open
21
+
22
+
23
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
24
+ ROOT = os.environ.get("MINIMAX_H3_ROOT", os.getcwd())
25
+ HF = os.path.join(ROOT, "HF")
26
+ COMFYORG = os.path.join(ROOT, "comfyorg")
27
+ TOOLS = SCRIPT_DIR
28
+ MODELS = os.path.join(ROOT, "output")
29
+
30
+ sys.path.insert(0, TOOLS)
31
+ from convert_int8_convrot import build_ratios, quantize_search # noqa: E402
32
+
33
+ sys.stdout.reconfigure(encoding="utf-8")
34
+ torch.set_grad_enabled(False)
35
+
36
+
37
+ DTYPE_BYTES = {"F64": 8, "F32": 4, "F16": 2, "BF16": 2, "I64": 8,
38
+ "I32": 4, "I16": 2, "I8": 1, "U8": 1, "BOOL": 1}
39
+ TORCH_TO_ST = {torch.float64: "F64", torch.float32: "F32", torch.float16: "F16",
40
+ torch.bfloat16: "BF16", torch.int64: "I64", torch.int32: "I32",
41
+ torch.int16: "I16", torch.int8: "I8", torch.uint8: "U8",
42
+ torch.bool: "BOOL"}
43
+ def quant_blob(groupsize):
44
+ return json.dumps({"format": "int8_tensorwise", "convrot": True,
45
+ "convrot_groupsize": groupsize}).encode("utf-8")
46
+
47
+
48
+ def block_layers(blocks, suffix):
49
+ return tuple(f"blocks.{block}.{suffix}" for block in blocks)
50
+
51
+
52
+ # Deterministic 64-row/full-column FL2VA audit. Attention output projections
53
+ # are both the most error-prone family and the cheapest useful BF16 upgrade.
54
+ OUT_PROJ_ERR_GE_105 = (2, 1, 0, 3, 5, 7, 15, 38, 49, 6, 9, 45, 4, 19)
55
+ OUT_PROJ_ERR_GE_100 = OUT_PROJ_ERR_GE_105 + (14, 43, 8, 17, 10, 11, 47, 27, 44, 12, 13, 46, 20)
56
+ TOP_FC2 = (49, 45, 39, 29, 44)
57
+
58
+ QUALITY_PROFILES = {
59
+ "compact": (),
60
+ # ~20.39 GiB with dynamic rank16.
61
+ "quality20": block_layers(OUT_PROJ_ERR_GE_105, "attn.out_proj")
62
+ + block_layers(TOP_FC2[:1], "mlp.fc2"),
63
+ # ~21.00 GiB: recommended first 24 GiB load/generation candidate.
64
+ "quality21": block_layers(OUT_PROJ_ERR_GE_100, "attn.out_proj")
65
+ + block_layers(TOP_FC2[:3], "mlp.fc2"),
66
+ # ~21.97 GiB: only after quality21 demonstrates enough activation headroom.
67
+ "quality22": block_layers(range(50), "attn.out_proj")
68
+ + block_layers(TOP_FC2, "mlp.fc2"),
69
+ }
70
+ def tensor_bytes(dtype, shape):
71
+ total = DTYPE_BYTES[dtype]
72
+ for dim in shape:
73
+ total *= dim
74
+ return total
75
+
76
+
77
+ class ShardReader:
78
+ def __init__(self, path):
79
+ self.path = os.path.abspath(path)
80
+ indexes = [name for name in os.listdir(self.path) if name.endswith(".safetensors.index.json")]
81
+ if len(indexes) != 1:
82
+ raise SystemExit(f"ожидался один *.safetensors.index.json в {self.path}, найдено {len(indexes)}")
83
+ index = json.load(open(os.path.join(self.path, indexes[0]), encoding="utf-8"))
84
+ self.weight_map = index["weight_map"]
85
+ self._files = {}
86
+ for name in sorted(set(self.weight_map.values())):
87
+ full = os.path.join(self.path, name)
88
+ if not os.path.isfile(full):
89
+ raise SystemExit(f"нет шарда из index: {full}")
90
+ self._files[name] = safe_open(full, framework="pt")
91
+
92
+ def keys(self):
93
+ return list(self.weight_map)
94
+
95
+ def get_slice(self, key):
96
+ return self._files[self.weight_map[key]].get_slice(key)
97
+
98
+ def get_tensor(self, key):
99
+ return self._files[self.weight_map[key]].get_tensor(key)
100
+
101
+ def close(self):
102
+ self._files.clear()
103
+
104
+ def __enter__(self):
105
+ return self
106
+
107
+ def __exit__(self, exc_type, exc, traceback):
108
+ self.close()
109
+
110
+
111
+ def validate_source(reader):
112
+ keys = set(reader.keys())
113
+ if len(keys) != 638:
114
+ raise SystemExit(f"неожиданное число исходных тензоров: {len(keys)}, ожидалось 638")
115
+ shapes = {
116
+ "transformer_blocks.0.attn.to_q.weight": [7168, 5376],
117
+ "transformer_blocks.0.attn.to_k.weight": [7168, 5376],
118
+ "transformer_blocks.0.attn.to_v.weight": [7168, 5376],
119
+ "transformer_blocks.0.attn.to_out.0.weight": [5376, 7168],
120
+ "transformer_blocks.0.ff.net.0.proj.weight": [28672, 5376],
121
+ "transformer_blocks.0.ff.net.2.weight": [5376, 14336],
122
+ "transformer_blocks.0.adaln_proj.linear.weight": [96768, 2688],
123
+ "norm_out.linear.weight": [10752, 2688],
124
+ "time_embedder.linear_1.weight": [5376, 256],
125
+ "time_embedder.linear_2.weight": [2688, 5376],
126
+ }
127
+ for key, expected_shape in shapes.items():
128
+ if key not in keys:
129
+ raise SystemExit(f"в источнике нет {key}")
130
+ actual = reader.get_slice(key).get_shape()
131
+ if actual != expected_shape:
132
+ raise SystemExit(f"форма {key}: {actual}, ожидалось {expected_shape}")
133
+ print("источник diffusers: 638 тензоров, 50 DiT-блоков, формы верны")
134
+
135
+
136
+ def task(kind, entries, source=None, prefix=None, **extra):
137
+ out = {"kind": kind, "entries": entries, "source": source, "prefix": prefix}
138
+ out.update(extra)
139
+ return out
140
+
141
+
142
+ def build_tasks(reader, rank, grid, time_mode="dynamic", bf16_layers=(), groupsize=256):
143
+ tasks = []
144
+ used = set()
145
+ quant_count = curve_count = 0
146
+ bf16_layers = set(bf16_layers)
147
+ seen_main_layers = set()
148
+
149
+ def add_copy(out_key, src_key, kind="copy"):
150
+ sl = reader.get_slice(src_key)
151
+ tasks.append(task(kind, [(out_key, sl.get_dtype(), sl.get_shape())], source=src_key))
152
+ used.add(src_key)
153
+
154
+ def add_qkv(out_key, src_prefix, quantized, groupsize=256):
155
+ sources = tuple(src_prefix + f".attn.to_{name}.weight" for name in ("q", "k", "v"))
156
+ shape = reader.get_slice(sources[0]).get_shape()
157
+ out_shape = [shape[0] * 3, shape[1]]
158
+ if quantized:
159
+ layer = out_key[:-len(".weight")]
160
+ blob = quant_blob(groupsize)
161
+ entries = [(out_key, "I8", out_shape),
162
+ (layer + ".weight_scale", "F32", [out_shape[0], 1]),
163
+ (layer + ".comfy_quant", "U8", [len(blob)])]
164
+ tasks.append(task("quant_qkv", entries, source=sources, groupsize=groupsize, blob=blob))
165
+ else:
166
+ tasks.append(task("copy_qkv", [(out_key, reader.get_slice(sources[0]).get_dtype(), out_shape)], source=sources))
167
+ used.update(sources)
168
+
169
+ def add_quant(out_key, src_key, kind="quant", groupsize=256):
170
+ nonlocal quant_count
171
+ shape = reader.get_slice(src_key).get_shape()
172
+ layer = out_key[:-len(".weight")]
173
+ blob = quant_blob(groupsize)
174
+ entries = [(out_key, "I8", shape),
175
+ (layer + ".weight_scale", "F32", [shape[0], 1]),
176
+ (layer + ".comfy_quant", "U8", [len(blob)])]
177
+ tasks.append(task(kind, entries, source=src_key, groupsize=groupsize, blob=blob))
178
+ used.add(src_key)
179
+ quant_count += 1
180
+
181
+ def add_main_qkv(out_key, src_prefix):
182
+ nonlocal quant_count
183
+ layer = out_key[:-len(".weight")]
184
+ seen_main_layers.add(layer)
185
+ quantized = layer not in bf16_layers
186
+ add_qkv(out_key, src_prefix, quantized=quantized, groupsize=groupsize)
187
+ if quantized:
188
+ quant_count += 1
189
+
190
+ def add_main(out_key, src_key, quant_kind="quant", copy_kind="copy"):
191
+ layer = out_key[:-len(".weight")]
192
+ seen_main_layers.add(layer)
193
+ if layer in bf16_layers:
194
+ add_copy(out_key, src_key, kind=copy_kind)
195
+ else:
196
+ add_quant(out_key, src_key, kind=quant_kind, groupsize=groupsize)
197
+
198
+ def add_curve(out_prefix, src_prefix):
199
+ nonlocal curve_count
200
+ weight_key, bias_key = src_prefix + ".weight", src_prefix + ".bias"
201
+ out_features = reader.get_slice(weight_key).get_shape()[0]
202
+ tasks.append(task("curve", [(out_prefix + ".weight", "F32", [out_features, rank]),
203
+ (out_prefix + ".bias", "F32", [out_features])],
204
+ source=src_prefix, prefix=out_prefix))
205
+ used.update((weight_key, bias_key))
206
+ curve_count += 1
207
+
208
+ for block in range(50):
209
+ src = f"transformer_blocks.{block}"
210
+ out = f"blocks.{block}"
211
+ add_main_qkv(out + ".attn.qkv_proj.weight", src)
212
+ add_main(out + ".attn.out_proj.weight", src + ".attn.to_out.0.weight")
213
+ add_copy(out + ".attn.q_norm.weight", src + ".attn.norm_q.weight")
214
+ add_copy(out + ".attn.k_norm.weight", src + ".attn.norm_k.weight")
215
+ add_main(out + ".mlp.fc1.weight", src + ".ff.net.0.proj.weight",
216
+ quant_kind="quant_fc1", copy_kind="copy_fc1")
217
+ add_main(out + ".mlp.fc2.weight", src + ".ff.net.2.weight")
218
+ add_copy(out + ".norm1.weight", src + ".norm1.weight")
219
+ add_copy(out + ".norm2.weight", src + ".norm2.weight")
220
+ add_curve(out + ".adaln_proj.linear", src + ".adaln_proj.linear")
221
+
222
+ for block in range(2):
223
+ src = f"token_refiner.refiner_blocks.{block}"
224
+ out = f"token_refiner.blocks.{block}"
225
+ add_qkv(out + ".attn.qkv_proj.weight", src, quantized=False)
226
+ add_copy(out + ".attn.out_proj.weight", src + ".attn.to_out.0.weight")
227
+ add_copy(out + ".attn.q_norm.weight", src + ".attn.norm_q.weight")
228
+ add_copy(out + ".attn.k_norm.weight", src + ".attn.norm_k.weight")
229
+ add_copy(out + ".mlp.fc1.weight", src + ".ff.net.0.proj.weight", kind="copy_fc1")
230
+ add_copy(out + ".mlp.fc2.weight", src + ".ff.net.2.weight")
231
+ add_copy(out + ".norm1.weight", src + ".norm1.weight")
232
+ add_copy(out + ".norm2.weight", src + ".norm2.weight")
233
+
234
+ add_copy("token_refiner.final_norm.weight", "token_refiner.final_norm.weight")
235
+ for out_key, src_key in (
236
+ ("condition_proj.weight", "context_embedder.weight"),
237
+ ("condition_proj.bias", "context_embedder.bias"),
238
+ ("video_patch_proj.weight", "proj_in.weight"),
239
+ ("video_patch_proj.bias", "proj_in.bias"),
240
+ ("audio_patch_proj.weight", "audio_proj_in.weight"),
241
+ ("audio_patch_proj.bias", "audio_proj_in.bias"),
242
+ ("final_layer.video_out.weight", "proj_out.weight"),
243
+ ("final_layer.video_out.bias", "proj_out.bias"),
244
+ ("final_layer.audio_out.weight", "audio_proj_out.weight"),
245
+ ("final_layer.audio_out.bias", "audio_proj_out.bias"),
246
+ ("final_layer.norm.weight", "norm_out.norm.weight"),
247
+ ):
248
+ add_copy(out_key, src_key)
249
+ add_curve("final_layer.adaln_proj.linear", "norm_out.linear")
250
+
251
+ time_pairs = (
252
+ ("time_embedder.proj_in.weight", "time_embedder.linear_1.weight"),
253
+ ("time_embedder.proj_in.bias", "time_embedder.linear_1.bias"),
254
+ ("time_embedder.proj_out.weight", "time_embedder.linear_2.weight"),
255
+ ("time_embedder.proj_out.bias", "time_embedder.linear_2.bias"),
256
+ )
257
+ if time_mode == "dynamic":
258
+ for out_key, src_key in time_pairs:
259
+ add_copy(out_key, src_key)
260
+ tasks.append(task("basis", [("adaln_curve_basis", "F32", [2688, rank]),
261
+ ("adaln_curve_mean", "F32", [2688])]))
262
+ elif time_mode == "table":
263
+ used.update(src for _, src in time_pairs)
264
+ tasks.append(task("table", [("adaln_t_table", "F32", [grid, rank])]))
265
+ else:
266
+ raise ValueError(time_mode)
267
+ missing, extra = set(reader.keys()) - used, used - set(reader.keys())
268
+ if missing or extra:
269
+ raise SystemExit(f"маппинг diffusers неполон: не использовано {len(missing)}, неизвестных {len(extra)}; {sorted(missing)[:3]}")
270
+ tasks.append(task("rope", [("rope.inv_freq", "F32", [16])]))
271
+ unknown_bf16 = bf16_layers - seen_main_layers
272
+ if unknown_bf16:
273
+ raise SystemExit(f"неизвестные BF16-слои: {sorted(unknown_bf16)}")
274
+ expected_quant = 200 - len(bf16_layers)
275
+ if quant_count != expected_quant or curve_count != 51:
276
+ raise SystemExit(f"план неполон: INT8={quant_count}/{expected_quant}, adaLN={curve_count}/51")
277
+ entries = [entry for item in tasks for entry in item["entries"]]
278
+ expected_entries = (937 if time_mode == "dynamic" else 932) - 2 * len(bf16_layers)
279
+ if len(entries) != expected_entries or len({entry[0] for entry in entries}) != len(entries):
280
+ raise SystemExit(f"неверный выходной keyset: {len(entries)} вместо {expected_entries}")
281
+ return tasks
282
+
283
+
284
+ def inspect_reference(tasks, path, time_mode="dynamic", bf16_layers=()):
285
+ planned = {key: (dtype, shape) for item in tasks for key, dtype, shape in item["entries"]}
286
+ bf16_layers = set(bf16_layers)
287
+ with safe_open(path, framework="pt") as ref:
288
+ ref_keys = set(ref.keys())
289
+ expected_missing = set()
290
+ for layer in bf16_layers:
291
+ expected_missing.update((layer + ".weight_scale", layer + ".comfy_quant"))
292
+ expected_extra = set()
293
+ if time_mode == "dynamic":
294
+ expected_missing.add("adaln_t_table")
295
+ expected_extra.update({"adaln_curve_basis", "adaln_curve_mean",
296
+ "time_embedder.proj_in.weight", "time_embedder.proj_in.bias",
297
+ "time_embedder.proj_out.weight", "time_embedder.proj_out.bias"})
298
+ actual_missing = ref_keys - set(planned)
299
+ actual_extra = set(planned) - ref_keys
300
+ if actual_missing != expected_missing or actual_extra != expected_extra:
301
+ raise SystemExit("keyset расходится с ожидаемым расширением pruned-формата: "
302
+ f"missing={sorted(actual_missing ^ expected_missing)[:5]} "
303
+ f"extra={sorted(actual_extra ^ expected_extra)[:5]}")
304
+ mismatches = []
305
+ for key, (dtype, shape) in planned.items():
306
+ if key not in ref_keys or "adaln_proj.linear" in key or key == "adaln_t_table":
307
+ continue
308
+ sl = ref.get_slice(key)
309
+ layer = key[:-len(".weight")] if key.endswith(".weight") else ""
310
+ dtype_mismatch = sl.get_dtype() != dtype and layer not in bf16_layers
311
+ if dtype_mismatch or sl.get_shape() != shape:
312
+ mismatches.append((key, dtype, shape, sl.get_dtype(), sl.get_shape()))
313
+ if mismatches:
314
+ raise SystemExit(f"формат расходится с pruned-эталоном вне curve-части: {mismatches[:3]}")
315
+ print(f"эталон comfyorg-pruned: общие формы совпадают; dynamic={time_mode == 'dynamic'}, "
316
+ f"BF16 main={len(bf16_layers)}")
317
+
318
+
319
+ def make_curve(reader, rank, grid, device):
320
+ w1 = reader.get_tensor("time_embedder.linear_1.weight").to(device=device, dtype=torch.float32)
321
+ b1 = reader.get_tensor("time_embedder.linear_1.bias").to(device=device, dtype=torch.float32)
322
+ w2 = reader.get_tensor("time_embedder.linear_2.weight").to(device=device, dtype=torch.float32)
323
+ b2 = reader.get_tensor("time_embedder.linear_2.bias").to(device=device, dtype=torch.float32)
324
+ half = 128
325
+ freqs = torch.exp(-math.log(10000.0) * torch.arange(half, dtype=torch.float32, device=device) / half)
326
+
327
+ def evaluate(t):
328
+ args = t[:, None] * freqs[None]
329
+ emb = torch.cat((torch.cos(args), torch.sin(args)), dim=1)
330
+ return F.silu(F.linear(F.silu(F.linear(emb, w1, b1)), w2, b2))
331
+
332
+ # 2049 points are sufficient to determine the shared subspace. The output
333
+ # table may be denser: Comfy derives the grid length from table.shape[0].
334
+ fit_t = torch.linspace(0.0, 1.0, 2049, dtype=torch.float32, device=device)
335
+ curve = evaluate(fit_t)
336
+ # Evaluate the real runtime formula in F32, then solve the tiny singular
337
+ # directions in F64 on CPU. F32 SVD bottoms out at ~1.09e-6 relative error
338
+ # for rank 16; the F64 solve followed by F32 storage reaches ~2.72e-7.
339
+ curve_cpu = curve.cpu()
340
+ curve64 = curve_cpu.double()
341
+ mean64 = curve64.mean(0)
342
+ centered64 = curve64 - mean64
343
+ _, singular, vh = torch.linalg.svd(centered64, full_matrices=False)
344
+ basis64 = vh[:rank].T.contiguous()
345
+ basis = basis64.to(device=device, dtype=torch.float32)
346
+ mean = mean64.to(device=device, dtype=torch.float32)
347
+ table_t = torch.linspace(0.0, 1.0, grid, dtype=torch.float32, device=device)
348
+ table_curve = evaluate(table_t)
349
+ table = ((table_curve.cpu().double() - mean64) @ basis64).to(torch.float32)
350
+ energy = (singular[:rank].square().sum() / singular.square().sum()).item()
351
+ reconstruction = table @ basis.cpu().T + mean.cpu()
352
+ grid_error = ((reconstruction - table_curve.cpu()).norm() / table_curve.cpu().norm()).item()
353
+ # Real runtime values usually lie between table rows. Midpoints provide a
354
+ # sensitive deterministic check of the linear interpolation error.
355
+ mid_t = (torch.arange(grid - 1, dtype=torch.float32, device=device) + 0.5) / (grid - 1)
356
+ mid_curve = evaluate(mid_t).cpu()
357
+ mid_coords = (table[:-1] + table[1:]) * 0.5
358
+ mid_reconstruction = mid_coords @ basis.cpu().T + mean.cpu()
359
+ midpoint_error = ((mid_reconstruction - mid_curve).norm() / mid_curve.norm()).item()
360
+ midpoint_max = ((mid_reconstruction - mid_curve).norm(dim=1) /
361
+ mid_curve.norm(dim=1).clamp(min=1e-12)).max().item()
362
+ projection = torch.cat((basis, mean[:, None]), dim=1)
363
+ del w1, b1, w2, b2, curve, curve_cpu, curve64, centered64, vh, basis64
364
+ del table_curve, reconstruction, mid_curve, mid_reconstruction, mid_coords
365
+ print(f"adaLN curve: rank={rank}, grid={grid}, энергия={energy:.10f}, "
366
+ f"grid err={grid_error:.8%}, midpoint err={midpoint_error:.8%}, "
367
+ f"max={midpoint_max:.8%}")
368
+ return projection, table
369
+
370
+
371
+ def make_header(tasks):
372
+ header = {}
373
+ offset = 0
374
+ for item in tasks:
375
+ for key, dtype, shape in item["entries"]:
376
+ size = tensor_bytes(dtype, shape)
377
+ header[key] = {"dtype": dtype, "shape": shape, "data_offsets": [offset, offset + size]}
378
+ offset += size
379
+ raw = json.dumps(header, separators=(",", ":")).encode("utf-8")
380
+ raw += b" " * ((-len(raw)) % 8)
381
+ return raw, offset
382
+
383
+
384
+ def raw_bytes(tensor):
385
+ tensor = tensor.detach().to(device="cpu").contiguous()
386
+ if tensor.dtype not in TORCH_TO_ST:
387
+ raise TypeError(f"неподдерживаемый dtype {tensor.dtype}")
388
+ return tensor.view(torch.uint8).numpy().tobytes()
389
+
390
+
391
+ def write_tensor(stream, tensor, expected):
392
+ key, dtype, shape = expected
393
+ actual_dtype = TORCH_TO_ST.get(tensor.dtype)
394
+ if actual_dtype != dtype or list(tensor.shape) != shape:
395
+ raise RuntimeError(f"{key}: получили {actual_dtype} {list(tensor.shape)}, ожидалось {dtype} {shape}")
396
+ blob = raw_bytes(tensor)
397
+ expected_bytes = tensor_bytes(dtype, shape)
398
+ if len(blob) != expected_bytes:
399
+ raise RuntimeError(f"{key}: байт {len(blob)}, ожидалось {expected_bytes}")
400
+ stream.write(blob)
401
+
402
+
403
+ def build(reader, tasks, reference, dst, rank, grid, device, search_min, clip_margin, overwrite):
404
+ partial = dst + ".partial"
405
+ if (os.path.exists(dst) or os.path.exists(partial)) and not overwrite:
406
+ raise SystemExit(f"выход или partial уже существует; используйте --overwrite: {dst}")
407
+ os.makedirs(os.path.dirname(os.path.abspath(dst)), exist_ok=True)
408
+ header, data_size = make_header(tasks)
409
+ projection, table = make_curve(reader, rank, grid, device)
410
+ ratios = build_ratios(search_min)
411
+ t0 = time.time()
412
+ quant_done = curve_done = 0
413
+ expected_quant = sum(item["kind"] in ("quant", "quant_fc1", "quant_qkv") for item in tasks)
414
+
415
+ def report_block(key):
416
+ match = re.fullmatch(r"blocks\.(\d+)\.mlp\.fc2\.weight", key)
417
+ if match:
418
+ print(f" DiT block {int(match.group(1)):02d}/49: INT8 {quant_done}/{expected_quant}, "
419
+ f"{time.time() - t0:.0f} c", flush=True)
420
+
421
+ with safe_open(reference, framework="pt") as ref, open(partial, "wb") as stream:
422
+ stream.write(struct.pack("<Q", len(header)))
423
+ stream.write(header)
424
+ for item in tasks:
425
+ if item["kind"] == "copy":
426
+ tensor = reader.get_tensor(item["source"])
427
+ write_tensor(stream, tensor, item["entries"][0])
428
+ del tensor
429
+ report_block(item["entries"][0][0])
430
+ elif item["kind"] in ("copy_qkv", "quant_qkv"):
431
+ weight = torch.cat([reader.get_tensor(key) for key in item["source"]], dim=0)
432
+ if item["kind"] == "copy_qkv":
433
+ write_tensor(stream, weight, item["entries"][0])
434
+ del weight
435
+ continue
436
+ weight = weight.to(device=device, dtype=torch.float32)
437
+ qdata, scale = quantize_search(weight, item["groupsize"], ratios, clip_margin=clip_margin)
438
+ write_tensor(stream, qdata.cpu(), item["entries"][0])
439
+ write_tensor(stream, scale.cpu(), item["entries"][1])
440
+ blob = torch.tensor(list(item["blob"]), dtype=torch.uint8)
441
+ write_tensor(stream, blob, item["entries"][2])
442
+ quant_done += 1
443
+ del weight, qdata, scale, blob
444
+ elif item["kind"] in ("copy_fc1", "quant_fc1"):
445
+ weight = reader.get_tensor(item["source"])
446
+ half = weight.shape[0] // 2
447
+ weight = torch.cat((weight[half:], weight[:half]), dim=0)
448
+ if item["kind"] == "copy_fc1":
449
+ write_tensor(stream, weight, item["entries"][0])
450
+ del weight
451
+ continue
452
+ weight = weight.to(device=device, dtype=torch.float32)
453
+ qdata, scale = quantize_search(weight, item["groupsize"], ratios, clip_margin=clip_margin)
454
+ write_tensor(stream, qdata.cpu(), item["entries"][0])
455
+ write_tensor(stream, scale.cpu(), item["entries"][1])
456
+ blob = torch.tensor(list(item["blob"]), dtype=torch.uint8)
457
+ write_tensor(stream, blob, item["entries"][2])
458
+ quant_done += 1
459
+ del weight, qdata, scale, blob
460
+ elif item["kind"] == "quant":
461
+ weight = reader.get_tensor(item["source"]).to(device=device, dtype=torch.float32)
462
+ qdata, scale = quantize_search(weight, item["groupsize"], ratios, clip_margin=clip_margin)
463
+ write_tensor(stream, qdata.cpu(), item["entries"][0])
464
+ write_tensor(stream, scale.cpu(), item["entries"][1])
465
+ blob = torch.tensor(list(item["blob"]), dtype=torch.uint8)
466
+ write_tensor(stream, blob, item["entries"][2])
467
+ quant_done += 1
468
+ del weight, qdata, scale, blob
469
+ report_block(item["entries"][0][0])
470
+ elif item["kind"] == "curve":
471
+ source = item["source"]
472
+ weight = reader.get_tensor(source + ".weight").to(device=device, dtype=torch.float32)
473
+ bias = reader.get_tensor(source + ".bias").to(device=device, dtype=torch.float32)
474
+ packed = weight @ projection
475
+ curve_weight = packed[:, :rank]
476
+ curve_bias = bias + packed[:, rank]
477
+ write_tensor(stream, curve_weight.cpu(), item["entries"][0])
478
+ write_tensor(stream, curve_bias.cpu(), item["entries"][1])
479
+ curve_done += 1
480
+ del weight, bias, packed, curve_weight, curve_bias
481
+ elif item["kind"] == "table":
482
+ write_tensor(stream, table.cpu(), item["entries"][0])
483
+ elif item["kind"] == "basis":
484
+ write_tensor(stream, projection[:, :rank].cpu(), item["entries"][0])
485
+ write_tensor(stream, projection[:, rank].cpu(), item["entries"][1])
486
+ elif item["kind"] == "rope":
487
+ write_tensor(stream, ref.get_tensor("rope.inv_freq"), item["entries"][0])
488
+ else:
489
+ raise RuntimeError(item["kind"])
490
+ expected_size = 8 + len(header) + data_size
491
+ actual_size = os.path.getsize(partial)
492
+ if actual_size != expected_size:
493
+ raise RuntimeError(f"partial имеет {actual_size} байт, ожидалось {expected_size}")
494
+ with safe_open(partial, framework="pt") as result:
495
+ expected_keys = sum(len(item["entries"]) for item in tasks)
496
+ if len(result.keys()) != expected_keys:
497
+ raise RuntimeError(f"safetensors открылся, но ключей {len(result.keys())}, ожидалось {expected_keys}")
498
+ os.replace(partial, dst)
499
+ print(f"готово: {dst}\n {actual_size / 2**30:.3f} GiB, INT8={quant_done}, curve={curve_done}, {time.time() - t0:.0f} c")
500
+
501
+
502
+ def defaults(variant, rank, grid, time_mode, profile):
503
+ source = os.path.join(HF, "transformer" if variant == "fl2va" else "transformer_ref")
504
+ reference = os.path.join(COMFYORG, f"minimax-h3-{variant}-pruned-int8-convrot-comfyorg.safetensors")
505
+ curve_tag = f"table-k{rank}-g{grid}" if time_mode == "table" else f"dynamic-k{rank}"
506
+ dst = os.path.join(MODELS, f"minimax-h3-{variant}-int8-lean-convrot-{curve_tag}-{profile}.safetensors")
507
+ return source, reference, dst
508
+
509
+
510
+ def main():
511
+ ap = argparse.ArgumentParser()
512
+ ap.add_argument("variant", choices=("fl2va", "ref2va"))
513
+ ap.add_argument("--rank", type=int, default=16, choices=(8, 16, 32, 64))
514
+ ap.add_argument("--time-mode", choices=("dynamic", "table"), default="dynamic",
515
+ help="dynamic сохраняет исходный F32 time_embedder; table совместим с pruned")
516
+ ap.add_argument("--grid", type=int, default=4097,
517
+ help="число строк table или плотность численной проверки dynamic basis")
518
+ ap.add_argument("--profile", choices=tuple(QUALITY_PROFILES), default="quality21")
519
+ ap.add_argument("--bf16-layer", action="append", default=[],
520
+ help="дополнительный base-name основного слоя, например blocks.48.mlp.fc2")
521
+ ap.add_argument("--groupsize", type=int, choices=(16, 64, 256), default=256)
522
+ ap.add_argument("--src", default="")
523
+ ap.add_argument("--reference", default="")
524
+ ap.add_argument("--dst", default="")
525
+ ap.add_argument("--device", default="cuda:0")
526
+ ap.add_argument("--search-min", type=float, default=0.80)
527
+ ap.add_argument("--clip-margin", type=float, default=0.05)
528
+ ap.add_argument("--dry-run", action="store_true")
529
+ ap.add_argument("--overwrite", action="store_true")
530
+ args = ap.parse_args()
531
+ if args.grid < 2:
532
+ ap.error("--grid должен быть не меньше 2")
533
+
534
+ bf16_layers = set(QUALITY_PROFILES[args.profile]) | set(args.bf16_layer)
535
+ source, reference, dst = defaults(args.variant, args.rank, args.grid, args.time_mode, args.profile)
536
+ source = args.src or source
537
+ reference = args.reference or reference
538
+ dst = args.dst or dst
539
+ print(f"variant={args.variant} rank={args.rank} time={args.time_mode} profile={args.profile}\n"
540
+ f"BF16 main={sorted(bf16_layers)}\nsrc={source}\nreference={reference}\ndst={dst}")
541
+ reader = ShardReader(source)
542
+ try:
543
+ validate_source(reader)
544
+ tasks = build_tasks(reader, args.rank, args.grid, args.time_mode, bf16_layers, args.groupsize)
545
+ inspect_reference(tasks, reference, args.time_mode, bf16_layers)
546
+ _, data_size = make_header(tasks)
547
+ entries = sum(len(item["entries"]) for item in tasks)
548
+ quant_count = sum(item["kind"] in ("quant", "quant_fc1", "quant_qkv") for item in tasks)
549
+ print(f"план: {entries} тензоров, {quant_count} INT8 g{args.groupsize}, "
550
+ f"BF16 main={len(bf16_layers)}, 51 adaLN curve F32 k={args.rank} time={args.time_mode}; "
551
+ f"данные {data_size / 2**30:.3f} GiB")
552
+ if args.dry_run:
553
+ print("dry-run: веса не читались целиком, GPU не использовалась, файл не создан")
554
+ return
555
+ build(reader, tasks, reference, dst, args.rank, args.grid, args.device, args.search_min,
556
+ args.clip_margin, args.overwrite)
557
+ finally:
558
+ reader.close()
559
+
560
+
561
+ if __name__ == "__main__":
562
+ main()
tools/mm_validate_dynamic_built.py ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Validate a built MiniMax-H3 dynamic-basis checkpoint against raw HF weights."""
3
+ import argparse
4
+ import json
5
+ import math
6
+ import os
7
+ import sys
8
+
9
+ import torch
10
+ import torch.nn.functional as F
11
+ from safetensors import safe_open
12
+
13
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ ROOT = os.environ.get("MINIMAX_H3_ROOT", os.getcwd())
15
+ sys.path.insert(0, SCRIPT_DIR)
16
+ from mm_quantize_lean import QUALITY_PROFILES, ShardReader # noqa: E402
17
+
18
+ sys.stdout.reconfigure(encoding="utf-8")
19
+ torch.set_grad_enabled(False)
20
+
21
+
22
+ def rel(actual, expected):
23
+ return ((actual - expected).norm() / expected.norm().clamp(min=1e-12)).item()
24
+
25
+
26
+ def main():
27
+ ap = argparse.ArgumentParser()
28
+ ap.add_argument("variant", choices=("fl2va", "ref2va"))
29
+ ap.add_argument("checkpoint")
30
+ ap.add_argument("--src", default="", help="raw diffusers transformer directory")
31
+ ap.add_argument("--profile", choices=tuple(QUALITY_PROFILES), default="quality21")
32
+ ap.add_argument("--samples", type=int, default=9)
33
+ args = ap.parse_args()
34
+
35
+ source = args.src or os.path.join(ROOT, "HF",
36
+ "transformer" if args.variant == "fl2va" else "transformer_ref")
37
+ expected_bf16 = set(QUALITY_PROFILES[args.profile])
38
+ results = {}
39
+
40
+ with ShardReader(source) as raw, safe_open(args.checkpoint, framework="pt") as built:
41
+ keys = set(built.keys())
42
+ quant = [key for key in keys if key.endswith(".comfy_quant")]
43
+ groups = {}
44
+ for key in quant:
45
+ config = json.loads(bytes(built.get_tensor(key).numpy()).decode())
46
+ groups[config["convrot_groupsize"]] = groups.get(config["convrot_groupsize"], 0) + 1
47
+
48
+ actual_bf16 = set()
49
+ for block in range(50):
50
+ for suffix in ("attn.qkv_proj", "attn.out_proj", "mlp.fc1", "mlp.fc2"):
51
+ base = f"blocks.{block}.{suffix}"
52
+ if built.get_slice(base + ".weight").get_dtype() == "BF16":
53
+ actual_bf16.add(base)
54
+ if actual_bf16 != expected_bf16:
55
+ raise RuntimeError(f"BF16 profile mismatch: -{sorted(expected_bf16 - actual_bf16)} "
56
+ f"+{sorted(actual_bf16 - expected_bf16)}")
57
+
58
+ time_pairs = (
59
+ ("time_embedder.linear_1.weight", "time_embedder.proj_in.weight"),
60
+ ("time_embedder.linear_1.bias", "time_embedder.proj_in.bias"),
61
+ ("time_embedder.linear_2.weight", "time_embedder.proj_out.weight"),
62
+ ("time_embedder.linear_2.bias", "time_embedder.proj_out.bias"),
63
+ )
64
+ time_bitwise = all(torch.equal(raw.get_tensor(src), built.get_tensor(dst))
65
+ for src, dst in time_pairs)
66
+ if not time_bitwise:
67
+ raise RuntimeError("time_embedder differs from raw HF")
68
+
69
+ # All quality21 BF16 islands are out_proj or fc2 and should be exact copies.
70
+ bf16_bad = []
71
+ for base in sorted(actual_bf16):
72
+ parts = base.split(".")
73
+ block = int(parts[1])
74
+ suffix = ".".join(parts[2:])
75
+ if suffix == "attn.out_proj":
76
+ src = f"transformer_blocks.{block}.attn.to_out.0.weight"
77
+ elif suffix == "mlp.fc2":
78
+ src = f"transformer_blocks.{block}.ff.net.2.weight"
79
+ else:
80
+ raise RuntimeError(f"validator needs mapping for {base}")
81
+ if not torch.equal(raw.get_tensor(src), built.get_tensor(base + ".weight")):
82
+ bf16_bad.append(base)
83
+ if bf16_bad:
84
+ raise RuntimeError(f"BF16 tensors differ: {bf16_bad}")
85
+
86
+ w1 = built.get_tensor("time_embedder.proj_in.weight").float()
87
+ b1 = built.get_tensor("time_embedder.proj_in.bias").float()
88
+ w2 = built.get_tensor("time_embedder.proj_out.weight").float()
89
+ b2 = built.get_tensor("time_embedder.proj_out.bias").float()
90
+ basis = built.get_tensor("adaln_curve_basis").float()
91
+ mean = built.get_tensor("adaln_curve_mean").float()
92
+ orth_error = (basis.T @ basis - torch.eye(basis.shape[1])).abs().max().item()
93
+
94
+ t = torch.linspace(0.0, 1.0, args.samples, dtype=torch.float32)
95
+ half = 128
96
+ freqs = torch.exp(-math.log(10000.0) * torch.arange(half, dtype=torch.float32) / half)
97
+ phase = t[:, None] * freqs[None]
98
+ sinusoid = torch.cat((torch.cos(phase), torch.sin(phase)), dim=1)
99
+ u = F.silu(F.linear(F.silu(F.linear(sinusoid, w1, b1)), w2, b2))
100
+ coords = (u - mean) @ basis
101
+
102
+ curve_errors = {}
103
+ for block in (0, 24, 49):
104
+ src = f"transformer_blocks.{block}.adaln_proj.linear"
105
+ dst = f"blocks.{block}.adaln_proj.linear"
106
+ exact = F.linear(u, raw.get_tensor(src + ".weight").float(),
107
+ raw.get_tensor(src + ".bias").float())
108
+ approx = F.linear(coords, built.get_tensor(dst + ".weight").float(),
109
+ built.get_tensor(dst + ".bias").float())
110
+ curve_errors[f"block_{block}"] = rel(approx, exact)
111
+ del exact, approx
112
+ exact = F.linear(u, raw.get_tensor("norm_out.linear.weight").float(),
113
+ raw.get_tensor("norm_out.linear.bias").float())
114
+ approx = F.linear(coords, built.get_tensor("final_layer.adaln_proj.linear.weight").float(),
115
+ built.get_tensor("final_layer.adaln_proj.linear.bias").float())
116
+ curve_errors["final"] = rel(approx, exact)
117
+
118
+ results = {
119
+ "checkpoint": args.checkpoint,
120
+ "bytes": os.path.getsize(args.checkpoint),
121
+ "keys": len(keys),
122
+ "quant": len(quant),
123
+ "quant_groups": groups,
124
+ "bf16_main": len(actual_bf16),
125
+ "time_embedder_bitwise": time_bitwise,
126
+ "bf16_main_bitwise": len(actual_bf16) - len(bf16_bad),
127
+ "basis_shape": list(basis.shape),
128
+ "basis_orthogonality_max_abs": orth_error,
129
+ "curve_samples": args.samples,
130
+ "adaln_relative_errors": curve_errors,
131
+ }
132
+
133
+ print(json.dumps(results, ensure_ascii=False, indent=2))
134
+
135
+
136
+ if __name__ == "__main__":
137
+ main()