Skip to content

Commit

Permalink
fix spike bins for arbitrary ThetaCycles, testing with objrec for NCy…
Browse files Browse the repository at this point in the history
…cles=300
  • Loading branch information
rcoreilly committed Jun 19, 2024
1 parent 0fe4592 commit 4f2d1c4
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 9 deletions.
5 changes: 3 additions & 2 deletions axon/layerparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ func (ly *LayerParams) SpikeFromG(ctx *Context, ni, di uint32, lpl *Pool) {
SetNrnV(ctx, ni, di, SpkMax, spkmax)
}
}
bin := ctx.Cycle / 50
spksper := ctx.ThetaCycles / 4
bin := ctx.Cycle / spksper
spk := NrnV(ctx, ni, di, Spike)
switch bin {
case 0:
Expand All @@ -724,7 +725,7 @@ func (ly *LayerParams) SpikeFromG(ctx *Context, ni, di uint32, lpl *Pool) {
AddNrnV(ctx, ni, di, SpkBin1, spk)
case 2:
AddNrnV(ctx, ni, di, SpkBin2, spk)
case 3:
default:
AddNrnV(ctx, ni, di, SpkBin3, spk)
}
}
Expand Down
Binary file modified axon/shaders/gpu_cycle.spv
Binary file not shown.
45 changes: 45 additions & 0 deletions examples/objrec/bench_results.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
# v2.0.0-dev0.2.0

Linear approximation to synaptic calcium integration:

## MacBook Pro M3 Max

Major improvements for GPU at all NData, major for NData 32 (5x), 16 (4x):
```
GPU:
* NData 1: 59
* NData 2: 39
* NData 4: 27
* NData 8: 20
* NData 16: 15
* NData 32: 12
```

Not much diff for ndata now on CPU beyond 4, NThreads = 16
```
CPU:
* NData 1: 90
* NData 2: 76
* NData 4: 69
* NData 8: 63
* NData 16: 62
* NData 32: 62
```

## HPC2 ccnl-0 AMD EPYC 7502 32-Core Processor + NVIDIA A100 GPU

```
GPU:
* NData 4: 105
* NData 8: 83
* NData 16: 76
* NData 32: 77
```

```
CPU:
* NData 16: 180 (ccnl-0)
* NData 16: 280 (Node 3)
* NData 16: 385 (Node 3, v0.0.8 -- previous SynCa)
```

# v1.8.0

results are PerTrlMSec
Expand Down
3 changes: 3 additions & 0 deletions examples/objrec/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ type RunConfig struct { //types:add
// total number of trials per epoch. Should be an even multiple of NData.
NTrials int `default:"128"`

// total number of cycles per trial.
NCycles int `default:"300"`

// how frequently (in epochs) to compute PCA on hidden representations to measure variance?
PCAInterval int `default:"5"`

Expand Down
8 changes: 5 additions & 3 deletions examples/objrec/objrec.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (ss *Sim) New() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
ss.Context.Defaults()
ss.Context.ThetaCycles = int32(ss.Config.Run.NCycles)
// ss.Context.SlowInterval = 100
}

