The inaccurate flop results after several rounds
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- machine-learning, performance
Línea de trabajo
Comienza con la llamada a profiler.get_model_profile y reproduce las mediciones repetidas usando el bucle test_model proporcionado y una forma de entrada fija. Compara los FLOPs, MACs, parámetros y la latencia de las rondas posteriores con la primera ronda; se considera terminado cuando repetir el profiling del mismo modelo y entrada no hace que aumenten los FLOPs.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi I tried to use the method "get_model_profile" to get the latency and flop for my model. To get avoid of the influence from randomness, I used this method in a for loop for several times, and then an average operation would be done.
However, I found the results for the following rounds of the first one are not correct, which is far away from the theoritical result. As shown in the fig below, you could see the flops is increasing with the round, which is not correct, since I gave the same size of input into the model.
And this is the code:
def test_model(model, input_shape, warmup=20, num_tests=1000):
results = []
for _ in range(num_tests):
#from profiler import get_model_profile
flops, macs, params, latency = profiler.get_model_profile(
model=model,
input_shape=input_shape,
print_profile=False,
detailed=True,
module_depth=-1,
top_modules=1,
warm_up=warmup,
as_string=False
)
del sys.modules['profiler']
results.append((flops/10**9, macs/10**9, params/10**3, latency*10**3))
df = pd.DataFrame(results, columns=['FLOPs', 'MACs', 'Params', 'Latency'])
return df
df_swin = test_model(Swin, (batch_size, math.prod(input_resolution), dim), warmup=warmup, num_tests=num_tests)
I tried to modify this code, and found if I could assign the model again in a different iteration with the profiler imported again, then the result is correct, shown in the fig below.
And the following is the modified code.
def test_model(input_shape, warmup=20, num_tests=1000):
results = []
for _ in range(num_tests):
#from profiler import get_model_profile
import profiler
model = MySwinTransformerModel(dim, input_resolution, num_heads, window_size, mlp_ratio, depth).to(device)
# model = MyTensorizedTransformerModel(dim, input_resolution, num_heads, n_proj, mlp_ratio, depth).to(device)
flops, macs, params, latency = profiler.get_model_profile(
model=model,
input_shape=input_shape,
print_profile=False,
detailed=True,
module_depth=-1,
top_modules=1,
warm_up=warmup,
as_string=False
)
del sys.modules['profiler']
results.append((flops/10**9, macs/10**9, params/10**3, latency*10**3))
df = pd.DataFrame(results, columns=['FLOPs', 'MACs', 'Params', 'Latency'])
return df
- Lenguaje dominante
- Python
- Estrellas
- 6.8k
- Forks
- 1.1k
- Merge medio
- 4 d 22 h
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de deepspeedai/DeepSpeedExamples
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 52/100
deepspeedai/DeepSpeedExamples#996 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
deepspeedai/DeepSpeedExamples#995 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 52/100
deepspeedai/DeepSpeedExamples#989 ·
-
moe example 404Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
deepspeedai/DeepSpeedExamples#984 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
deepspeedai/DeepSpeedExamples#979 · 6 comentarios ·
Todos los issues de deepspeedai/DeepSpeedExamples
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
PedestrianDynamics/pyFDS-Evac#199 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
521xueweihan/HelloGitHub#3790 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
sandialabs/atlas-ui-3#978 ·
Los mantenedores suelen responder en 1 día
-
area: tests perceived difficulty: 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Nitjsefnie-Harness-Commons/daedalus#1255 ·
Los mantenedores suelen responder en 1 día
-
hf-audiolm-qwen: `generate_until` hardcodes `.to("cuda")` and aborts on non-CUDA acceleratorsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
EleutherAI/lm-evaluation-harness#4256 ·
Los mantenedores suelen responder en 1 día