Skip to content

Commit

Permalink
Merge pull request #494 from kitsudaiki/qa/various-minor-updates-and-…
Browse files Browse the repository at this point in the history
…fixes

related issue: #492
  • Loading branch information
kitsudaiki authored Nov 5, 2024
2 parents 370b9c4 + fc9aa49 commit ab8ab53
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
- fixed memory-corruption in cluster-resize, because a pointer was used after free
- fixed missing drawio-images in documentation when generating in CI
- fixed random crash, which can appear while creating checkpoints
- when making a request over direct-io but the output is empty, there was no response and the connection got stuck, which was fixed
- when using direct-io right from the beginning to train a cluster, the cluster remained empty, which was fixed

### Removed

Expand Down
11 changes: 7 additions & 4 deletions src/hanami/src/api/websocket/cluster_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,13 @@ recvClusterInputMessage(Cluster* cluster, const void* data, const uint64_t dataS
}

InputInterface* inputInterface = &it->second;
if (inputInterface->inputNeurons.size() < msg.numberofvalues()) {
inputInterface->inputNeurons.resize(msg.numberofvalues());
}
inputInterface->ioBuffer.resize(msg.numberofvalues());
inputInterface->initBuffer(msg.numberofvalues(), 1);

// resize the input-hexagon
const uint32_t numberOfNeuronBlocks
= (inputInterface->inputNeurons.size() / NEURONS_PER_NEURONBLOCK) + 1;
cluster->hexagons[inputInterface->targetHexagonId].neuronBlocks.resize(
numberOfNeuronBlocks);

for (uint64_t i = 0; i < msg.numberofvalues(); i++) {
inputInterface->inputNeurons[i].value = msg.values(i);
Expand Down
1 change: 1 addition & 0 deletions src/hanami/src/core/processing/cpu/cpu_worker_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ CpuWorkerThread::handleProcessTask(const WorkerTask task)
// handle special-case that there are no neuron-blocks to process
if (hexagon->neuronBlocks.size() == 0) {
if (task.hexagonId == task.cluster->hexagons.size() - 1) {
handleClientOutput(*task.cluster);
task.cluster->updateClusterState(task);
return;
}
Expand Down
31 changes: 12 additions & 19 deletions src/hanami/src/core/processing/cpu/processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ synapseProcessingBackward_train(Cluster& cluster,
Synapse* synapse = nullptr;
Neuron* targetNeuron = nullptr;
float halfPotential = 0.0f;
float condition = 0.0f;
constexpr float createBorder = 0.02f;
constexpr float adjustment = (1.0f / 1.5f) - 1.0f;
const float range = connection->potentialRange;
bool condition = false;
const bool isAbleToCreate = connection->origin.isInput || cluster.enableCreation;
constexpr float createBorder = 0.05f;
const float range = connection->potentialRange;
float potential = connection->potential - connection->lowerBound;
potential = range * (potential > range) + potential * (potential <= range);

Expand All @@ -110,20 +109,14 @@ synapseProcessingBackward_train(Cluster& cluster,
val = synapse->weight;
if (potential < synapse->border) {
val *= ((1.0f / synapse->border) * potential);
condition = static_cast<float>(connection->origin.isInput)
* static_cast<float>(potential < (1.0f - createBorder) * synapse->border)
* static_cast<float>(potential > createBorder * synapse->border);
synapse->border = synapse->border * (1.0f + (condition * adjustment));
synapse->weight = synapse->weight * (1.0f + (condition * adjustment));

cluster.enableCreation = cluster.enableCreation || (condition != 0);

condition = static_cast<float>(connection->origin.isInput == false)
* static_cast<float>(cluster.enableCreation)
* static_cast<float>(potential < synapse->border - createBorder)
* static_cast<float>(potential > createBorder);
synapse->border = synapse->border * (1.0f + (condition * adjustment));
synapse->weight = synapse->weight * (1.0f + (condition * adjustment));
condition = cluster.enableCreation
&& potential < (1.0f - createBorder) * synapse->border
&& potential > createBorder * synapse->border
&& potential < synapse->border - createBorder && potential > createBorder;
synapse->border = synapse->border * static_cast<float>(condition == false)
+ potential * static_cast<float>(condition);

cluster.enableCreation = cluster.enableCreation || condition;
}
targetNeuron
= &targetNeuronBlock->neurons[synapse->targetNeuronId % NEURONS_PER_NEURONBLOCK];
Expand All @@ -137,7 +130,7 @@ synapseProcessingBackward_train(Cluster& cluster,
}

connection->splitValue
= halfPotential * static_cast<float>(potential > 0.01f && isAbleToCreate);
= halfPotential * static_cast<float>(potential > 0.00001f && isAbleToCreate);
}

/**
Expand Down

0 comments on commit ab8ab53

Please sign in to comment.