TQL: Expressions and Queries
TQL (Tensor Query Language) is Tensormorph's expression and query language - the same syntax powers selection filters, breakpoint conditions, custom panel queries, and the sel= parameter of a shareable Tensormorph URL. It has one canonical form: plain ASCII source, which renders as typeset math notation wherever there's room to show it (the Console, the query bar, saved query lists), so you always author in the same portable text form regardless of how it's displayed.
Where you type TQL
The command palette (Ctrl+P) doubles as a unified input with prefix-selected modes:
| Prefix | Mode |
|---|---|
| (none) | Fuzzy search over commands, tensors, and views |
> | Run a command by name |
: | Filter the current view by a TQL predicate |
# | Jump to a bookmark |
? | Natural-language input, translated to a TQL expression before running |
The Console panel is a full TQL REPL for longer expressions, multi-step queries, or anything you want to save and reuse.
What a TQL expression can reference
TQL expressions read from the same tensor statistics available everywhere else in Tensormorph - shape, dtype, moments, norms, NaN/Inf/zero counts - plus structural properties from the address space (layer index, module type, tensor name pattern). A predicate like "every tensor with a non-zero NaN count" or "every Linear layer with absmax above a threshold" is a filter over already-computed statistics, which is why TQL queries return near-instantly even across a very large model.
Example expressions
# Structural + statistical filter
layer.type == "attention" and tensor.absmax > 10
# Selection by name pattern, scoped to a module
model["layer.12"].tensor("*.q_proj.weight")
# Used as a breakpoint condition (see Runtime Traces)
tensor.nan_count > 0The same predicate syntax is valid in a selection filter (:), a saved query, a runtime capture condition, and a shareable URL's sel=tql:... parameter - there's one grammar to learn, not one per feature.
Saving and sharing a query
Any query typed in the Console or the filter bar can be saved as a named, reusable expression, stored in your project's .tmproj file (see File Formats) alongside bookmarks and layouts - so a useful diagnostic query is something you write once per project, not once per session.
Related resources
- Tensor Statistics - the data every TQL predicate ultimately reads.
- Keyboard Shortcuts - the palette prefixes above, and how to open the Console.
- Runtime Traces - using a TQL predicate as a capture-point condition.