HLO Prettier
Readable XLA HLO, right inside Visual Studio Code.
HLO Prettier combines theme-friendly syntax highlighting with configurable
document formatting for .hlo files and common XLA/JAX text dumps.
XLA is an open-source compiler that optimizes machine
learning models for CPUs, GPUs, and other accelerators. HLO is its internal
representation, progressively optimized and transformed by
HLO passes.

Highlights
- Highlights modules, computations, shapes, primitive types, identifiers,
attributes, literals, strings, and comments.
- Formats indentation, horizontal spacing, instruction attributes, and spacing
between computations.
- Supports Format Document, format on save, spaces, and tabs.
- Preserves strings, comments, and metadata that you choose not to format.
- Handles incomplete HLO without getting in your way.
Open the Command Palette and run Format Document, or use your usual VS Code
formatting shortcut. Select HLO Prettier if VS Code asks you to choose a
formatter.

For automatic formatting, add this to your VS Code settings.json:
{
"[hlo]": {
"editor.defaultFormatter": "5yearsKim.hlo-prettier",
"editor.formatOnSave": true,
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"hloPrettier.printWidth": 120,
"hloPrettier.attributeWrapping": "auto",
"hloPrettier.formatMetadata": false,
"hloPrettier.blankLinesBetweenComputations": 1
}
Settings
| Setting |
Default |
What it controls |
hloPrettier.printWidth |
120 |
Line width used by automatic attribute wrapping |
hloPrettier.attributeWrapping |
"auto" |
Attribute wrapping: auto, preserve, or onePerLine |
hloPrettier.formatMetadata |
false |
Whether metadata internals are formatted |
hloPrettier.blankLinesBetweenComputations |
1 |
Blank lines between top-level computations (0–2) |
Indentation follows VS Code's editor.insertSpaces and editor.tabSize
settings for HLO files.
Recognized files
HLO Prettier recognizes .hlo files and these common dump patterns without
taking over every .txt file:
*module_[0-9][0-9][0-9][0-9].*{before_optimizations,after_optimizations}.txt
The module pattern requires the conventional four-digit module sequence while
covering timestamp-prefixed dumps, computation names other than jit_*,
accelerator-specific suffixes such as
sm_90_gpu_after_optimizations, and either pre- or post-optimization HLO. The
particular sequence value, such as module_0000, is not assumed to be stable.
For another filename, select HLO using VS Code's language-mode picker.
License
Apache License 2.0