Add CPU test for ModernBert Model #2264
97 tests run, 5 passed, 77 skipped, 15 failed.
Annotations
Check failure on line 53 in forge/test/models/pytorch/multimodal/clip/test_clip.py
github-actions / TT-Forge-FE Tests
test_clip.test_clip_pytorch[openai/clip-vit-base-patch32]
RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f44e6a181f0>
variant = 'openai/clip-vit-base-patch32'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", ["openai/clip-vit-base-patch32"])
def test_clip_pytorch(record_forge_property, variant):
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH,
model="clip",
variant=variant,
suffix="text",
source=Source.HUGGINGFACE,
task=Task.TEXT_GENERATION,
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load processor and model from HuggingFace
model = download_model(CLIPModel.from_pretrained, variant, torchscript=True)
processor = download_model(CLIPProcessor.from_pretrained, variant)
# Load image from the IAM dataset
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
# Process image
text = [
"a photo of a cat",
"a photo of a dog",
]
inputs = processor(text=text, images=image, return_tensors="pt")
inputs = [inputs["input_ids"], inputs["pixel_values"], inputs["attention_mask"]]
framework_model = CLIPTextWrapper(model)
inputs = [inputs[0], inputs[2]]
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/multimodal/clip/test_clip.py:53:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_clip_openai_clip_vit_base_patch32_text_gen_hf_text], graph_name='pt_clip_openai_clip...cles_offset=0, forge_module=<forge._C.ForgeGraphModule object at 0x7f43fe158cb0>, compiled_binary=None, attach_to=None)
def run_mlir_compiler(context: CompileContext) -> CompileDepth:
assert context.forge_module is not None
> context.compiled_binary = forge._C.run_mlir_compiler(context.forge_module)
E RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
forge/forge/compile.py:976: RuntimeError
Check failure on line 55 in forge/test/models/pytorch/text/gpt2/test_gpt2.py
github-actions / TT-Forge-FE Tests
test_gpt2.test_gpt2_text_gen[gpt2]
RuntimeError: Tensor 6 - data type mismatch: expected Float32, got UInt8
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f44b5b53520>
variant = 'gpt2'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", ["gpt2"])
def test_gpt2_text_gen(record_forge_property, variant):
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="gpt2", variant=variant, task=Task.TEXT_GENERATION, source=Source.HUGGINGFACE
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load tokenizer and model from HuggingFace
config = GPT2Config.from_pretrained(variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = GPT2Config(**config_dict)
model = download_model(GPT2LMHeadModel.from_pretrained, variant, config=config)
# Wrapper to get around past key values
class Wrapper(torch.nn.Module):
def __init__(self, model):
super().__init__()
self.model = model
def forward(self, input_ids, attention_mask):
return self.model(input_ids, None, attention_mask)
input_ids = torch.cat(
[torch.randint(1, model.config.vocab_size, (1, 255)), torch.zeros(1, 1, dtype=torch.int64)], dim=-1
).to(torch.int64)
attn_mask = torch.ones(1, 256)
inputs = [input_ids, attn_mask]
framework_model = Wrapper(model)
# Forge compile framework model
compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
# Model Verification
> verify(inputs, framework_model, compiled_model)
forge/test/models/pytorch/text/gpt2/test_gpt2.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/verify/verify.py:302: in verify
co_out = compiled_model(*inputs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <forge.compiled_graph_state.CompiledModel object at 0x7f43f9acbbe0>
inputs = (tensor([[29133, 28000, 17958, 22849, 11636, 28204, 34532, 32312, 14762, 43444, 13158, 47523, 49381, 42088, 25607, 398...1., 1., 1., 1., 1.,
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]]))
inputs_and_parameters = [tensor([[29133, 28000, 17958, 22849, 11636, 28204, 34532, 32312, 14762, 43444, 13158, 47523, 49381, 42088, 25607, 398... [1.00000e-05],
[1.00000e-05],
[1.00000e-05],
[1.00000e-05]]]), tensor([0.12500]), ...]
def __call__(self, *inputs: AnyTensor) -> List[torch.Tensor]:
"""
Run inference on the compiled model.
Parameters
----------
inputs: [Tensor, ...]
Input tensors
Returns
-------
List[Tensor]
Output tensors
"""
self.inputs = [*to_pt_tensors(inputs)]
inputs_and_parameters = [
*self.inputs,
*self.fwd_compiled_graph_state.get_ordered_constant_tensors(),
*self.fwd_compiled_graph_state.get_ordered_parameter_tensors(),
]
assert all(
[isinstance(t, torch.Tensor) for t in inputs_and_parameters]
), "All inputs should be torch tensors by now."
if self.training() and isinstance(self.framework_module, PyTorchModule):
for name, param in self.framework_module.module.named_parameters():
if param.requires_grad:
our_tensor = self.fwd_compiled_graph_state.get_parameter_tensor(name)
# NOTE: for parameters that require gradients, we want to share the same tensor with the PyTorch
# module. This is because we want to be able to optimize the parameters both on the device
# (through our runtime) and via the torch optimizers. So this ensures that whichever side updates
# the parameter value, the other side can see the change.
#
# This could change in the future, but for now ensure that our premise is correct.
assert param is our_tensor
logger.info(
f"Running model {self.framework_module.get_name()} {self.fwd_compiled_graph_state.graph.get_name()} on device..."
)
> all_outputs = run_binary(self.compiled_binary, int(ProgramId.FORWARD), inputs_and_parameters)
E RuntimeError: Tensor 6 - data type mismatch: expected Float32, got UInt8
forge/forge/compiled_graph_state.py:253: RuntimeError
Check failure on line 63 in forge/test/models/pytorch/text/opt/test_opt.py
github-actions / TT-Forge-FE Tests
test_opt.test_opt_causal_lm[facebook/opt-125m]
RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43dc1a7a30>
variant = 'facebook/opt-125m'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_opt_causal_lm(record_forge_property, variant):
if variant != "facebook/opt-125m":
pytest.skip("Skipping due to the current CI/CD pipeline limitations")
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="opt", variant=variant, task=Task.CAUSAL_LM, source=Source.HUGGINGFACE
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load tokenizer and model from HuggingFace
# Variants: "facebook/opt-125m", "facebook/opt-350m", "facebook/opt-1.3b"
config = OPTConfig.from_pretrained(variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = OPTConfig(**config_dict)
framework_model = download_model(OPTForCausalLM.from_pretrained, variant, config=config)
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
tokenizer.pad_token = tokenizer.eos_token
# Input sample
prefix_text = "My name is Thomas and my main"
input_tokens = tokenizer(
prefix_text,
max_length=256,
padding="max_length",
truncation=True,
return_tensors="pt",
)
inputs = [input_tokens["input_ids"], input_tokens["attention_mask"]]
# Forge compile framework model
> compiled_model = forge.compile(
framework_model,
inputs,
module_name,
)
forge/test/models/pytorch/text/opt/test_opt.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_opt_facebook_opt_125m_clm_hf], graph_name='pt_opt_facebook_opt_125m_clm_hf', compile...cles_offset=0, forge_module=<forge._C.ForgeGraphModule object at 0x7f44b1b65230>, compiled_binary=None, attach_to=None)
def run_mlir_compiler(context: CompileContext) -> CompileDepth:
assert context.forge_module is not None
> context.compiled_binary = forge._C.run_mlir_compiler(context.forge_module)
E RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
forge/forge/compile.py:976: RuntimeError
Check failure on line 67 in forge/test/models/pytorch/text/phi2/test_phi2.py
github-actions / TT-Forge-FE Tests
test_phi2.test_phi2_clm[microsoft/phi-2]
AssertionError: Data mismatch on output 0 between framework and Forge codegen
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f44e4e21120>
variant = 'microsoft/phi-2'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants, ids=variants)
def test_phi2_clm(record_forge_property, variant):
if variant != "microsoft/phi-2":
pytest.skip("Skipping due to the current CI/CD pipeline limitations")
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="phi2", variant=variant, task=Task.CAUSAL_LM, source=Source.HUGGINGFACE
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load PhiConfig from pretrained variant, disable return_dict and caching.
config = PhiConfig.from_pretrained(variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = PhiConfig(**config_dict)
# Load model and tokenizer from HuggingFace
framework_model = PhiForCausalLM.from_pretrained(variant, trust_remote_code=True, config=config)
framework_model.eval()
tokenizer = AutoTokenizer.from_pretrained(variant, return_tensors="pt", trust_remote_code=True)
tokenizer.add_special_tokens({"pad_token": "[PAD]"})
# input_prompt
input_prompt = "Write a detailed analogy between mathematics and a lighthouse."
# Tokenize input
inputs = tokenizer(
input_prompt,
return_tensors="pt",
max_length=256,
pad_to_max_length=True,
truncation=True,
)
input_ids = inputs["input_ids"].to(torch.int32)
attn_mask = inputs["attention_mask"].to(torch.float32)
inputs = [input_ids, attn_mask]
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/text/phi2/test_phi2.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:678: in generate_initial_graph
module, module_inputs = convert_to_forge_module(
forge/forge/compile.py:1021: in convert_to_forge_module
forge_module, dev_types, module_inputs = generate_forge_module(
forge/forge/tvm_to_python.py:2140: in generate_forge_module
verify_framework_vs_forge_codegen(framework_outputs, forge_outputs, verify_cfg=verify_cfg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
frame_outputs = [tensor([[[ 6.17570, 8.31606, 4.25982, ..., -1.74712, -1.74752, -1.74717],
[ 5.07636, 3.62571, 1.85676, ...71, -3.92533],
[ 8.07223, 11.88663, 11.73339, ..., -3.90528, -3.90507, -3.90656]]], grad_fn=<ViewBackward0>)]
forge_outputs = (Forge Tensor: tensor([[[ 6.17487, 8.31714, 4.26098, ..., -1.74720, -1.74759, -1.74724],
[ 5.07510, 3.625... [10.83244, 14.59324, 13.97810, ..., 1.54481, 1.54382, 1.54469]]], grad_fn=<AddBackward0>), DataFormat.Float32,)
verify_cfg = DepricatedVerifyConfig(graph_name='graph', enabled=False, intermediates=False, rtol={torch.float32: None, torch.float1...ent_checking=True, enable_parameter_gradient_checking=True, _input_gradient_queue=None, _parameter_gradient_queue=None)
def verify_framework_vs_forge_codegen(frame_outputs, forge_outputs, verify_cfg):
from forge.verify.compare import compare_tensor_to_golden
test_pass = True
for i, (golden, output) in enumerate(zip(frame_outputs, forge_outputs)):
test_pass &= compare_tensor_to_golden(
f"Framework vs. Forge codegen output {i}", golden, output.value(), is_forge=False, verify_cfg=verify_cfg
)
> assert test_pass, f"Data mismatch on output {i} between framework and Forge codegen"
E AssertionError: Data mismatch on output 0 between framework and Forge codegen
forge/forge/tvm_to_python.py:1987: AssertionError
Check failure on line 56 in forge/test/models/pytorch/text/qwen/test_qwen_v2.py
github-actions / TT-Forge-FE Tests
test_qwen_v2.test_qwen_clm[Qwen/Qwen2.5-0.5B]
NotImplementedError: Unknown output type: <class 'transformers.cache_utils.DynamicCache'>
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f26f20e0>
variant = 'Qwen/Qwen2.5-0.5B'
@pytest.mark.parametrize("variant", variants, ids=variants)
@pytest.mark.nightly
def test_qwen_clm(record_forge_property, variant):
if variant != "Qwen/Qwen2.5-0.5B":
pytest.skip("Skipping due to the current CI/CD pipeline limitations")
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="qwen_v2", variant=variant, task=Task.CAUSAL_LM, source=Source.HUGGINGFACE
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load model and tokenizer
framework_model = AutoModelForCausalLM.from_pretrained(variant, device_map="cpu")
framework_model.config.return_dict = False
tokenizer = AutoTokenizer.from_pretrained(variant)
# Prepare input
prompt = "Give me a short introduction to large language models."
messages = [{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
# Tokenize and generate
model_inputs = tokenizer([text], return_tensors="pt")
input_ids = model_inputs["input_ids"]
attention_mask = model_inputs["attention_mask"]
inputs = [input_ids, attention_mask]
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/text/qwen/test_qwen_v2.py:56:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:678: in generate_initial_graph
module, module_inputs = convert_to_forge_module(
forge/forge/compile.py:1021: in convert_to_forge_module
forge_module, dev_types, module_inputs = generate_forge_module(
forge/forge/tvm_to_python.py:2074: in generate_forge_module
framework_outputs = framework_mod.cpu_eval_forward(*pytorch_inputs)
forge/forge/module.py:142: in cpu_eval_forward
outputs = flatten_structured_output([outputs])
forge/forge/tvm_utils.py:112: in flatten_structured_output
sub_output = flatten_structured_output(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
outputs = (tensor([[[ 4.53052, 8.29057, 4.07659, ..., -5.43016, -5.43139, -5.43012],
[ 7.01902, 8.79074, 8.06051, ... [10.09287, 11.01321, 11.03911, ..., -3.17600, -3.17630, -3.17623]]], grad_fn=<UnsafeViewBackward0>), DynamicCache())
def flatten_structured_output(outputs):
from forge.tensor import Tensor
new_outputs = []
for i in range(len(outputs)):
out = outputs[i]
if isinstance(out, (list, tuple)):
sub_output = flatten_structured_output(
out,
)
new_outputs += sub_output
elif isinstance(out, dict):
sub_output = []
for k, v in out.items():
sub_output.append(v)
sub_output = flatten_structured_output(
sub_output,
)
new_outputs += sub_output
elif isinstance(out, (torch.Tensor, tf.Tensor, Tensor, np.ndarray)):
new_outputs.append(out)
elif out is None:
continue
else:
> raise NotImplementedError(f"Unknown output type: {type(out)}")
E NotImplementedError: Unknown output type: <class 'transformers.cache_utils.DynamicCache'>
forge/forge/tvm_utils.py:133: NotImplementedError
Check failure on line 49 in forge/test/models/pytorch/text/roberta/test_roberta.py
github-actions / TT-Forge-FE Tests
test_roberta.test_roberta_masked_lm[xlm-roberta-base]
RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43dc1a7010>
variant = 'xlm-roberta-base'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", ["xlm-roberta-base"])
def test_roberta_masked_lm(record_forge_property, variant):
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="roberta", variant=variant, task=Task.MASKED_LM, source=Source.HUGGINGFACE
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load Albert tokenizer and model from HuggingFace
tokenizer = download_model(AutoTokenizer.from_pretrained, variant)
framework_model = download_model(AutoModelForMaskedLM.from_pretrained, variant)
# Input processing
text = "Hello I'm a <mask> model."
input_tokens = tokenizer.encode(
text,
max_length=128,
padding="max_length",
truncation=True,
return_tensors="pt",
)
attention_mask = torch.zeros_like(input_tokens)
attention_mask[input_tokens != 1] = 1
inputs = [input_tokens, attention_mask]
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/text/roberta/test_roberta.py:49:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_roberta_xlm_roberta_base_mlm_hf], graph_name='pt_roberta_xlm_roberta_base_mlm_hf', c...cles_offset=0, forge_module=<forge._C.ForgeGraphModule object at 0x7f43f2773170>, compiled_binary=None, attach_to=None)
def run_mlir_compiler(context: CompileContext) -> CompileDepth:
assert context.forge_module is not None
> context.compiled_binary = forge._C.run_mlir_compiler(context.forge_module)
E RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
forge/forge/compile.py:976: RuntimeError
Check failure on line 168 in forge/test/models/pytorch/text/t5/test_t5.py
github-actions / TT-Forge-FE Tests
test_t5.test_t5_generation[t5-base]
ValueError: Data mismatch -> AutomaticValueChecker (compare_with_golden): framework_model=tensor([[[-18.88008, -10.41466, -14.89029, ..., -43.63989, -43.76201, -43.71423]]], grad_fn=<UnsafeViewBackward0>), compiled_model=tensor([[[-31.69363, -10.19963, -13.79479, ..., -44.44143, -44.45059, -44.40383]]])
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f2a1cdc0>
variant = 't5-base'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants)
def test_t5_generation(record_forge_property, variant):
if variant not in {"t5-small", "google/flan-t5-small", "t5-base", "t5-large"}:
pytest.skip(f"Skipping {variant} due to the current CI/CD pipeline limitations")
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="t5", variant=variant, task=Task.TEXT_GENERATION, source=Source.HUGGINGFACE
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load tokenizer and model from HuggingFace
# Variants: t5-small, t5-base, t5-large
config = download_model(T5Config.from_pretrained, variant)
config_dict = config.to_dict()
config_dict["return_dict"] = False
config_dict["use_cache"] = False
config = T5Config(**config_dict)
model = download_model(T5ForConditionalGeneration.from_pretrained, variant, config=config)
tokenizer = AutoTokenizer.from_pretrained(variant)
inputs = tokenizer(
"summarize: Researchers have extensively studied the benefits of having pets, "
"particularly dogs, on human health and well-being. Findings suggest that pet ownership "
"can lead to improved mental health, reduced stress levels, and even physical health benefits "
"such as lower blood pressure and increased physical activity levels due to regular walks.",
return_tensors="pt",
)
input_ids = inputs.input_ids
decoder_start_token_tensor = torch.tensor(model.generation_config.decoder_start_token_id, dtype=torch.long)
decoder_input_ids = torch.ones((1, 1), dtype=torch.long) * decoder_start_token_tensor
inputs = [input_ids, decoder_input_ids]
class Wrapper(torch.nn.Module):
def __init__(self, model):
super().__init__()
self.model = model
def forward(self, input_ids, decoder_input_ids):
inputs = {"input_ids": input_ids, "decoder_input_ids": decoder_input_ids}
output = self.model(**inputs)
return output
framework_model = Wrapper(model)
# Forge compile
compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
# Model Verification
> verify(inputs, framework_model, compiled_model)
forge/test/models/pytorch/text/t5/test_t5.py:168:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/verify/verify.py:333: in verify
verify_cfg.value_checker.check(fw, co)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <forge.verify.value_checkers.AutomaticValueChecker object at 0x7f45116b26b0>
fw_out = tensor([[[-18.88008, -10.41466, -14.89029, ..., -43.63989, -43.76201, -43.71423]]], grad_fn=<UnsafeViewBackward0>)
co_out = tensor([[[-31.69363, -10.19963, -13.79479, ..., -44.44143, -44.45059, -44.40383]]])
def check(self, fw_out, co_out):
if not compare_with_golden(fw_out, co_out, self.pcc, self.rtol, self.atol, self.dissimilarity_threshold):
> raise ValueError(
f"Data mismatch -> AutomaticValueChecker (compare_with_golden): framework_model={fw_out}, compiled_model={co_out}"
)
E ValueError: Data mismatch -> AutomaticValueChecker (compare_with_golden): framework_model=tensor([[[-18.88008, -10.41466, -14.89029, ..., -43.63989, -43.76201, -43.71423]]], grad_fn=<UnsafeViewBackward0>), compiled_model=tensor([[[-31.69363, -10.19963, -13.79479, ..., -44.44143, -44.45059, -44.40383]]])
forge/forge/verify/value_checkers.py:38: ValueError
Check failure on line 51 in forge/test/models/pytorch/vision/autoencoder/test_autoencoder.py
github-actions / TT-Forge-FE Tests
test_autoencoder.test_conv_ae_pytorch
RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f9b6a680>
@pytest.mark.nightly
def test_conv_ae_pytorch(record_forge_property):
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="autoencoder", variant="conv", task=Task.IMAGE_ENCODING, source=Source.GITHUB
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Instantiate model
# NOTE: The model has not been pre-trained or fine-tuned.
# This is for demonstration purposes only.
framework_model = ConvAE()
# Define transform to normalize data
transform = transforms.Compose(
[
transforms.ToTensor(),
transforms.Normalize((0.1307,), (0.3081,)),
]
)
# Load sample from MNIST dataset
dataset = load_dataset("mnist")
sample = dataset["train"][0]["image"]
sample_tensor = transform(sample).unsqueeze(0)
inputs = [sample_tensor]
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/vision/autoencoder/test_autoencoder.py:51:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_autoencoder_conv_img_enc_github], graph_name='pt_autoencoder_conv_img_enc_github', c...cles_offset=0, forge_module=<forge._C.ForgeGraphModule object at 0x7f44e6a815b0>, compiled_binary=None, attach_to=None)
def run_mlir_compiler(context: CompileContext) -> CompileDepth:
assert context.forge_module is not None
> context.compiled_binary = forge._C.run_mlir_compiler(context.forge_module)
E RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
forge/forge/compile.py:976: RuntimeError
Check failure on line 84 in forge/test/models/pytorch/vision/densenet/test_densenet.py
github-actions / TT-Forge-FE Tests
test_densenet.test_densenet_161_pytorch[densenet161]
RuntimeError: Tensor 0 - stride mismatch: expected [150528, 50176, 224, 1], got [3, 1, 672, 3]
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f9b6bbe0>
variant = 'densenet161'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", ["densenet161"])
def test_densenet_161_pytorch(record_forge_property, variant):
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH,
model="densenet",
variant=variant,
source=Source.TORCHVISION,
task=Task.IMAGE_CLASSIFICATION,
)
# Record Forge Property
record_forge_property("model_name", module_name)
# STEP 2: Create Forge module from PyTorch model
framework_model = download_model(torch.hub.load, "pytorch/vision:v0.10.0", "densenet161", pretrained=True)
# STEP 3: Run inference on Tenstorrent device
img_tensor = get_input_img()
inputs = [img_tensor]
# Forge compile framework model
compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
# Model Verification
> verify(inputs, framework_model, compiled_model)
forge/test/models/pytorch/vision/densenet/test_densenet.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/verify/verify.py:302: in verify
co_out = compiled_model(*inputs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <forge.compiled_graph_state.CompiledModel object at 0x7f45334b3c10>
inputs = (tensor([[[[-1.92953, -1.92953, -1.91241, ..., -2.03228, -1.94666, -1.92953],
[-1.99803, -1.89528, -1.91241... ..., -0.95041, -1.49072, -1.38614],
[-1.28157, -1.42100, -1.22928, ..., -0.74126, -1.12471, -1.28157]]]]),)
inputs_and_parameters = [tensor([[[[-1.92953, -1.92953, -1.91241, ..., -2.03228, -1.94666, -1.92953],
[-1.99803, -1.89528, -1.91241....22809e+00, 3.30098e+00, 2.08003e+00, 3.74907e+00, 2.18630e+00, 2.48350e+00, 3.65909e+00]]]], requires_grad=True), ...]
def __call__(self, *inputs: AnyTensor) -> List[torch.Tensor]:
"""
Run inference on the compiled model.
Parameters
----------
inputs: [Tensor, ...]
Input tensors
Returns
-------
List[Tensor]
Output tensors
"""
self.inputs = [*to_pt_tensors(inputs)]
inputs_and_parameters = [
*self.inputs,
*self.fwd_compiled_graph_state.get_ordered_constant_tensors(),
*self.fwd_compiled_graph_state.get_ordered_parameter_tensors(),
]
assert all(
[isinstance(t, torch.Tensor) for t in inputs_and_parameters]
), "All inputs should be torch tensors by now."
if self.training() and isinstance(self.framework_module, PyTorchModule):
for name, param in self.framework_module.module.named_parameters():
if param.requires_grad:
our_tensor = self.fwd_compiled_graph_state.get_parameter_tensor(name)
# NOTE: for parameters that require gradients, we want to share the same tensor with the PyTorch
# module. This is because we want to be able to optimize the parameters both on the device
# (through our runtime) and via the torch optimizers. So this ensures that whichever side updates
# the parameter value, the other side can see the change.
#
# This could change in the future, but for now ensure that our premise is correct.
assert param is our_tensor
logger.info(
f"Running model {self.framework_module.get_name()} {self.fwd_compiled_graph_state.graph.get_name()} on device..."
)
> all_outputs = run_binary(self.compiled_binary, int(ProgramId.FORWARD), inputs_and_parameters)
E RuntimeError: Tensor 0 - stride mismatch: expected [150528, 50176, 224, 1], got [3, 1, 672, 3]
forge/forge/compiled_graph_state.py:253: RuntimeError
Check failure on line 93 in forge/test/models/pytorch/vision/efficientnet/test_efficientnet.py
github-actions / TT-Forge-FE Tests
test_efficientnet.test_efficientnet_timm[efficientnet_b0]
RuntimeError: TT_THROW @ /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal/tt_metal/impl/program/program.cpp:898: tt::exception
info:
Statically allocated circular buffers on core range [(x=0,y=0) - (x=6,y=6)] grow to 1942368 B which is beyond max L1 size of 1499136 B
backtrace:
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/libtt_metal.so(+0x1657eb) [0x7f4515c0f7eb]
--- tt::tt_metal::detail::Program_::validate_circular_buffer_region(tt::tt_metal::v0::IDevice const*)
--- tt::tt_metal::v0::CommandQueue::run_command_impl(tt::tt_metal::CommandInterface const&)
--- tt::tt_metal::v0::EnqueueProgram(tt::tt_metal::v0::CommandQueue&, tt::tt_metal::v0::Program&, bool)
--- void ttnn::device_operation::detail::launch_on_worker_thread<tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >, unsigned char, long, tt::tt_metal::operation::DeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t, std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> >, tt::tt_metal::v0::IDevice*>(unsigned char, long, tt::tt_metal::operation::DeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > > const&, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t const&, std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> >&, tt::tt_metal::v0::IDevice*&)
--- tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_return_value_t ttnn::device_operation::detail::launch_on_single_device<tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > > >(unsigned char, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::operation_attributes_t const&, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t const&)
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x306fe99) [0x7f4518ed1e99]
--- tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_return_value_t ttnn::device_operation::detail::invoke<tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > > >(unsigned char, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::operation_attributes_t const&, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t const&)
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x306c5df) [0x7f4518ece5df]
--- std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > tt::tt_metal::operation::run_without_autoformat<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >(tt::tt_metal::operation::DeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >&&, std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > const&, std::vector<std::optional<tt::tt_metal::Tensor const>, std::allocator<std::optional<tt::tt_metal::Tensor const> > > const&, std::vector<std::optional<tt::tt_metal::Tensor>, std::allocator<std::optional<tt::tt_metal::Tensor> > > const&, unsigned char)
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x46873f) [0x7f45162ca73f]
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x471d90) [0x7f45162d3d90]
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x4729ec) [0x7f45162d49ec]
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(_ZN4ttnn10operations4conv6conv2d18optimized_conv_newERKN2tt8tt_metal6TensorES7_St8optionalIS6_ERKNS0_14sliding_window19SlidingWindowConfigEjjbbRKNS2_34OptimizedConvParallelizationConfigERKNS2_24OptimizedConvBlockConfigERKNS4_12MemoryConfigENS4_8DataTypeESt5arrayIjLm4EEbRKSt7variantIJNS_28GrayskullComputeKernelConfigENS_27WormholeComputeKernelConfigEEEbbbbb+0x18f1) [0x7f4516252df1]
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(_ZN4ttnn10operations4conv6conv2d6conv2dIN2tt8tt_metal2v07IDeviceEEESt5tupleIJNS5_6TensorEjjS9_St8optionalIS9_EEERKS9_SE_PT_jjjjjSt5arrayIjLm2EESI_SI_SI_jSA_ISD_ERKSA_IKNS2_12Conv2dConfigEERKSA_IKSt7variantIJNS_28GrayskullComputeKernelConfigENS_27WormholeComputeKernelConfigEEEERKSA_IKNS5_12MemoryConfigEE+0xf7b) [0x7f451624094b]
--- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/build/lib/SharedLib/libTTMLIR.so(+0x761d13) [0x7f451aa92d13]
--- tt::runtime::ttnn::operations::conv::run(tt::target::ttnn::Conv2dOp const*, tt::runtime::ttnn::ProgramContext&)
--- tt::runtime::ttnn::runProgram(tt::tt_metal::distributed::MeshDevice&, tt::runtime::Binary, unsigned int, std::vector<tt::tt_metal::Tensor*, std::allocator<tt::tt_metal::Tensor*> > const&)
--- tt::runtime::ttnn::submit(tt::runtime::Device, tt::runtime::Binary, unsigned int, std::vector<tt::runtime::Tensor, std::allocator<tt::runtime::Tensor> > const&)
--- tt::runtime::submit(tt::runtime::Device, tt::runtime::Binary, unsigned int, std::vector<tt::runtime::Tensor, std::allocator<tt::runtime::Tensor> > const&)
--- tt::run_binary(tt::runtime::Binary&, int, std::vector<at::Tensor, std::allocator<at::Tensor> > const&)
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0x316b30) [0x7f45271fdb30]
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0x316a7e) [0x7f45271fda7e]
--- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xe17a5) [0x7f4526fc87a5]
--- /opt/ttforge-toolchain/venv/bin/python(+0x18ab32) [0x55d6cf9b1b32]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x55d6cf9a839b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x59c7) [0x55d6cf9a1a97]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0xc4) [0x55d6cf9a7574]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x55d6cf9c010b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6c0) [0x55d6cf99c790]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x55d6cf9c0172]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
--- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x55d6cf9a761d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x55d6cf9a839b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x68ce) [0x55d6cf9a299e]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x8af) [0x55d6cf99c97f]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
--- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x55d6cf9a761d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
--- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x55d6cf9c010b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6c0) [0x55d6cf99c790]
--- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6c0) [0x55d6cf99c790]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
--- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x55d6cf9a761d]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
--- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
--- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x55d6cf9a839b]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x68ce) [0x55d6cf9a299e]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
--- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
--- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43dc1504c0>
variant = 'efficientnet_b0'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants)
def test_efficientnet_timm(record_forge_property, variant):
if variant != "efficientnet_b0":
pytest.skip("Skipping due to the current CI/CD pipeline limitations")
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH,
model="efficientnet",
variant=variant,
source=Source.TIMM,
task=Task.IMAGE_CLASSIFICATION,
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Load model
framework_model = download_model(timm.create_model, variant, pretrained=True)
framework_model.eval()
# Load and pre-process image
try:
url, filename = (
"https://github.com/pytorch/hub/raw/master/images/dog.jpg",
"dog.jpg",
)
urllib.request.urlretrieve(url, filename)
img = Image.open(filename).convert("RGB")
config = resolve_data_config({}, model=framework_model)
transform = create_transform(**config)
img_tensor = transform(img).unsqueeze(0)
except:
logger.warning(
"Failed to download the image file, replacing input with random tensor. Please check if the URL is up to date"
)
img_tensor = torch.rand(1, 3, 224, 224)
inputs = [img_tensor]
# Forge compile framework model
compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
# Model Verification
> verify(inputs, framework_model, compiled_model)
forge/test/models/pytorch/vision/efficientnet/test_efficientnet.py:93:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/verify/verify.py:302: in verify
co_out = compiled_model(*inputs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <forge.compiled_graph_state.CompiledModel object at 0x7f43f2b487f0>
inputs = (tensor([[[[-1.92953, -1.92953, -1.92953, ..., -2.04940, -1.92953, -1.92953],
[-2.01516, -1.87816, -1.89528... ..., -0.91556, -1.61272, -1.40357],
[-1.26414, -1.43843, -1.19442, ..., -0.67155, -1.14213, -1.28157]]]]),)
inputs_and_parameters = [tensor([[[[-1.92953, -1.92953, -1.92953, ..., -2.04940, -1.92953, -1.92953],
[-2.01516, -1.87816, -1.89528...2.44088, 3.86180, 3.68086, 2.09527, 3.81788, 4.29909, 4.17497, 2.64127, 3.81770, 3.27010]]]], requires_grad=True), ...]
def __call__(self, *inputs: AnyTensor) -> List[torch.Tensor]:
"""
Run inference on the compiled model.
Parameters
----------
inputs: [Tensor, ...]
Input tensors
Returns
-------
List[Tensor]
Output tensors
"""
self.inputs = [*to_pt_tensors(inputs)]
inputs_and_parameters = [
*self.inputs,
*self.fwd_compiled_graph_state.get_ordered_constant_tensors(),
*self.fwd_compiled_graph_state.get_ordered_parameter_tensors(),
]
assert all(
[isinstance(t, torch.Tensor) for t in inputs_and_parameters]
), "All inputs should be torch tensors by now."
if self.training() and isinstance(self.framework_module, PyTorchModule):
for name, param in self.framework_module.module.named_parameters():
if param.requires_grad:
our_tensor = self.fwd_compiled_graph_state.get_parameter_tensor(name)
# NOTE: for parameters that require gradients, we want to share the same tensor with the PyTorch
# module. This is because we want to be able to optimize the parameters both on the device
# (through our runtime) and via the torch optimizers. So this ensures that whichever side updates
# the parameter value, the other side can see the change.
#
# This could change in the future, but for now ensure that our premise is correct.
assert param is our_tensor
logger.info(
f"Running model {self.framework_module.get_name()} {self.fwd_compiled_graph_state.graph.get_name()} on device..."
)
> all_outputs = run_binary(self.compiled_binary, int(ProgramId.FORWARD), inputs_and_parameters)
E RuntimeError: TT_THROW @ /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal/tt_metal/impl/program/program.cpp:898: tt::exception
E info:
E Statically allocated circular buffers on core range [(x=0,y=0) - (x=6,y=6)] grow to 1942368 B which is beyond max L1 size of 1499136 B
E backtrace:
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/libtt_metal.so(+0x1657eb) [0x7f4515c0f7eb]
E --- tt::tt_metal::detail::Program_::validate_circular_buffer_region(tt::tt_metal::v0::IDevice const*)
E --- tt::tt_metal::v0::CommandQueue::run_command_impl(tt::tt_metal::CommandInterface const&)
E --- tt::tt_metal::v0::EnqueueProgram(tt::tt_metal::v0::CommandQueue&, tt::tt_metal::v0::Program&, bool)
E --- void ttnn::device_operation::detail::launch_on_worker_thread<tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >, unsigned char, long, tt::tt_metal::operation::DeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t, std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> >, tt::tt_metal::v0::IDevice*>(unsigned char, long, tt::tt_metal::operation::DeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > > const&, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t const&, std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> >&, tt::tt_metal::v0::IDevice*&)
E --- tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_return_value_t ttnn::device_operation::detail::launch_on_single_device<tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > > >(unsigned char, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::operation_attributes_t const&, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t const&)
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x306fe99) [0x7f4518ed1e99]
E --- tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_return_value_t ttnn::device_operation::detail::invoke<tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > > >(unsigned char, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::operation_attributes_t const&, tt::tt_metal::operation::OldInfraDeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >::tensor_args_t const&)
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x306c5df) [0x7f4518ece5df]
E --- std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > tt::tt_metal::operation::run_without_autoformat<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >(tt::tt_metal::operation::DeviceOperation<std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > >&&, std::vector<tt::tt_metal::Tensor, std::allocator<tt::tt_metal::Tensor> > const&, std::vector<std::optional<tt::tt_metal::Tensor const>, std::allocator<std::optional<tt::tt_metal::Tensor const> > > const&, std::vector<std::optional<tt::tt_metal::Tensor>, std::allocator<std::optional<tt::tt_metal::Tensor> > > const&, unsigned char)
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x46873f) [0x7f45162ca73f]
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x471d90) [0x7f45162d3d90]
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(+0x4729ec) [0x7f45162d49ec]
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(_ZN4ttnn10operations4conv6conv2d18optimized_conv_newERKN2tt8tt_metal6TensorES7_St8optionalIS6_ERKNS0_14sliding_window19SlidingWindowConfigEjjbbRKNS2_34OptimizedConvParallelizationConfigERKNS2_24OptimizedConvBlockConfigERKNS4_12MemoryConfigENS4_8DataTypeESt5arrayIjLm4EEbRKSt7variantIJNS_28GrayskullComputeKernelConfigENS_27WormholeComputeKernelConfigEEEbbbbb+0x18f1) [0x7f4516252df1]
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib/_ttnn.so(_ZN4ttnn10operations4conv6conv2d6conv2dIN2tt8tt_metal2v07IDeviceEEESt5tupleIJNS5_6TensorEjjS9_St8optionalIS9_EEERKS9_SE_PT_jjjjjSt5arrayIjLm2EESI_SI_SI_jSA_ISD_ERKSA_IKNS2_12Conv2dConfigEERKSA_IKSt7variantIJNS_28GrayskullComputeKernelConfigENS_27WormholeComputeKernelConfigEEEERKSA_IKNS5_12MemoryConfigEE+0xf7b) [0x7f451624094b]
E --- /__w/tt-forge-fe/tt-forge-fe/third_party/tt-mlir/build/lib/SharedLib/libTTMLIR.so(+0x761d13) [0x7f451aa92d13]
E --- tt::runtime::ttnn::operations::conv::run(tt::target::ttnn::Conv2dOp const*, tt::runtime::ttnn::ProgramContext&)
E --- tt::runtime::ttnn::runProgram(tt::tt_metal::distributed::MeshDevice&, tt::runtime::Binary, unsigned int, std::vector<tt::tt_metal::Tensor*, std::allocator<tt::tt_metal::Tensor*> > const&)
E --- tt::runtime::ttnn::submit(tt::runtime::Device, tt::runtime::Binary, unsigned int, std::vector<tt::runtime::Tensor, std::allocator<tt::runtime::Tensor> > const&)
E --- tt::runtime::submit(tt::runtime::Device, tt::runtime::Binary, unsigned int, std::vector<tt::runtime::Tensor, std::allocator<tt::runtime::Tensor> > const&)
E --- tt::run_binary(tt::runtime::Binary&, int, std::vector<at::Tensor, std::allocator<at::Tensor> > const&)
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0x316b30) [0x7f45271fdb30]
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0x316a7e) [0x7f45271fda7e]
E --- /__w/tt-forge-fe/tt-forge-fe/forge/forge/_C.so(+0xe17a5) [0x7f4526fc87a5]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x18ab32) [0x55d6cf9b1b32]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x55d6cf9a839b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x59c7) [0x55d6cf9a1a97]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0xc4) [0x55d6cf9a7574]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x55d6cf9c010b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6c0) [0x55d6cf99c790]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0x122) [0x55d6cf9c0172]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x55d6cf9a761d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x55d6cf9a839b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x68ce) [0x55d6cf9a299e]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x8af) [0x55d6cf99c97f]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x55d6cf9a761d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
E --- /opt/ttforge-toolchain/venv/bin/python(PyObject_Call+0xbb) [0x55d6cf9c010b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6c0) [0x55d6cf99c790]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x6c0) [0x55d6cf99c790]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x1984d1) [0x55d6cf9bf4d1]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_FastCallDictTstate+0x16d) [0x55d6cf9a761d]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_Call_Prepend+0x5c) [0x55d6cf9bc62c]
E --- /opt/ttforge-toolchain/venv/bin/python(+0x29d464) [0x55d6cfac4464]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyObject_MakeTpCall+0x25b) [0x55d6cf9a839b]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x68ce) [0x55d6cf9a299e]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x2b60) [0x55d6cf99ec30]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x18db) [0x55d6cf99d9ab]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyFunction_Vectorcall+0x7c) [0x55d6cf9b238c]
E --- /opt/ttforge-toolchain/venv/bin/python(_PyEval_EvalFrameDefault+0x5632) [0x55d6cf9a1702]
forge/forge/compiled_graph_state.py:253: RuntimeError
Check failure on line 90 in forge/test/models/onnx/vision/perceiverio/test_perceiverio.py
github-actions / TT-Forge-FE Tests
test_perceiverio.test_perceiverio_for_image_classification_pytorch[deepmind/vision-perceiver-conv]
RuntimeError: Unknown type of tensor: <class 'transformers.models.perceiver.modeling_perceiver.PerceiverClassifierOutput'>
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f9b6a8c0>
variant = 'deepmind/vision-perceiver-conv'
@pytest.mark.nightly
@pytest.mark.parametrize("variant", variants)
def test_perceiverio_for_image_classification_pytorch(record_forge_property, variant):
if variant != "deepmind/vision-perceiver-conv":
pytest.skip("Skipping due to the current CI/CD pipeline limitations")
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH,
model="perceiverio",
variant=variant,
task=Task.IMAGE_CLASSIFICATION,
source=Source.HUGGINGFACE,
)
# Record Forge Property
record_forge_property("model_name", module_name)
# Sample Image
pixel_values = get_sample_data(variant)
# Load the model from HuggingFace
if variant == "deepmind/vision-perceiver-learned":
framework_model = PerceiverForImageClassificationLearned.from_pretrained(variant)
elif variant == "deepmind/vision-perceiver-conv":
framework_model = PerceiverForImageClassificationConvProcessing.from_pretrained(variant)
elif variant == "deepmind/vision-perceiver-fourier":
framework_model = PerceiverForImageClassificationFourier.from_pretrained(variant)
else:
logger.info(f"The model {variant} is not supported")
framework_model.eval()
inputs = [pixel_values]
# Forge compile framework model
compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
# Model Verification
> verify(inputs, framework_model, compiled_model)
forge/test/models/pytorch/vision/perceiverio/test_perceiverio.py:90:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/verify/verify.py:306: in verify
fw_out = to_pt_tensors(fw_out)
forge/forge/tensor.py:1145: in to_pt_tensors
pytorch_tensors.append(to_pt_tensor(t))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
t = PerceiverClassifierOutput(loss=None, logits=tensor([[-1.11859e+00, 5.54117e-02, 8.96913e-02, -3.91987e-01, 1.12919e...2, -4.16583e-01, -4.41801e-01]], grad_fn=<SliceBackward0>), hidden_states=None, attentions=None, cross_attentions=None)
def to_pt_tensor(t: AnyTensor) -> torch.Tensor:
if isinstance(t, torch.Tensor):
return t
elif isinstance(t, (tf.Tensor, tf.Variable)):
pt = torch.Tensor(t.numpy() if t.dtype != tf.bfloat16 else tf.cast(t, tf.float32).numpy()).type(
map_tf_dtype_to_pt(t.dtype)
)
pt.requires_grad = (
t.trainable if isinstance(t, tf.Variable) else torch.is_complex(pt) or torch.is_floating_point(pt)
)
return pt
elif isinstance(t, Tensor):
assert t.has_value(), "Expected Forge tensor to have a value"
return t.value()
else:
> raise RuntimeError(f"Unknown type of tensor: {type(t)}")
E RuntimeError: Unknown type of tensor: <class 'transformers.models.perceiver.modeling_perceiver.PerceiverClassifierOutput'>
forge/forge/tensor.py:1165: RuntimeError
Check failure on line 48 in forge/test/models/pytorch/vision/ssd300_resnet50/test_ssd300_resnet50.py
github-actions / TT-Forge-FE Tests
test_ssd300_resnet50.test_pytorch_ssd300_resnet50
RuntimeError: Failed to run MLIR compiler pass pipeline.
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f0e06200>
@pytest.mark.nightly
def test_pytorch_ssd300_resnet50(record_forge_property):
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH, model="ssd300_resnet50", source=Source.TORCH_HUB, task=Task.IMAGE_CLASSIFICATION
)
# Record Forge Property
record_forge_property("model_name", module_name)
# STEP 2 : prepare model
framework_model = torch.hub.load("NVIDIA/DeepLearningExamples:torchhub", "nvidia_ssd", pretrained=False)
url = "https://api.ngc.nvidia.com/v2/models/nvidia/ssd_pyt_ckpt_amp/versions/19.09.0/files/nvidia_ssdpyt_fp16_190826.pt"
checkpoint_path = "nvidia_ssdpyt_fp16_190826.pt"
response = requests.get(url)
with open(checkpoint_path, "wb") as f:
f.write(response.content)
checkpoint = torch.load(checkpoint_path, map_location=torch.device("cpu"))
framework_model.load_state_dict(checkpoint["model"])
framework_model.eval()
# STEP 3 : prepare input
img = "http://images.cocodataset.org/val2017/000000397133.jpg"
HWC = prepare_input(img)
CHW = np.swapaxes(np.swapaxes(HWC, 0, 2), 1, 2)
batch = np.expand_dims(CHW, axis=0)
input_batch = torch.from_numpy(batch).float()
inputs = [input_batch]
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/vision/ssd300_resnet50/test_ssd300_resnet50.py:48:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_ssd300_resnet50_base_img_cls_torchhub], graph_name='pt_ssd300_resnet50_base_img_cls_...cles_offset=0, forge_module=<forge._C.ForgeGraphModule object at 0x7f43f6ff2f70>, compiled_binary=None, attach_to=None)
def run_mlir_compiler(context: CompileContext) -> CompileDepth:
assert context.forge_module is not None
> context.compiled_binary = forge._C.run_mlir_compiler(context.forge_module)
E RuntimeError: Failed to run MLIR compiler pass pipeline.
forge/forge/compile.py:976: RuntimeError
Check failure on line 77 in forge/test/models/pytorch/vision/swin/test_swin.py
github-actions / TT-Forge-FE Tests
test_swin.test_swin_v2_tiny_4_256_hf_pytorch[microsoft/swinv2-tiny-patch4-window8-256]
AssertionError: Data mismatch on output 0 between framework and Forge codegen
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f8e6f6d0>
variant = 'microsoft/swinv2-tiny-patch4-window8-256'
@pytest.mark.nightly
@pytest.mark.skip_model_analysis
@pytest.mark.parametrize("variant", ["microsoft/swinv2-tiny-patch4-window8-256"])
def test_swin_v2_tiny_4_256_hf_pytorch(record_forge_property, variant):
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH,
model="swin",
variant=variant,
source=Source.HUGGINGFACE,
task=Task.IMAGE_CLASSIFICATION,
)
# Record Forge Property
record_forge_property("model_name", module_name)
feature_extractor = ViTImageProcessor.from_pretrained(variant)
framework_model = Swinv2Model.from_pretrained(variant)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
inputs = load_image(url, feature_extractor)
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/vision/swin/test_swin.py:77:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
forge/forge/compile.py:678: in generate_initial_graph
module, module_inputs = convert_to_forge_module(
forge/forge/compile.py:1021: in convert_to_forge_module
forge_module, dev_types, module_inputs = generate_forge_module(
forge/forge/tvm_to_python.py:2140: in generate_forge_module
verify_framework_vs_forge_codegen(framework_outputs, forge_outputs, verify_cfg=verify_cfg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
frame_outputs = [tensor([[[ 0.16558, -0.19731, -0.95477, ..., -0.30099, 0.03799, 0.19308],
[ 1.29881, 0.18637, -1.01701, ...53e-02, 5.80386e-01, -2.40810e-02, -8.48633e-01, -3.12144e-01, 1.05894e+00, 9.82384e-02]], grad_fn=<ViewBackward0>)]
forge_outputs = (Forge Tensor: tensor([[[ 6.75329e-01, 1.34220e+00, 1.81449e+00, ..., -2.06357e+00, 5.81979e+00, -1.65330e+00],
...5.02966e-02, -1.30092e+00, -4.25503e-01, 1.27871e+00, 8.33039e-03]], grad_fn=<SqueezeBackward1>), DataFormat.Float32)
verify_cfg = DepricatedVerifyConfig(graph_name='graph', enabled=False, intermediates=False, rtol={torch.float32: None, torch.float1...ent_checking=True, enable_parameter_gradient_checking=True, _input_gradient_queue=None, _parameter_gradient_queue=None)
def verify_framework_vs_forge_codegen(frame_outputs, forge_outputs, verify_cfg):
from forge.verify.compare import compare_tensor_to_golden
test_pass = True
for i, (golden, output) in enumerate(zip(frame_outputs, forge_outputs)):
test_pass &= compare_tensor_to_golden(
f"Framework vs. Forge codegen output {i}", golden, output.value(), is_forge=False, verify_cfg=verify_cfg
)
> assert test_pass, f"Data mismatch on output {i} between framework and Forge codegen"
E AssertionError: Data mismatch on output 0 between framework and Forge codegen
forge/forge/tvm_to_python.py:1987: AssertionError
Check failure on line 95 in forge/test/models/onnx/vision/yolo/test_yolo_v5.py
github-actions / TT-Forge-FE Tests
test_yolo_v5.test_yolov5_640x640[yolov5s]
RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
Raw output
record_forge_property = <function record_property.<locals>.append_property at 0x7f43f0df71c0>
size = 's'
@pytest.mark.nightly
@pytest.mark.parametrize("size", size, ids=["yolov5" + s for s in size])
def test_yolov5_640x640(record_forge_property, size):
if size != "s":
pytest.skip("Skipping due to the current CI/CD pipeline limitations")
# Build Module Name
module_name = build_module_name(
framework=Framework.PYTORCH,
model="yolo_v5",
variant="yolov5" + size,
task="imgcls",
source="torchhub",
suffix="640x640",
)
# Record Forge Property
record_forge_property("model_name", module_name)
framework_model, inputs, _ = generate_model_yoloV5I640_imgcls_torchhub_pytorch(
"ultralytics/yolov5",
size=size,
)
# Forge compile framework model
> compiled_model = forge.compile(framework_model, sample_inputs=inputs, module_name=module_name)
forge/test/models/pytorch/vision/yolo/test_yolo_v5.py:95:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module pt_yolo_v5_yolov5s_imgcls_torchhub_640x640], graph_name='pt_yolo_v5_yolov5s_imgcls_torc...cles_offset=0, forge_module=<forge._C.ForgeGraphModule object at 0x7f44b5a826f0>, compiled_binary=None, attach_to=None)
def run_mlir_compiler(context: CompileContext) -> CompileDepth:
assert context.forge_module is not None
> context.compiled_binary = forge._C.run_mlir_compiler(context.forge_module)
E RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
forge/forge/compile.py:976: RuntimeError
Check failure on line 73 in forge/test/mlir/llama/tests/test_llama_prefil.py
github-actions / TT-Forge-FE Tests
test_llama_prefil.test_llama_prefil_on_device_decode_on_cpu[meta-llama/Llama-3.2-1B]
RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
Raw output
model_path = 'meta-llama/Llama-3.2-1B'
@pytest.mark.parametrize("model_path", ["openlm-research/open_llama_3b", "meta-llama/Llama-3.2-1B"])
@pytest.mark.nightly
def test_llama_prefil_on_device_decode_on_cpu(model_path):
"""
This function tests the inference of the Llama models split into two parts:
- The first part is the prefilling of the model on the device.
- The second part is the decoding of the model on the CPU without KV cache.
"""
if model_path == "openlm-research/open_llama_3b":
pytest.skip("Insufficient host DRAM to run this model (requires a bit more than 32 GB during compile time)")
# Load Llama model and tokenizer
model, tokenizer = load_model(model_path, return_dict=True)
# Prepare input sentence
prompt = "Q: What is the largest animal?\nA:"
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
# cast input_ids to int32 since int64 causes embedding op data mismatch. Tracking issue: https://github.com/tenstorrent/tt-forge-fe/issues/952
input_ids = input_ids.to(torch.int32)
# This is the part of the model needed for prefill; model without the last Linear layer (lm_head)
model_decoder = model.get_decoder()
> compiled_decoder = forge.compile(model_decoder, sample_inputs=input_ids)
forge/test/mlir/llama/tests/test_llama_prefil.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
forge/forge/compile.py:253: in compile_main
return forge_compile_from_context(compile_context)
forge/forge/compile.py:295: in forge_compile_from_context
next_stage = stage_to_func[current_stage](context)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
context = CompileContext(modules=[Module LlamaModel], graph_name='LlamaModel', compiler_cfg=CompilerConfig(enable_training=False...cles_offset=0, forge_module=<forge._C.ForgeGraphModule object at 0x7f43e89d39f0>, compiled_binary=None, attach_to=None)
def run_mlir_compiler(context: CompileContext) -> CompileDepth:
assert context.forge_module is not None
> context.compiled_binary = forge._C.run_mlir_compiler(context.forge_module)
E RuntimeError: Found Unsupported operations while lowering from TTForge to TTIR in forward graph
forge/forge/compile.py:976: RuntimeError