Skip to content

Allow selection of verbosity level for vtrace_fmt! messages - #3932

Open
joannabrozek wants to merge 25 commits into
google:mainfrom
antmicro:max_trace_verbosity
Open

joannabrozek wants to merge 25 commits into
google:mainfrom
antmicro:max_trace_verbosity

Conversation

@joannabrozek

@joannabrozek joannabrozek commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

Add support for excluding vtrace_fmt! messages according to max_trace_verbosity flag for:

  • DSLX interpreter:

    • Added the max_trace_verbosity flag with the default value set to 100 (see xls/dslx/interpreter_main.cc)
    • Added a new private member verbosity_ to the TraceData class to be able to pass the verbosity of vtrace_fmt!() messages (see xls/dslx/bytecode/bytecode.h)
    • Added max_trace_verbosity flag propagation using BytecodeInterpreterOptions to the bytecode interpreter, where the vtrace messages are filtered (see xls/dslx/bytecode/bytecode_interpreter.cc)
    • Added a bytecode interpreter test for vtrace_fmt!() (see xls/dslx/bytecode/bytecode_interpreter_test.cc)
  • IR interpreter:

    • Added code position propagation (by adding the emit_positions flag, which is enabled by default, as it was previously hardcoded as enabled as well - see xls/dslx/ir_convert/ir_converter_main.cc)
    • Restored displaying messages from trace_fmt!() and vtrace_fmt!() (see the xls/dslx/run_routines/run_routines.cc file)
    • Added a fix to populate SourceInfo inside Trace so that the displayed logs include information about which file they came from and their location (row and column) - see xls/dslx/ir_convert/function_converter.cc
    • Added two tests (one for a function and the second for a process) to verify if messages are filtered - see xls/dslx/interpreter_test.py
    • Added displaying messages for processes by adding a DslxInterpreterEvents pointer and populating it (see xls/dslx/run_routines/run_routines.cc and xls/dslx/run_routines/ir_test_runner.cc)
    • Added vtrace_fmt!() messages filtering (see xls/interpreter/ir_interpreter.cc)
    • Updated the test (see xls/interpreter/ir_evaluator_test_base.cc)
  • JIT and AOT:

    • Added a new private member max_trace_verbosity_ to the EvaluatorOptions and JitEvaluatorOptions classes to be able to propagate the max_trace_verbosity flag (see xls/interpreter/evaluator_options.h and xls/jit/jit_evaluator_options.h)
    • Added the max_trace_verbosity flag and passed it using JitEvaluatorOptions (see xls/jit/aot_compiler_main.cc)
    • Enabled max_trace_verbosity flag propagation using EvaluatorOptions for function and block wrappers (see xls/jit/jit_function_wrapper_cc.tmpl, xls/jit/function_base_jit_wrapper.h and xls/jit/block_base_jit_wrapper.h)
    • Added vtrace_fmt!() messages filtering (see xls/jit/jit_callbacks.cc)
    • Added an example with JIT tests and defined wrappers (see xls/examples/vtrace_fmt.x, xls/examples/vtrace_fmt_block_jit_test.cc, xls/examples/vtrace_fmt_jit_test.cc, xls/examples/vtrace_fmt_proc_jit_test.cc)
    • Added support for JIT functions (see xls/jit/function_jit.cc) and a test (see xls/jit/function_jit_test.cc)
    • Added support for JIT blocks (see xls/jit/block_jit.cc) and updated the test (see xls/interpreter/block_evaluator_test_base.cc)
    • Added support for JIT processes (see xls/jit/proc_jit.cc) and a test (see xls/interpreter/proc_evaluator_test_base.cc)
    • Updated the AOT test (see xls/jit/function_jit_aot_test.cc)
  • eval_ir_main tool:

    • Added the max_trace_verbosity flag and passed it using JitEvaluatorOptions (see xls/tools/eval_ir_main.cc)
    • Added a test (see xls/tools/eval_ir_main_test.py)
  • eval_proc_main tool:

    • Added the max_trace_verbosity flag and passed it using BlockEvaluator (see xls/tools/eval_proc_main.cc)
    • Added a test (see xls/tools/eval_proc_main_test.py)
  • codegen_main tool:

@joannabrozek joannabrozek changed the title Add max_trace_verbosity flag Allow selection of verbosity level for vtrace_fmt! messages Mar 10, 2026
@joannabrozek
joannabrozek marked this pull request as ready for review April 21, 2026 13:24
Comment thread xls/dslx/bytecode/bytecode_emitter.cc Outdated
if (node->verbosity().has_value()) {
XLS_ASSIGN_OR_RETURN(InterpValue verbosity_val,
type_info_->GetConstExpr(*node->verbosity()));
absl::StatusOr<int64_t> verbosity_as_int64 =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to assume here that if the node has a verbosity value then the constexpr is a valid int64, and just do XLS_ASSIGN_OR_RETURN. Perhaps add a check for this in validate_concrete_type.cc if it's not really checked in type inference currently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used XLS_ASSIGN_OR_RETURN as mentioned.

}

