Skip to content

Conversation

@ngc92
Copy link
Collaborator

@ngc92 ngc92 commented Jan 4, 2026

  • rework philox RNG code
  • add explicit "empty" tests to Tensor class

Copilot AI review requested due to automatic review settings January 4, 2026 13:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the Philox random number generator API and adds convenience methods to the Tensor class for checking empty state. The main changes include replacing multiple RNG generate calls with a single call that produces multiple values at once, and adding an empty() method and explicit operator bool() to Tensor for null-checking.

  • Refactored Philox4x32 RNG to support generating multiple random numbers in a single call using std::span
  • Added empty() and explicit operator bool() methods to Tensor struct for checking null data pointers
  • Updated all RNG usage sites to use the new consolidated API

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utilities/tensor.h Adds empty() method and explicit operator bool() for checking if tensor data is null
src/utilities/philox.h Refactors RNG API with new generate_4() and templated generate() methods that accept std::span
src/utilities/lazy_allocator.cpp Uses new Tensor operator bool() to check for null backing in tracing mode
src/utilities/comm.h Changes schedule_destructive_all_to_all parameter from const Tensor& to Tensor&
src/utilities/comm.cpp Updates function signature to match header change
src/models/llama_model.cpp Fixes indentation/whitespace
src/models/llama_gradients.cpp Converts from multiple RNG generate calls to single call with std::span

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 4, 2026 13:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

auto rng_1 = mRng.generate(2*mStepCounter + 0, layer_idx);
auto rng_2 = mRng.generate(2*mStepCounter + 1, layer_idx + 12345);
std::array<std::uint32_t, 8> rng;
mRng.generate(std::span(rng), 2*mStepCounter, layer_idx);
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

The RNG sequence has been changed. The old code generated the second batch of 4 random numbers with y = layer_idx + 12345, but the new code uses y = layer_idx for all batches. This means rng[4], rng[5], and rng[6] will have different values than they had before, potentially breaking deterministic behavior or changing the results. If this change is intentional, it should be documented.

Suggested change
mRng.generate(std::span(rng), 2*mStepCounter, layer_idx);
mRng.generate(std::span(rng).subspan(0, 4), 2*mStepCounter, layer_idx);
mRng.generate(std::span(rng).subspan(4, 4), 2*mStepCounter, layer_idx + 12345);

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 4, 2026 13:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ngc92 ngc92 force-pushed the more-tiny-fixes branch 2 times, most recently from 4020148 to 9fff7cc Compare January 4, 2026 14:21
Copilot AI review requested due to automatic review settings January 4, 2026 14:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 4, 2026 15:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ngc92 ngc92 merged commit a3ccd37 into dev Jan 4, 2026
35 checks passed
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.

2 participants