Keyword arguments are silently ignored when a decorated function is called without positional arguments

Abierto Apto para principiantes
#88 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
performance

Línea de trabajo

Empieza en nsight/collection/core.py y sigue cómo se gestiona la configuración en el momento de la llamada alrededor de _sanitize_configs y la comprobación if len(args) > 0. Lee test_config_at_call_time_with_kwargs y añade cobertura para una llamada solo con argumentos con nombre, como bench(n=4096). Se considera terminado cuando los argumentos con nombre se usan como configuración o provocan de forma coherente la ProfilerException documentada, sin recurrir silenciosamente al valor predeterminado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

Calling a function decorated with @nsight.analyze.kernel with only keyword arguments drops them. The call is profiled with the parameter default (or with the decorator-time configs), and the results report that configuration instead of the requested one. No error or warning is raised.

import nsight
import torch

@nsight.analyze.kernel
def bench(n: int = 64) -> None:
    a = torch.randn(n, n, device="cuda")
    b = torch.randn(n, n, device="cuda")
    with nsight.annotate("add"):
        _ = a + b

df = bench(n=4096).to_dataframe()
print(df[["Annotation", "n", "Metric"]])   # n is 64, not 4096

The same happens with @nsight.analyze.kernel(configs=[(64,)]) and bench(n=4096).

bench(42, y=23) already raises ProfilerException: Keyword arguments are not supported yet: ['y'] (_sanitize_configs in nsight/collection/core.py, tested by test_config_at_call_time_with_kwargs). That check sits inside if len(args) > 0:, so it is skipped when there are no positional arguments.

Expected

The same ProfilerException, or the keyword arguments being used as the configuration.

Environment

nsight-python main at c89d4b5, Python 3.12.3, Linux x86_64.

How this was checked: no GPU was available, so the profiling backend was replaced by a mock (NVTX ranges and NCUCollector.collect). Config handling, the run loop, extraction and aggregation were the real nsight code. An equivalent script with the kernel launch stubbed out shows n=64 in the results for both cases (requested n=4096, profiled n=64). It has not been run on a GPU with NCU or CUPTI.

A small fix is ready if you approve it: move the existing check out of the if len(args) > 0: block, so keyword arguments raise the same ProfilerException on every call, and add a test next to test_config_at_call_time_with_kwargs. That turns today's silent wrong result into an error for callers who use bench(n=...). Supporting keyword arguments instead would be your call.

This was found with an AI coding assistant (Claude Code, claude-fable-5-2), which also wrote and ran the mocked repro and drafted this report.

Lenguaje dominante
Python
Estrellas
301
Forks
23
Merge medio
2 d 20 h
PR fusionados (30 d)
12

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/nsight-python

Todos los issues de NVIDIA/nsight-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.