TEST_F(BytecodeInterpreterTest, VtraceFmtBitsValueDefaultFormat) {
constexpr std::string_view kProgram = R"(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's verify, either here or in a different test, that regular trace_fmt! works as expected with a max verbosity set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in the same file.

Comment thread xls/interpreter/block_evaluator.cc Outdated
absl::Span<const absl::flat_hash_map<std::string, Value>> inputs,
const std::optional<verilog::ResetProto>& reset, int64_t seed) const {
const std::optional<verilog::ResetProto>& reset, int64_t seed,
const std::optional<int64_t> max_trace_verbosity = 0) const {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should make this non-optional wherever the distinction between 0 and nullopt is irrelevant throughout the PR. It's unusual to have an optional default to 0, and probably a sign that passing in nullopt is irrelevant in such places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've migrated to non-optional throughout the PR.

@joannabrozek
joannabrozek force-pushed the max_trace_verbosity branch from 656fb31 to 641815b Compare May 8, 2026 12:52
@joannabrozek

Copy link
Copy Markdown
Contributor Author

@richmckeever, thank you for the review. I've rebased the code and added the suggested changes. Let me know if there's still something missing.

@magancarz
magancarz force-pushed the max_trace_verbosity branch from 641815b to 6c51a0e Compare May 15, 2026 12:27
@magancarz

magancarz commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

I've rebased changes onto the latest main and resolved conflicts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, we get this failure internally:

libcxx/include/__memory/unique_ptr.h: error: allocating an object of abstract class type 'xls::(anonymous namespace)::JitContinuationAdapter'
  756 |   return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
      |                              ^
fifo_fuzz_test.cc: note: in instantiation of function template specialization 'std::make_unique<xls::(anonymous namespace)::JitContinuationAdapter, std::unique_ptr<xls::BlockJitContinuation>, xls::BlockJit *&, 0>' requested here
  256 |   return std::make_unique<JitContinuationAdapter>(std::move(blk_cont), jit);
      |               ^
block_evaluator.h: note: unimplemented pure virtual method 'SetMaxTraceVerbosity' in 'JitContinuationAdapter'
  444 |   virtual void SetMaxTraceVerbosity(int64_t value) = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see pure virtual SetMaxTraceVerbosity from BlockContinuation is not implemented in a newly added JitContinuationAdapter class deriving from BlockContinuation. For reference, you can see how we implemented it in BlockContinuationJitWrapper as a lazy init for max_trace_verbosity of BlockJitContinuation or noop in StatelessBlockContinuation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy I see JitContinuationAdapter class is only available internally. Can this be fixed on Google's side?

@mikex-oss

Copy link
Copy Markdown
Collaborator

@magancarz @joannabrozek I can try to fix the JitContinuationAdapter issue, but the PR has gotten outdated. The internal import was garbage collected, and I cannot trigger a re-import because it reports "error: Cannot find a merge reference for Pull Request 3932. It might have a conflict with head."

Can you please try rebasing?

Comment thread xls/jit/jit_callbacks.h Outdated
std::unique_ptr<TypeManager> type_manager = std::make_unique<TypeManager>();

RuntimeObserver* observer = nullptr;
int64_t max_trace_verbosity_ = 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove underscore (because it's a struct).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@rw1nkler
rw1nkler force-pushed the max_trace_verbosity branch from 6c51a0e to 239b582 Compare June 25, 2026 14:58
@rw1nkler

Copy link
Copy Markdown
Contributor

@mikex-oss I rebased this PR

@proppy

proppy commented Oct 9, 2026

Copy link
Copy Markdown
Member

@rw1nkler sorry can you rebase again?

@richmckeever

Copy link
Copy Markdown
Collaborator

Looks like we need another rebase.

@rw1nkler

rw1nkler commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Rebased, requires #5259 to build correctly without the cache in nightly CI

Comment thread bazel_downloader.cfg Outdated
rewrite ftp.gnu.org/(?:pub/)?gnu/(.*) https://ftpmirror.gnu.org/$1
rewrite ftp.gnu.org/(?:pub/)?gnu/(.*) https://ftp.gnu.org/gnu/$1

# TODO: Remove once BCR fixes sv-lang@10.0.1-20260316-f04e8156 integrity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superfluous now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I updated the PR

@grebe
grebe requested review from proppy and richmckeever November 9, 2026 23:28
joannabrozek and others added 25 commits November 12, 2026 21:45
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
@rw1nkler
rw1nkler force-pushed the max_trace_verbosity branch from 89d3261 to c732f0b Compare November 12, 2026 21:39
@rw1nkler

Copy link
Copy Markdown
Contributor

PTAL @grebe @richmckeever

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants