Skip to content

Commit b99ce07

Browse files
authored
Fix numpy/meta ops for DPT/Dinov3 tests (#2325)
1 parent b259e3c commit b99ce07

File tree

20 files changed

+343
-51
lines changed

20 files changed

+343
-51
lines changed

src/mindnlp/inference/layers/activation.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55

66
class SiluAndMul(nn.Module):
7-
8-
def __init__(self):
9-
super().__init__() # pylint: disable=useless-parent-delegation
10-
117
@mindtorch.compile
128
def forward(self, x: mindtorch.Tensor) -> mindtorch.Tensor:
139
x, y = x.chunk(2, -1)

src/mindnlp/inference/layers/attention.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ def forward(self, q: mindtorch.Tensor, k: mindtorch.Tensor, v: mindtorch.Tensor)
3737
k_cache, v_cache = self.k_cache, self.v_cache
3838
if k_cache.numel() and v_cache.numel():
3939
store_kvcache(k, v, k_cache, v_cache, context.slot_mapping)
40-
if context.is_prefill:
41-
if context.block_tables is not None: # prefix cache
42-
k, v = k_cache, v_cache
43-
# pylint: disable=undefined-variable
44-
o = flash_attn_varlen_func(q, k, v,
45-
max_seqlen_q=context.max_seqlen_q, cu_seqlens_q=context.cu_seqlens_q,
46-
max_seqlen_k=context.max_seqlen_k, cu_seqlens_k=context.cu_seqlens_k,
47-
softmax_scale=self.scale, causal=True, block_table=context.block_tables)
48-
else: # decode
49-
# flash_attn_with_kvcache is conditionally imported from flash_attn
50-
# pylint: disable=undefined-variable
51-
o = flash_attn_with_kvcache(q.unsqueeze(1), k_cache, v_cache, # noqa: F821
52-
cache_seqlens=context.context_lens, block_table=context.block_tables,
53-
softmax_scale=self.scale, causal=True)
54-
return o
40+
# if context.is_prefill:
41+
# if context.block_tables is not None: # prefix cache
42+
# k, v = k_cache, v_cache
43+
# # pylint: disable=undefined-variable
44+
# o = flash_attn_varlen_func(q, k, v,
45+
# max_seqlen_q=context.max_seqlen_q, cu_seqlens_q=context.cu_seqlens_q,
46+
# max_seqlen_k=context.max_seqlen_k, cu_seqlens_k=context.cu_seqlens_k,
47+
# softmax_scale=self.scale, causal=True, block_table=context.block_tables)
48+
# else: # decode
49+
# # flash_attn_with_kvcache is conditionally imported from flash_attn
50+
# # pylint: disable=undefined-variable
51+
# o = flash_attn_with_kvcache(q.unsqueeze(1), k_cache, v_cache, # noqa: F821
52+
# cache_seqlens=context.context_lens, block_table=context.block_tables,
53+
# softmax_scale=self.scale, causal=True)
54+
# return o

src/mindnlp/inference/layers/sampler.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44

55
class Sampler(nn.Module):
6-
7-
def __init__(self):
8-
super().__init__() # pylint: disable=useless-parent-delegation
9-
106
def forward(self, logits: mindtorch.Tensor, temperatures: mindtorch.Tensor):
117
logits = logits.to(mindtorch.float)
128
greedy_tokens = logits.argmax(dim=-1)

src/mindnlp/patch/diffusers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ def setup_diffusers_module():
2323
# Redirect mindnlp.diffusers to diffusers
2424
if 'mindnlp.diffusers' not in sys.modules:
2525
sys.modules['mindnlp.diffusers'] = diffusers
26-

src/mindnlp/patch/diffusers/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ def patch_diffusers_common():
2323
)
2424
except ImportError:
2525
pass
26-

src/mindnlp/patch/registry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,3 @@ def apply_all_patches(verbose: bool = False):
237237
apply_safetensors_patches(verbose=verbose)
238238
apply_transformers_patches(verbose=verbose)
239239
apply_diffusers_patches(verbose=verbose)
240-

src/mindnlp/patch/transformers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ def setup_transformers_module():
3838
transformers_module_name_nlp = 'mindnlp.transformers'
3939
if transformers_module_name_nlp not in sys.modules or not isinstance(sys.modules[transformers_module_name_nlp], _LazyModule):
4040
sys.modules[transformers_module_name_nlp] = lazy_module
41-

src/mindnlp/patch/transformers/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,3 @@ def empty_fn(*args, **kwargs):
7474
# Patch cache utils
7575
transformers.cache_utils.DynamicLayer.update = dynamic_layer_update
7676
transformers.cache_utils.DynamicSlidingWindowLayer.update = dynamic_sliding_window_layer_update
77-

src/mindnlp/patch/transformers/v4_55.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ def patch_pre_trained_model_v4_55():
1717
'from_pretrained',
1818
[transformers.modeling_utils.restore_default_torch_dtype]
1919
)
20-

src/mindnlp/patch/transformers/v4_56.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ def patch_pre_trained_model_v4_56():
1717
'from_pretrained',
1818
[transformers.modeling_utils.restore_default_dtype]
1919
)
20-

0 commit comments

Comments
 (0)