Expand Down Expand Up @@ -265,20 +266,21 @@ func (ss *Sim) InitRandSeed(run int) {
func (ss *Sim) ConfigLoops() {
man := looper.NewManager()

ncyc := ss.Config.Run.NCycles
trls := int(math32.IntMultipleGE(float32(ss.Config.Run.NTrials), float32(ss.Config.Run.NData)))

man.AddStack(etime.Train).
AddTime(etime.Run, ss.Config.Run.NRuns).
AddTime(etime.Epoch, ss.Config.Run.NEpochs).
AddTimeIncr(etime.Trial, trls, ss.Config.Run.NData).
AddTime(etime.Cycle, 200)
AddTime(etime.Cycle, ncyc)

man.AddStack(etime.Test).
AddTime(etime.Epoch, 1).
AddTimeIncr(etime.Trial, trls, ss.Config.Run.NData).
AddTime(etime.Cycle, 200)
AddTime(etime.Cycle, ncyc)

axon.LooperStdPhases(man, &ss.Context, ss.Net, 150, 199) // plus phase timing
axon.LooperStdPhases(man, &ss.Context, ss.Net, ncyc-50, ncyc-1) // plus phase timing
axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code

for mode := range man.Stacks {
Expand Down
10 changes: 10 additions & 0 deletions examples/objrec/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ var ParamSets = netparams.Sets{
"Layer.Learn.LrnNMDA.Tau": "100", // 100 def
"Layer.Learn.LrnNMDA.Gbar": "0.006",
"Layer.Learn.RLRate.SigmoidLinear": "true", // true > false later; more stable
"Layer.Learn.CaLearn.Norm": "80", // 80 works
"Layer.Learn.CaLearn.SpkVGCC": "true", // sig better..
"Layer.Learn.CaLearn.SpkVgccCa": "35", // 70 / 5 or 35 / 10 both work
"Layer.Learn.CaLearn.VgccTau": "10", // 10 > 5 ?
"Layer.Learn.CaLearn.Dt.MTau": "2",
"Layer.Learn.CaLearn.Dt.PTau": "50",
"Layer.Learn.CaLearn.Dt.DTau": "50",
"Layer.Learn.CaSpk.Dt.MTau": "5",
"Layer.Learn.CaSpk.Dt.PTau": "50",
"Layer.Learn.CaSpk.Dt.DTau": "50",
}},
{Sel: "#V1", Desc: "pool inhib (not used), initial activity",
Params: params.Params{
Expand Down
3 changes: 3 additions & 0 deletions examples/ra25x/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ type RunConfig struct {
// total number of trials per epoch. Should be an even multiple of NData.
NTrials int `default:"32"`

// total number of cycles per trial.
NCycles int `default:"300"`

// how often to run through all the test patterns, in terms of training epochs -- can use 0 or -1 for no testing
TestInterval int `default:"5"`

Expand Down
8 changes: 5 additions & 3 deletions examples/ra25x/ra25x.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (ss *Sim) New() {
ss.RandSeeds.Init(100) // max 100 runs
ss.InitRandSeed(0)
ss.Context.Defaults()
ss.Context.ThetaCycles = int32(ss.Config.Run.NCycles)
}

////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -235,20 +236,21 @@ func (ss *Sim) InitRandSeed(run int) {
func (ss *Sim) ConfigLoops() {
man := looper.NewManager()

ncyc := ss.Config.Run.NCycles
trls := int(math32.IntMultipleGE(float32(ss.Config.Run.NTrials), float32(ss.Config.Run.NData)))

man.AddStack(etime.Train).
AddTime(etime.Run, ss.Config.Run.NRuns).
AddTime(etime.Epoch, ss.Config.Run.NEpochs).
AddTimeIncr(etime.Trial, trls, ss.Config.Run.NData).
AddTime(etime.Cycle, 200)
AddTime(etime.Cycle, ncyc)

man.AddStack(etime.Test).
AddTime(etime.Epoch, 1).
AddTimeIncr(etime.Trial, trls, ss.Config.Run.NData).
AddTime(etime.Cycle, 200)
AddTime(etime.Cycle, ncyc)

axon.LooperStdPhases(man, &ss.Context, ss.Net, 150, 199) // plus phase timing
axon.LooperStdPhases(man, &ss.Context, ss.Net, ncyc-50, ncyc-1) // plus phase timing
axon.LooperSimCycleAndLearn(man, ss.Net, &ss.Context, &ss.ViewUpdate) // std algo code

for m, _ := range man.Stacks {
Expand Down
2 changes: 1 addition & 1 deletion simscripts/20-Fetch.cosh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func FetchJob(jid string, force bool) {
// fmt.Println(ff)
rfn := "@1:" + ff
scp {rfn} {ff}
if sstat == "Finalized" && strings.HasSuffix(ff, ".tsv") {
if (sstat == "Finalized" || sstat == "Fetched") && strings.HasSuffix(ff, ".tsv") {
if strings.Contains(ff, "_epc.tsv") {
databrowser.CleanCatTSV(ff, []string{"Run", "Epoch"})
idx := strings.Index(ff, "_epc.tsv")
Expand Down

0 comments on commit 4f2d1c4

Please sign in to comment.