Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANE Usage: 200% @ 16.1 W #57

Open
wangchou opened this issue Mar 8, 2023 · 2 comments
Open

ANE Usage: 200% @ 16.1 W #57

wangchou opened this issue Mar 8, 2023 · 2 comments

Comments

@wangchou
Copy link

wangchou commented Mar 8, 2023

Is ANE usage 200% correct?
Screenshot 0005-03-08 at 10 18 07

This test model goes to 200% when creating XCode performance report.

Device: MacBook M1 Air
OS: macOS 13.2

import torch
from torch import Tensor
from torch import nn
import coremltools as ct
from coremltools.models.neural_network import quantization_utils

class MyModule(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, x: Tensor):
        for i in range(1,500):
            x = x @ x
        return x

module = MyModule()
module.eval()

input_x = torch.ones(1024, 1024)
traced_module = torch.jit.trace(module, input_x)

# convert to coreml model
module = ct.convert(
    traced_module,
    inputs=[ct.TensorType(name="input_x", shape=input_x.shape)],
    outputs=[ct.TensorType(name="output")],
    compute_units=ct.ComputeUnit.ALL,
)

module_fp16 = quantization_utils.quantize_weights(module, nbits=16)
module_fp16.save(f"module_fp16.mlmodel")
@dehydratedpotato
Copy link

@wangchou oh yeah that is definitely a bug. Probably from a flaw in the way asitop estimates the usage based on ane power (this is done because ane usage is not directly provided by the system)

@stonerl
Copy link

stonerl commented Apr 3, 2023

The problem is that ane_max_power = 8.0 is hardcoded.

According to your screenshot, you're using 16 watts. Which lets this calculation fail:

cpu_metrics_dict["ane_W"] / args.interval / ane_max_power * 100)

So, either the hardcoded value of 8 is wrong and/or the watt usage reported by powermetrics is. It could be both tough. Apple seems to consistently break the values reported by powermetrics with each release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants