Skip to content

rl/log_reader: use NumPy view in _add_feature - #572

Open
Arjunmehta312 wants to merge 1 commit into
google:mainfrom
Arjunmehta312:rl-log-reader-numpy-extend
Open

rl/log_reader: use NumPy view in _add_feature#572
Arjunmehta312 wants to merge 1 commit into
google:mainfrom
Arjunmehta312:rl-log-reader-numpy-extend

Conversation

@Arjunmehta312

Copy link
Copy Markdown

Summary

Use the existing zero-copy NumPy view exposed by
LogReaderTensorValue when populating protobuf repeated fields in
_add_feature.

Motivation

LogReaderTensorValue already provides a NumPy view over the underlying
tensor buffer. Extending protobuf repeated fields from that view avoids
iterating through the ctypes-backed sequence while preserving identical
serialized output.

Validation

  • Serialized SequenceExample output is byte-for-byte identical.
  • Extended compiler_opt/rl/log_reader_test.py with an additional serialized-output assertion.
  • ruff check passes on the modified files.
  • Benchmarks on representative synthetic workloads measured approximately a 15% improvement in read_log_as_sequence_examples.

LogReaderTensorValue already exposes a zero-copy NumPy view of the
underlying tensor buffer. Extend the protobuf repeated fields from that
view instead of iterating through the ctypes-backed sequence.

Serialized output is unchanged, and the sequence-example conversion test
now asserts byte-for-byte equality.

Test: compiler_opt/rl/log_reader_test.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant