PhysicsNeMo is an open-source PyTorch framework for creating, training, and fine-tuning machine-learning models for physics, scientific computing, and engineering. Researchers and engineers use its reusable components and training recipes for applications such as aerodynamics, weather forecasting, structural mechanics, geophysics, and thermal design. The catalogue entries provide rules and skills for working with PhysicsNeMo projects.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/nvidia/physicsnemo/mod-003k-add-high-level-comments-for-complex-tensor-operationsgit clone --depth 1 https://github.com/NVIDIA/physicsnemoWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/nvidia/physicsnemo/mod-003k-add-high-level-comments-for-complex-tensor-operations)<a href="https://agentmods.dev/rules/nvidia/physicsnemo/mod-003k-add-high-level-comments-for-complex-tensor-operations"><img src="https://agentmods.dev/badge/rules/nvidia/physicsnemo/mod-003k-add-high-level-comments-for-complex-tensor-operations.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00030 | $0.00817 |
| Opus 5 | $0.00015 | $0.00409 |
| Sonnet 5 | $0.00006 | $0.00163 |
| Haiku 4.5 | $0.00003 | $0.00082 |
Grade A, and why
mod-003k-add-high-level-comments-for-complex-tensor-operations scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
When writing model code with complex tensor operations, rule MOD-003k should be followed. Explicitly reference "Following rule MOD-003k, which recommends high-level comments for complex tensor operations..." when adding explanatory comments.
MOD-003k: Add high-level comments for complex tensor operations
Description:
Model code that involves complex tensor operations should include high-level comments that explain what blocks of code accomplish semantically. One-line comments every few lines of tensor operations is sufficient.
Comments should focus on high-level semantic explanations rather than low-level syntactic details. For example, use "Compute the encodings" instead of "Doing a concatenation followed by a linear projection, followed by a nonlinear activation". The goal is to give a high-level overview of what a block of tensor operations accomplishes.
When multiple tensor operations are chained, it is welcomed to add short inline comments with the tensor shapes of computed tensors, e.g.:
x = torch.cat([y, z], dim=1) # (B, 2*C_in, H, W)
The symbols chosen in the comments should be consistent with the docstring (possibly shortened versions of dimension names for explicitness).
Rationale:
High-level comments make complex tensor manipulation code more understandable without cluttering it with excessive detail. Shape annotations help developers track tensor dimensions through complex operations, catching shape mismatches early. Consistency with docstring notation creates a unified mental model.
Example:
def forward(self, x: torch.Tensor, context: torch.Tensor) -> torch.Tensor:
"""Process input with context conditioning."""
# Encode input features
h = self.encoder(x) # (B, C_enc, H, W)
# Combine with context information
c = self.context_proj(context) # (B, C_enc)
c = c[:, :, None, None].expand(-1, -1, h.shape[2], h.shape[3]) # (B, C_enc, H, W)
h = torch.cat([h, c], dim=1) # (B, 2*C_enc, H, W)
# Apply attention mechanism
h = self.attention(h) # (B, 2*C_enc, H, W)
# Decode to output
out = self.decoder(h) # (B, C_out, H, W)
return out
Anti-pattern:
# WRONG: No comments for complex operations
def forward(self, x: torch.Tensor, context: torch.Tensor) -> torch.Tensor:
h = self.encoder(x)
c = self.context_proj(context)
c = c[:, :, None, None].expand(-1, -1, h.shape[2], h.shape[3])
h = torch.cat([h, c], dim=1)
h = self.attention(h)
out = self.decoder(h)
return out
# WRONG: Too low-level, syntactic comments
def forward(self, x: torch.Tensor, context: torch.Tensor) -> torch.Tensor:
# Pass x through encoder layer
h = self.encoder(x)
# Project context using linear layer
c = self.context_proj(context)
# Add two None dimensions and expand
c = c[:, :, None, None].expand(-1, -1, h.shape[2], h.shape[3])
# Concatenate h and c along dimension 1
h = torch.cat([h, c], dim=1)
# Apply attention
h = self.attention(h)
# Pass through decoder
out = self.decoder(h)
return out
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 6d ago First seen · 90 lines · 30 tokens per session scan A 4f6c4d819303
mod-003k-add-high-level-comments-for-complex-tensor-operations is a cursor rule published in the GitHub repository NVIDIA/physicsnemo (3,222 stars, last pushed yesterday), licensed Apache-2.0. It adds 30 tokens to every session and 817 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
specs
This directory contains product and tech specs for Streamlit features.
workflows
This folder contains all GitHub Actions workflows for the Streamlit repository. Workflows automate CI/CD, testing, releases, and maintenance tasks.
skills
This file provides guidance to AI coding agents (Claude Code, Cursor, Copilot, etc.) when working with skills in this repository.
python_tests
We use the unit tests to cover internal behavior that can work without the web / backend counterpart. We aim for 95%+ unit test coverage of our Python code in lib/streamlit.