Keyword arguments are silently ignored when a decorated function is called without positional arguments
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- performance
调研方向
从 nsight/collection/core.py 开始,追踪 _sanitize_configs 周围以及 if len(args) > 0 检查处的调用时配置处理。阅读 test_config_at_call_time_with_kwargs,并为仅使用关键字参数的调用(例如 bench(n=4096))补充测试覆盖。完成标准是:关键字参数要么被用作配置,要么始终引发文档所述的 ProfilerException,且不会静默回退到默认值。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 301
- 派生
- 23
- 平均合并
- 2 天 20 小时
- 30 天内合并 PR
- 12
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/nsight-python 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 54/100
NVIDIA/nsight-python#89 ·
维护者通常 1 天内回复
-
Enable collecting metrics from a set可能重新可做 @Alok-Joshi 于 57 天前认领,目前没有进行中的 PR。 未关闭
NVIDIA/nsight-python#7 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 NVIDIA/nsight-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
FAIRmat-NFDI/pynxtools#861 ·
-
Criteria can pass when the deliverable is missing可能已有人在做 @clementtisseau 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
harveyai/harvey-labs#217 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
priority/medium roadmap/v1.1.1 stakeholder/rapr type/bug
难度 2/5 1-3 小时 新手友好度 83/100
databrickslabs/ontos#1420 ·
维护者通常 3 天内回复
-
[Bug] method_logger uses fragile definition-time inspect stack frame instead of func.__qualname__未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复