Skip to content

Commit

Permalink
RLCSE: fix MCMC and GatherFeatures, overwrite dumps (#395)
Browse files Browse the repository at this point in the history
The JIT will append dumps to existing files, so using RLCSE to save
dumps was creating large files (each sequence's dump is periodically
updated to show the impact of the current parameters).

Also I was going to make MCMC and such subcommands, but changed my mind,
and forgot to hook the options back up.
  • Loading branch information
AndyAyersMS authored Feb 10, 2024
1 parent 5b47b91 commit 7ceb604
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/jit-rl-cse/MLCSE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static void PolicyGradient(IEnumerable<Method> methods)
// number of times we cycle through the methods
int nRounds = Get(s_commands.NumberOfRounds);
// how many trials per method each cycle (minibatch)
int nIter =Get(s_commands.MinibatchSize);
int nIter = Get(s_commands.MinibatchSize);
// how often to show results
bool showEvery = Get(s_commands.ShowRounds);
uint showEveryInterval = Get(s_commands.ShowRoundsInterval);
Expand Down Expand Up @@ -622,10 +622,20 @@ static void PolicyGradient(IEnumerable<Method> methods)
QVDumpDot(method, s);
}

// Dump dasm/dump if we don't have one already
// Write out dasm/dump for method with this sequence, and baseline.
// Overwrite method dumps every so often, so we see fresh likelihood computations.
// Dasm and baselines should not change so initial ones are fine.
//
bool shouldOverwriteDump = (r > 0) && (summaryInterval > 0) && (r % (4 * summaryInterval) == summaryInterval);

string cleanSequence = updateSequence.Replace(',', '_');
string dumpFile = Path.Combine(dumpDir, $"dump-{method.spmiIndex}-{cleanSequence}.d");

if (shouldOverwriteDump && File.Exists(dumpFile))
{
File.Delete(dumpFile);
}

if (!File.Exists(dumpFile))
{
List<string> dumpOptions = new List<string>(updateOptions);
Expand Down Expand Up @@ -801,7 +811,6 @@ static void PolicyGradient(IEnumerable<Method> methods)
Console.Write($" B:{MetricsParser.GetBaseLikelihoods(batchRuns[lastValidRun]),-60}");
}
}
Console.Write(batchDetails[lastValidRun]);
Console.ResetColor();
}
}
Expand Down Expand Up @@ -1022,7 +1031,7 @@ static void MCMC(IEnumerable<Method> methods)
// Show each method's summary
bool showEachCase = Get(s_commands.ShowEachMethod);
// show each particular trial result
bool showEachRun = Get(s_commands.ShowEachRun);
bool showEachRun = Get(s_commands.ShowEachMCMCRun);
// Show the Markov Chain
bool showMC = Get(s_commands.ShowMarkovChain);
// Draw the Markov Chain (tree)
Expand Down
3 changes: 3 additions & 0 deletions src/jit-rl-cse/MLCSECommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public MLCSECommands(string[] args) : base("Use ML to explore JIT CSE Heuristics
Options.Add(UseSpecificMethods);
Options.Add(UseAdditionalMethods);

Options.Add(GatherFeatures);

Options.Add(DoMCMC);
Options.Add(RememberMCMC);
Options.Add(ShowEachMethod);
Options.Add(ShowEachMCMCRun);
Expand Down

0 comments on commit 7ceb604

Please sign in to comment.