Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tsoc
hg-misc-tools
Commits
6e26d46d
Commit
6e26d46d
authored
Mar 05, 2026
by
one
Browse files
[xcl-lens] Allow a file as input
parent
a049d737
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
16 deletions
+54
-16
projects/xcl-lens/README.md
projects/xcl-lens/README.md
+5
-7
projects/xcl-lens/src/xcl_lens/main.py
projects/xcl-lens/src/xcl_lens/main.py
+49
-9
No files found.
projects/xcl-lens/README.md
View file @
6e26d46d
...
...
@@ -61,16 +61,14 @@ mpirun -np 4 xcl-lens \
### Process an Existing File
```
bash
xcl-lens
cat
rccl-log.txt
xcl-lens rccl-log.txt
cat
rccl-log.txt | xcl-lens
```
###
Verbose Mode
###
Options
By default, only the report is printed. Use
`-v`
or
`--verbose`
to also print raw log lines:
```
bash
xcl-lens
-v
./build/all_reduce_perf
-b
4
-e
2G
-f
2
-w
3
-n
3
-g
1
```
`--summary`
is used to suppress the raw log.
`-v`
is used to extend summary reports.
## Development
...
...
projects/xcl-lens/src/xcl_lens/main.py
View file @
6e26d46d
...
...
@@ -32,23 +32,63 @@ def main():
log_prefix
=
f
"[Rank
{
rank
}
]"
# Parse command line arguments
parser
=
argparse
.
ArgumentParser
(
description
=
"RCCL Log Parser Wrapper"
)
parser
.
add_argument
(
"--no-raw"
,
action
=
"store_true"
,
help
=
"Don't print raw log lines in addition to the report"
parser
=
argparse
.
ArgumentParser
(
description
=
"RCCL Log Parser Wrapper
\n\n
"
"Usage modes:
\n
"
" 1. Pipe input: cat log.txt | xcl-lens
\n
"
" 2. Read files: xcl-lens log1.txt log2.txt
\n
"
" 3. Wrap command: xcl-lens ./all_reduce_perf"
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
)
parser
.
add_argument
(
"--summary"
,
action
=
"store_true"
,
help
=
"Print summary report only"
)
parser
.
add_argument
(
"-v"
,
"--verbose"
,
action
=
"store_true"
,
help
=
"Print verbose reports"
)
parser
.
add_argument
(
"command"
,
nargs
=
argparse
.
REMAINDER
,
help
=
"
The e
xecutable
and argument
s to r
un
"
"command"
,
nargs
=
argparse
.
REMAINDER
,
help
=
"
E
xecutable
to run, or log file
s to r
ead
"
)
args
=
parser
.
parse_args
()
cmd
=
args
.
command
# Check if command is provided
if
not
cmd
and
rank
==
0
:
parser
.
print_help
()
sys
.
exit
(
1
)
# Case 1: No command provided - check for stdin
if
not
cmd
:
if
not
sys
.
stdin
.
isatty
():
try
:
rccl_parser
=
RcclLogParser
()
for
line
in
sys
.
stdin
:
if
not
args
.
summary
:
print
(
f
"
{
line
}
"
,
end
=
""
,
flush
=
True
)
rccl_parser
.
collect
(
line
)
if
rank
==
0
:
rccl_parser
.
report
(
verbose
=
args
.
verbose
)
sys
.
exit
(
0
)
except
KeyboardInterrupt
:
sys
.
exit
(
130
)
else
:
if
rank
==
0
:
parser
.
print_help
()
sys
.
exit
(
1
)
# Case 2: Check if first argument is an existing file (treat as log file)
if
os
.
path
.
isfile
(
cmd
[
0
]):
try
:
rccl_parser
=
RcclLogParser
()
for
filename
in
cmd
:
if
not
os
.
path
.
isfile
(
filename
):
print
(
f
"
{
log_prefix
}
Error: File not found:
{
filename
}
"
)
sys
.
exit
(
1
)
with
open
(
filename
,
encoding
=
"utf-8"
,
errors
=
"replace"
)
as
f
:
for
line
in
f
:
if
not
args
.
summary
:
print
(
f
"
{
line
}
"
,
end
=
""
,
flush
=
True
)
rccl_parser
.
collect
(
line
)
if
rank
==
0
:
rccl_parser
.
report
(
verbose
=
args
.
verbose
)
sys
.
exit
(
0
)
except
KeyboardInterrupt
:
sys
.
exit
(
130
)
# Get the environment variables
env
=
os
.
environ
.
copy
()
...
...
@@ -72,7 +112,7 @@ def main():
# Collect all output lines
for
line
in
process
.
stdout
:
if
not
args
.
no_raw
:
if
not
args
.
summary
:
print
(
f
"
{
line
}
"
,
end
=
""
,
flush
=
True
)
parser
.
collect
(
line
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment