Fix module-config tensor init: shape-bounded randint high, int-dtype randint, float-dtype xavier, bfloat16 default, int64 for index tensors - #228
Merged
Conversation
Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com>
Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com>
Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com>
Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com>
kiszk
marked this pull request as ready for review
July 22, 2026 03:33
Collaborator
Author
|
@moriohara @anubhavjana Could you please review this PR? |
moriohara
enabled auto-merge
July 23, 2026 10:31
anubhavjana
approved these changes
Jul 23, 2026
🔄 merge-queue-integration: running |
assaftibm
pushed a commit
that referenced
this pull request
Aug 10, 2026
…randint, float-dtype xavier, bfloat16 default, int64 for index tensors (#228) * use xavier for initialization Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com> * update YAML files Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com> * Fix handling of position_embeddings Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com> * Fix comments Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com> --------- Signed-off-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com> Co-authored-by: Moriyoshi Ohara <ohara@jp.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes four defects in the auto-generated module test configs and the generator/API that produces them (
utils/module_discovery/auto_generate_module_config.py). The source fixes make future regenerations correct; the four existing YAMLs undertests/configs/module_tests/are updated to match.Fixes #225
Problems & fixes
1.
randintupper bound was a fixed 10000_tensor_info_to_specset the exclusive upper bound of integer tensors to a fixed10000, unrelated to the tensor's own shape. For index/position/cache tensors this produces out-of-range values and unexpected element accesses.Fix (source):
high = max(min(shape), 1)— the tensor's smallest dimension, guarded to be ≥ 1.2. Integer tensors initialized with
randnSome
torch.int32/torch.int64tensors usedinit: xavier.torch.randn(normal_kernel_cpu) orxavieris float-only and raisesNotImplementedErrorfor integer dtypes.Fix (source): any integer dtype (
int/uint/long/short/bool) now always usesrandint.3. Floating-point tensors defaulted to
float32instead ofbfloat16from_pretraineddefaults to float32, so models loaded without an explicit dtype recorded float tensors asfloat32. Spyre runs in bfloat16, so bfloat16 should be the default in both the generator and the API.Fix (source):
DEFAULT_FLOAT_DTYPE = torch.bfloat16constant.load_model_onlynowsetdefaultstorch_dtypeto bfloat16 (explicit caller values still honored)._tensor_info_to_specnormalizes any captured float dtype (float16/32/64/half/double) to bfloat16 on emit.4. Special (index) tensors kept a floating-point dtype
Tensors matched by
_is_special_tensor()(name containsposition/mask/ids) carry indices, not activations, and are always initialized withrandint. Some - notablyposition_embeddingswere captured under a floating-point dtype, leaving the inconsistent combination of a float dtype withrandintinit.Fix (source):
_is_special_tensor()forposition_embeddingsreturns False.YAML changes
Applied to all four configs (
granite_3_3_8b_instruct,granite_4_1_8b,Ministral-3-14B-Instruct-2512,Mistral-Small-3.2-24B-Instruct-2506):high: 10000→ the tensor's smallest dimension (cache_position [128]→128, all others →1).init: randn→init: randint(+init_args.high) — hit the RotaryEmbedding inputs ingranite_4_1_8bandMistral-Small.init: randn→init: xavierfor numerical stabilitydtype: torch.float32→torch.bfloat16— ingranite_4_1_8bandMistral-Small.position_embeddingstensor-list entries (float dtype +randint) →init: xavier— 8 per file across all four configs.Comments, YAML anchors (
&id001/*id001), and thesupported_dtypesglobal block are preserved.