Skip to content

[WIP] Feature/milq - #5

Open
Gistbatch wants to merge 4 commits into
developfrom
feature/milq
Open

Gistbatch wants to merge 4 commits into
developfrom
feature/milq

Conversation

@Gistbatch

@Gistbatch Gistbatch commented Jul 4, 2024

Copy link
Copy Markdown
Collaborator

This is a naive port of our milq scheduler to C++.
There are still multiple TODOs to fix,and probably tons of performance improvements.
The build seems fine @kayaercument how are we supposed to include the QRM?
Also, some things are missing compared to the QRM setup, like git hooks.

Some more todos:

  • Tests
  • Docs
  • Implement this as a meta technique. We can probably use some stuff from Patrick, too

@Gistbatch
Gistbatch requested a review from Ectras July 4, 2024 14:46
#define MILQ_BINPACKING_HPP

#include <Schedule.hpp>
#include <string>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unused include

Suggested change
#include <string>

Comment thread include/milq/Estimate.hpp

#include <QuantumResourceManager.hpp>
#include <qdmi.h>
#include <vector>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unused include

Suggested change
#include <vector>

@@ -0,0 +1,18 @@
#ifndef MILQ_BINPACKING_HPP

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd prefer #pragma once (this is e.g. also used in the passes repository)

Comment thread include/milq/Convert.hpp

namespace milq
{
std::vector<JobProxy> convert_to_proxies(const std::vector<QuantumTask> &tasks);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Writing doc comments is actually free

#ifndef MILQ_BINPACKING_HPP
#define MILQ_BINPACKING_HPP

#include <Schedule.hpp>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Usually it's quotes for non-system headers:

#include "File.hpp" // user-written file include
#include <vector> // system header include


std::vector<Schedule> improve_population(std::vector<Schedule> &population)
{
auto population_copy = population;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shallow copy

}
if (!candidates.empty())
{
std::uniform_int_distribution<int> candidate_distribution(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The end of the distribution is inclusive, so this can be out of bounds.

Comment on lines +176 to +209
for (auto &job : bucket->job_proxies)
{
auto &machine = *std::min_element(
schedule.get_machines().begin(), schedule.get_machines().end(),
[](const Machine *m1, const Machine *m2)
{ return m1->capacity < m2->capacity; });
if (machine->buckets.empty())
{
// TODO proprose new cuts ore put them in multipile
// buckets if necessary
machine->buckets.push_back(bucket);
}
else
{
auto &smallest_bucket = *std::min_element(
machine->buckets.begin(), machine->buckets.end(),
[&machine](const Bucket *b1, const Bucket *b2)
{
return remaining_capacity(b1, machine->capacity) <
remaining_capacity(b2, machine->capacity);
});
if (remaining_capacity(smallest_bucket, machine->capacity) <
job->num_qubits)
{
// TODO proprose new cuts ore put them in multipile
// buckets if necessary
machine->buckets.push_back(bucket);
}
else
{
smallest_bucket->job_proxies.push_back(job);
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not sure if this works. You iterate over the jobs, but then you are adding the whole bucket without breaking. I can't verify easily that this doesn't add jobs twice.

Comment on lines +254 to +261
return std::accumulate(
population.begin(), population.end(), 0,
[&x](int sum, Schedule &other)
{ return sum + x.hamming_distance(other); }) <
std::accumulate(
population.begin(), population.end(), 0,
[&y](int sum, Schedule &other)
{ return sum + y.hamming_distance(other); });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The accumulates should go into separate lines for separability

Comment on lines +305 to +308
best_schedule =
current_best.get_makespan() < best_schedule.get_makespan()
? current_best
: best_schedule;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shouldn't this be somehow handled by the omp reduction? (I don't know this functionality)

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